*/
//Default values
define('AWP_DEFAULT_ITEM_SHOW',5);
define('AWP_DEFAULT_MORE_TEXT','More..');
//Disable Plugins
//define('AWP_CONTACTFORM_DISABLE',1);
//define('AWP_NEWSLETTER_DISABLE',1);
//define('AWP_NEWS_DISABLE',1);
//define('AWP_EVENTS_DISABLE',1);
//define('AWP_TESTIMONIALS_DISABLE',1);
//define('AWP_JOBS_DISABLE',1);
//define('AWP_CASES_DISABLE',1);
/*
User updateable define statements ends here..
Changing define statements below will make plugin to not work properly.
* */
//Plugin Version
define('AWP_VERSION', '1.1');
//Plugin folders
define('AWP_LIB_DIR', AWP_PLUGIN_BASEPATH . '/lib');
define('AWP_INC_DIR', AWP_PLUGIN_BASEPATH . '/inc');
define('AWP_PLUGINS_DIR', AWP_LIB_DIR . '/Plugin');
define('AWP_WIDGETS_DIR', AWP_LIB_DIR . '/widgets');
//plugin template folder
define('AWP_CONTACTFORM_TEMPLATEPATH',AWP_INC_DIR.'/contact-forms/templates');
define('AWP_CASES_TEMPLATEPATH',AWP_INC_DIR.'/cases/templates');
define('AWP_NEWSLETTER_TEMPLATEPATH',AWP_INC_DIR.'/newsletter/templates');
define('AWP_NEWS_TEMPLATEPATH',AWP_INC_DIR.'/news/templates');
define('AWP_EVENTS_TEMPLATEPATH',AWP_INC_DIR.'/events/templates');
define('AWP_TESTIMONIALS_TEMPLATEPATH',AWP_INC_DIR.'/testimonials/templates');
define('AWP_JOBSFORM_TEMPLATEPATH',AWP_INC_DIR.'/jobs/templates/jobapplicant');
define('AWP_JOBSEARCHFORM_TEMPLATEPATH',AWP_INC_DIR.'/jobs/templates/jobsearch');
define('AWP_JOBDESCRIPTION_TEMPLATEPATH',AWP_INC_DIR.'/jobs/templates/jobdescription');
define('AWP_JOBLISTS_TEMPLATEPATH',AWP_INC_DIR.'/jobs/templates/joblists');
//Default Template
define('AWP_EVENTS_DEFAULT_TEMPLATE','default-events.php');
define('AWP_NEWS_DEFAULT_TEMPLATE','default-news.php');
define('AWP_TESTIMONIALS_DEFAULT_TEMPLATE','default-testimonials.php');
define('AWP_NEWSLETTER_WIDGET_DEFAULT_TEMPLATE','widget-default-template-usphone.php');
//Apptivo API URL's
//Dont change this unless specified, changing to incorrect values will make plugins to not work properly.
define('APPTIVO_API_URL','https://api.apptivo.com/');
define('APPTIVO_BUSINESS_SERVICES', APPTIVO_API_URL.'app/services/v1/BusinessSiteServices?wsdl');
define('APPTIVO_BUSINESS_INDEX', APPTIVO_API_URL.'ts/services/AppJobWebService?wsdl');
//API Key and Access Keys Settings.
$eCommerce_api_Key = get_option('apptivo_ecommerce_apikey');
$eCommerce_access_key = get_option('apptivo_ecommerce_accesskey');
$business_site_key = get_option('apptivo_sitekey');
if(!empty($eCommerce_api_Key) )
{
update_option('apptivo_apikey',$eCommerce_api_Key);
update_option('apptivo_accesskey',$eCommerce_access_key);
}else if(!empty($business_site_key)) {
update_option('apptivo_apikey',$business_site_key);
delete_option('apptivo_sitekey');
}
$apptivo_api_key = get_option('apptivo_apikey');
$apptivo_accesskey = get_option('apptivo_accesskey');
define('APPTIVO_BUSINESS_API_KEY',trim($apptivo_api_key));
define('APPTIVO_BUSINESS_ACCESS_KEY',trim($apptivo_accesskey));
/**
* Loads plugins
*
* @return void
*/
function awp_load_plugins()
{
ob_start();
//include Plugin Files.
$plugin_dir = @opendir(AWP_PLUGINS_DIR);
if ($plugin_dir) {
while (($entry = @readdir($plugin_dir)) !== false) {
if (strrchr($entry, '.') === '.php') {
require_once AWP_PLUGINS_DIR . '/' . $entry;
}
}
@closedir($plugin_dir);
}
}
/**
* Load Widgets
*
*/
function awp_load_widgets()
{
//include widget files
$widget_dir = @opendir(AWP_WIDGETS_DIR);
if ($widget_dir) {
while (($entry = @readdir($widget_dir)) !== false) {
if (strrchr($entry, '.') === '.php') {
require_once AWP_WIDGETS_DIR . '/' . $entry;
}
}
@closedir($widget_dir);
}
}
/**
* Recursive strips slahes from the var
*
* @param mixed $var
* @return mixed
*/
function awp_stripslashes($var)
{
if (is_string($var)) {
return stripslashes($var);
} elseif (is_array($var)) {
$var = array_map('awp_stripslashes', $var);
}
return $var;
}
/**
* Sort customformfields by order
*/
function awp_sort_by_order($a, $b) {
return $a["order"] - $b["order"];
}
/**
* Search for value using key in multi-dimensional array
* returns index if value found
* returns false if no value is found
*/
function awp_recursive_array_search($haystack, $needle, $index = null)
{
$aIt = new RecursiveArrayIterator($haystack);
$it = new RecursiveIteratorIterator($aIt);
while($it->valid())
{
if (((isset($index) AND ($it->key() == $index)) OR (!isset($index))) AND ($it->current() == $needle)) {
return $aIt->key();
}
$it->next();
}
return false;
}
/**
* Add contact form scripts and styles, only when short code is present in page/posts
*/
function awp_check_for_shortcode($posts,$shortcode) {
if ( empty($posts) )
return $posts;
// false because we have to search through the posts first
$found = false;
// search through each post
foreach ($posts as $post) {
// check the post content for the short code
if ((stripos($post->post_content, $shortcode))!==false)
{ // we have found a post with the short code
$found = true;
}
// stop the search
break;
}
return $found;
}
/**
* Converts value to boolean
*
* @param mixed $value
* @return boolean
*/
function awp_to_boolean($value)
{
if (is_string($value)) {
switch (strtolower($value)) {
case '+':
case '1':
case 'y':
case 'on':
case 'yes':
case 'true':
case 'enabled':
return true;
case '-':
case '0':
case 'n':
case 'no':
case 'off':
case 'false':
case 'disabled':
return false;
}
}
return (boolean) $value;
}
function awp_date_compare($a, $b)
{
$t1 = strtotime($a['datetime']);
$t2 = strtotime($b['datetime']);
return $t1 - $t2;
}
function awp_creation_date_compare($a, $b)
{
$t1 = $a->creationDate;
$t2 = $b->creationDate;
return $t1 - $t2;
}
function awp_sort_by_sequence($a, $b) {
return $a->sequenceNumber - $b->sequenceNumber;
}
/**
* Pagination
*
* @param unknown_type $reload
* @param unknown_type $page
* @param unknown_type $tpages
* @return unknown
*/
function awp_paginate($reload, $page, $tpages,$totalitems) {
$firstlabel = "<<";
$prevlabel = "<";
$nextlabel = ">";
$lastlabel = ">>";
$out = '
";
return $out;
}
/**
* To Make Soap Call
*
* @param unknown_type $wsdl
* @param unknown_type $function
* @param unknown_type $params
* @return unknown
*/
function getsoapCall($wsdl,$function,$params)
{
$client = new SoapClient($wsdl);
try {
$response = $client->__soapCall($function, array($params));
}catch(Exception $e){
$e->getMessage();
return 'E_100';
}
return $response;
}
/**
* LoadMemCache Methods.
*
* @param unknown_type $wsdl
* @param unknown_type $key_publishdate
* @param unknown_type $plugincall_key
* @param unknown_type $method_publishdate
* @param unknown_type $plugincall_function
* @param unknown_type $publishdate_params
* @param unknown_type $plugincall_params
* @return unknown
*/
/**
* get ApptiovWordPress(awp) Templates
*
* @param unknown_type $dir
* @param unknown_type $type == 'widget' => "Widget Templates" , $type == 'plugin' => "Plugin templates"
* @return Template Array Lists.
*/
function get_awpTemplates($dir,$type)
{
$default_headers = array(
'Template Name' => 'Template Name',
'Template Type' => 'Template Type'
);
$templates = array();
$dir_news = $dir;
// Open a known directory, and proceed to read its contents
if (is_dir($dir_news)) {
if ($dh = opendir($dir_news)) {
while (($file = readdir($dh)) !== false) {
if ( substr( $file, -4 ) == '.php' )
{
$plugin_data = get_file_data( $dir_news."/".$file, $default_headers, '' );
if(strlen(trim($plugin_data['Template Name'])) != 0 )
{
if(strtolower(trim($plugin_data['Template Type'])) == 'widget' && strtolower($type) == 'widget' )
{
$templates[$plugin_data['Template Name']] = $file;
}else if(strtolower(trim($plugin_data['Template Type'])) == 'shortcode' && strtolower($type) == 'plugin')
{
$templates[$plugin_data['Template Name']] = $file;
}else if(strtolower(trim($plugin_data['Template Type'])) == 'inline' && strtolower($type) == 'inline')
{
$templates[$plugin_data['Template Name']] = $file;
}
}
}
}
closedir($dh);
}
}
return $templates;
}
/**
* Remove html tags from string
*
* @param string $str
* @return string
*/
function html_remove($str){
return $str;
return preg_replace("/<[^>]*>/","",$str);
}
/**
* Convert Object to array.
*
* @param unknown_type $objectValue
* @return unknown
*/
function awp_convertObjToArray($objectValue)
{ if(!empty($objectValue)){
if(is_array($objectValue)) {
$arrayValue = $objectValue;
}
else {
$arrayValue = array();
array_push($arrayValue,$objectValue);
}
return $arrayValue;
}
}
/**
*
* @param $wsdl
* @param string $publishdate_key
* @param string $plugincall_key
* @param $publishdate_function
* @param $plugincall_function
* @param $publishdate_params
* @param $plugincall_params
* @return
*/
function get_data($wsdl,$publishdate_key,$plugincall_key,$publishdate_function,$plugincall_function,$publishdate_params,$plugincall_params)
{
$cache_obj = new AWP_Cache_Util(); //Create Object in AWP_DataCache class
$response = $cache_obj->get_data($wsdl, $publishdate_key, $plugincall_key, $publishdate_function, $plugincall_function, $publishdate_params, $plugincall_params);
return $response;
}
/**
* Recursive creates directory
*
* @param string $path
* @param integer $mask
* @param string
* @return boolean
*/
function awp_mkdir($path, $mask = 0755, $curr_path = '')
{
$path = awp_realpath($path);
$path = trim($path, '/');
$dirs = explode('/', $path);
foreach ($dirs as $dir) {
if ($dir == '') {
return false;
}
$curr_path .= ($curr_path == '' ? '' : '/') . $dir;
if (!@is_dir($curr_path)) {
if (@mkdir($curr_path, $mask)) {
@chmod($curr_path, $mask);
} else {
return false;
}
}
}
return true;
}
/**
* Recursive remove dir
*
* @param string $path
* @param array $exclude
* @return void
*/
function awp_rmdir($path, $exclude = array(), $remove = true)
{
$dir = @opendir($path);
if ($dir) {
while (($entry = @readdir($dir)) !== false) {
$full_path = $path . '/' . $entry;
if ($entry != '.' && $entry != '..' && !in_array($full_path, $exclude)) {
if (@is_dir($full_path)) {
awp_rmdir($full_path, $exclude);
} else {
@unlink($full_path);
}
}
}
@closedir($dir);
if ($remove) {
@rmdir($path);
}
}
}
/**
* Recursive empty dir
*
* @param string $path
* @param array $exclude
* @return void
*/
function awp_emptydir($path, $exclude = array())
{
awp_rmdir($path, $exclude, false);
}
/**
* Returns realpath of given path
*
* @param string $path
*/
function awp_realpath($path)
{
$path = awp_path($path);
$parts = explode('/', $path);
$absolutes = array();
foreach ($parts as $part) {
if ('.' == $part) {
continue;
}
if ('..' == $part) {
array_pop($absolutes);
} else {
$absolutes[] = $part;
}
}
return implode('/', $absolutes);
}
/**
* Converts win path to unix
*
* @param string $path
* @return string
*/
function awp_path($path)
{
$path = preg_replace('~[/\\\]+~', '/', $path);
$path = rtrim($path, '/');
return $path;
}
//Label Field
function awp_labelfield($field='',$class='contactform_field_label',$before='',$after='')
{
$fieldid=$field['fieldid'];
$showtext=$field['showtext'];
return $before.''.$after;
}
function awp_jobsearch_textfield ($field='',$class='',$before='',$after='')
{
$fieldid = $field['fieldid'];
$showtext = $field['showtext'];
$required = $field['required'];
$fieldtype = $field['type'];
$options = $field['options'];
switch( $fieldid )
{
case "keywords" :
$html = '';
break;
case "customfield1" :
if($fieldtype == 'select') :
$html .= '';
endif;
break;
case "customfield2" :
if($fieldtype == 'checkbox') :
foreach($options as $opt_val)
{ $opt_value = strtoupper(trim($opt_val));
$opt_value = str_replace(" ","_",$opt_value);
$html .= '
';
}
endif;
if($fieldtype == 'select') :
$html .= '';
endif;
break;
}
return $html;
}
/**
* Enter description here...
*
* @param unknown_type $forms
* @param unknown_type $field
* @param unknown_type $countries
* @param Bollean $value_present
* @param unknown_type $before
* @param unknown_type $after
* @return unknown
*/
function awp_textfield($forms='',$field='',$countries='',$value_present='',$before='',$after='',$placeholder=false, $tabindex='')
{
$fieldid=$field['fieldid'];
$showtext=$field['showtext'];
$validation=$field['validation'];
$required=$field['required'];
$fieldtype=$field['type'];
$options=$field['options'];
$optionvalues=array();
$place_text = '';
if($placeholder)
{
$place_text = 'placeholder="'.$showtext.'"';
}
if($fieldtype=="select" || $fieldtype=="radio" || $fieldtype=="checkbox" ){
if(trim($fieldid) == 'industry')
{
$optionvalues=$options;
$fieldtype = 'select';
} else if(trim($options)!=""){
$optionvalues=split("[\n]",trim($options));//Split the String line by line.
}
}
if ($value_present) :
$postValue = $_REQUEST[$fieldid];
else :
$postValue="";
endif;
//Required Class
if($required){
$mandate_property='"mandatory="true"';
$validateclass=" required";
}
else{
$mandate_property="";
$validateclass="";
}
//Field Validation Class
switch($validation)
{
case "email":
$validateclass .=" email";
break;
case "url":
$validateclass .=" url";
break;
case "number":
$validateclass .=" number";
break;
}
//Captcha Class
if($fieldid=='captcha')
{
$captcha_class = 'captcha';
}
else{
$captcha_class = '';
}
switch($fieldtype)
{
case "text":
$html = '';
break;
case "textarea":
$html = '';
break;
case "select":
if($fieldid == 'country'){
$html = '';
} else if($fieldid == 'industry')
{
if(!empty($optionvalues))
{
$html .= '';
}else {
$html .= '';
}
}
else{
$html = '';
}
break;
case "radio":
$i=0;$opt=0;
foreach( $optionvalues as $optionvalue )
{
if(trim($postValue) == trim($optionvalue)){
$selected='checked="checked"';
}
else{
$selected = "";
}
if(!empty($optionvalue) && strlen(trim($optionvalue)) != 0)
{
if($i>0)
$html .=' ';
$html .='';
}
$opt++;
}
break;
case "checkbox":
$i=0;$opt=0;
foreach( $optionvalues as $optionvalue )
{
$selected ="";
foreach($postValue as $value){
if(trim($value) == trim($optionvalue)){
$selected='checked="checked"';
}
}
if(!empty($optionvalue) && strlen(trim($optionvalue)) != 0)
{
if($i>0)
$html .=' ';
$html.='';
$i++;$opt++;
}
}
break;
case "captcha":
$html ='
';
break;
case "file":
$html ='';
$html.= '';
break;
}
return $before.$html.$after;
}
/**
* SubMit Button Type
*
* @param array $contactform
* @return html field(form submit type)
*/
function awp_submit_type($forms='',$form_submitname='',$class='',$before='',$after='', $tabindex)
{
if(strlen(trim($form_submitname)) != 0 ) :
$html ='';
endif;
if($forms[submit_button_type] == "submit" ){
if(strlen(trim($forms[submit_button_val])) != 0)
{
$value = $forms[submit_button_val];
}else {
$value = 'Submit';
}
$button_value = 'value="'.$value.'"';
}
else{
if(strlen(trim($forms[submit_button_val])) == 0)
{
$imgSrc = awp_image('submit_button');
}else {
$imgSrc = $forms[submit_button_val];
}
$button_value = 'src="'.$imgSrc.'"';
}
$html .= '';
return $before.$html.$after;
}
/**
* Enter description here...
*
* @param unknown_type $forms
* @param unknown_type $field
* @param unknown_type $countries
* @param Bollean $value_present
* @param unknown_type $before
* @param unknown_type $after
* @return unknown
*/
function cases_textfield($forms='',$field='',$countries='',$value_present='',$before='',$after='',$placeholder=false, $tabindex='',$dafaultselect=false)
{
$fieldid=$field['fieldid'];
$showtext=$field['showtext'];
$validation=$field['validation'];
$required=$field['required'];
$fieldtype=$field['type'];
$options=$field['options'];
$optionvalues=array();
$place_text = '';
if($placeholder)
{
$place_text = 'placeholder="'.$showtext.'"';
}
if($fieldtype=="select" || $fieldtype=="radio" || $fieldtype=="checkbox" ){
$optionvalues=split("[\n]",trim($options));//Split the String line by line.
}
if ($value_present) :
$postValue = $_REQUEST[$fieldid];
else :
$postValue="";
endif;
//Required Class
if($required){
$mandate_property='"mandatory="true"';
$validateclass=" required";
}
else{
$mandate_property="";
$validateclass="";
}
//Field Validation Class
switch($validation)
{
case "email":
$validateclass .=" email";
break;
case "url":
$validateclass .=" url";
break;
case "number":
$validateclass .=" number";
break;
case "phonenumber":
$validateclass .=" phonenumber";
break;
}
//Captcha Class
if($fieldid=='captcha')
{
$captcha_class = 'captcha';
}
else{
$captcha_class = '';
}
switch($fieldtype)
{
case "text":
$html = '';
break;
case "textarea":
$html = '';
break;
case "select":
$html = '';
break;
case "radio":
$i=0;$opt=0;
foreach( $optionvalues as $optionvalue )
{
if(trim($postValue) == trim($optionvalue)){
$selected='checked="checked"';
}
else{
$selected = "";
}
if(!empty($optionvalue) && strlen(trim($optionvalue)) != 0)
{
if($i>0)
$html .=' ';
$html .='';
}
$opt++;
}
break;
case "checkbox":
$i=0;$opt=0;
foreach( $optionvalues as $optionvalue )
{
$selected ="";
if(!empty($postValue)) :
foreach($postValue as $value){
if(trim($value) == trim($optionvalue)){
$selected='checked="checked"';
}
}
endif;
if(!empty($optionvalue) && strlen(trim($optionvalue)) != 0)
{
if($i>0)
$html .=' ';
$html.=' ';
$i++;
}
$opt++;
}
break;
case "captcha":
$html ='
';
break;
case "file":
$html ='';
$html.= '';
break;
}
return $before.$html.$after;
}
function cases_submit_type($forms='',$form_submitname='',$class='',$before='',$after='', $tabindex)
{
if($forms[submit_button_type] == "submit" ){
if(strlen(trim($forms[submit_button_val])) != 0)
{
$value = $forms[submit_button_val];
}else {
$value = 'Submit';
}
$button_value = 'value="'.$value.'"';
}
else{
if(strlen(trim($forms[submit_button_val])) == 0)
{
$imgSrc = awp_image('submit_button');
}else {
$imgSrc = $forms[submit_button_val];
}
$button_value = 'src="'.$imgSrc.'"';
}
$html .= '';
return $before.$html.$after;
}
/**
* Create Label Fields
*
* @param unknown_type $showtext
* @param unknown_type $customtext
* @param unknown_type $class
* @param unknown_type $before
* @param unknown_type $after
* @return unknown
*/
function awp_create_labelfield($showtext='',$customtext='',$class='',$before='',$after='',$fieldid='')
{
if($showtext == '' || strlen(trim($showtext)) == 0) :
$showtext = $customtext;
endif;
return $before.''.$after;
}
function awp_create_textfiled($type='',$fieldid='',$class='',$before='',$after='')
{
switch(strtolower($type))
{
case "checkbox" :
$html = $before.''.$after;
break;
}
return $html;
}
//Mandatory Field.
function awp_mandatoryfield($field='',$before='',$after='',$mandatory_symbol = '*')
{
$required=$field['required'];
if($required):
return $before.$mandatory_symbol.$after;
endif;
}
//Powered By Apptivo.
function poweredby_apptivo()
{
$apptivo_logo = '
';
return $apptivo_logo;
}