public static function onAddScripts()
 {
     $operations = new BannerOperations();
     $arrValues = $operations->getGeneralSettingsValues();
     $includesGlobally = UniteFunctionsBanner::getVal($arrValues, "includes_globally", "on");
     $strPutIn = UniteFunctionsBanner::getVal($arrValues, "pages_for_includes");
     $isPutIn = BannerRotatorOutput::isPutIn($strPutIn, true);
     //Put the includes only on pages with active widget or shortcode
     //If the put in match, then include them always (ignore this if)
     if ($isPutIn == false && $includesGlobally == "off") {
         $isWidgetActive = is_active_widget(false, false, "banner-rotator-widget", true);
         $hasShortcode = UniteFunctionsWPBanner::hasShortcode("banner_rotator");
         if ($isWidgetActive == false && $hasShortcode == false) {
             return false;
         }
     }
     //Banner Rotator CSS settings
     self::addStyle("banner-rotator", "banner-rotator", "css");
     self::addStyle("caption", "banner-rotator-caption", "css");
     //jQuery
     $setBase = is_ssl() ? "https://" : "http://";
     $url_jquery = $setBase . "ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js?app=banner-rotator";
     self::addScriptAbsoluteUrl($url_jquery, "jquery");
     //Banner Rotator JS
     self::addScript("jquery.flashblue-plugins", "js", "flashblue.plugins");
     self::addScript("jquery.banner-rotator", "js");
 }
    protected function drawImageInput($setting)
    {
        $class = UniteFunctionsBanner::getVal($setting, "class");
        if (!empty($class)) {
            $class = "class='{$class}'";
        }
        $settingsID = $setting["id"];
        $buttonID = $settingsID . "_button";
        $spanPreviewID = $buttonID . "_preview";
        $img = "";
        $value = UniteFunctionsBanner::getVal($setting, "value");
        if (!empty($value)) {
            $urlImage = $value;
            $imagePath = UniteFunctionsWPBanner::getImageRealPathFromUrl($urlImage);
            if (file_exists($realPath)) {
                $filepath = UniteFunctionsWPBanner::getImagePathFromURL($urlImage);
                $urlImage = UniteBaseClassBanner::getImageUrl($filepath, 100, 70, true);
            }
            $img = "<img width='100' height='70' src='{$urlImage}'></img>";
        }
        ?>
				<span id='<?php 
        echo $spanPreviewID;
        ?>
' class='setting-image-preview'><?php 
        echo $img;
        ?>
</span>
				
				<input type="hidden" id="<?php 
        echo $setting["id"];
        ?>
" name="<?php 
        echo $setting["name"];
        ?>
" value="<?php 
        echo $setting["value"];
        ?>
" />
				
				<input type="button" id="<?php 
        echo $buttonID;
        ?>
" class='button-image-select button-primary btn-blue <?php 
        echo $class;
        ?>
' value="Choose Image"></input>
			<?php 
    }
示例#3
0
if (GlobalsBannerRotator::$isNewVersion == false) {
    $wrapperClass = " oldwp";
}
$nonce = wp_create_nonce("bannerrotator_actions");
?>
<script type="text/javascript">
	var g_bannerNonce = "<?php 
echo $nonce;
?>
";
	var g_uniteDirPlagin = "<?php 
echo self::$dir_plugin;
?>
";
	var g_urlContent = "<?php 
echo UniteFunctionsWPBanner::getUrlContent();
?>
";
	var g_urlAjaxShowImage = "<?php 
echo UniteBaseClassBanner::$url_ajax_showimage;
?>
";
	var g_urlAjaxActions = "<?php 
echo UniteBaseClassBanner::$url_ajax_actions;
?>
";
	var g_settingsObj = {};
	
</script>

