_plugin_activated=false; $settings=get_option("awp_plugins"); if(get_option("awp_plugins")!=="false"){ if($settings["testimonials"]) $this->_plugin_activated=true; } } /** * Returns plugin instance * * @return AIP_Plugin_BrowserCache */ function &instance() { static $instances = array(); if (!isset($instances[0])) { $class = __CLASS__; $instances[0] = & new $class(); } return $instances[0]; } /** * Runs plugin */ function run() { if($this->_plugin_activated){ add_action( 'widgets_init', array(&$this,'register_widget')); add_shortcode('apptivo_testimonials_fullview',array(&$this, 'show_testimonials_fullview')); add_shortcode('apptivo_testimonials_inline',array(&$this,'show_testimonials_inline')); } add_action('the_posts',array(&$this,'check_for_shortcode')); } function check_for_shortcode($posts) { $testimonial_fullView=awp_check_for_shortcode($posts,'[apptivo_testimonials_fullview'); $testimonial_inlineView=awp_check_for_shortcode($posts,'[apptivo_testimonials_inline'); if ($testimonial_inlineView){ // load styles and scripts $this->loadscripts(); } return $posts; } function loadscripts() { wp_enqueue_script('jquery_cycleslider.js',AWP_PLUGIN_BASEURL. '/assets/js/jquery.cycle.all.latest.js',array('jquery')); } /* Add Testimonials */ function add_testimonials() { $awp_testimonials_options = array( 'name' => stripslashes($_POST['awp_testimonials_name']), 'jobtitle' => stripslashes($_POST['awp_testimonials_jobtitle']), 'company' => stripslashes($_POST['awp_testimonials_company']), 'website' => $_POST['awp_testimonials_website'], 'email' => $_POST['awp_testimonials_email'], 'imageurl' => $_POST['awp_testimonials_imageurl'], 'testimonial' => stripslashes($_POST['awp_testimonials_cnt']), 'order' => $_POST['awp_testimonials_order'] ); $awp_testimonials_options= wp_parse_args($awp_testimonials_options,array( 'name' => '', 'jobtitle' => '', 'company' => '', 'website' => '', 'email' => '', 'imageurl' =>'', 'testimonial' =>'', 'order' => '' )); extract($awp_testimonials_options); $testimonial = apply_filters('the_content', $testimonial); $response = addTestimonials($account, $accountId, $company, $contact, $contactId,$creationDate, $email, $firmId, $images, $jobtitle, $name, $returnStatus, $order, $siteTestimonialId, $testimonial, $imageurl, $testimonialStatus, $website); return $response; } //Update Testimonials function update_testimonials() { $awp_testimonials_options = array( 'testimonialId' => $_REQUEST['awp_tstid'], 'accountId' => $_REQUEST['awp_tst_accountId'], 'contactId' => $_REQUEST['awp_tst_contactId'], 'name' => stripslashes($_POST['awp_testimonials_name']), 'jobtitle' => stripslashes($_POST['awp_testimonials_jobtitle']), 'company' => stripslashes($_POST['awp_testimonials_company']), 'website' => $_POST['awp_testimonials_website'], 'email' => $_POST['awp_testimonials_email'], 'imageurl' => $_POST['awp_testimonials_imageurl'], 'testimonial' => stripslashes($_POST['awp_testimonials_cnt']), 'order' => $_POST['awp_testimonials_order'] ); $awp_testimonials_options= wp_parse_args($awp_testimonials_options,array( 'testimonialId' => '', 'accountId' => '', 'contactId' => '', 'name' => '', 'jobtitle' => '', 'company' => '', 'website' => '', 'email' => '', 'imageurl' =>'', 'testimonial' =>'', 'order' => '' )); extract($awp_testimonials_options); $testimonial = apply_filters('the_content', $testimonial); $response = updateTestimonials($account, $accountId, $company, $contact, $contactId, $creationDate, $email, $firmId, $images, $jobtitle, $name, $returnStatus, $order, $testimonialId, $testimonial, $imageurl, $testimonialStatus, $website); return $response; } //Delete Testimonials function delete_testimonials(){ $awp_tstid = $_REQUEST['tstid']; $response = deleteTestimonialByTestimonialId($awp_tstid); return $response; } function options() { ?>


Testimonials

For Complete instructions,see the Developer's Guide.

_plugin_activated){ echo "Testiomonials plugin is currently disabled. Please enable this in Apptivo General Settings."; }else if (isset($_POST['awp_testimonial_add'])) { //Add Testimonials. $addtestimonials_response = $this->add_testimonials(); if(strlen(trim($_POST['awp_testimonials_name'])) == 0 ) { $_SESSION['awp_testmonials_messge'] = 'Please enter a testimonial name'; }else if($addtestimonials_response->return->responseCode != '1000') { $_SESSION['awp_testmonials_messge'] = ''.$addtestimonials_response->return->responseMessage.''; }else { $_SESSION['awp_testmonials_messge'] = 'Testimonials Added Successfully'; } }else if ($_POST['awp_testimonial_update'] == 'Update') { //Update Testimonails. $updatetestimonials_response = $this->update_testimonials(); if($updatetestimonials_response->return->responseCode != '1000') { $_SESSION['awp_testmonials_messge'] = ''.$updatetestimonials_response->return->responseMessage.''; }else { $_SESSION['awp_testmonials_messge'] = 'Testimonials Updated Successfully'; } }else if ($_REQUEST['tstmode'] == 'delete') { //Delete Testimonails. $deletetestimonials_response = $this->delete_testimonials(); if($deletetestimonials_response->return->responseCode != '1000') { $_SESSION['awp_testmonials_messge'] = ''.$deletetestimonials_response->return->responseMessage.''; }else { $_SESSION['awp_testmonials_messge'] = 'Testimonials Deleted Successfully'; } }else { $_SESSION['awp_testmonials_messge'] = ''; } switch($_REQUEST['keys']) { case fullviewsetting: $this->fullViewSettings(); break; case inlineviewsetting: $this->inlineViewSettings(); break; default : $this->get_all_testimonials(); //Display All testimonilas Lists. if ($_REQUEST['tstmode'] == 'edit') //Testimonails Edit. { $awp_tstid = $_REQUEST['tstid']; $all_awp_testimonials = getTestimonialByTestimonialId($awp_tstid); if($all_awp_testimonials->methodResponse->responseCode != '1000' && isset($all_awp_testimonials->methodResponse)) { echo '

'.$all_awp_testimonials->methodResponse->responseMessage.'

'; } $this->edit_testimonials($all_awp_testimonials); //Testimonails Edit Form. } else { $this->testimonials_form(); //Testimonails Create Form. } break; } ?>
save_testimonials_Settings(); echo '

Full View Settings Saved Successfully.

'; } $this->fullview_settings(); ?>
save_inline_settings(); echo '

Inline View Settings Saved Successfully.

'; } $this->inlineview_settings(); ?>

'.$_SESSION['awp_testmonials_messge'].'

'; endif; $all_awp_testimonials = awp_convertObjToArray($all_awp_testimonials->testimonialsList); $numberofitems = count($all_awp_testimonials); if($numberofitems>0){ $itemsperpage =5; $tpages = ceil($numberofitems/$itemsperpage); $currentpage = intval($_GET['pageno']); if($currentpage<=0) $currentpage = 1; if($currentpage>=$tpages) $currentpage = $tpages; $start = ( $currentpage - 1 ) * $itemsperpage; $all_awp_testimonials = array_slice( $all_awp_testimonials, $start, $itemsperpage ); $reload = $_SERVER['PHP_SELF'].'?page=awp_testimonials'; if(!empty($all_awp_testimonials)){ ?>
$itemsperpage) { echo awp_paginate($reload,$currentpage,$tpages,$numberofitems); } ?> siteTestimonialId && $_GET['tstmode'] =='edit') { $class = "active"; }else { $class = "inactive"; } $cur_page = intval($_GET['pageno']); if( $cur_page == '' || $cur_page == 0 || $currentpage == 1) { $cur_page = 0; }else { $cur_page = $cur_page - 1; } ?>
r
account->accountName; ?> contact->companyName; ?> account->website; ?> email; ?> testimonial))) < 30) { echo strip_tags(html_entity_decode($awp_testimonial->testimonial)); } else { $sub = strip_tags(html_entity_decode($awp_testimonial->testimonial)); echo $sub = substr($sub, 0, 30).'...'; } ?> sequenceNumber; ?>
'Template Name' ); $templates = array(); $dir_testimonials = AWP_NEWSLETTER_TEMPLATEPATH; // Open a known directory, and proceed to read its contents if (is_dir($dir_testimonials)) { if ($dh = opendir($dir_testimonials)) { while (($file = readdir($dh)) !== false) { if ( substr( $file, -4 ) == '.php' ) { $plugin_data = get_file_data( $dir_testimonials."/".$file, $default_headers, '' ); if(strlen(trim($plugin_data['Template Name'])) != 0 ) { $templates[$plugin_data['Template Name']] = $file; } } } closedir($dh); } } return $templates; } //Inline View Settings form function inlineview_settings(){ $awp_testimonials_inline_settings = get_option('awp_testimonials_inline_settings'); //Inline theme template. $awp_tst_themetemplates = get_awpTemplates(TEMPLATEPATH.'/testimonials','Inline'); //Inline plugin template. $awp_tst_plugintemplates = get_awpTemplates(AWP_TESTIMONIALS_TEMPLATEPATH,'Inline'); ksort($awp_tst_plugintemplates); if( empty($awp_testimonials_inline_settings) ) { echo ' Save the the below settings to get the Shortcode for inline view. '; } ?>

