Пример #1
0
 /**
  * 
  * check export / import actions
  */
 private function checkExportImport()
 {
     //set message on start
     $message = UniteFunctionsRev::getGetVar("m");
     if ($message == "is") {
         //import success message
         $this->messageOnStart = "Import slider parameters and slides success!!!";
     }
     $clientAction = UniteFunctionsRev::getPostGetVariable("client_action");
     $helper = new HelperUniteOperationsRev();
     switch ($clientAction) {
         case "export_slider":
             $helper->exportSlider($this->sliderID);
             break;
         case "import_slider":
             $helper->importSlider($this->sliderID);
             //redirect
             $urlSlider = HelperUniteRev::getViewUrl_Slider($this->sliderID);
             $urlSlider .= "&m=is";
             UniteFunctionsRev::redirectToUrl($urlSlider);
             break;
     }
 }
    public function previewOutputMarkup($sliderID, $output = null)
    {
        if ($sliderID == "empty_output") {
            $this->loadingMessageOutput();
            exit;
        }
        if ($output == null) {
            $output = new RevSliderOutput();
        }
        $slider = new RevSlider();
        $slider->initByID($sliderID);
        $isWpmlExists = UniteWpmlRev::isWpmlExists();
        $useWpml = $slider->getParam("use_wpml", "off");
        $wpmlActive = false;
        if ($isWpmlExists && $useWpml == "on") {
            $wpmlActive = true;
            $arrLanguages = UniteWpmlRev::getArrLanguages(false);
            //set current lang to output
            $currentLang = UniteFunctionsRev::getPostGetVariable("lang");
            if (empty($currentLang)) {
                $currentLang = UniteWpmlRev::getCurrentLang();
            }
            if (empty($currentLang)) {
                $currentLang = $arrLanguages[0];
            }
            $output->setLang($currentLang);
            $selectLangChoose = UniteFunctionsRev::getHTMLSelect($arrLanguages, $currentLang, "id='select_langs'", true);
        }
        $output->setPreviewMode();
        //put the output html
        $urlPlugin = "http://yourpluginpath/";
        $urlPreviewPattern = UniteBaseClassRev::$url_ajax_actions . "&client_action=preview_slider&only_markup=true&sliderid=" . $sliderID . "&lang=[lang]&nonce=[nonce]";
        $nonce = wp_create_nonce("revslider_actions");
        $setBase = is_ssl() ? "https://" : "http://";
        $f = new ThemePunch_Fonts();
        $my_fonts = $f->get_all_fonts();
        ?>
			<html>
			<head>
				<script type='text/javascript' src='<?php 
        echo $setBase;
        ?>
ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js'></script>
			</head>
			<body style="padding:0px;margin:0px;">
				<?php 
        if ($wpmlActive == true) {
            ?>
					<div style="margin-bottom:10px;text-align:center;">
					<?php 
            _e("Choose language", REVSLIDER_TEXTDOMAIN);
            ?>
: <?php 
            echo $selectLangChoose;
            ?>
					</div>

					<script type="text/javascript">
						var g_previewPattern = '<?php 
            echo $urlPreviewPattern;
            ?>
';
						jQuery("#select_langs").change(function(){
							var lang = this.value;
							var nonce = "<?php 
            echo $nonce;
            ?>
";
							var pattern = g_previewPattern;
							var urlPreview = pattern.replace("[lang]",lang).replace("[nonce]",nonce);
							location.href = urlPreview;
						});

						jQuery('body').on('click', '#rev_replace_images', function(){
							var from = jQuery('input[name="orig_image_path"]').val();
							var to = jQuery('input[name="replace_image_path"]').val();

							jQuery('#rev_script_content').val(jQuery('#rev_script_content').val().replace(from, to));
							jQuery('#rev_the_content').val(jQuery('#rev_the_content').val().replace(from, to));
							jQuery('#rev_style_content').val(jQuery('#rev_style_content').val().replace(from, to));
							jQuery('#rev_head_content').val(jQuery('#rev_head_content').val().replace(from, to));
						});

					</script>
				<?php 
        }
        ?>
			<?php 
        //UniteBaseClassRev::$url_plugin
        ob_start();
        ?>
<link rel='stylesheet' href='<?php 
        echo $urlPlugin;
        ?>
css/settings.css?rev=<?php 
        echo GlobalsRevSlider::SLIDER_REVISION;
        ?>
' type='text/css' media='all' />
<?php 
        $http = is_ssl() ? 'https' : 'http';
        if (!empty($my_fonts)) {
            foreach ($my_fonts as $c_font) {
                ?>
<link rel='stylesheet' href="<?php 
                echo $http . '://fonts.googleapis.com/css?family=' . strip_tags($c_font['url']);
                ?>
" type='text/css' /><?php 
                echo "\n";
            }
        }
        ?>
<script type='text/javascript' src='<?php 
        echo $urlPlugin;
        ?>
js/jquery.themepunch.tools.min.js?rev=<?php 
        echo GlobalsRevSlider::SLIDER_REVISION;
        ?>
'></script>
<script type='text/javascript' src='<?php 
        echo $urlPlugin;
        ?>
js/jquery.themepunch.revolution.min.js?rev=<?php 
        echo GlobalsRevSlider::SLIDER_REVISION;
        ?>
'></script>
<?php 
        $head_content = ob_get_contents();
        ob_clean();
        ob_end_clean();
        ob_start();
        $custom_css = RevOperations::getStaticCss();
        echo $custom_css . "\n\n";
        echo '/*****************' . "\n";
        echo ' ** ' . __('CAPTIONS CSS', REVSLIDER_TEXTDOMAIN) . "\n";
        echo ' ****************/' . "\n\n";
        $db = new UniteDBRev();
        $styles = $db->fetch(GlobalsRevSlider::$table_css);
        echo UniteCssParserRev::parseDbArrayToCss($styles, "\n");
        $style_content = ob_get_contents();
        ob_clean();
        ob_end_clean();
        ob_start();
        $output->putSliderBase($sliderID);
        $content = ob_get_contents();
        ob_clean();
        ob_end_clean();
        $script_content = substr($content, strpos($content, '<script type="text/javascript">'), strpos($content, '</script>') + 9 - strpos($content, '<script type="text/javascript">'));
        $content = htmlentities(str_replace($script_content, '', $content));
        $script_content = str_replace('				', '', $script_content);
        $script_content = str_replace(array('<script type="text/javascript">', '</script>'), '', $script_content);
        ?>
			<style>
				body 	 { font-family:sans-serif; font-size:12px;}
				textarea { background:#f1f1f1; border:#ddd; font-size:10px; line-height:16px; margin-bottom:40px; padding:10px;}
				.rev_cont_title { color:#000; text-decoration:none;font-size:14px; line-height:24px; font-weight:800;background: #D5D5D5;padding: 10px;}
				.rev_cont_title a,
				.rev_cont_title a:visited { margin-left:25px;font-size:12px;line-height:12px;float:right;background-color:#8e44ad; color:#fff; padding:8px 10px;text-decoration:none;}
				.rev_cont_title a:hover	  { background-color:#9b59b6}
			</style>
			<p><?php 
        $dir = wp_upload_dir();
        ?>
				<?php 
        _e('Replace image path:', REVSLIDER_TEXTDOMAIN);
        ?>
 <?php 
        _e('From:', REVSLIDER_TEXTDOMAIN);
        ?>
 <input type="text" name="orig_image_path" value="<?php 
        echo @$dir['baseurl'];
        ?>
" /> <?php 
        _e('To:', REVSLIDER_TEXTDOMAIN);
        ?>
 <input type="text" name="replace_image_path" value="" /> <input id="rev_replace_images" type="button" name="replace_images" value="<?php 
        _e('Replace', REVSLIDER_TEXTDOMAIN);
        ?>
" />
			</p>

			<div class="rev_cont_title"><?php 
        _e('Header', REVSLIDER_TEXTDOMAIN);
        ?>
 <a class="button-primary revpurple export_slider_standalone copytoclip" data-idt="rev_head_content"  href="javascript:void(0);" original-title=""><?php 
        _e('Mark to Copy', REVSLIDER_TEXTDOMAIN);
        ?>
</a><div style="clear:both"></div></div>
			<textarea id="rev_head_content" readonly="true" style="width: 100%; height: 100px; color:#3498db"><?php 
        echo $head_content;
        ?>
</textarea>
			<div class="rev_cont_title"><?php 
        _e('CSS', REVSLIDER_TEXTDOMAIN);
        ?>
<a class="button-primary revpurple export_slider_standalone copytoclip" data-idt="rev_style_content"  href="javascript:void(0);" original-title=""><?php 
        _e('Mark to Copy', REVSLIDER_TEXTDOMAIN);
        ?>
</a></div>
			<textarea id="rev_style_content" readonly="true" style="width: 100%; height: 100px;"><?php 
        echo $style_content;
        ?>
</textarea>
			<div class="rev_cont_title"><?php 
        _e('Body', REVSLIDER_TEXTDOMAIN);
        ?>
<a class="button-primary revpurple export_slider_standalone copytoclip" data-idt="rev_the_content"  href="javascript:void(0);" original-title=""><?php 
        _e('Mark to Copy', REVSLIDER_TEXTDOMAIN);
        ?>
</a></div>
			<textarea id="rev_the_content" readonly="true" style="width: 100%; height: 100px;"><?php 
        echo $content;
        ?>
</textarea>
			<div class="rev_cont_title"><?php 
        _e('Script', REVSLIDER_TEXTDOMAIN);
        ?>
<a class="button-primary revpurple export_slider_standalone copytoclip" data-idt="rev_script_content"  href="javascript:void(0);" original-title=""><?php 
        _e('Mark to Copy', REVSLIDER_TEXTDOMAIN);
        ?>
</a></div>
			<textarea id="rev_script_content" readonly="true" style="width: 100%; height: 100px;"><?php 
        echo $script_content;
        ?>
</textarea>

			<script>
				jQuery('body').on('click','.copytoclip',function() {
					jQuery("#"+jQuery(this).data('idt')).select();
				});
			</script>
			</body>
			</html>
			<?php 
        exit;
    }
 public static function onAjaxAction()
 {
     $slider = new RevSlider();
     $slide = new RevSlide();
     $operations = new RevOperations();
     $action = self::getPostGetVar("client_action");
     $data = self::getPostGetVar("data");
     //$nonce = self::getPostGetVar("nonce");
     try {
         //verify the nonce
         //				$isVerified = wp_verify_nonce($nonce, "revslider_actions");
         //
         //				if($isVerified == false)
         //					UniteFunctionsRev::throwError("Wrong request");
         switch ($action) {
             //start font
             case 'add_google_fonts':
                 $f = new ThemePunch_Fonts();
                 $result = $f->add_new_font($data);
                 if ($result === true) {
                     self::ajaxResponseSuccessRedirect(__("Font successfully created!", REVSLIDER_TEXTDOMAIN), self::getViewUrl("sliders"));
                 } else {
                     self::ajaxResponseError($result, false);
                 }
                 break;
             case 'remove_google_fonts':
                 if (!isset($data['handle'])) {
                     self::ajaxResponseError(__('Font not found', REVSLIDER_TEXTDOMAIN), false);
                 }
                 $f = new ThemePunch_Fonts();
                 $result = $f->remove_font_by_handle($data['handle']);
                 if ($result === true) {
                     self::ajaxResponseSuccess(__("Font successfully removed!", REVSLIDER_TEXTDOMAIN), array('data' => $result));
                 } else {
                     self::ajaxResponseError($result, false);
                 }
                 break;
             case 'edit_google_fonts':
                 if (!isset($data['handle'])) {
                     self::ajaxResponseError(__('No handle given', REVSLIDER_TEXTDOMAIN), false);
                 }
                 if (!isset($data['url'])) {
                     self::ajaxResponseError(__('No parameters given', REVSLIDER_TEXTDOMAIN), false);
                 }
                 $f = new ThemePunch_Fonts();
                 $result = $f->edit_font_by_handle($data);
                 if ($result === true) {
                     self::ajaxResponseSuccess(__("Font successfully changed!", REVSLIDER_TEXTDOMAIN), array('data' => $result));
                 } else {
                     self::ajaxResponseError($result, false);
                 }
                 break;
                 //end font
             //end font
             case "export_slider":
                 $sliderID = self::getGetVar("sliderid");
                 $dummy = self::getGetVar("dummy");
                 $slider->initByID($sliderID);
                 $slider->exportSlider($dummy);
                 break;
             case "import_slider":
                 $updateAnim = self::getPostGetVar("update_animations");
                 $updateStatic = self::getPostGetVar("update_static_captions");
                 self::importSliderHandle(null, $updateAnim, $updateStatic);
                 break;
             case "import_slider_slidersview":
                 $viewBack = self::getViewUrl(self::VIEW_SLIDERS);
                 $updateAnim = self::getPostGetVar("update_animations");
                 $updateStatic = self::getPostGetVar("update_static_captions");
                 self::importSliderHandle($viewBack, $updateAnim, $updateStatic);
                 break;
             case "create_slider":
                 self::requireSettings("slider_settings");
                 $settingsMain = self::getSettings("slider_main");
                 $settingsParams = self::getSettings("slider_params");
                 $data = $operations->modifyCustomSliderParams($data);
                 //var_dump($settingsMain);
                 $newSliderID = $slider->createSliderFromOptions($data, $settingsMain, $settingsParams);
                 if ($newSliderID > 0) {
                     self::ajaxResponseSuccessRedirect(__("The slider successfully created", REVSLIDER_TEXTDOMAIN), self::getViewUrl("sliders"));
                 }
                 break;
             case "update_slider":
                 self::requireSettings("slider_settings");
                 $settingsMain = self::getSettings("slider_main");
                 $settingsParams = self::getSettings("slider_params");
                 $data = $operations->modifyCustomSliderParams($data);
                 $slider->updateSliderFromOptions($data, $settingsMain, $settingsParams);
                 sdsconfig::getgeneratecssfile();
                 self::ajaxResponseSuccess(__("Slider updated", REVSLIDER_TEXTDOMAIN));
                 break;
             case "delete_slider":
                 $isDeleted = $slider->deleteSliderFromData($data);
                 if (is_array($isDeleted)) {
                     $isDeleted = implode(', ', $isDeleted);
                     self::ajaxResponseError("Template can't be deleted, it is still being used by the following Sliders: " . $isDeleted);
                 } else {
                     self::ajaxResponseSuccessRedirect(__("The slider deleted", REVSLIDER_TEXTDOMAIN), self::getViewUrl(self::VIEW_SLIDERS));
                 }
                 break;
             case "duplicate_slider":
                 $slider->duplicateSliderFromData($data);
                 self::ajaxResponseSuccessRedirect(__("The duplicate successfully, refreshing page...", REVSLIDER_TEXTDOMAIN), self::getViewUrl(self::VIEW_SLIDERS));
                 break;
             case "add_slide":
                 $numSlides = $slider->createSlideFromData($data);
                 $sliderID = $data["sliderid"];
                 if ($numSlides == 1) {
                     $responseText = __("Slide Created", REVSLIDER_TEXTDOMAIN);
                 } else {
                     $responseText = $numSlides . " " . __("Slides Created", REVSLIDER_TEXTDOMAIN);
                 }
                 $urlRedirect = self::getViewUrl(self::VIEW_SLIDES, "id={$sliderID}");
                 sdsconfig::getgeneratecssfile();
                 self::ajaxResponseSuccessRedirect($responseText, $urlRedirect);
                 break;
             case "add_slide_fromslideview":
                 $slideID = $slider->createSlideFromData($data, true);
                 $urlRedirect = self::getViewUrl(self::VIEW_SLIDE, "id={$slideID}");
                 $responseText = __("Slide Created, redirecting...", REVSLIDER_TEXTDOMAIN);
                 sdsconfig::getgeneratecssfile();
                 self::ajaxResponseSuccessRedirect($responseText, $urlRedirect);
                 break;
             case "update_slide":
                 require self::getSettingsFilePath("slide_settings");
                 $slide->updateSlideFromData($data, $slideSettings);
                 sdsconfig::getgeneratecssfile();
                 self::ajaxResponseSuccess(__("Slide updated", REVSLIDER_TEXTDOMAIN));
                 break;
             case "update_static_slide":
                 $slide->updateStaticSlideFromData($data);
                 sdsconfig::getgeneratecssfile();
                 self::ajaxResponseSuccess(__("Static Layers updated", REVSLIDER_TEXTDOMAIN));
                 break;
             case "delete_slide":
                 $isPost = $slide->deleteSlideFromData($data);
                 if ($isPost) {
                     $message = __("Post Deleted Successfully", REVSLIDER_TEXTDOMAIN);
                 } else {
                     $message = __("Slide Deleted Successfully", REVSLIDER_TEXTDOMAIN);
                 }
                 $sliderID = UniteFunctionsRev::getVal($data, "sliderID");
                 self::ajaxResponseSuccessRedirect($message, self::getViewUrl(self::VIEW_SLIDES, "id={$sliderID}"));
                 break;
             case "duplicate_slide":
                 $sliderID = $slider->duplicateSlideFromData($data);
                 self::ajaxResponseSuccessRedirect(__("Slide Duplicated Successfully", REVSLIDER_TEXTDOMAIN), self::getViewUrl(self::VIEW_SLIDES, "id={$sliderID}"));
                 break;
             case "copy_move_slide":
                 $sliderID = $slider->copyMoveSlideFromData($data);
                 self::ajaxResponseSuccessRedirect(__("The operation successfully, refreshing page...", REVSLIDER_TEXTDOMAIN), self::getViewUrl(self::VIEW_SLIDES, "id={$sliderID}"));
                 break;
             case "get_static_css":
                 sdsconfig::getgeneratecssfile();
                 $contentCSS = $operations->getStaticCss();
                 self::ajaxResponseData($contentCSS);
                 break;
             case "get_dynamic_css":
                 sdsconfig::getgeneratecssfile();
                 $contentCSS = $operations->getDynamicCss();
                 self::ajaxResponseData($contentCSS);
                 break;
             case "insert_captions_css":
                 $arrCaptions = $operations->insertCaptionsContentData($data);
                 sdsconfig::getgeneratecssfile();
                 self::ajaxResponseSuccess(__("CSS saved succesfully!", REVSLIDER_TEXTDOMAIN), array("arrCaptions" => $arrCaptions));
                 break;
             case "update_captions_css":
                 $arrCaptions = $operations->updateCaptionsContentData($data);
                 sdsconfig::getgeneratecssfile();
                 self::ajaxResponseSuccess(__("CSS saved succesfully!", REVSLIDER_TEXTDOMAIN), array("arrCaptions" => $arrCaptions));
                 break;
             case "delete_captions_css":
                 $arrCaptions = $operations->deleteCaptionsContentData($data);
                 sdsconfig::getgeneratecssfile();
                 self::ajaxResponseSuccess(__("Style deleted succesfully!", REVSLIDER_TEXTDOMAIN), array("arrCaptions" => $arrCaptions));
                 break;
             case "update_static_css":
                 $staticCss = $operations->updateStaticCss($data);
                 sdsconfig::getgeneratecssfile();
                 self::ajaxResponseSuccess(__("CSS saved succesfully!", REVSLIDER_TEXTDOMAIN), array("css" => $staticCss));
                 break;
             case "insert_custom_anim":
                 $arrAnims = $operations->insertCustomAnim($data);
                 //$arrCaptions =
                 self::ajaxResponseSuccess(__("Animation saved succesfully!", REVSLIDER_TEXTDOMAIN), $arrAnims);
                 //,array("arrCaptions"=>$arrCaptions)
                 break;
             case "update_custom_anim":
                 $arrAnims = $operations->updateCustomAnim($data);
                 self::ajaxResponseSuccess(__("Animation saved succesfully!", REVSLIDER_TEXTDOMAIN), $arrAnims);
                 //,array("arrCaptions"=>$arrCaptions)
                 break;
             case "delete_custom_anim":
                 $arrAnims = $operations->deleteCustomAnim($data);
                 self::ajaxResponseSuccess(__("Animation saved succesfully!", REVSLIDER_TEXTDOMAIN), $arrAnims);
                 //,array("arrCaptions"=>$arrCaptions)
                 break;
             case "update_slides_order":
                 $slider->updateSlidesOrderFromData($data);
                 self::ajaxResponseSuccess(__("Order updated successfully", REVSLIDER_TEXTDOMAIN));
                 break;
             case "change_slide_image":
                 $slide->updateSlideImageFromData($data);
                 $sliderID = UniteFunctionsRev::getVal($data, "slider_id");
                 self::ajaxResponseSuccessRedirect(__("Slide Changed Successfully", REVSLIDER_TEXTDOMAIN), self::getViewUrl(self::VIEW_SLIDES, "id={$sliderID}"));
                 break;
             case "preview_slide":
                 $operations->putSlidePreviewByData($data);
                 break;
                 // case "preview_slider":
                 // 	$sliderID = UniteFunctionsRev::getPostGetVariable("sliderid");
                 // 	$operations->previewOutput($sliderID);
                 // break;
             // case "preview_slider":
             // 	$sliderID = UniteFunctionsRev::getPostGetVariable("sliderid");
             // 	$operations->previewOutput($sliderID);
             // break;
             case "preview_slider":
                 $sliderID = UniteFunctionsRev::getPostGetVariable("sliderid");
                 $do_markup = UniteFunctionsRev::getPostGetVariable("only_markup");
                 if ($do_markup == 'true') {
                     $operations->previewOutputMarkup($sliderID);
                 } else {
                     $operations->previewOutput($sliderID);
                 }
                 break;
             case "toggle_slide_state":
                 $currentState = $slide->toggleSlideStatFromData($data);
                 self::ajaxResponseData(array("state" => $currentState));
                 break;
             case "slide_lang_operation":
                 $responseData = $slide->doSlideLangOperation($data);
                 self::ajaxResponseData($responseData);
                 break;
             case "update_plugin":
                 self::updatePlugin(self::DEFAULT_VIEW);
                 break;
             case "update_text":
                 self::updateSettingsText();
                 sdsconfig::getgeneratecssfile();
                 self::ajaxResponseSuccess(__("All files successfully updated", REVSLIDER_TEXTDOMAIN));
                 break;
             case "update_general_settings":
                 $new_data = array();
                 // print_r($data);
                 foreach ($data as $key => $value) {
                     $new_data[$key] = $value;
                 }
                 $operations->updateGeneralSettings($new_data);
                 // sdsconfig::getgeneratecssfile();
                 self::ajaxResponseSuccess(__("General settings updated", REVSLIDER_TEXTDOMAIN));
                 break;
             case "update_posts_sortby":
                 $slider->updatePostsSortbyFromData($data);
                 self::ajaxResponseSuccess(__("Sortby updated", REVSLIDER_TEXTDOMAIN));
                 break;
             case "replace_image_urls":
                 $slider->replaceImageUrlsFromData($data);
                 self::ajaxResponseSuccess(__("Image urls replaced", REVSLIDER_TEXTDOMAIN));
                 break;
             case "reset_slide_settings":
                 $slider->resetSlideSettings($data);
                 sdsconfig::getgeneratecssfile();
                 self::ajaxResponseSuccess(__("Settings in all Slides changed", REVSLIDER_TEXTDOMAIN));
                 break;
             case 'delete_uploaded_image':
                 self::delete_uploaded_file($data);
                 break;
             case 'get_uploaded_images':
                 self::get_uploaded_files_json();
                 break;
             case 'add_slider_pos_val':
                 $newdata = array();
                 if (!empty($data)) {
                     $k = array_keys($data);
                     $k = preg_replace_callback('/\\[[0-9]+/', create_function('$match', 'return "";'), $k[0]);
                     foreach ($data as $key => $arr) {
                         $newdata[$k][] = $arr;
                     }
                     $data = $newdata;
                 }
                 sdsconfig::editSetting('revslideropencart', $data);
                 self::ajaxResponseSuccess(__("Slider Position Save SuccessFully", REVSLIDER_TEXTDOMAIN));
                 break;
             default:
                 self::ajaxResponseError("wrong ajax action: {$action} ");
                 break;
         }
     } catch (Exception $e) {
         $message = $e->getMessage();
         if ($action == "preview_slide" || $action == "preview_slider") {
             echo $message;
             exit;
         }
         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;
 }
Пример #4
0
 /**
  * 
  * onAjax action handler
  */
 public static function onAjaxAction()
 {
     $actionIndicator = self::getPostGetVar("action");
     if ($actionIndicator != "uniterevolution_ajax_action") {
         return false;
     }
     $action = self::getPostGetVar("client_action");
     $data = self::getPostGetVar("data");
     $nonce = self::getPostGetVar("nonce");
     $slider = new RevSlider();
     $slide = new RevSlide();
     $operations = new RevOperations();
     try {
         //verify the nonce
         $isVerified = wp_verify_nonce($nonce, "revslider_actions");
         if ($isVerified == false) {
             UniteFunctionsRev::throwError("Wrong request");
         }
         switch ($action) {
             case "export_slider":
                 RevOperations::validatePermission(GlobalsRevSlider::PERMISSION_SLIDER_OPERATIONS);
                 $sliderID = self::getGetVar("sliderid");
                 $dummy = self::getGetVar("dummy");
                 $slider->initByID($sliderID);
                 $slider->exportSlider($dummy);
                 break;
             case "import_slider":
                 RevOperations::validatePermission(GlobalsRevSlider::PERMISSION_SLIDER_OPERATIONS);
                 $updateAnim = self::getPostGetVar("update_animations");
                 $updateStatic = self::getPostGetVar("update_static_captions");
                 self::importSliderHandle(null, $updateAnim, $updateStatic);
                 break;
             case "import_slider_slidersview":
                 RevOperations::validatePermission(GlobalsRevSlider::PERMISSION_SLIDER_OPERATIONS);
                 $viewBack = self::getViewUrl(self::VIEW_SLIDERS);
                 $updateAnim = self::getPostGetVar("update_animations");
                 $updateStatic = self::getPostGetVar("update_static_captions");
                 self::importSliderHandle($viewBack, $updateAnim, $updateStatic);
                 break;
             case "create_slider":
                 RevOperations::validatePermission(GlobalsRevSlider::PERMISSION_SLIDER_OPERATIONS);
                 self::requireSettings("slider_settings");
                 $settingsMain = self::getSettings("slider_main");
                 $settingsParams = self::getSettings("slider_params");
                 $data = $operations->modifyCustomSliderParams($data);
                 $newSliderID = $slider->createSliderFromOptions($data, $settingsMain, $settingsParams);
                 self::ajaxResponseSuccessRedirect(__ug("The slider successfully created", REVSLIDER_TEXTDOMAIN), self::getViewUrl("sliders"));
                 break;
             case "update_slider":
                 RevOperations::validatePermission(GlobalsRevSlider::PERMISSION_SLIDER_SETTINGS);
                 self::requireSettings("slider_settings");
                 $settingsMain = self::getSettings("slider_main");
                 $settingsParams = self::getSettings("slider_params");
                 $data = $operations->modifyCustomSliderParams($data);
                 $slider->updateSliderFromOptions($data, $settingsMain, $settingsParams);
                 self::ajaxResponseSuccess(__ug("Slider updated", REVSLIDER_TEXTDOMAIN));
                 break;
             case "delete_slider":
                 RevOperations::validatePermission(GlobalsRevSlider::PERMISSION_SLIDER_OPERATIONS);
                 $isDeleted = $slider->deleteSliderFromData($data);
                 if (is_array($isDeleted)) {
                     $isDeleted = implode(', ', $isDeleted);
                     self::ajaxResponseError("Template can't be deleted, it is still being used by the following Sliders: " . $isDeleted);
                 } else {
                     self::ajaxResponseSuccessRedirect(__ug("The slider deleted", REVSLIDER_TEXTDOMAIN), self::getViewUrl(self::VIEW_SLIDERS));
                 }
                 break;
             case "duplicate_slider":
                 RevOperations::validatePermission(GlobalsRevSlider::PERMISSION_SLIDER_OPERATIONS);
                 $slider->duplicateSliderFromData($data);
                 self::ajaxResponseSuccessRedirect(__ug("The duplicate successfully, refreshing page...", REVSLIDER_TEXTDOMAIN), self::getViewUrl(self::VIEW_SLIDERS));
                 break;
             case "add_slide":
                 RevOperations::validatePermission(GlobalsRevSlider::PERMISSION_SLIDE_OPERATIONS);
                 $numSlides = $slider->createSlideFromData($data);
                 $sliderID = $data["sliderid"];
                 if ($numSlides == 1) {
                     $responseText = __ug("Slide Created", REVSLIDER_TEXTDOMAIN);
                 } else {
                     $responseText = $numSlides . " " . __ug("Slides Created", REVSLIDER_TEXTDOMAIN);
                 }
                 $urlRedirect = self::getViewUrl(self::VIEW_SLIDES, "id={$sliderID}");
                 self::ajaxResponseSuccessRedirect($responseText, $urlRedirect);
                 break;
             case "add_slide_fromslideview":
                 RevOperations::validatePermission(GlobalsRevSlider::PERMISSION_SLIDE_OPERATIONS);
                 $slideID = $slider->createSlideFromData($data, true);
                 $urlRedirect = self::getViewUrl(self::VIEW_SLIDE, "id={$slideID}");
                 $responseText = __ug("Slide Created, redirecting...", REVSLIDER_TEXTDOMAIN);
                 self::ajaxResponseSuccessRedirect($responseText, $urlRedirect);
                 break;
             case "update_slide":
                 RevOperations::validatePermission(GlobalsRevSlider::PERMISSION_EDIT_SLIDE);
                 require self::getSettingsFilePath("slide_settings");
                 $slide->updateSlideFromData($data, $slideSettings);
                 self::ajaxResponseSuccess(__ug("Slide updated", REVSLIDER_TEXTDOMAIN));
                 break;
             case "delete_slide":
                 RevOperations::validatePermission(GlobalsRevSlider::PERMISSION_SLIDE_OPERATIONS);
                 $isPost = $slide->deleteSlideFromData($data);
                 if ($isPost) {
                     $message = __ug("Post Deleted Successfully", REVSLIDER_TEXTDOMAIN);
                 } else {
                     $message = __ug("Slide Deleted Successfully", REVSLIDER_TEXTDOMAIN);
                 }
                 $sliderID = UniteFunctionsRev::getVal($data, "sliderID");
                 self::ajaxResponseSuccessRedirect($message, self::getViewUrl(self::VIEW_SLIDES, "id={$sliderID}"));
                 break;
             case "update_static_slide":
                 $slide->updateStaticSlideFromData($data);
                 self::ajaxResponseSuccess(__ug("Static Global Layers updated", REVSLIDER_TEXTDOMAIN));
                 break;
             case "duplicate_slide":
                 RevOperations::validatePermission(GlobalsRevSlider::PERMISSION_SLIDE_OPERATIONS);
                 $sliderID = $slider->duplicateSlideFromData($data);
                 self::ajaxResponseSuccessRedirect(__ug("Slide Duplicated Successfully", REVSLIDER_TEXTDOMAIN), self::getViewUrl(self::VIEW_SLIDES, "id={$sliderID}"));
                 break;
             case "copy_move_slide":
                 RevOperations::validatePermission(GlobalsRevSlider::PERMISSION_SLIDE_OPERATIONS);
                 $sliderID = $slider->copyMoveSlideFromData($data);
                 self::ajaxResponseSuccessRedirect(__ug("The operation successfully, refreshing page...", REVSLIDER_TEXTDOMAIN), self::getViewUrl(self::VIEW_SLIDES, "id={$sliderID}"));
                 break;
             case "get_static_css":
                 $contentCSS = $operations->getStaticCss();
                 self::ajaxResponseData($contentCSS);
                 break;
             case "get_dynamic_css":
                 $contentCSS = $operations->getDynamicCss();
                 self::ajaxResponseData($contentCSS);
                 break;
             case "insert_captions_css":
                 $arrCaptions = $operations->insertCaptionsContentData($data);
                 self::ajaxResponseSuccess(__ug("CSS saved succesfully!", REVSLIDER_TEXTDOMAIN), array("arrCaptions" => $arrCaptions));
                 break;
             case "update_captions_css":
                 $arrCaptions = $operations->updateCaptionsContentData($data);
                 self::ajaxResponseSuccess(__ug("CSS saved succesfully!", REVSLIDER_TEXTDOMAIN), array("arrCaptions" => $arrCaptions));
                 break;
             case "delete_captions_css":
                 $arrCaptions = $operations->deleteCaptionsContentData($data);
                 self::ajaxResponseSuccess(__ug("Style deleted succesfully!", REVSLIDER_TEXTDOMAIN), array("arrCaptions" => $arrCaptions));
                 break;
             case "update_static_css":
                 $staticCss = $operations->updateStaticCss($data);
                 self::ajaxResponseSuccess(__ug("CSS saved succesfully!", REVSLIDER_TEXTDOMAIN), array("css" => $staticCss));
                 break;
             case "insert_custom_anim":
                 $arrAnims = $operations->insertCustomAnim($data);
                 //$arrCaptions =
                 self::ajaxResponseSuccess(__ug("Animation saved succesfully!", REVSLIDER_TEXTDOMAIN), $arrAnims);
                 //,array("arrCaptions"=>$arrCaptions)
                 break;
             case "update_custom_anim":
                 $arrAnims = $operations->updateCustomAnim($data);
                 self::ajaxResponseSuccess(__ug("Animation saved succesfully!", REVSLIDER_TEXTDOMAIN), $arrAnims);
                 //,array("arrCaptions"=>$arrCaptions)
                 break;
             case "delete_custom_anim":
                 $arrAnims = $operations->deleteCustomAnim($data);
                 self::ajaxResponseSuccess(__ug("Animation saved succesfully!", REVSLIDER_TEXTDOMAIN), $arrAnims);
                 //,array("arrCaptions"=>$arrCaptions)
                 break;
             case "update_slides_order":
                 RevOperations::validatePermission(GlobalsRevSlider::PERMISSION_SLIDE_OPERATIONS);
                 $slider->updateSlidesOrderFromData($data);
                 self::ajaxResponseSuccess(__ug("Order updated successfully", REVSLIDER_TEXTDOMAIN));
                 break;
             case "change_slide_image":
                 RevOperations::validatePermission(GlobalsRevSlider::PERMISSION_SLIDE_OPERATIONS);
                 $slide->updateSlideImageFromData($data);
                 $sliderID = UniteFunctionsRev::getVal($data, "slider_id");
                 self::ajaxResponseSuccessRedirect(__ug("Slide Changed Successfully", REVSLIDER_TEXTDOMAIN), self::getViewUrl(self::VIEW_SLIDES, "id={$sliderID}"));
                 break;
             case "preview_slide":
                 $operations->putSlidePreviewByData($data);
                 break;
             case "preview_slider":
                 $sliderID = UniteFunctionsRev::getPostGetVariable("sliderid");
                 $do_markup = UniteFunctionsRev::getPostGetVariable("only_markup");
                 if ($do_markup == 'true') {
                     $operations->previewOutputMarkup($sliderID);
                 } else {
                     $operations->previewOutput($sliderID);
                 }
                 break;
             case "toggle_slide_state":
                 $currentState = $slide->toggleSlideStatFromData($data);
                 self::ajaxResponseData(array("state" => $currentState));
                 break;
             case "slide_lang_operation":
                 $responseData = $slide->doSlideLangOperation($data);
                 self::ajaxResponseData($responseData);
                 break;
             case "update_plugin":
                 self::updatePlugin(self::DEFAULT_VIEW);
                 break;
             case "update_text":
                 self::updateSettingsText();
                 self::ajaxResponseSuccess(__ug("All files successfully updated", REVSLIDER_TEXTDOMAIN));
                 break;
             case "update_general_settings":
                 $operations->updateGeneralSettings($data);
                 self::ajaxResponseSuccess(__ug("General settings updated", REVSLIDER_TEXTDOMAIN));
                 break;
             case "update_posts_sortby":
                 $slider->updatePostsSortbyFromData($data);
                 self::ajaxResponseSuccess(__ug("Sortby updated", REVSLIDER_TEXTDOMAIN));
                 break;
             case "replace_image_urls":
                 RevOperations::validatePermission(GlobalsRevSlider::PERMISSION_SLIDER_OPERATIONS);
                 $slider->replaceImageUrlsFromData($data);
                 self::ajaxResponseSuccess(__ug("Image urls replaced", REVSLIDER_TEXTDOMAIN));
                 break;
             case "reset_slide_settings":
                 RevOperations::validatePermission(GlobalsRevSlider::PERMISSION_SLIDE_OPERATIONS);
                 $slider->resetSlideSettings($data);
                 self::ajaxResponseSuccess(__ug("Settings in all Slides changed", REVSLIDER_TEXTDOMAIN));
                 break;
             default:
                 self::ajaxResponseError("wrong ajax action: {$action} ");
                 break;
         }
     } catch (Exception $e) {
         $message = $e->getMessage();
         if ($action == "preview_slide" || $action == "preview_slider") {
             echo $message;
             exit;
         }
         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;
 }
Пример #5
0
 /**
  * 
  * onAjax action handler
  */
 public static function onAjaxAction()
 {
     $slider = new RevSlider();
     $slide = new RevSlide();
     $operations = new RevOperations();
     $action = self::getPostGetVar("client_action");
     $data = self::getPostGetVar("data");
     $nonce = self::getPostGetVar("nonce");
     try {
         //verify the nonce
         $isVerified = wp_verify_nonce($nonce, "revslider_actions");
         if ($isVerified == false) {
             UniteFunctionsRev::throwError("Wrong request");
         }
         switch ($action) {
             case 'add_google_fonts':
                 $f = new ThemePunch_Fonts();
                 $result = $f->add_new_font($data);
                 if ($result === true) {
                     self::ajaxResponseSuccess(__("Font successfully created!", REVSLIDER_TEXTDOMAIN), array('data' => $result, 'is_redirect' => true, 'redirect_url' => self::getFontsUrl()));
                 } else {
                     self::ajaxResponseError($result, false);
                 }
                 break;
             case 'remove_google_fonts':
                 if (!isset($data['handle'])) {
                     self::ajaxResponseError(__('Font not found', REVSLIDER_TEXTDOMAIN), false);
                 }
                 $f = new ThemePunch_Fonts();
                 $result = $f->remove_font_by_handle($data['handle']);
                 if ($result === true) {
                     self::ajaxResponseSuccess(__("Font successfully removed!", REVSLIDER_TEXTDOMAIN), array('data' => $result));
                 } else {
                     self::ajaxResponseError($result, false);
                 }
                 break;
             case 'edit_google_fonts':
                 if (!isset($data['handle'])) {
                     self::ajaxResponseError(__('No handle given', REVSLIDER_TEXTDOMAIN), false);
                 }
                 if (!isset($data['url'])) {
                     self::ajaxResponseError(__('No parameters given', REVSLIDER_TEXTDOMAIN), false);
                 }
                 $f = new ThemePunch_Fonts();
                 $result = $f->edit_font_by_handle($data);
                 if ($result === true) {
                     self::ajaxResponseSuccess(__("Font successfully changed!", REVSLIDER_TEXTDOMAIN), array('data' => $result));
                 } else {
                     self::ajaxResponseError($result, false);
                 }
                 break;
             case "export_slider":
                 $sliderID = self::getGetVar("sliderid");
                 $dummy = self::getGetVar("dummy");
                 $slider->initByID($sliderID);
                 $slider->exportSlider($dummy);
                 break;
             case "import_slider":
                 $updateAnim = self::getPostGetVar("update_animations");
                 $updateStatic = self::getPostGetVar("update_static_captions");
                 self::importSliderHandle(null, $updateAnim, $updateStatic);
                 break;
             case "import_slider_slidersview":
                 $viewBack = self::getViewUrl(self::VIEW_SLIDERS);
                 $updateAnim = self::getPostGetVar("update_animations");
                 $updateStatic = self::getPostGetVar("update_static_captions");
                 self::importSliderHandle($viewBack, $updateAnim, $updateStatic);
                 break;
             case "create_slider":
                 self::requireSettings("slider_settings");
                 $settingsMain = self::getSettings("slider_main");
                 $settingsParams = self::getSettings("slider_params");
                 $data = $operations->modifyCustomSliderParams($data);
                 $newSliderID = $slider->createSliderFromOptions($data, $settingsMain, $settingsParams);
                 self::ajaxResponseSuccessRedirect(__("The slider successfully created", REVSLIDER_TEXTDOMAIN), self::getViewUrl("sliders"));
                 break;
             case "update_slider":
                 self::requireSettings("slider_settings");
                 $settingsMain = self::getSettings("slider_main");
                 $settingsParams = self::getSettings("slider_params");
                 $data = $operations->modifyCustomSliderParams($data);
                 $slider->updateSliderFromOptions($data, $settingsMain, $settingsParams);
                 self::ajaxResponseSuccess(__("Slider updated", REVSLIDER_TEXTDOMAIN));
                 break;
             case "delete_slider":
                 $isDeleted = $slider->deleteSliderFromData($data);
                 if (is_array($isDeleted)) {
                     $isDeleted = implode(', ', $isDeleted);
                     self::ajaxResponseError("Template can't be deleted, it is still being used by the following Sliders: " . $isDeleted);
                 } else {
                     self::ajaxResponseSuccessRedirect(__("The slider deleted", REVSLIDER_TEXTDOMAIN), self::getViewUrl(self::VIEW_SLIDERS));
                 }
                 break;
             case "duplicate_slider":
                 $slider->duplicateSliderFromData($data);
                 self::ajaxResponseSuccessRedirect(__("The duplicate successfully, refreshing page...", REVSLIDER_TEXTDOMAIN), self::getViewUrl(self::VIEW_SLIDERS));
                 break;
             case "add_slide":
                 $numSlides = $slider->createSlideFromData($data);
                 $sliderID = $data["sliderid"];
                 if ($numSlides == 1) {
                     $responseText = __("Slide Created", REVSLIDER_TEXTDOMAIN);
                 } else {
                     $responseText = $numSlides . " " . __("Slides Created", REVSLIDER_TEXTDOMAIN);
                 }
                 $urlRedirect = self::getViewUrl(self::VIEW_SLIDES, "id={$sliderID}");
                 self::ajaxResponseSuccessRedirect($responseText, $urlRedirect);
                 break;
             case "add_slide_fromslideview":
                 $slideID = $slider->createSlideFromData($data, true);
                 $urlRedirect = self::getViewUrl(self::VIEW_SLIDE, "id={$slideID}");
                 $responseText = __("Slide Created, redirecting...", REVSLIDER_TEXTDOMAIN);
                 self::ajaxResponseSuccessRedirect($responseText, $urlRedirect);
                 break;
             case "update_slide":
                 require self::getSettingsFilePath("slide_settings");
                 $slide->updateSlideFromData($data, $slideSettings);
                 self::ajaxResponseSuccess(__("Slide updated", REVSLIDER_TEXTDOMAIN));
                 break;
             case "update_static_slide":
                 $slide->updateStaticSlideFromData($data);
                 self::ajaxResponseSuccess(__("Static Layers updated", REVSLIDER_TEXTDOMAIN));
                 break;
             case "delete_slide":
                 $isPost = $slide->deleteSlideFromData($data);
                 if ($isPost) {
                     $message = __("Post Deleted Successfully", REVSLIDER_TEXTDOMAIN);
                 } else {
                     $message = __("Slide Deleted Successfully", REVSLIDER_TEXTDOMAIN);
                 }
                 $sliderID = UniteFunctionsRev::getVal($data, "sliderID");
                 self::ajaxResponseSuccessRedirect($message, self::getViewUrl(self::VIEW_SLIDES, "id={$sliderID}"));
                 break;
             case "duplicate_slide":
                 $sliderID = $slider->duplicateSlideFromData($data);
                 self::ajaxResponseSuccessRedirect(__("Slide Duplicated Successfully", REVSLIDER_TEXTDOMAIN), self::getViewUrl(self::VIEW_SLIDES, "id={$sliderID}"));
                 break;
             case "copy_move_slide":
                 $sliderID = $slider->copyMoveSlideFromData($data);
                 self::ajaxResponseSuccessRedirect(__("The operation successfully, refreshing page...", REVSLIDER_TEXTDOMAIN), self::getViewUrl(self::VIEW_SLIDES, "id={$sliderID}"));
                 break;
             case "get_static_css":
                 $contentCSS = $operations->getStaticCss();
                 self::ajaxResponseData($contentCSS);
                 break;
             case "get_dynamic_css":
                 $contentCSS = $operations->getDynamicCss();
                 self::ajaxResponseData($contentCSS);
                 break;
             case "insert_captions_css":
                 $arrCaptions = $operations->insertCaptionsContentData($data);
                 self::ajaxResponseSuccess(__("CSS saved succesfully!", REVSLIDER_TEXTDOMAIN), array("arrCaptions" => $arrCaptions));
                 break;
             case "update_captions_css":
                 $arrCaptions = $operations->updateCaptionsContentData($data);
                 self::ajaxResponseSuccess(__("CSS saved succesfully!", REVSLIDER_TEXTDOMAIN), array("arrCaptions" => $arrCaptions));
                 break;
             case "delete_captions_css":
                 $arrCaptions = $operations->deleteCaptionsContentData($data);
                 self::ajaxResponseSuccess(__("Style deleted succesfully!", REVSLIDER_TEXTDOMAIN), array("arrCaptions" => $arrCaptions));
                 break;
             case "update_static_css":
                 $staticCss = $operations->updateStaticCss($data);
                 self::ajaxResponseSuccess(__("CSS saved succesfully!", REVSLIDER_TEXTDOMAIN), array("css" => $staticCss));
                 break;
             case "insert_custom_anim":
                 $arrAnims = $operations->insertCustomAnim($data);
                 //$arrCaptions =
                 self::ajaxResponseSuccess(__("Animation saved succesfully!", REVSLIDER_TEXTDOMAIN), $arrAnims);
                 //,array("arrCaptions"=>$arrCaptions)
                 break;
             case "update_custom_anim":
                 $arrAnims = $operations->updateCustomAnim($data);
                 self::ajaxResponseSuccess(__("Animation saved succesfully!", REVSLIDER_TEXTDOMAIN), $arrAnims);
                 //,array("arrCaptions"=>$arrCaptions)
                 break;
             case "delete_custom_anim":
                 $arrAnims = $operations->deleteCustomAnim($data);
                 self::ajaxResponseSuccess(__("Animation saved succesfully!", REVSLIDER_TEXTDOMAIN), $arrAnims);
                 //,array("arrCaptions"=>$arrCaptions)
                 break;
             case "update_slides_order":
                 $slider->updateSlidesOrderFromData($data);
                 self::ajaxResponseSuccess(__("Order updated successfully", REVSLIDER_TEXTDOMAIN));
                 break;
             case "change_slide_image":
                 $slide->updateSlideImageFromData($data);
                 $sliderID = UniteFunctionsRev::getVal($data, "slider_id");
                 self::ajaxResponseSuccessRedirect(__("Slide Changed Successfully", REVSLIDER_TEXTDOMAIN), self::getViewUrl(self::VIEW_SLIDES, "id={$sliderID}"));
                 break;
             case "preview_slide":
                 $operations->putSlidePreviewByData($data);
                 break;
             case "preview_slider":
                 $sliderID = UniteFunctionsRev::getPostGetVariable("sliderid");
                 $do_markup = UniteFunctionsRev::getPostGetVariable("only_markup");
                 if ($do_markup == 'true') {
                     $operations->previewOutputMarkup($sliderID);
                 } else {
                     $operations->previewOutput($sliderID);
                 }
                 break;
             case "toggle_slide_state":
                 $currentState = $slide->toggleSlideStatFromData($data);
                 self::ajaxResponseData(array("state" => $currentState));
                 break;
             case "slide_lang_operation":
                 $responseData = $slide->doSlideLangOperation($data);
                 self::ajaxResponseData($responseData);
                 break;
             case "update_plugin":
                 self::updatePlugin(self::DEFAULT_VIEW);
                 break;
             case "update_text":
                 self::updateSettingsText();
                 self::ajaxResponseSuccess(__("All files successfully updated", REVSLIDER_TEXTDOMAIN));
                 break;
             case "update_general_settings":
                 $operations->updateGeneralSettings($data);
                 self::ajaxResponseSuccess(__("General settings updated", REVSLIDER_TEXTDOMAIN));
                 break;
             case "update_posts_sortby":
                 $slider->updatePostsSortbyFromData($data);
                 self::ajaxResponseSuccess(__("Sortby updated", REVSLIDER_TEXTDOMAIN));
                 break;
             case "replace_image_urls":
                 $slider->replaceImageUrlsFromData($data);
                 self::ajaxResponseSuccess(__("Image urls replaced", REVSLIDER_TEXTDOMAIN));
                 break;
             case "reset_slide_settings":
                 $slider->resetSlideSettings($data);
                 self::ajaxResponseSuccess(__("Settings in all Slides changed", REVSLIDER_TEXTDOMAIN));
                 break;
             case "activate_purchase_code":
                 $result = false;
                 if (!empty($data['username']) && !empty($data['api_key']) && !empty($data['code'])) {
                     $result = $operations->checkPurchaseVerification($data);
                 } else {
                     UniteFunctionsRev::throwError(__('The API key, the Purchase Code and the Username need to be set!', REVSLIDER_TEXTDOMAIN));
                     exit;
                 }
                 if ($result) {
                     self::ajaxResponseSuccessRedirect(__("Purchase Code Successfully Activated", REVSLIDER_TEXTDOMAIN), self::getViewUrl(self::VIEW_SLIDERS));
                 } else {
                     UniteFunctionsRev::throwError(__('Purchase Code is invalid', REVSLIDER_TEXTDOMAIN));
                 }
                 break;
             case "deactivate_purchase_code":
                 $result = $operations->doPurchaseDeactivation($data);
                 if ($result) {
                     self::ajaxResponseSuccessRedirect(__("Successfully removed validation", REVSLIDER_TEXTDOMAIN), self::getViewUrl(self::VIEW_SLIDERS));
                 } else {
                     UniteFunctionsRev::throwError(__('Could not remove Validation!', REVSLIDER_TEXTDOMAIN));
                 }
                 break;
             case "dismiss_notice":
                 update_option('revslider-valid-notice', 'false');
                 self::ajaxResponseSuccess(__(".", REVSLIDER_TEXTDOMAIN));
                 break;
             default:
                 self::ajaxResponseError("wrong ajax action: {$action} ");
                 break;
         }
     } catch (Exception $e) {
         $message = $e->getMessage();
         if ($action == "preview_slide" || $action == "preview_slider") {
             echo $message;
             exit;
         }
         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;
 }
    /**
     * 
     * preview slider output
     * if output object is null - create object
     */
    public function previewOutput($sliderID, $output = null)
    {
        if ($sliderID == "empty_output") {
            $this->loadingMessageOutput();
            exit;
        }
        if ($output == null) {
            $output = new RevSliderOutput();
        }
        $slider = new RevSlider();
        $slider->initByID($sliderID);
        $isWpmlExists = UniteWpmlRev::isWpmlExists();
        $useWpml = $slider->getParam("use_wpml", "off");
        $wpmlActive = false;
        if ($isWpmlExists && $useWpml == "on") {
            $wpmlActive = true;
            $arrLanguages = UniteWpmlRev::getArrLanguages(false);
            //set current lang to output
            $currentLang = UniteFunctionsRev::getPostGetVariable("lang");
            if (empty($currentLang)) {
                $currentLang = UniteWpmlRev::getCurrentLang();
            }
            if (empty($currentLang)) {
                $currentLang = $arrLanguages[0];
            }
            $output->setLang($currentLang);
            $selectLangChoose = UniteFunctionsRev::getHTMLSelect($arrLanguages, $currentLang, "id='select_langs'", true);
        }
        $output->setPreviewMode();
        //put the output html
        $urlPlugin = RevSliderAdmin::$url_plugin . "rs-plugin/";
        $urlPreviewPattern = UniteBaseClassRev::$url_ajax_actions . "&client_action=preview_slider&sliderid=" . $sliderID . "&lang=[lang]&nonce=[nonce]";
        $nonce = wp_create_nonce("revslider_actions");
        $setBase = is_ssl() ? "https://" : "http://";
        ?>
				<html>
					<head>
						<link rel='stylesheet' href='<?php 
        echo $urlPlugin;
        ?>
css/settings.css?rev=<?php 
        echo GlobalsRevSlider::SLIDER_REVISION;
        ?>
' type='text/css' media='all' />
						<?php 
        //check if dynamic-captions.css exists. If not, include captions.php
        //if(file_exists(UniteBaseClassRev::$path_plugin."rs-plugin/css/dynamic-captions.css") == false){
        ?>
							<link rel='stylesheet' href='<?php 
        echo $urlPlugin;
        ?>
css/captions.php?rev=<?php 
        echo GlobalsRevSlider::SLIDER_REVISION;
        ?>
' type='text/css' media='all' />
							<?php 
        /*}else{
        			?>
        			<link rel='stylesheet' href='<?php echo $urlPlugin?>css/dynamic-captions.css?rev=<?php echo GlobalsRevSlider::SLIDER_REVISION; ?>' type='text/css' media='all' />
        			<?php
        		}*/
        $custom_css = RevOperations::getStaticCss();
        echo '<style type="text/css">' . $custom_css . '</style>';
        /*<!--link rel='stylesheet' href='<?php echo $urlPlugin?>css/static-captions.css?rev=<?php echo GlobalsRevSlider::SLIDER_REVISION; ?>' type='text/css' media='all' /-->*/
        ?>
						
						<script type='text/javascript' src='<?php 
        echo $setBase;
        ?>
ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js'></script>
						<script type='text/javascript' src='<?php 
        echo $urlPlugin;
        ?>
js/jquery.themepunch.plugins.min.js?rev=<?php 
        echo GlobalsRevSlider::SLIDER_REVISION;
        ?>
'></script>
						<script type='text/javascript' src='<?php 
        echo $urlPlugin;
        ?>
js/jquery.themepunch.revolution.min.js?rev=<?php 
        echo GlobalsRevSlider::SLIDER_REVISION;
        ?>
'></script>
					</head>
					<body style="padding:0px;margin:0px;">	
						<?php 
        if ($wpmlActive == true) {
            ?>
							<div style="margin-bottom:10px;text-align:center;">
							<?php 
            _e("Choose language", REVSLIDER_TEXTDOMAIN);
            ?>
: <?php 
            echo $selectLangChoose;
            ?>
							</div>
							
							<script type="text/javascript">
								var g_previewPattern = '<?php 
            echo $urlPreviewPattern;
            ?>
';
								jQuery("#select_langs").change(function(){
									var lang = this.value;
									var nonce = "<?php 
            echo $nonce;
            ?>
";
									var pattern = g_previewPattern;
									var urlPreview = pattern.replace("[lang]",lang).replace("[nonce]",nonce);
									location.href = urlPreview;
								});
							</script>
						<?php 
        }
        ?>
						
						<?php 
        $output->putSliderBase($sliderID);
        ?>
					</body>
				</html>
			<?php 
        exit;
    }
require_once JPATH_ADMINISTRATOR . "/components/com_uniterevolution2/inc_php/framework/include_framework.php";
require_once JPATH_ADMINISTRATOR . "/components/com_uniterevolution2/inc_php/revslider_globals.class.php";
//error_reporting(E_ALL); // debug
/**
 * 
 * get revolution slider captions css
 */
function putRevCssCaptions()
{
    $tableCss = "#__" . GlobalsRevSlider::TABLE_CSS_NAME;
    $db = new UniteDBRev();
    $arrStyles = $db->fetch($tableCss);
    $cssStyles = UniteCssParserRev::parseDbArrayToCss($arrStyles, "\n");
    header('Content-type: text/css');
    echo $cssStyles;
    exit;
}
$action = UniteFunctionsRev::getPostGetVariable("action");
if (empty($action)) {
    echo "action not given";
    exit;
}
switch ($action) {
    case "getcaptions":
        putRevCssCaptions();
        break;
    default:
        echo "action not found: {$action}";
        exit;
        break;
}
 /**
  * 
  * onAjax action handler
  */
 public static function onAjaxAction()
 {
     $slider = new RevSlider();
     $slide = new RevSlide();
     $operations = new RevOperations();
     $action = self::getPostGetVar("client_action");
     $data = self::getPostGetVar("data");
     try {
         switch ($action) {
             case "export_slider":
                 $sliderID = self::getGetVar("sliderid");
                 $slider->initByID($sliderID);
                 $slider->exportSlider();
                 break;
             case "import_slider":
                 self::importSliderHandle();
                 break;
             case "import_slider_slidersview":
                 $viewBack = self::getViewUrl(self::VIEW_SLIDERS);
                 self::importSliderHandle($viewBack);
                 break;
             case "create_slider":
                 $newSliderID = $slider->createSliderFromOptions($data);
                 self::ajaxResponseSuccessRedirect(__("The slider successfully created", REVSLIDER_TEXTDOMAIN), self::getViewUrl("sliders"));
                 break;
             case "update_slider":
                 $slider->updateSliderFromOptions($data);
                 self::ajaxResponseSuccess(__("Slider updated", REVSLIDER_TEXTDOMAIN));
                 break;
             case "delete_slider":
                 $slider->deleteSliderFromData($data);
                 self::ajaxResponseSuccessRedirect(__("The slider deleted", REVSLIDER_TEXTDOMAIN), self::getViewUrl(self::VIEW_SLIDERS));
                 break;
             case "duplicate_slider":
                 $slider->duplicateSliderFromData($data);
                 self::ajaxResponseSuccessRedirect(__("The duplicate successfully, refreshing page...", REVSLIDER_TEXTDOMAIN), self::getViewUrl(self::VIEW_SLIDERS));
                 break;
             case "add_slide":
                 $numSlides = $slider->createSlideFromData($data);
                 $sliderID = $data["sliderid"];
                 if ($numSlides == 1) {
                     $responseText = __("Slide Created", REVSLIDER_TEXTDOMAIN);
                 } else {
                     $responseText = $numSlides . " " . __("Slides Created", REVSLIDER_TEXTDOMAIN);
                 }
                 $urlRedirect = self::getViewUrl(self::VIEW_SLIDES, "id={$sliderID}");
                 self::ajaxResponseSuccessRedirect($responseText, $urlRedirect);
                 break;
             case "add_slide_fromslideview":
                 $slideID = $slider->createSlideFromData($data, true);
                 $urlRedirect = self::getViewUrl(self::VIEW_SLIDE, "id={$slideID}");
                 $responseText = __("Slide Created, redirecting...", REVSLIDER_TEXTDOMAIN);
                 self::ajaxResponseSuccessRedirect($responseText, $urlRedirect);
                 break;
             case "update_slide":
                 $slide->updateSlideFromData($data);
                 self::ajaxResponseSuccess(__("Slide updated", REVSLIDER_TEXTDOMAIN));
                 break;
             case "delete_slide":
                 $slide->deleteSlideFromData($data);
                 $sliderID = UniteFunctionsRev::getVal($data, "sliderID");
                 self::ajaxResponseSuccessRedirect(__("Slide Deleted Successfully", REVSLIDER_TEXTDOMAIN), self::getViewUrl(self::VIEW_SLIDES, "id={$sliderID}"));
                 break;
             case "duplicate_slide":
                 $sliderID = $slider->duplicateSlideFromData($data);
                 self::ajaxResponseSuccessRedirect(__("Slide Duplicated Successfully", REVSLIDER_TEXTDOMAIN), self::getViewUrl(self::VIEW_SLIDES, "id={$sliderID}"));
                 break;
             case "copy_move_slide":
                 $sliderID = $slider->copyMoveSlideFromData($data);
                 self::ajaxResponseSuccessRedirect(__("The operation successfully, refreshing page...", REVSLIDER_TEXTDOMAIN), self::getViewUrl(self::VIEW_SLIDES, "id={$sliderID}"));
                 break;
             case "get_captions_css":
                 $contentCSS = $operations->getCaptionsContent();
                 self::ajaxResponseData($contentCSS);
                 break;
             case "update_captions_css":
                 $arrCaptions = $operations->updateCaptionsContentData($data);
                 self::ajaxResponseSuccess(__("CSS file saved succesfully!", REVSLIDER_TEXTDOMAIN), array("arrCaptions" => $arrCaptions));
                 break;
             case "restore_captions_css":
                 $operations->restoreCaptionsCss();
                 $contentCSS = $operations->getCaptionsContent();
                 self::ajaxResponseData($contentCSS);
                 break;
             case "update_slides_order":
                 $slider->updateSlidesOrderFromData($data);
                 self::ajaxResponseSuccess(__("Order updated successfully", REVSLIDER_TEXTDOMAIN));
                 break;
             case "change_slide_image":
                 $slide->updateSlideImageFromData($data);
                 $sliderID = UniteFunctionsRev::getVal($data, "slider_id");
                 self::ajaxResponseSuccessRedirect(__("Slide Changed Successfully", REVSLIDER_TEXTDOMAIN), self::getViewUrl(self::VIEW_SLIDES, "id={$sliderID}"));
                 break;
             case "preview_slide":
                 $operations->putSlidePreviewByData($data);
                 break;
             case "preview_slider":
                 $sliderID = UniteFunctionsRev::getPostGetVariable("sliderid");
                 $operations->previewOutput($sliderID);
                 break;
             case "toggle_slide_state":
                 $currentState = $slide->toggleSlideStatFromData($data);
                 self::ajaxResponseData(array("state" => $currentState));
                 break;
             case "slide_lang_operation":
                 $responseData = $slide->doSlideLangOperation($data);
                 self::ajaxResponseData($responseData);
                 break;
             case "update_plugin":
                 self::updatePlugin(self::DEFAULT_VIEW);
                 break;
             case "update_text":
                 self::updateSettingsText();
                 self::ajaxResponseSuccess("All files successfully updated");
                 break;
             case "update_general_settings":
                 $operations->updateGeneralSettings($data);
                 self::ajaxResponseSuccess(__("General settings updated"));
                 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;
 }
$user = JFactory::getUser();
// Access check.
if ($user->authorise('core.manage', "com_uniterevolution2") == false) {
    return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
}
$currentDir = dirname(__FILE__) . "/";
$currentFile = __FILE__;
$currentFolder = dirname($currentFile);
require_once $currentFolder . "/includes.php";
require_once $currentFolder . "/revslider_admin.php";
$action = UniteFunctionsRev::getPostGetVariable("action");
switch ($action) {
    case "getcaptions":
        RevOperations::putRevCssCaptions();
        break;
}
//add tiny box dropdown menu
$tinybox = new RevSlider_TinyBox();
$productAdmin = new RevSliderAdmin($currentFile);
//set global title
$title = JText::_('COM_UNITEREVOLUTION2');
JToolBarHelper::title($title, 'generic.png');
//enable mootools on sliders view when the permissions option is
//enable toolbar options button on a sliders view.
$manager_permission = $user->authorise('core.admin', GlobalsRevSlider::PLUGIN_NAME);
$view = UniteFunctionsRev::getPostGetVariable("view");
if ((!$view || $view == "sliders") && $manager_permission) {
    JToolBarHelper::preferences('com_uniterevolution2', 550, 875);
} else {
    UniteFunctionJoomlaRev::disableMootools();
}
Пример #10
0
    /**
     * 
     * preview slider output
     * if output object is null - create object
     */
    public function previewOutput($sliderID, $output = null)
    {
        if ($sliderID == "empty_output") {
            $this->loadingMessageOutput();
            exit;
        }
        if ($output == null) {
            $output = new RevSliderOutput();
        }
        $slider = new RevSlider();
        $slider->initByID($sliderID);
        $isWpmlExists = UniteWpmlRev::isWpmlExists();
        $useWpml = $slider->getParam("use_wpml", "off");
        $wpmlActive = false;
        if ($isWpmlExists && $useWpml == "on") {
            $wpmlActive = true;
            $arrLanguages = UniteWpmlRev::getArrLanguages(false);
            //set current lang to output
            $currentLang = UniteFunctionsRev::getPostGetVariable("lang");
            if (empty($currentLang)) {
                $currentLang = UniteWpmlRev::getCurrentLang();
            }
            if (empty($currentLang)) {
                $currentLang = $arrLanguages[0];
            }
            $output->setLang($currentLang);
            $selectLangChoose = UniteFunctionsRev::getHTMLSelect($arrLanguages, $currentLang, "id='select_langs'", true);
        }
        $output->setPreviewMode();
        //put the output html
        $urlPlugin = RevSliderAdmin::$url_plugin . "rs-plugin/";
        $urlPreviewPattern = UniteBaseClassRev::$url_ajax_actions . "&client_action=preview_slider&sliderid={$sliderID}&lang=[lang]";
        ?>
				<html>
					<head>
						<link rel='stylesheet' href='<?php 
        echo $urlPlugin;
        ?>
css/settings.css' type='text/css' media='all' />
						<link rel='stylesheet' href='<?php 
        echo $urlPlugin;
        ?>
css/captions.css' type='text/css' media='all' />
						<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js'></script>
						<script type='text/javascript' src='<?php 
        echo $urlPlugin;
        ?>
js/jquery.themepunch.revolution.min.js'></script>
					</head>
					<body style="padding:0px;margin:0px;">						
						<?php 
        if ($wpmlActive == true) {
            ?>
							<div style="margin-bottom:10px;text-align:center;">
							<?php 
            _e("Choose language");
            ?>
: <?php 
            echo $selectLangChoose;
            ?>
							</div>
							
							<script type="text/javascript">
								var g_previewPattern = '<?php 
            echo $urlPreviewPattern;
            ?>
';
								jQuery("#select_langs").change(function(){
									var lang = this.value;
									var pattern = g_previewPattern;
									var urlPreview = pattern.replace("[lang]",lang);
									location.href = urlPreview;
								});
							</script>
						<?php 
        }
        ?>
						
						<?php 
        $output->putSliderBase($sliderID);
        ?>
					</body>
				</html>
			<?php 
        exit;
    }