示例#1
0
 /**
  * 
  * onAjax action handler
  */
 public static function onAjaxAction()
 {
     $slider = new ShowBizSlider();
     $slide = new BizSlide();
     $templates = new ShowBizTemplate();
     $operations = new BizOperations();
     $wildcards = new ShowBizWildcards();
     $action = self::getPostGetVar("client_action");
     $data = self::getPostGetVar("data");
     $nonce = self::getPostGetVar("nonce");
     try {
         //verify the nonce
         $isVerified = wp_verify_nonce($nonce, "showbiz_actions");
         if ($isVerified == false) {
             UniteFunctionsBiz::throwError("Wrong request");
         }
         switch ($action) {
             case "update_general_settings":
                 $operations->updateGeneralSettings($data);
                 self::ajaxResponseSuccess(__("General settings updated", SHOWBIZ_TEXTDOMAIN));
                 break;
             case "export_slider":
                 $sliderID = self::getGetVar("sliderid");
                 $slider->initByID($sliderID);
                 $slider->exportSlider();
                 break;
             case "import_slider":
                 self::importSliderHandle();
                 break;
             case "create_slider":
                 $newSliderID = $slider->createSliderFromOptions($data);
                 self::ajaxResponseSuccessRedirect("The slider successfully created", self::getViewUrl("sliders"));
                 break;
             case "update_slider":
                 $slider->updateSliderFromOptions($data);
                 self::ajaxResponseSuccess("Slider updated");
                 break;
             case "delete_slider":
                 $slider->deleteSliderFromData($data);
                 self::ajaxResponseSuccessRedirect("The slider deleted", self::getViewUrl(self::VIEW_SLIDERS));
                 break;
             case "duplicate_slider":
                 $slider->duplicateSliderFromData($data);
                 self::ajaxResponseSuccessRedirect("The duplicate successfully, refreshing page...", self::getViewUrl(self::VIEW_SLIDERS));
                 break;
             case "add_slide":
                 $slider->createSlideFromData($data);
                 $sliderID = $data["sliderid"];
                 self::ajaxResponseSuccessRedirect("Slide Created, refreshing...", self::getViewUrl(self::VIEW_SLIDES, "id={$sliderID}"));
                 break;
             case "update_slide":
                 $slide->updateSlideFromData($data);
                 self::ajaxResponseSuccess("Slide updated");
                 break;
             case "delete_slide":
                 $slide->deleteSlideFromData($data);
                 $sliderID = UniteFunctionsBiz::getVal($data, "sliderID");
                 self::ajaxResponseSuccessRedirect("Slide Deleted Successfully", self::getViewUrl(self::VIEW_SLIDES, "id={$sliderID}"));
                 break;
             case "duplicate_slide":
                 $sliderID = $slider->duplicateSlideFromData($data);
                 self::ajaxResponseSuccessRedirect("Slide Duplicated Successfully", self::getViewUrl(self::VIEW_SLIDES, "id={$sliderID}"));
                 break;
             case "update_slides_order":
                 $slider->updateSlidesOrderFromData($data);
                 self::ajaxResponseSuccess("Order updated successfully");
                 break;
             case "preview_slide":
                 $operations->putSlidePreviewByData($data);
                 break;
             case "preview_slider":
                 $sliderID = UniteFunctionsBiz::getPostVariable("sliderid");
                 $operations->previewOutput($sliderID);
                 break;
             case "preview_template":
                 $templateID = UniteFunctionsBiz::getPostGetVariable("templateid");
                 $operations->previewTemplateOutput($templateID);
                 break;
             case "toggle_slide_state":
                 $currentState = $slide->toggleSlideStatFromData($data);
                 self::ajaxResponseData(array("state" => $currentState));
                 break;
             case "update_plugin":
                 self::updateShowbizPlugin();
                 break;
             case "create_template":
                 $templates->addFromData($data);
                 self::ajaxResponseSuccess("Template Added Successfully");
                 break;
             case "delete_template":
                 $templates->deleteFromData($data);
                 self::ajaxResponseSuccess("Template Deleted Successfully");
                 break;
             case "duplicate_template":
                 $templates->duplicateFromData($data);
                 self::ajaxResponseSuccess("Template Duplicated Successfully");
                 break;
             case "get_template_content":
                 $content = $templates->getContentFromData($data);
                 $arrData = array("content" => $content);
                 self::ajaxResponseData($arrData);
                 break;
             case "get_template_css":
                 $css = $templates->getCssFromData($data);
                 $arrData = array("css" => $css);
                 self::ajaxResponseData($arrData);
                 break;
             case "update_template_content":
                 $templates->updateContentFromData($data);
                 self::ajaxResponseSuccess("Content Updated Successfully");
                 break;
             case "update_template_title":
                 $templates->updateTitleFromData($data);
                 self::ajaxResponseSuccess("Title Updated Successfully");
                 break;
             case "update_template_css":
                 $templates->updateCssFromData($data);
                 self::ajaxResponseSuccess("Css Updated Successfully");
                 break;
             case "restore_original_template":
                 $templates->restoreOriginalFromData($data);
                 self::ajaxResponseSuccess("Template Restored");
                 break;
             case "update_posts_sortby":
                 $slider->updatePostsSortbyFromData($data);
                 self::ajaxResponseSuccess("Sortby updated");
                 break;
             case "change_slide_image":
                 $slide->updateSlideImageFromData($data);
                 self::ajaxResponseSuccess("Image Changed");
                 break;
             case "add_wildcard":
                 $response = $wildcards->addFromData($data);
                 self::ajaxResponseSuccess("Added successfully", $response);
                 break;
             case "remove_wildcard":
                 $response = $wildcards->removeFromData($data);
                 self::ajaxResponseSuccess("Removed successfully", $response);
                 break;
             case "activate_purchase_code":
                 $result = false;
                 if (!empty($data['username']) && !empty($data['api_key']) && !empty($data['code'])) {
                     $result = $operations->checkPurchaseVerification($data);
                 } else {
                     UniteFunctionsBiz::throwError(__('The API key, the Purchase Code and the Username need to be set!'));
                     exit;
                 }
                 if ($result) {
                     self::ajaxResponseSuccessRedirect(__("Purchase Code Successfully Activated"), self::getViewUrl(self::VIEW_SLIDERS));
                 } else {
                     UniteFunctionsBiz::throwError(__('Purchase Code is invalid'));
                 }
                 break;
             case "deactivate_purchase_code":
                 $result = $operations->doPurchaseDeactivation($data);
                 if ($result) {
                     self::ajaxResponseSuccessRedirect(__("Successfully removed validation"), self::getViewUrl(self::VIEW_SLIDERS));
                 } else {
                     UniteFunctionsBiz::throwError(__('Could not remove Validation!'));
                 }
                 break;
             case "dismiss_notice":
                 update_option('showbiz-valid-notice', 'false');
                 self::ajaxResponseSuccess(__("."));
                 break;
             default:
                 self::ajaxResponseError("wrong ajax action: {$action} ");
                 break;
         }
     } catch (Exception $e) {
         $message = $e->getMessage();
         self::ajaxResponseError($message);
     }
     //it's an ajax action, so exit
     self::ajaxResponseError("No response output on <b> {$action} </b> action. please check with the developer.");
     exit;
 }
