Ejemplo n.º 1
0
<?php

/**
 * First let's check if rotator ID is provided
 */
$rid = isset($_GET['rid']) ? $_GET['rid'] : '';
$bid = isset($_GET['bid']) ? intval($_GET['bid']) : 0;
if (!preg_match('/^[0-9a-f]{16}$/', $rid)) {
    exit('Please set a correct rotator ID');
}
/**
 * Then include some files
 */
require 'config.php';
require 'include/banner_rotator.class.php';
require 'include/banner_rotator_storage.class.php';
/**
 * Now we can process click and redirect user somewhere
 */
$storage = new BannerRotatorStorage($rid);
$rotator = new BannerRotator($storage);
$url = $rotator->click($bid);
header('Location: ' . $url);
 public function getArrSliders()
 {
     $where = "";
     $response = $this->db->fetch(GlobalsBannerRotator::$table_sliders, $where, "id");
     $arrSliders = array();
     foreach ($response as $arrData) {
         $slider = new BannerRotator();
         $slider->initByDBData($arrData);
         $arrSliders[] = $slider;
     }
     return $arrSliders;
 }
Ejemplo n.º 3
0
 public static function onAjaxAction()
 {
     $slider = new BannerRotator();
     $slide = new BannerSlide();
     $operations = new BannerOperations();
     $action = self::getPostGetVar("client_action");
     $data = self::getPostGetVar("data");
     $nonce = self::getPostGetVar("nonce");
     try {
         //Verify the nonce
         $isVerified = wp_verify_nonce($nonce, "bannerrotator_actions");
         if ($isVerified == false) {
             UniteFunctionsBanner::throwError("Wrong request");
         }
         switch ($action) {
             case "export_slider":
                 $sliderID = self::getGetVar("sliderid");
                 $dummy = self::getGetVar("dummy");
                 $slider->initByID($sliderID);
                 $slider->exportSlider($dummy);
                 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", BANNERROTATOR_TEXTDOMAIN), self::getViewUrl("sliders"));
                 break;
             case "update_slider":
                 $slider->updateSliderFromOptions($data);
                 self::ajaxResponseSuccess(__("Slider updated", BANNERROTATOR_TEXTDOMAIN));
                 break;
             case "delete_slider":
                 $slider->deleteSliderFromData($data);
                 self::ajaxResponseSuccessRedirect(__("The slider deleted", BANNERROTATOR_TEXTDOMAIN), self::getViewUrl(self::VIEW_SLIDERS));
                 break;
             case "duplicate_slider":
                 $slider->duplicateSliderFromData($data);
                 self::ajaxResponseSuccessRedirect(__("The duplicate successfully, refreshing page...", BANNERROTATOR_TEXTDOMAIN), self::getViewUrl(self::VIEW_SLIDERS));
                 break;
             case "add_slide":
                 $numSlides = $slider->createSlideFromData($data);
                 $sliderID = $data["sliderid"];
                 if ($numSlides == 1) {
                     $responseText = __("Slide Created", BANNERROTATOR_TEXTDOMAIN);
                 } else {
                     $responseText = $numSlides . " " . __("Slides Created", BANNERROTATOR_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...", BANNERROTATOR_TEXTDOMAIN);
                 self::ajaxResponseSuccessRedirect($responseText, $urlRedirect);
                 break;
             case "update_slide":
                 $slide->updateSlideFromData($data);
                 self::ajaxResponseSuccess(__("Slide updated", BANNERROTATOR_TEXTDOMAIN));
                 break;
             case "delete_slide":
                 $slide->deleteSlideFromData($data);
                 $sliderID = UniteFunctionsBanner::getVal($data, "sliderID");
                 self::ajaxResponseSuccessRedirect(__("Slide Deleted Successfully", BANNERROTATOR_TEXTDOMAIN), self::getViewUrl(self::VIEW_SLIDES, "id={$sliderID}"));
                 break;
             case "duplicate_slide":
                 $sliderID = $slider->duplicateSlideFromData($data);
                 self::ajaxResponseSuccessRedirect(__("Slide Duplicated Successfully", BANNERROTATOR_TEXTDOMAIN), self::getViewUrl(self::VIEW_SLIDES, "id={$sliderID}"));
                 break;
             case "copy_move_slide":
                 $sliderID = $slider->copyMoveSlideFromData($data);
                 self::ajaxResponseSuccessRedirect(__("The operation successfully, refreshing page...", BANNERROTATOR_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!", BANNERROTATOR_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", BANNERROTATOR_TEXTDOMAIN));
                 break;
             case "change_slide_image":
                 $slide->updateSlideImageFromData($data);
                 $sliderID = UniteFunctionsBanner::getVal($data, "slider_id");
                 self::ajaxResponseSuccessRedirect(__("Slide Changed Successfully", BANNERROTATOR_TEXTDOMAIN), self::getViewUrl(self::VIEW_SLIDES, "id={$sliderID}"));
                 break;
             case "preview_slide":
                 $operations->putSlidePreviewByData($data);
                 break;
             case "preview_slider":
                 $sliderID = UniteFunctionsBanner::getPostVariable("sliderid");
                 $operations->previewOutput($sliderID);
                 break;
             case "toggle_slide_state":
                 $currentState = $slide->toggleSlideStateFromData($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;
 }
Ejemplo n.º 4
0
<?php

/**
 * First let's check if rotator ID is provided
 */
$rid = isset($_GET['rid']) ? $_GET['rid'] : '';
if (!preg_match('/^[0-9a-f]{16}$/', $rid)) {
    exit('Please set a correct rotator ID');
}
/**
 * Then include some files
 */
require 'config.php';
require 'include/banner_rotator.class.php';
require 'include/banner_rotator_storage.class.php';
/**
 * And now we are ready to load and "rotate" some banners
 */
$storage = new BannerRotatorStorage($rid);
$rotator = new BannerRotator($storage);
$banner = $rotator->rotate();
/**
 * Finally, we can render the template with the selected banner
 */
include 'template.php';
Ejemplo n.º 5
0
<?php

$settingsMain = self::getSettings("slider_main");
$settingsParams = self::getSettings("slider_params");
$settingsSliderMain = new BannerRotatorSettingsProduct();
$settingsSliderParams = new UniteSettingsProductSidebarBanner();
//Check existing slider data
$sliderID = self::getGetVar("id");
if (!empty($sliderID)) {
    $slider = new BannerRotator();
    $slider->initByID($sliderID);
    //Get setting fields
    $settingsFields = $slider->getSettingsFields();
    $arrFieldsMain = $settingsFields["main"];
    $arrFieldsParams = $settingsFields["params"];
    //Set setting values from the slider
    $settingsMain->setStoredValues($arrFieldsParams);
    //Set custom type params values:
    $settingsMain = BannerRotatorSettingsProduct::setSettingsCustomValues($settingsMain, $arrFieldsParams);
    $settingsParams->setStoredValues($arrFieldsParams);
    //Update short code setting
    $shortcode = $slider->getShortcode();
    $settingsMain->updateSettingValue("shortcode", $shortcode);
    $linksEditSlides = self::getViewUrl(BannerRotatorAdmin::VIEW_SLIDES, "id={$sliderID}");
    $settingsSliderParams->init($settingsParams);
    $settingsSliderMain->init($settingsMain);
    $settingsSliderParams->isAccordion(true);
    require self::getPathTemplate("slider_edit");
} else {
    $settingsSliderParams->init($settingsParams);
    $settingsSliderMain->init($settingsMain);
    public function form($instance)
    {
        $slider = new BannerRotator();
        $arrSliders = $slider->getArrSlidersShort();
        if (empty($arrSliders)) {
            echo __("No sliders found, Please create a slider");
        } else {
            $field = "banner_rotator";
            $fieldPages = "banner_rotator_pages";
            $fieldCheck = "banner_rotator_homepage";
            $sliderID = UniteFunctionsBanner::getVal($instance, $field);
            $homepage = UniteFunctionsBanner::getVal($instance, $fieldCheck);
            $pagesValue = UniteFunctionsBanner::getVal($instance, $fieldPages);
            $fieldID = $this->get_field_id($field);
            $fieldName = $this->get_field_name($field);
            $select = UniteFunctionsBanner::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);
            ?>
				Choose Slider: <?php 
            echo $select;
            ?>
				<div style="padding-top:10px;"></div>
				
				<label for="<?php 
            echo $fieldID_check;
            ?>
">Home Page Only:</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;
            ?>
">Pages: (example: 2,10) </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 
        }
    }
Ejemplo n.º 7
0
<?php

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


	
    public function previewOutput($sliderID, $output = null)
    {
        if ($sliderID == "empty_output") {
            $this->loadingMessageOutput();
            exit;
        }
        if ($output == null) {
            $output = new BannerRotatorOutput();
        }
        $output->setPreviewMode();
        $slider = new BannerRotator();
        $slider->initByID($sliderID);
        $isWpmlExists = UniteWpmlBanner::isWpmlExists();
        $useWpml = $slider->getParam("useWpml", "false");
        $wpmlActive = false;
        if ($isWpmlExists && $useWpml == "true") {
            $wpmlActive = true;
            $arrLanguages = UniteWpmlBanner::getArrLanguages(false);
            //Set current lang to output
            $currentLang = UniteFunctionsBanner::getPostGetVariable("lang");
            if (empty($currentLang)) {
                $currentLang = UniteWpmlBanner::getCurrentLang();
            }
            if (empty($currentLang)) {
                $currentLang = $arrLanguages[0];
            }
            $output->setLang($currentLang);
            $selectLangChoose = UniteFunctionsBanner::getHTMLSelect($arrLanguages, $currentLang, "id='select_langs'", true);
        }
        //Put the output html
        $urlPlugin = BannerRotatorAdmin::$url_plugin;
        $urlPreviewPattern = UniteBaseClassBanner::$url_ajax_actions . "&client_action=preview_slider&sliderid={$sliderID}&lang=[lang]&nonce=[nonce]";
        $nonce = wp_create_nonce("bannerrotator_actions");
        $setBase = is_ssl() ? "https://" : "http://";
        ?>
				<html>
					<head>
						<link rel='stylesheet' href='<?php 
        echo $urlPlugin;
        ?>
css/banner-rotator.css' type='text/css' media='all' />
						<link rel='stylesheet' href='<?php 
        echo $urlPlugin;
        ?>
css/caption.css' type='text/css' media='all' />
						<script type='text/javascript' src='<?php 
        echo $setBase;
        ?>
ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js'></script>
						<script type='text/javascript' src='<?php 
        echo $urlPlugin;
        ?>
js/jquery.flashblue-plugins.js'></script>
						<script type='text/javascript' src='<?php 
        echo $urlPlugin;
        ?>
js/jquery.banner-rotator.js'></script>
					</head>
					<body style="padding:0px;margin:0px;">
						<?php 
        if ($wpmlActive) {
            ?>
							<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 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;
    }
Ejemplo n.º 9
0
<?php

$sliderID = self::getGetVar("id");
if (empty($sliderID)) {
    UniteFunctionsBanner::throwError("Slider ID not found");
}
$slider = new BannerRotator();
$slider->initByID($sliderID);
$sliderParams = $slider->getParams();
$arrSliders = $slider->getArrSlidersShort($sliderID);
$selectSliders = UniteFunctionsBanner::getHTMLSelect($arrSliders, "", "id='selectSliders'", true);
$numSliders = count($arrSliders);
//Set iframe parameters
$width = $sliderParams["width"];
$height = $sliderParams["height"];
$iframeWidth = $width + 60;
$iframeHeight = $height + 50;
$iframeStyle = "width:{$iframeWidth}px;height:{$iframeHeight}px;";
//Handle wpml
$isWpmlExists = UniteWpmlBanner::isWpmlExists();
$useWpml = $slider->getParam("useWpml", "false");
$wpmlActive = false;
if ($isWpmlExists && $useWpml == "true") {
    $wpmlActive = true;
    //Get langs floating menu
    $urlIconDelete = self::$url_plugin . "images/icon-trash.png";
    $urlIconEdit = self::$url_plugin . "images/icon-edit.png";
    $urlIconPreview = self::$url_plugin . "images/preview.png";
    $textDelete = __("Delete Slide", BANNERROTATOR_TEXTDOMAIN);
    $textEdit = __("Edit Slide", BANNERROTATOR_TEXTDOMAIN);
    $textPreview = __("Preview Slide", BANNERROTATOR_TEXTDOMAIN);
Ejemplo n.º 10
0
<?php

//Get input
$slideID = UniteFunctionsBanner::getGetVar("id");
//Init slide object
$slide = new BannerSlide();
$slide->initByID($slideID);
$slideParams = $slide->getParams();
$operations = new BannerOperations();
//Init slider object
$sliderID = $slide->getSliderID();
$slider = new BannerRotator();
$slider->initByID($sliderID);
$sliderParams = $slider->getParams();
$arrSlideNames = $slider->getArrSlideNames();
//Set slide delay
$sliderDelay = $slider->getParam("delay", "9000");
$slideDelay = $slide->getParam("delay", "");
if (empty($slideDelay)) {
    $slideDelay = $sliderDelay;
}
require self::getSettingsFilePath("slide_settings");
require self::getSettingsFilePath("layer_settings");
$settingsLayerOutput = new UniteSettingsProductSidebarBanner();
$settingsSlideOutput = new UniteSettingsBannerProductBanner();
$arrLayers = $slide->getLayers();
//Get settings objects
$settingsLayer = self::getSettings("layer_settings");
$settingsSlide = self::getSettings("slide_settings");
$cssContent = self::getSettings("css_captions_content");
$arrCaptionClasses = $operations->getArrCaptionClasses($cssContent);
 private function addLangFromData($data)
 {
     $sliderID = UniteFunctionsBanner::getVal($data, "sliderid");
     $slideID = UniteFunctionsBanner::getVal($data, "slideid");
     $lang = UniteFunctionsBanner::getVal($data, "lang");
     //duplicate slide
     $slider = new BannerRotator();
     $slider->initByID($sliderID);
     $newSlideID = $slider->duplicateSlide($slideID);
     //update new slide
     $this->initByID($newSlideID);
     $arrUpdate = array();
     $arrUpdate["lang"] = $lang;
     $arrUpdate["parentid"] = $slideID;
     $this->updateParamsInDB($arrUpdate);
     $urlIcon = UniteWpmlBanner::getFlagUrl($lang);
     $title = UniteWpmlBanner::getLangTitle($lang);
     $newSlide = new BannerSlide();
     $newSlide->initByID($slideID);
     $arrLangCodes = $newSlide->getArrChildLangCodes();
     $isAll = UniteWpmlBanner::isAllLangsInArray($arrLangCodes);
     $html = "<li>\n\t\t\t\t\t\t<img id=\"icon_lang_{$newSlideID}\" class=\"icon_slide_lang\" src=\"{$urlIcon}\" title=\"{$title}\" data-slideid=\"{$newSlideID}\" data-lang=\"{$lang}\">\n\t\t\t\t\t\t<div class=\"icon_lang_loader loader_round\" style=\"display:none\"></div>\t\t\t\t\t\t\t\t\n\t\t\t\t\t</li>";
     $response = array();
     $response["operation"] = "add";
     $response["isAll"] = $isAll;
     $response["html"] = $html;
     return $response;
 }