Example #1
0
<?php

$sliderID = self::getGetVar("id");
if (empty($sliderID)) {
    UniteFunctionsBiz::throwError("Slider ID not found");
}
$slider = new ShowBizSlider();
$slider->initByID($sliderID);
$sliderParams = $slider->getParams();
$arrSlides = $slider->getSlides();
$numSlides = count($arrSlides);
$linksSliderSettings = self::getViewUrl(ShowBizAdmin::VIEW_SLIDER, "id={$sliderID}");
$templateName = "slides_gallery";
//set posts params
if ($slider->isSourceFromPosts()) {
    $templateName = "slides_posts";
    $params = $slider->getParams();
    $postCatID = $slider->getPostCategory();
    $isMultiple = strpos($postCatID, ",") !== false;
    //get category name
    $isMultiple = true;
    /*
    if($isMultiple == false){
    	$catData = UniteFunctionsWPBiz::getCategoryData($postCatID);
    	if(empty($catData))
    		UniteFunctionsBiz::throwError("Category with id: $postCatID not found");
    	
    	$catName = $catData["cat_name"];
    	
    	$urlCatPosts = UniteFunctionsWPBiz::getUrlSlidesEditByCatID($postCatID);		
    	$linkCatPosts = UniteFunctionsBiz::getHtmlLink($urlCatPosts, $catName,"","",true);
 /**
  *
  * scan and get all sliders post types
  */
 public static function getAllSlidersPostTypes()
 {
     $sliders = new ShowBizSlider();
     $arrSliders = $sliders->getArrSliders();
     $arrAssoc = array();
     //the post shoudl be always in
     $arrAssoc["post"] = "post";
     foreach ($arrSliders as $slider) {
         $postTypes = $slider->getParam("post_types", "post");
         $arrPostTypes = explode(",", $postTypes);
         $assoc = UniteFunctionsBiz::arrayToAssoc($arrPostTypes);
         $arrAssoc = array_merge($arrAssoc, $assoc);
     }
     $arr = UniteFunctionsBiz::assocToArray($arrAssoc);
     return $arr;
 }
    /**
     * 
     * the form
     */
    public function form($instance)
    {
        $slider = new ShowBizSlider();
        $arrSliders = $slider->getArrSlidersShort();
        if (empty($arrSliders)) {
            echo __("No sliders found, Please create a slider");
        } else {
            $field = "showbiz";
            $fieldPages = "showbiz_pages";
            $fieldCheck = "showbiz_homepage";
            $fieldTitle = "showbiz_title";
            $sliderID = UniteFunctionsBiz::getVal($instance, $field);
            $homepage = UniteFunctionsBiz::getVal($instance, $fieldCheck);
            $pagesValue = UniteFunctionsBiz::getVal($instance, $fieldPages);
            $title = UniteFunctionsBiz::getVal($instance, $fieldTitle);
            $fieldID = $this->get_field_id($field);
            $fieldName = $this->get_field_name($field);
            $select = UniteFunctionsBiz::getHTMLSelect($arrSliders, $sliderID, 'name="' . $fieldName . '" id="' . $fieldID . '"', true);
            $fieldID_check = $this->get_field_id($fieldCheck);
            $fieldName_check = $this->get_field_name($fieldCheck);
            $checked = "";
            if ($homepage == "on") {
                $checked = "checked='checked'";
            }
            $fieldPages_ID = $this->get_field_id($fieldPages);
            $fieldPages_Name = $this->get_field_name($fieldPages);
            $fieldTitle_ID = $this->get_field_id($fieldTitle);
            $fieldTitle_Name = $this->get_field_name($fieldTitle);
            ?>
			<label for="<?php 
            echo $fieldTitle_ID;
            ?>
"><?php 
            _e("Title", SHOWBIZ_TEXTDOMAIN);
            ?>
:</label>
			<input type="text" name="<?php 
            echo $fieldTitle_Name;
            ?>
" id="<?php 
            echo $fieldTitle_ID;
            ?>
" value="<?php 
            echo $title;
            ?>
" class="widefat">
			
			<br><br>
		
			<?php 
            _e("Choose Slider", SHOWBIZ_TEXTDOMAIN);
            ?>
: <?php 
            echo $select;
            ?>
			
			<div style="padding-top:10px;"></div>
						
			<label for="<?php 
            echo $fieldID_check;
            ?>
"><?php 
            _e("Home Page Only", SHOWBIZ_TEXTDOMAIN);
            ?>
:</label>
			<input type="checkbox" name="<?php 
            echo $fieldName_check;
            ?>
" id="<?php 
            echo $fieldID_check;
            ?>
" <?php 
            echo $checked;
            ?>
 >
			
			<br><br>
			
			<label for="<?php 
            echo $fieldPages_ID;
            ?>
"><?php 
            _e("Pages: (example: 2,10)", SHOWBIZ_TEXTDOMAIN);
            ?>
 </label>
			<input type="text" name="<?php 
            echo $fieldPages_Name;
            ?>
" id="<?php 
            echo $fieldPages_ID;
            ?>
" value="<?php 
            echo $pagesValue;
            ?>
">
			
			<div style="padding-top:10px;"></div>
		<?php 
        }
        //else
    }
 /**
  * 
  * get sliders array - function don't belong to the object!
  */
 public function getArrSliders()
 {
     $where = "";
     $response = $this->db->fetch(GlobalsShowBiz::$table_sliders, $where, "id");
     $arrSliders = array();
     foreach ($response as $arrData) {
         $slider = new ShowBizSlider();
         $slider->initByDBData($arrData);
         $arrSliders[] = $slider;
     }
     return $arrSliders;
 }
Example #5
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;
 }
 /**
 		/* toggle slide state from data
 */
 public function toggleSlideStatFromData($data)
 {
     $sliderID = UniteFunctionsBiz::getVal($data, "slider_id");
     $slideID = UniteFunctionsBiz::getVal($data, "slide_id");
     //init slider
     $slider = new ShowBizSlider();
     $slider->initByID($sliderID);
     if ($slider->isSourceFromPosts()) {
         $this->initByPostID($slideID, $sliderID);
         $state = $this->getParam("state", "published");
         $newState = $state == "published" ? "unpublished" : "published";
         $wpStatus = $newState == "published" ? UniteFunctionsWPBiz::STATE_PUBLISHED : UniteFunctionsWPBiz::STATE_DRAFT;
         //update the state in wp
         UniteFunctionsWPBiz::updatePostState($slideID, $wpStatus);
     } else {
         $this->initByID($slideID);
         $state = $this->getParam("state", "published");
         $newState = $state == "published" ? "unpublished" : "published";
         $arrUpdate = array();
         $arrUpdate["state"] = $newState;
         $this->updateParamsInDB($arrUpdate);
     }
     $this->params["state"] = $newState;
     return $newState;
 }