示例#2
0
$slideSettings->addSelect("template_id", $arrTemplates, "Item Template", "", $params);
$slideSettings->addHr();
//-----------------------
//enable link
$slideSettings->addSelect_boolean("enable_link", "Enable Link", false, "Enable", "Disable");
$slideSettings->startBulkControl("enable_link", UniteSettingsBiz::CONTROL_TYPE_SHOW, "true");
//link
$params = array("description" => "A link on the whole slide pic");
$slideSettings->addTextBox("link", "", "Slide Link", $params);
$slideSettings->addHr();
$slideSettings->endBulkControl();
$params = array("description" => "", "width" => 300, "height" => 200);
$slideSettings->addImage("slide_image", "", "Slide Image", $params);
//editor
$params = array("description" => "");
$slideSettings->addEditor("slide_text", "", "Slide Text", $params);
$params = array("description" => "Overwrite the global excerpt words limit option for this slide", "class" => "small");
$slideSettings->addTextBox("showbiz_excerpt_limit", "", "Excerpt Words Limit", $params);
$slideSettings->addHr();
$params = array("description" => "The youtube ID, example: 9bZkp7q19f0", "class" => "medium");
$slideSettings->addTextBox("youtube_id", "", "Youtube ID", $params);
$params = array("description" => "The youtube ID, example: 18554749", "class" => "medium");
$slideSettings->addTextBox("vimeo_id", "", "Vimeo ID", $params);
$slideSettings->addHr();
//add the wildcards
$slideSettings->addStaticText("Those custom options can be used for variety of purposes in the templates section.");
$objWildcards = new ShowBizWildcards();
$settingsWildcards = $objWildcards->getWildcardsSettings(true);
$slideSettings->addFromSettingsObject($settingsWildcards);
//store settings
self::storeSettings("slide_settings", $slideSettings);
 /**
  * 
  * process template html
  * get item html and process it by the template
  */
 public function processTemplateHtml($html)
 {
     $title = $this->getValue("title");
     $alias = $this->getValue("alias");
     $urlImage = $this->imageUrl;
     $urlImageOrig = $this->imageUrlOrig;
     $text = $this->getValue("slide_text");
     $link = $this->getValue("link");
     if (empty($link)) {
         $link = "#";
     }
     $date = $this->getValue("date");
     $dateModified = $this->getValue("date_modified");
     $excerpt = $this->getValue("excerpt");
     $youtubeID = $this->getValue("youtube_id");
     $vimeoID = $this->getValue("vimeo_id");
     $authorName = $this->getValue("author_name");
     $authorID = $this->getValue("author_id");
     $numComments = $this->getValue("num_comments");
     $catList = $this->getValue("catlist");
     $tagList = $this->getValue("taglist");
     $postID = $this->id;
     if ($this->getValue('lazy_load') == 'on') {
         $html = UniteFunctionsBiz::add_lazy_loading($html, $this->getValue('lazy_load_image'), $this->getValue('lazy_load_height'));
     }
     //replace the items in the html
     $html = $this->replacePlaceholder("title", $title, $html);
     $html = $this->replacePlaceholder("id", $postID, $html);
     $html = $this->replacePlaceholder("alias", $alias, $html);
     $html = $this->replacePlaceholder("name", $alias, $html);
     $html = $this->replacePlaceholder("empty_image", UniteBaseClassBiz::$url_plugin . 'images/transparent.png', $html);
     $html = $this->replacePlaceholder("image", $urlImage, $html);
     $html = $this->replacePlaceholder("image_orig", $urlImageOrig, $html);
     $html = $this->replacePlaceholder("content", $text, $html);
     $html = $this->replacePlaceholder("link", $link, $html);
     $html = $this->replacePlaceholder("date", $date, $html);
     $html = $this->replacePlaceholder("modified_date", $dateModified, $html);
     $html = $this->replacePlaceholder("excerpt", $excerpt, $html);
     $html = $this->replacePlaceholder("youtube_id", $youtubeID, $html);
     $html = $this->replacePlaceholder("vimeo_id", $vimeoID, $html);
     $html = $this->replacePlaceholder("author_id", $authorID, $html);
     $html = $this->replacePlaceholder("author", $authorName, $html);
     $html = $this->replacePlaceholder("numcomments", $numComments, $html);
     $html = $this->replacePlaceholder("catlist", $catList, $html);
     $html = $this->replacePlaceholder("taglist", $tagList, $html);
     //replace custom options:
     $wildcards = new ShowBizWildcards();
     $arrCustomOptionsNames = $wildcards->getWildcardsSettingNames();
     foreach ($arrCustomOptionsNames as $name => $title) {
         $html = $this->replacePlaceholder($name, $this->getValue($name), $html, false);
     }
     //replace woocommerce options:
     $enableWC = $this->getParam("enable_wc", "on");
     if ($enableWC == "on" && UniteFunctionsWooCommerceBiz::isWooCommerceExists() && $this->slideType == self::TYPE_POST) {
         $WCRegularPrice = get_post_meta($this->id, "_regular_price", true);
         $WCSalePrice = get_post_meta($this->id, "_sale_price", true);
         $WCStock = get_post_meta($this->id, "_stock", true);
         $WCProduct = get_product($this->id);
         $WCRating = $WCProduct->get_average_rating();
         if (empty($WCRating)) {
             $WCRating = 0;
         }
         $WCCategories = $WCProduct->get_categories(",");
         $html = $this->replacePlaceholder("wc_regular_price", $WCRegularPrice, $html);
         $html = $this->replacePlaceholder("wc_sale_price", $WCSalePrice, $html);
         $html = $this->replacePlaceholder("wc_stock", $WCStock, $html);
         $html = $this->replacePlaceholder("wc_rating", $WCRating, $html);
         $html = $this->replacePlaceholder("wc_categories", $WCCategories, $html);
     }
     //process meta tags:
     $arrMatches = array();
     //preg_match('/\[showbiz_meta:\w+\]/', $html, $arrMatches);
     preg_match_all('/\\[showbiz_meta:\\w+\\]/', $html, $arrMatches);
     foreach ($arrMatches as $matches) {
         if (is_array($matches)) {
             foreach ($matches as $match) {
                 $meta = str_replace("[showbiz_meta:", "", $match);
                 $meta = str_replace("]", "", $meta);
                 $metaValue = get_post_meta($postID, $meta, true);
                 $html = str_replace($match, $metaValue, $html);
             }
         }
     }
     //$meta = get_post_meta($this->id);dmp($meta);exit();
     //replace all the normal shortcodes
     $html = do_shortcode($html);
     //check for shortcodes
     return $html;
 }
示例#4
0
<?php

$operations = new BizOperations();
$templates = new ShowBizTemplate();
$titleText = "ShowBiz Skin Editor";
//new item prefix
$templatesPrefix = "Item Template";
$templatesType = GlobalsShowBiz::TEMPLATE_TYPE_ITEM;
$arrTemplates = $templates->getList($templatesType);
$arrButtons = $operations->getArrEditorButtons();
//set buttons array
//$arrButtons["break"] = "";
$arrOriginalTemplates = BizOperations::getArrInitItemTemplates(true);
//merge with wildcards
$objWildcards = new ShowBizWildcards();
$arrWildcards = $objWildcards->getWildcardsSettingNames();
$linkShowAll = self::getPageUrl(ShowBizAdmin::VIEW_TEMPLATES);
$filterID = UniteFunctionsBiz::getGetVar("id");
$showCustomOptions = true;
$arrCustomOptions = $objWildcards->getArrCustomOptions();
$showClasses = true;
$arrClasses = $operations->getArrEditorClasses();
$standartOptionsName = "Post Options";
$linkHelp = GlobalsShowBiz::LINK_HELP_TEMPLATES_ITEMS;
require self::getPathTemplate("templates");
?>