*Developers Guide - Testimonials Inline Shortcodes.
*Developers Guide - Testimonials Inline Templates.
  (Default : )
  (Default : )
'page_ID', 'selected' => $awp_testimonials_inline_settings['page_ID'])); ?>
*Developers Guide - Testimonials Inline CSS.
getAllTestimonialsForFullView(); $awp_testimonials_settings = get_option('awp_testimonials_settings'); ob_start(); if(empty($awp_testimonials_settings)) { echo awp_messagelist('testimonialsconfigure-display-page');//Testimonials are not configured in admin page }else if(empty($awp_testimonials['alltestimonials'])) { echo awp_messagelist('testimonials-display-page'); //Testimonials are not found.Need to create Testimonials. }else { include $awp_testimonials['templatefile']; } $show_testimonials = ob_get_clean(); return $show_testimonials; } function display_testimonials() { $awp_testimonials = $this->getAllTestimonialsForInline(); $awp_testimonials['alltestimonials'] = array_slice($awp_testimonials['alltestimonials'],0,$awp_testimonials['itemstoshow']); unset($awp_testimonials['templatefile']); unset($awp_testimonials['custom_css']); return $awp_testimonials; } //Short code for inline view function show_testimonials_inline(){ $awp_testimonials_inline_settings = get_option('awp_testimonials_inline_settings'); $awp_testimonials = $this->getAllTestimonialsForInline(); ob_start(); if(empty($awp_testimonials_inline_settings)) { echo awp_messagelist('testimonialsconfigure-display-page'); //Testimonials are not configured in admin page }else if(empty($awp_testimonials[alltestimonials])) { echo awp_messagelist('testimonials-display-page'); //Testimonials are not found.Need to create Testimonials. }else { include $awp_testimonials['templatefile']; } $show_testimonials = ob_get_clean(); return $show_testimonials; } /** * Testimonials Inline View. * * @return unknown */ function getAllTestimonialsForInline(){ $awp_testimonials_inline_settings = get_option('awp_testimonials_inline_settings'); if($awp_testimonials_inline_settings['template_type']=="awp_plugin_template") : $templatefile=AWP_TESTIMONIALS_TEMPLATEPATH."/".$awp_testimonials_inline_settings['template_layout']; // Plugin templates else : $templatefile=TEMPLATEPATH."/testimonials/".$awp_testimonials_inline_settings['template_layout']; //theme templates endif; if (!file_exists($templatefile)) : $templatefile = AWP_TESTIMONIALS_TEMPLATEPATH."/sliderview1.php"; endif; $response = getAllTestimonials(); $awp_all_testimonials = awp_convertObjToArray($response->testimonialsList); $page_details = get_page($awp_testimonials_inline_settings['page_ID']); $awp_testimonials = array(); $order=$awp_testimonials_inline_settings['order']; $awp_testimonials = $this->sortTestimonialByOrder($awp_all_testimonials, $order); $testimonials = array(); $testimonials['alltestimonials'] = $awp_testimonials; $testimonials['custom_css'] = $awp_testimonials_inline_settings['custom_css']; $testimonials['itemstoshow'] = $awp_testimonials_inline_settings['itemstoshow']; $testimonials['pagelink'] = $page_details->guid; $testimonials['more_text'] = $awp_testimonials_inline_settings['more_text']; $testimonials['templatefile'] = $templatefile; return $testimonials; } /** * Testimonials Full View. * * @return unknown */ function getAllTestimonialsForFullView(){ $awp_testimonials_settings = get_option('awp_testimonials_settings'); if($awp_testimonials_settings['template_type']=="awp_plugin_template") : $templatefile=AWP_TESTIMONIALS_TEMPLATEPATH."/".$awp_testimonials_settings['template_layout']; //plugin templates else : $templatefile=TEMPLATEPATH."/testimonials/".$awp_testimonials_settings['template_layout']; //theme templates endif; if (!file_exists($templatefile)) : $templatefile = AWP_TESTIMONIALS_TEMPLATEPATH."/".AWP_TESTIMONIALS_DEFAULT_TEMPLATE; endif; $response = getAllTestimonials(); $awp_all_testimonials = awp_convertObjToArray($response->testimonialsList); $order=$awp_testimonials_settings['order']; $awp_testimonials = $this->sortTestimonialByOrder($awp_all_testimonials, $order); $testimonials = array(); $testimonials['alltestimonials'] = $awp_testimonials; $testimonials['custom_css'] = $awp_testimonials_settings['custom_css']; $testimonials['templatefile'] = $templatefile; return $testimonials; } /** * Sorting Testimonails. * * @param unknown_type $awp_testimonials * @param unknown_type $order * @return unknown */ function sortTestimonialByOrder($awp_testimonials,$order){ if(!empty($awp_testimonials)) { switch($order){ case '1': usort($awp_testimonials,'awp_creation_date_compare'); break; case '2': usort($awp_testimonials,'awp_creation_date_compare'); $awp_testimonials = array_reverse($awp_testimonials); break; case '3': shuffle($awp_testimonials); break; default: usort($awp_testimonials,'awp_sort_by_sequence'); break; } return $awp_testimonials; } return false;//No data available. } //function is to append page content with shortcode function update_page_content() { $awp_testimonials_settings = get_option('awp_testimonials_settings'); $page_details = get_page($awp_testimonials_settings['page_ID']); $page_content = str_replace('[apptivo_testimonials_fullview]', '', $page_details->post_content) . "[apptivo_testimonials_fullview]"; //Update page $my_post = array(); $my_post[ID] = $awp_testimonials_settings['page_ID']; $my_post['post_content'] = $page_content; //Update the post into the database wp_update_post($my_post); } //Full View Settings Form function fullview_settings() { $awp_testimonials_settings = get_option('awp_testimonials_settings'); //Full view theme template $awp_tst_themetemplates = get_awpTemplates(TEMPLATEPATH.'/testimonials','Plugin'); //Full view Plugin template $awp_tst_plugintemplates = get_awpTemplates(AWP_TESTIMONIALS_TEMPLATEPATH,'Plugin'); $awp_tst_plugintemplates = get_awpTemplates(AWP_TESTIMONIALS_TEMPLATEPATH,'Plugin'); ksort($awp_tst_plugintemplates); if( empty($awp_testimonials_settings) ) : echo ' Save the the below settings to get the Shortcode for full view. '; endif; // if( empty($awp_testimonials_settings) ) ?>

*Developers Guide - Testimonials Fullview Shortcodes.
*Developers Guide - Testimonials Fullview Templates.
*Developers Guide - Testimonials Fullview CSS.
$_POST['awp_testimonials_templatetype'], 'template_layout' => $testimonial_layout, 'style' => $_POST['style'], 'custom_css' => stripslashes($_POST['custom_css']), 'order' => $_POST['order'], 'itemstoshow' => is_numeric($_POST['itemstoshow'])?$_POST['itemstoshow']:AWP_DEFAULT_ITEM_SHOW, 'more_text' => (trim($_POST['more_text'])!="")?$_POST['more_text']:AWP_DEFAULT_MORE_TEXT, 'page_ID' => $_POST['page_ID'], ); update_option('awp_testimonials_inline_settings', $awp_testimonials_inline_settings); } //Save Testomonials Settings function save_testimonials_Settings() { if ($_POST['awp_testimonials_templatetype'] == "awp_plugin_template") : $testimonial_layout = $_POST['awp_testimonials_plugintemplatelayout']; else : $testimonial_layout = $_POST['awp_testimonials_themetemplatelayout']; endif; $awp_testimonials_settings = array( 'template_type' => $_POST['awp_testimonials_templatetype'], 'template_layout' => $testimonial_layout, 'custom_css' => stripslashes($_POST['custom_css']), 'order' => $_POST['order'], 'page_ID' => $_POST['page_ID'], 'itemsperpage' => (!empty($_POST['itemsperpage'])) ? $_POST['itemsperpage'] : 5 ); update_option('awp_testimonials_settings', $awp_testimonials_settings); } //Testimonials Form function testimonials_form(){ ?>