Example #7
0
<?php

$slider = new ShowBizSlider();
$arrSliders = $slider->getArrSliders();
$addNewLink = self::getViewUrl(ShowBizAdmin::VIEW_SLIDER);
require self::getPathTemplate("sliders");
?>


	
Example #8
0
<?php

//$tax = get_taxonomies();dmp($tax);exit();
$settingsMain = self::getSettings("slider_main");
$settingsParams = self::getSettings("slider_params");
$settingsSliderMain = new ShowBizSettingsProduct();
$settingsSliderParams = new UniteSettingsProductSidebarBiz();
//check existing slider data:
$sliderID = self::getGetVar("id");
//get taxonomies with cats
$postTypesWithCats = BizOperations::getPostTypesWithCatsForClient();
$jsonTaxWithCats = UniteFunctionsBiz::jsonEncodeForClientSide($postTypesWithCats);
$viewTemplates = self::getPageUrl(ShowBizAdmin::VIEW_TEMPLATES, "id=");
$viewTemplatesNav = self::getPageUrl(ShowBizAdmin::VIEW_TEMPLATES_NAV, "id=");
if (!empty($sliderID)) {
    $slider = new ShowBizSlider();
    $slider->initByID($sliderID);
    //get setting fields
    $settingsFields = $slider->getSettingsFields();
    $arrFieldsMain = $settingsFields["main"];
    $arrFieldsParams = $settingsFields["params"];
    //modify arrows type for backword compatability
    $arrowsType = UniteFunctionsBiz::getVal($arrFieldsParams, "navigation_arrows");
    switch ($arrowsType) {
        case "verticalcentered":
            $arrFieldsParams["navigation_arrows"] = "solo";
            break;
    }
    //set custom type params values:
    $settingsMain = ShowBizSettingsProduct::setSettingsCustomValues($settingsMain, $arrFieldsParams, $postTypesWithCats);
    //set setting values from the slider
Example #9
0
<?php

//get input
$slideID = UniteFunctionsBiz::getGetVar("id");
//init slide object
$slide = new BizSlide();
$slide->initByID($slideID);
$slideParams = $slide->getParams();
$operations = new BizOperations();
//init slider object
$sliderID = $slide->getSliderID();
$slider = new ShowBizSlider();
$slider->initByID($sliderID);
$sliderParams = $slider->getParams();
require self::getSettingsFilePath("slide_settings");
$settingsSlideOutput = new UniteSettingsBizProductBiz();
$settingsSlide = self::getSettings("slide_settings");
//set stored values from "slide params"
$settingsSlide->setStoredValues($slideParams);
$settingsSlideOutput->init($settingsSlide);
//set various parameters needed for the page
$imageUrl = $slide->getImageUrl();
$slideTitle = $slide->getParam("title", "Slide");
$slideOrder = $slide->getOrder();
$closeUrl = self::getViewUrl(ShowBizAdmin::VIEW_SLIDES, "id={$sliderID}");
require self::getPathTemplate("slide");
?>