<div id="div_debug"></div>
 public function importSliderFromPost()
 {
     try {
         $sliderID = UniteFunctionsBanner::getPostVariable("sliderid");
         $sliderExists = !empty($sliderID);
         if ($sliderExists) {
             $this->initByID($sliderID);
         }
         $filepath = $_FILES["import_file"]["tmp_name"];
         if (file_exists($filepath) == false) {
             UniteFunctionsBanner::throwError("Import file not found!!!");
         }
         //Get content array
         $content = @file_get_contents($filepath);
         $arrSlider = @unserialize($content);
         if (empty($arrSlider)) {
             UniteFunctionsBanner::throwError("Wrong export slider file format!");
         }
         //Update slider params
         $sliderParams = $arrSlider["params"];
         if ($sliderExists) {
             $sliderParams["title"] = $this->arrParams["title"];
             $sliderParams["alias"] = $this->arrParams["alias"];
             $sliderParams["shortcode"] = $this->arrParams["shortcode"];
         }
         if (isset($sliderParams["backgroundImage"])) {
             $sliderParams["backgroundImage"] = UniteFunctionsWPBanner::getImageUrlFromPath($sliderParams["backgroundImage"]);
         }
         $json_params = json_encode($sliderParams);
         //Update slider or craete new
         if ($sliderExists) {
             $arrUpdate = array("params" => $json_params);
             $this->db->update(GlobalsBannerRotator::$table_sliders, $arrUpdate, array("id" => $sliderID));
         } else {
             //New slider
             $arrInsert = array();
             $arrInsert["params"] = $json_params;
             $arrInsert["title"] = UniteFunctionsBanner::getVal($sliderParams, "title", "Slider1");
             $arrInsert["alias"] = UniteFunctionsBanner::getVal($sliderParams, "alias", "slider1");
             $sliderID = $this->db->insert(GlobalsBannerRotator::$table_sliders, $arrInsert);
         }
         /************************
         			    - Slides handle -
         			************************/
         //Delete current slides
         if ($sliderExists) {
             $this->deleteAllSlides();
         }
         //Create all slides
         $arrSlides = $arrSlider["slides"];
         foreach ($arrSlides as $slide) {
             $params = $slide["params"];
             $layers = $slide["layers"];
             //Convert params images
             if (isset($params["image"])) {
                 $params["image"] = UniteFunctionsWPBanner::getImageUrlFromPath($params["image"]);
             }
             //Convert layers images
             foreach ($layers as $key => $layer) {
                 if (isset($layer["image_url"])) {
                     $layer["image_url"] = UniteFunctionsWPBanner::getImageUrlFromPath($layer["image_url"]);
                     $layers[$key] = $layer;
                 }
             }
             //Create new slide
             $arrCreate = array();
             $arrCreate["slider_id"] = $sliderID;
             $arrCreate["slide_order"] = $slide["slide_order"];
             $arrCreate["layers"] = json_encode($layers);
             $arrCreate["params"] = json_encode($params);
             $this->db->insert(GlobalsBannerRotator::$table_slides, $arrCreate);
         }
     } catch (Exception $e) {
         $errorMessage = $e->getMessage();
         return array("success" => false, "error" => $errorMessage, "sliderID" => $sliderID);
     }
     return array("success" => true, "sliderID" => $sliderID);
 }