Add Testimonials

 *
  (For ex: http://www.example.com/)
 *

 *
  (For ex: http://www.example.com/)
 *
testimonial; the_editor($updated_value,'awp_testimonials_cnt','',FALSE); ?>
imageDetails) */ function addTestimonials($account, $accountId, $company, $contact, $contactId, $creationDate, $email, $firmId, $images, $jobTitle, $name, $returnStatus, $sequenceNumber, $siteTestimonialId, $testimonial, $testimonialImageUrl, $testimonialStatus, $website) { $mktg_testimonials = new AWP_MktTestimonial($account, $accountId, $company, $contact, $contactId, $creationDate, $email, $firmId, $images, $jobTitle, $name, $returnStatus, $sequenceNumber, $siteTestimonialId, $testimonial, $testimonialImageUrl, $testimonialStatus, $website); $params = array ( "arg0" => APPTIVO_SITE_KEY, "arg1" => APPTIVO_ACCESS_KEY, "arg2" => $mktg_testimonials, "arg3" => null ); $response = getsoapCall(APPTIVO_BUSINESS_SERVICES,'addTestimonial',$params); return $response; } /** * @method getAllTestimonials * @return */ function getAllTestimonials() { $pubdate_params = array ( "arg0" => APPTIVO_SITE_KEY ); $plugin_params = array ( "arg0" => APPTIVO_SITE_KEY, "arg1" => APPTIVO_ACCESS_KEY, "arg2" => null ); //Memcache $response = get_data(APPTIVO_BUSINESS_SERVICES,'-news-publisheddate','-news-data','getSiteLasteUpdateDate','fetchAllTestimonials',$pubdate_params,$plugin_params); // Without Memcache. //$response = getsoapCall(APPTIVO_BUSINESS_SERVICES,'fetchAllTestimonials',$plugin_params); return $response->return; } /** * @method getAllTestimonials * @return */ function getTestimonialByTestimonialId($awp_tstid) { $params = array ( "arg0" => APPTIVO_SITE_KEY, "arg1" => APPTIVO_ACCESS_KEY, "arg2" => $awp_tstid ); $response = getsoapCall(APPTIVO_BUSINESS_SERVICES,'fetchTestimonialByTestimonialId',$params); return $response->return; } /** * Enter description here... * * @param unknown_type $awp_tstid * @return unknown */ function deleteTestimonialByTestimonialId($awp_tstid) { $params = array ( "arg0" => APPTIVO_SITE_KEY, "arg1" => APPTIVO_ACCESS_KEY, "arg2" => $awp_tstid ); $response = getsoapCall(APPTIVO_BUSINESS_SERVICES,'removeTestimonialByTestimonialId',$params); return $response; } /** * To Update Testimnails. * */ function updateTestimonials($account, $accountId, $company, $contact, $contactId, $creationDate, $email, $firmId, $images, $jobTitle, $name, $returnStatus, $sequenceNumber, $siteTestimonialId, $testimonial, $testimonialImageUrl, $testimonialStatus, $website) { $mktg_testimonials = new AWP_MktTestimonial($account, $accountId, $company, $contact, $contactId, $creationDate, $email, $firmId, $images, $jobTitle, $name, $returnStatus, $sequenceNumber, $siteTestimonialId, $testimonial, $testimonialImageUrl, $testimonialStatus, $website); $params = array ( "arg0" => APPTIVO_SITE_KEY, "arg1" => APPTIVO_ACCESS_KEY, "arg2" => $mktg_testimonials, "arg3" => null ); $response = getsoapCall(APPTIVO_BUSINESS_SERVICES,'editTestimonial',$params); return $response; } ?>