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 
    }
 public function __construct($mainFile, $t, $defaultView)
 {
     parent::__construct($mainFile, $t);
     //Set view
     self::$view = self::getGetVar("view");
     if (empty(self::$view)) {
         self::$view = $defaultView;
     }
     //Add internal hook for adding a menu in arrMenus
     self::addAction(self::ACTION_ADMIN_MENU, "addAdminMenu");
     //If not inside plugin don't continue
     if ($this->isInsidePlugin() == true) {
         self::addAction(self::ACTION_ADD_SCRIPTS, "addCommonScripts");
         self::addAction(self::ACTION_ADD_SCRIPTS, "onAddScripts");
     }
     //A must event for any admin. call onActivate function.
     $this->addEvent_onActivate();
     self::addActionAjax("show_image", "onShowImage");
 }
 public function __construct($mainFile, $t)
 {
     parent::__construct($mainFile, $t);
     self::addAction(self::ACTION_ENQUEUE_SCRIPTS, "onAddScripts");
 }
Example #4
0
 public static function setDebugMode()
 {
     self::$debugMode = true;
 }
    private function putSlides()
    {
        $sliderType = $this->slider->getParam("sliderType");
        $publishedOnly = true;
        if ($this->previewMode == true && $this->oneSlideMode == true) {
            $publishedOnly = false;
        }
        $slides = $this->slider->getSlides($publishedOnly);
        $this->slidesNumIndex = $this->slider->getSlidesNumbersByIDs(true);
        if (empty($slides)) {
            ?>
				<div class="no-slides-text">
					No slides found, please add some slides
				</div>
				<?php 
        }
        $thumbWidth = $this->slider->getParam("thumbWidth", 72);
        $thumbHeight = $this->slider->getParam("thumbHeight", 54);
        $slideWidth = $this->slider->getParam("width", 1170);
        $slideHeight = $this->slider->getParam("height", 500);
        //For one slide preview
        if ($this->oneSlideMode == true) {
            $slides = $this->filterOneSlide($slides);
        }
        ?>
				<ul>
			<?php 
        foreach ($slides as $index => $slide) {
            $params = $slide->getParams();
            //Check if date is set
            $date_from = $slide->getParam("date_from", "");
            $date_to = $slide->getParam("date_to", "");
            if ($date_from != "") {
                $date_from = strtotime($date_from);
                if (time() < $date_from) {
                    continue;
                }
            }
            if ($date_to != "") {
                $date_to = strtotime($date_to);
                if (time() > $date_to) {
                    continue;
                }
            }
            $transition = $slide->getParam("slide_transition", "random");
            $urlSlideImage = $slide->getImageUrl();
            //Get image alt
            $imageFilename = $slide->getImageFilename();
            $info = pathinfo($imageFilename);
            $alt = $info["filename"];
            //Get thumb url
            $urlThumb = $slide->getParam("slide_thumb", "");
            if (empty($urlThumb)) {
                //try to get resized thumb
                $pathThumb = $slide->getImageFilepath();
                if (!empty($pathThumb)) {
                    $urlThumb = UniteBaseClassBanner::getImageUrl($pathThumb, $thumbWidth, $thumbHeight, true);
                }
            }
            //If not - put regular image:
            if (empty($urlThumb)) {
                $urlThumb = $slide->getImageUrl();
            }
            $htmlThumb = 'data-thumb="' . $urlThumb . '" ';
            //Get link
            $htmlLink = "";
            $enableLink = $slide->getParam("enable_link", "false");
            if ($enableLink == "true") {
                $linkType = $slide->getParam("link_type", "regular");
                switch ($linkType) {
                    //Normal link
                    default:
                    case "regular":
                        $link = $slide->getParam("link", "");
                        $linkOpenIn = $slide->getParam("link_open_in", "same");
                        $htmlTarget = "";
                        if ($linkOpenIn == "new") {
                            $htmlTarget = ' data-target="_blank"';
                        }
                        $htmlLink = "data-link=\"{$link}\" {$htmlTarget} ";
                        break;
                        //Link to slide
                    //Link to slide
                    case "slide":
                        $slideLink = UniteFunctionsBanner::getVal($params, "slide_link");
                        if (!empty($slideLink) && $slideLink != "nothing") {
                            //Get slide index from id
                            if (is_numeric($slideLink)) {
                                $slideLink = UniteFunctionsBanner::getVal($this->slidesNumIndex, $slideLink);
                            }
                            if (!empty($slideLink)) {
                                $htmlLink = "data-link=\"slide\" data-linktoslide=\"{$slideLink}\" ";
                            }
                        }
                        break;
                }
                //Set link position
                $linkPos = UniteFunctionsBanner::getVal($params, "link_pos", "front");
                if ($linkPos == "back") {
                    $htmlLink .= 'data-slideindex="back" ';
                }
            }
            //Set delay
            $htmlDelay = "";
            $delay = $slide->getParam("delay", "");
            if (!empty($delay) && is_numeric($delay)) {
                $htmlDelay = "data-delay=\"{$delay}\" ";
            }
            //Get duration
            $htmlDuration = "";
            $duration = $slide->getParam("transition_duration", "");
            if (!empty($duration) && is_numeric($duration)) {
                $htmlDuration = "data-masterspeed=\"{$duration}\" ";
            }
            //Get rotation
            $htmlRotation = "";
            $rotation = $slide->getParam("transition_rotation", "");
            if (!empty($rotation)) {
                $rotation = (int) $rotation;
                if ($rotation != 0) {
                    if ($rotation > 720 && $rotation != 999) {
                        $rotation = 720;
                    }
                    if ($rotation < -720) {
                        $rotation = -720;
                    }
                }
                $htmlRotation = "data-rotate=\"{$rotation}\" ";
            }
            $fullWidthVideoData = $this->getSlideFullWidthVideoData($slide);
            //Set full width centering
            $htmlImageCentering = "";
            $fullWidthCentering = $slide->getParam("fullwidth_centering", "false");
            if ($sliderType == "fullwidth" && $fullWidthCentering == "true") {
                $htmlImageCentering = ' data-fullwidthcentering="on"';
            }
            //Set first item
            $currentItem = $this->slider->getCurrentItemSetting();
            $htmlParams = $htmlDuration . $htmlLink . $htmlThumb . $htmlDelay . $htmlRotation;
            $bgType = $slide->getParam("background_type", "image");
            $styleImage = "";
            $urlImageTransparent = UniteBaseClassBanner::$url_plugin . "images/transparent.png";
            switch ($bgType) {
                case "trans":
                    $urlSlideImage = $urlImageTransparent;
                    break;
                case "solid":
                    $urlSlideImage = $urlImageTransparent;
                    $slideBGColor = $slide->getParam("slide_bg_color", "#d0d0d0");
                    $styleImage = "style='background-color:{$slideBGColor}'";
                    break;
            }
            //Additional params
            $imageAddParams = "";
            $lazyLoad = $this->slider->getParam("lazyLoad", "false");
            if ($lazyLoad == "true") {
                $imageAddParams .= "data-lazyload=\"{$urlSlideImage}\"";
                $urlSlideImage = UniteBaseClassBanner::$url_plugin . "images/dummy.png";
            }
            $imageAddParams .= $htmlImageCentering;
            //Html
            ?>
					<li data-transition="<?php 
            echo $transition;
            ?>
" <?php 
            echo $htmlParams;
            ?>
>
						<img src="<?php 
            echo $urlSlideImage;
            ?>
" <?php 
            echo $styleImage;
            ?>
 alt="<?php 
            echo $alt;
            ?>
" <?php 
            echo $imageAddParams;
            ?>
>
						<?php 
            //Put video
            if ($fullWidthVideoData["found"] == true) {
                //Backward compatability
                $this->putFullWidthVideoLayer($fullWidthVideoData);
            }
            $this->putCreativeLayer($slide);
            ?>
					</li>
				<?php 
        }
        ?>
				</ul>
			<?php 
    }