示例#5
0
require_once $folderIncludes . 'base.class.php';
require_once $folderIncludes . 'elements_base.class.php';
require_once $folderIncludes . 'base_admin.class.php';
require_once $folderIncludes . 'base_front.class.php';
//Include product files
require_once $currentFolder . '/includes/bannerrotator_settings_product.class.php';
require_once $currentFolder . '/includes/bannerrotator_globals.class.php';
require_once $currentFolder . '/includes/bannerrotator_operations.class.php';
require_once $currentFolder . '/includes/bannerrotator_slider.class.php';
require_once $currentFolder . '/includes/bannerrotator_output.class.php';
require_once $currentFolder . '/includes/bannerrotator_slide.class.php';
require_once $currentFolder . '/includes/bannerrotator_widget.class.php';
require_once $currentFolder . '/includes/bannerrotator_params.class.php';
try {
    //Register the slider widget
    UniteFunctionsWPBanner::registerWidget("BannerRotator_Widget");
    //Add shortcode
    function banner_rotator_shortcode($args)
    {
        $sliderAlias = UniteFunctionsBanner::getVal($args, 0);
        ob_start();
        $slider = BannerRotatorOutput::putSlider($sliderAlias);
        $content = ob_get_contents();
        ob_clean();
        ob_end_clean();
        //Handle slider output types
        if (!empty($slider)) {
            $outputType = $slider->getParam("output_type", "");
            switch ($outputType) {
                case "compress":
                    $content = str_replace("\n", "", $content);
示例#6
0
 protected static function updateSettingsText()
 {
     $filelist = UniteFunctionsBanner::getFileList(self::$path_settings, "xml");
     foreach ($filelist as $file) {
         $filepath = self::$path_settings . $file;
         UniteFunctionsWPBanner::writeSettingLanguageFile($filepath);
     }
 }
 public static function createTable($tableName)
 {
     global $wpdb;
     //If table exists - don't create it.
     $tableRealName = self::$table_prefix . $tableName;
     if (UniteFunctionsWPBanner::isDBTableExists($tableRealName)) {
         return false;
     }
     $charset_collate = '';
     if (method_exists($wpdb, "get_charset_collate")) {
         $charset_collate = $wpdb->get_charset_collate();
     } else {
         if (!empty($wpdb->charset)) {
             $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
         }
         if (!empty($wpdb->collate)) {
             $charset_collate .= " COLLATE {$wpdb->collate}";
         }
     }
     switch ($tableName) {
         case GlobalsBannerRotator::TABLE_SLIDERS_NAME:
             $sql = "CREATE TABLE " . self::$table_prefix . $tableName . " (\n\t\t\t\t\t\t\t  id int(9) NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t\t  title tinytext NOT NULL,\n\t\t\t\t\t\t\t  alias tinytext,\n\t\t\t\t\t\t\t  params text NOT NULL,\n\t\t\t\t\t\t\t  PRIMARY KEY (id)\n\t\t\t\t\t\t\t){$charset_collate};";
             break;
         case GlobalsBannerRotator::TABLE_SLIDES_NAME:
             $sql = "CREATE TABLE " . self::$table_prefix . $tableName . " (\n\t\t\t\t\t\t\t\t  id int(9) NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t\t\t  slider_id int(9) NOT NULL,\n\t\t\t\t\t\t\t\t  slide_order int not NULL,\t\n\t\t\t\t\t\t\t\t  params text NOT NULL,\n\t\t\t\t\t\t\t\t  layers text NOT NULL,\n\t\t\t\t\t\t\t\t  PRIMARY KEY (id)\n\t\t\t\t\t\t\t\t){$charset_collate};";
             break;
         case GlobalsBannerRotator::TABLE_SETTINGS_NAME:
             $sql = "CREATE TABLE " . self::$table_prefix . $tableName . " (\n\t\t\t\t\t\t\t\t  id int(9) NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t\t\t  general TEXT NOT NULL,\n\t\t\t\t\t\t\t\t  params TEXT NOT NULL,\n\t\t\t\t\t\t\t\t  PRIMARY KEY (id)\n\t\t\t\t\t\t\t\t){$charset_collate};";
             break;
         default:
             UniteFunctionsBanner::throwError("table: {$tableName} not found");
             break;
     }
     require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     dbDelta($sql);
 }
    public function putSliderBase($sliderID)
    {
        try {
            self::$sliderSerial++;
            $this->slider = new BannerRotator();
            $this->slider->initByMixed($sliderID);
            //Modify settings for admin preview mode
            if ($this->previewMode == true) {
                $this->modifyPreviewModeSettings();
            }
            //Set slider language
            $isWpmlExists = UniteWpmlBanner::isWpmlExists();
            $useWpml = $this->slider->getParam("useWpml", "false");
            if ($isWpmlExists && $useWpml == "true") {
                if ($this->previewMode == false) {
                    $this->sliderLang = UniteFunctionsWPBanner::getCurrentLangCode();
                }
            }
            //Edit html before slider
            $htmlBeforeSlider = "";
            if ($this->slider->getParam("loadGoogleFont", "false") == "true") {
                $googleFont = $this->slider->getParam("googleFont");
                $htmlBeforeSlider = BannerOperations::getCleanFontImport($googleFont);
            }
            //Put js to body handle
            if ($this->slider->getParam("js_to_body", "false") == "true") {
                $urlIncludeJS1 = UniteBaseClassBanner::$url_plugin . "js/jquery.flashblue-plugins.js";
                $urlIncludeJS2 = UniteBaseClassBanner::$url_plugin . "js/jquery.banner-rotator.js";
                $htmlBeforeSlider .= "<script type='text/javascript' src='../inc_php/{$urlIncludeJS1}'></script>";
                $htmlBeforeSlider .= "<script type='text/javascript' src='../inc_php/{$urlIncludeJS2}'></script>";
            }
            //The initial id can be alias
            $sliderID = $this->slider->getID();
            $bannerWidth = $this->slider->getParam("width", null, BannerRotator::VALIDATE_NUMERIC, "Slider Width");
            $bannerHeight = $this->slider->getParam("height", null, BannerRotator::VALIDATE_NUMERIC, "Slider Height");
            $sliderType = $this->slider->getParam("sliderType");
            //Slider id
            $this->sliderHtmlID = "banner_rotator_" . $sliderID . "_" . self::$sliderSerial;
            //Slider wrapper
            $this->sliderHtmlID_wrapper = $this->sliderHtmlID . "_wrapper";
            $containerStyle = "";
            $sliderPosition = $this->slider->getParam("position", "center");
            //Set position
            if ($sliderType != "fullscreen") {
                switch ($sliderPosition) {
                    case "center":
                    default:
                        $containerStyle .= "margin:0px auto;";
                        break;
                    case "left":
                        $containerStyle .= "float:left;";
                        break;
                    case "right":
                        $containerStyle .= "float:right;";
                        break;
                }
            }
            //Add background color
            $backgrondColor = trim($this->slider->getParam("backgroundColor"));
            if (!empty($backgrondColor)) {
                $containerStyle .= "background-color:{$backgrondColor};";
            }
            //Set padding
            //$containerStyle .= "padding:".$this->slider->getParam("padding","0")."px;";
            //Set margin
            if ($sliderType != "fullscreen") {
                if ($sliderPosition != "center") {
                    $containerStyle .= "margin-left:" . $this->slider->getParam("marginLeft", "0") . "px;" . "margin-right:" . $this->slider->getParam("marginRight", "0") . "px;";
                }
                $containerStyle .= "margin-top:" . $this->slider->getParam("marginTop", "0") . "px;" . "margin-bottom:" . $this->slider->getParam("marginBottom", "0") . "px;";
            }
            //Set height and width
            $bannerStyle = "display:none;";
            //Add background image (to banner style)
            $showBackgroundImage = $this->slider->getParam("showBackgroundImage", "false");
            if ($showBackgroundImage == "true") {
                $backgroundImage = $this->slider->getParam("backgroundImage");
                if (!empty($backgroundImage)) {
                    $bannerStyle .= "background-image:url({$backgroundImage});background-repeat:no-repeat;";
                }
            }
            //Set wrapper and slider class
            $sliderWrapperClass = "banner-rotator-wrapper";
            $sliderClass = "banner-rotator";
            $putResponsiveStyles = false;
            switch ($sliderType) {
                default:
                case "fixed":
                    $bannerStyle .= "height:{$bannerHeight}px;width:{$bannerWidth}px;";
                    $containerStyle .= "height:{$bannerHeight}px;width:{$bannerWidth}px;";
                    break;
                case "responsitive":
                    $putResponsiveStyles = true;
                    break;
                case "fullwidth":
                    $sliderWrapperClass .= " fullwidthbanner-container";
                    $sliderClass .= " fullwidthbanner";
                    $bannerStyle .= "max-height:{$bannerHeight}px;height:{$bannerHeight};";
                    $containerStyle .= "max-height:{$bannerHeight}px;";
                    break;
                case "fullscreen":
                    $sliderWrapperClass .= " fullscreen-container";
                    $sliderClass .= " fullscreenbanner";
                    break;
            }
            //Check inner / outer border
            $paddingType = $this->slider->getParam("padding_type", "outter");
            if ($paddingType == "inner") {
                $sliderWrapperClass .= " tp_inner_padding";
            }
            global $bannerRotatorVersion;
            ?>
				
				<!-- START BANNER ROTATOR <?php 
            echo $bannerRotatorVersion;
            ?>
 <?php 
            echo $sliderType;
            ?>
 mode -->
				
				<?php 
            if ($putResponsiveStyles == true) {
                $this->putResponsitiveStyles();
            }
            ?>
				
				<?php 
            echo $htmlBeforeSlider;
            ?>
				<div id="<?php 
            echo $this->sliderHtmlID_wrapper;
            ?>
" class="<?php 
            echo $sliderWrapperClass;
            ?>
" style="<?php 
            echo $containerStyle;
            ?>
">
					<div id="<?php 
            echo $this->sliderHtmlID;
            ?>
" class="<?php 
            echo $sliderClass;
            ?>
" style="<?php 
            echo $bannerStyle;
            ?>
">						
						<?php 
            $this->putSlides();
            ?>
					</div>
				</div>				
				<?php 
            $this->putJS();
            ?>
				<!-- END BANNER ROTATOR -->
				<?php 
        } catch (Exception $e) {
            $message = $e->getMessage();
            $this->putErrorMessage($message);
        }
    }
 public static function getImageRealPathFromUrl($urlImage)
 {
     $filepath = self::getImagePathFromURL($urlImage);
     $realPath = UniteFunctionsWPBanner::getPathContent() . $filepath;
     return $realPath;
 }
 public function getParamsForExport()
 {
     $arrParams = $this->getParams();
     $urlImage = UniteFunctionsBanner::getVal($arrParams, "image");
     if (!empty($urlImage)) {
         $arrParams["image"] = UniteFunctionsWPBanner::getImagePathFromURL($urlImage);
     }
     return $arrParams;
 }
示例#11
0
 public static function getCurrentLang()
 {
     self::validateWpmlExists();
     $wpml = new SitePress();
     if (is_admin()) {
         $lang = $wpml->get_default_language();
     } else {
         $lang = UniteFunctionsWPBanner::getCurrentLangCode();
     }
     return $lang;
 }