static function render($slider, $id, $params) { $shadow = $params->get(self::$key . 'shadow-image'); if (empty($shadow)) { $shadow = $params->get(self::$key . 'shadow'); if ($shadow == -1) { $shadow = null; } } if (!$shadow) { return ''; } N2JS::addFile(N2Filesystem::translate(dirname(__FILE__) . '/shadow/shadow.js'), $id); list($displayClass, $displayAttributes) = self::getDisplayAttributes($params, self::$key); list($style, $attributes) = self::getPosition($params, self::$key); $width = $params->get(self::$key . 'width'); if (is_numeric($width) || substr($width, -1) == '%' || substr($width, -2) == 'px') { $style .= 'width:' . $width . ';'; } else { $attributes['data-sswidth'] = $width; } $parameters = array('overlay' => $params->get(self::$key . 'position-mode') != 'simple' || 0, 'area' => intval($params->get(self::$key . 'position-area'))); N2JS::addInline('new NextendSmartSliderWidgetShadow("' . $id . '", ' . json_encode($parameters) . ');'); return N2Html::tag('div', $displayAttributes + $attributes + array('class' => $displayClass . "nextend-shadow", 'style' => $style), N2Html::image(N2ImageHelper::fixed($shadow), 'Shadow', array('style' => 'display: block; width:100%;max-width:none;', 'class' => 'n2-ow nextend-shadow-image'))); }
protected function getImageStyle() { $image = $this->getValue(); if (empty($image) || $image[0] == '{') { return ''; } return 'background-image:url(' . N2ImageHelper::fixed($image) . ');'; }
protected function renderType() { $params = $this->slider->params; N2JS::addFiles(N2Filesystem::translate(dirname(__FILE__) . "/gsap"), array("MainAnimationSimple.js", "TypeSimple.js", "ResponsiveSimple.js"), "smartslider-simple-type-frontend"); N2JS::addFiles(N2Filesystem::translate(dirname(__FILE__) . "/gsap"), array("BackgroundAnimation.js"), "smartslider-simple-type-frontend"); N2JS::addFiles(NEXTEND_SMARTSLIDER_ASSETS . "/js/animation", array("BackgroundAnimationAbstract.js", 'Flux.js'), "smartslider-simple-type-frontend"); $background = $params->get('background'); $css = $params->get('slider-css'); $slidecss = $params->get('slide-css'); if (!empty($background)) { $css = 'background-image: url(' . N2ImageHelper::fixed($background) . ');'; } $this->initBackgroundAnimation(); echo $this->openSliderElement(); ?> <div class="n2-ss-slider-1" style="<?php echo $css; ?> "> <?php echo $this->getBackgroundVideo($params); ?> <div class="n2-ss-slider-2"> <?php if ($this->backgroundAnimation) { ?> <div class="n2-ss-background-animation"></div> <?php } ?> <div class="n2-ss-slider-3" style="<?php echo $slidecss; ?> "> <?php echo $this->slider->staticHtml; foreach ($this->slider->slides as $i => $slide) { echo N2Html::tag('div', $slide->attributes + array('class' => 'n2-ss-slide n2-ss-canvas ' . $slide->classes, 'style' => $slide->style), $slide->background . $slide->getHTML()); } ?> </div> </div> </div> <?php $this->widgets->echoRemainder(); echo N2Html::closeTag('div'); $this->javaScriptProperties['mainanimation'] = array('type' => $params->get('animation'), 'duration' => intval($params->get('animation-duration')), 'delay' => intval($params->get('animation-delay')), 'ease' => $params->get('animation-easing'), 'parallax' => floatval($params->get('animation-parallax')), 'shiftedBackgroundAnimation' => $params->get('animation-shifted-background-animation')); $this->javaScriptProperties['mainanimation']['shiftedBackgroundAnimation'] = 0; $this->javaScriptProperties['carousel'] = intval($params->get('carousel')); $this->javaScriptProperties['dynamicHeight'] = intval($params->get('dynamic-height', '0')); $this->javaScriptProperties['dynamicHeight'] = 0; N2Plugin::callPlugin('nextendslider', 'onNextendSliderProperties', array(&$this->javaScriptProperties)); N2JS::addFirstCode("new NextendSmartSliderSimple('#{$this->slider->elementId}', " . json_encode($this->javaScriptProperties) . ");"); echo N2Html::clear(); }
function setFolder() { $folder = N2XmlHelper::getAttribute($this->_xml, 'folder'); if (!empty($folder) && $folder[0] != '$') { $folder = dirname($this->_form->_xmlfile) . '/' . $folder . '/'; } else { $folder = N2ImageHelper::fixed($folder, true); } $this->_folder = N2Filesystem::translate($folder); }
public function actionGenerateImage() { $this->validateToken(); $device = N2Request::getVar('device'); $this->validateVariable($device == 'tablet' || $device == 'mobile', 'device'); $image = N2Request::getVar('image'); $this->validateVariable(!empty($image), 'image'); N2Loader::import('libraries.image.image'); $scale = array('tablet' => 0.5, 'mobile' => 0.3); $newImage = N2Image::scaleImage('image', $image, $scale[$device], true); $this->response->respond(array('image' => N2ImageHelper::fixed($newImage))); }
function generateOptions(&$xml) { $this->values = array(); $html = ''; foreach ($xml->option as $option) { $value = N2XmlHelper::getAttribute($option, 'value'); $selected = $this->isSelected($value); $this->values[] = $value; $html .= N2Html::tag("div", array("class" => "n2-radio-option n2-imagelist-option" . ($selected ? ' n2-active' : ''), "style" => "background-image:url(" . N2ImageHelper::fixed(N2XmlHelper::getAttribute($option, 'image')) . ");"), N2Html::tag('span', array(), (string) $option)); } return $html; }
static function render($slider, $id, $params) { $html = ''; $play = $params->get(self::$key . 'play-image'); $playColor = $params->get(self::$key . 'play-color'); if (empty($play)) { $play = $params->get(self::$key . 'play'); if ($play == -1) { $play = null; } elseif ($play[0] != '$') { $play = N2Uri::pathToUri(dirname(__FILE__) . '/image/play/' . $play); } } if ($params->get(self::$key . 'mirror')) { $pause = str_replace('image/play/', 'image/pause/', $play); $pauseColor = $playColor; } else { $pause = $params->get(self::$key . 'pause-image'); $pauseColor = $params->get(self::$key . 'pause-color'); if (empty($pause)) { $pause = $params->get(self::$key . 'pause'); if ($pause == -1) { $pause = null; } elseif ($pause[0] != '$') { $pause = N2Uri::pathToUri(dirname(__FILE__) . '/image/pause/' . $pause); } } } $ext = pathinfo($play, PATHINFO_EXTENSION); if (substr($play, 0, 1) == '$' && $ext == 'svg') { list($color, $opacity) = N2Color::colorToSVG($playColor); $play = 'data:image/svg+xml;base64,' . base64_encode(str_replace(array('fill="#FFF"', 'opacity="1"'), array('fill="#' . $color . '"', 'opacity="' . $opacity . '"'), N2Filesystem::readFile(N2ImageHelper::fixed($play, true)))); } else { $play = N2ImageHelper::fixed($play); } $ext = pathinfo($pause, PATHINFO_EXTENSION); if (substr($pause, 0, 1) == '$' && $ext == 'svg') { list($color, $opacity) = N2Color::colorToSVG($pauseColor); $pause = 'data:image/svg+xml;base64,' . base64_encode(str_replace(array('fill="#FFF"', 'opacity="1"'), array('fill="#' . $color . '"', 'opacity="' . $opacity . '"'), N2Filesystem::readFile(N2ImageHelper::fixed($pause, true)))); } else { $pause = N2ImageHelper::fixed($pause); } if ($play && $pause) { N2CSS::addFile(N2Filesystem::translate(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'image' . DIRECTORY_SEPARATOR . 'style.css'), $id); N2JS::addFile(N2Filesystem::translate(dirname(__FILE__) . '/image/autoplay.js'), $id); list($displayClass, $displayAttributes) = self::getDisplayAttributes($params, self::$key); $styleClass = N2StyleRenderer::render($params->get(self::$key . 'style'), 'heading', $slider->elementId, 'div#' . $slider->elementId . ' '); list($style, $attributes) = self::getPosition($params, self::$key); N2JS::addInline('new NextendSmartSliderWidgetAutoplayImage("' . $id . '", ' . floatval($params->get(self::$key . 'responsive-desktop')) . ', ' . floatval($params->get(self::$key . 'responsive-tablet')) . ', ' . floatval($params->get(self::$key . 'responsive-mobile')) . ');'); $html = N2Html::tag('div', $displayAttributes + $attributes + array('class' => $displayClass . $styleClass . 'nextend-autoplay nextend-autoplay-image', 'style' => $style), N2Html::image($play, '', array('class' => 'nextend-autoplay-play n2-ow')) . N2Html::image($pause, '', array('class' => 'nextend-autoplay-pause n2-ow'))); } return $html; }
public function renderGroupOption($group, $sources) { $button = false; $buttons = array(); foreach ($sources as $type => $info) { /** * @var $info N2GeneratorInfo */ if ($info->hasConfiguration) { $buttons[$this->appType->router->createUrl(array("generator/checkConfiguration", array("sliderid" => N2Request::getInt('sliderid'), "group" => $group, "type" => $type)))] = $info->title; } elseif (!$info->installed) { $button = N2Html::link(n2_("Visit site"), $info->readMore, array("target" => "_blank", "class" => "n2-button n2-button-big n2-button-grey")); break; } else { $buttons[$this->appType->router->createUrl(array("generator/createSettings", array("sliderid" => N2Request::getInt('sliderid'), "group" => $group, "type" => $type)))] = $info->title; } } if (!$button && ($count = count($buttons))) { if ($count == 1) { reset($buttons); $key = key($buttons); $button = N2Html::link($buttons[$key], $key, array("class" => "n2-button n2-button-small n2-button-blue n2-h5")); } else { $keys = array_keys($buttons); $actions = array(); for ($i = 0; $i < count($keys); $i++) { $actions[] = N2Html::link($buttons[$keys[$i]], $keys[$i], array('class' => 'n2-h4')); } ob_start(); $this->widget->init("buttonmenu", array("content" => N2Html::tag('div', array('class' => 'n2-button-menu'), N2Html::tag('div', array('class' => 'n2-button-menu-inner n2-border-radius'), implode('', $actions))))); $buttonMenu = ob_get_clean(); $button = N2Html::tag('div', array('class' => 'n2-button n2-button-with-menu n2-button-small n2-h5 n2-button-blue'), N2Html::link($buttons[$keys[0]], $keys[0], array('class' => 'n2-button-inner')) . $buttonMenu); } } $this->widget->init("box", array('attributes' => array('class' => 'n2-box-generator'), 'image' => N2ImageHelper::fixed(N2Uri::pathToUri(N2Filesystem::translate($info->path . '/../dynamic.png'))), 'firstCol' => $button)); }
/** * @param $slider N2SmartSliderAbstract * @param $id * @param $params * * @return string */ static function render($slider, $id, $params) { $showImage = intval($params->get(self::$key . 'show-image')); $showTitle = intval($params->get(self::$key . 'title')); $showDescription = intval($params->get(self::$key . 'description')); if (!$showImage && !$showTitle && !$showDescription) { // Nothing to show return ''; } N2JS::addFile(N2Filesystem::translate(dirname(__FILE__) . '/default/thumbnail.js'), $id); N2LESS::addFile(N2Filesystem::translate(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'default' . DIRECTORY_SEPARATOR . 'style.less'), $slider->cacheId, array("sliderid" => $slider->elementId), NEXTEND_SMARTSLIDER_ASSETS . '/less' . NDS); list($displayClass, $displayAttributes) = self::getDisplayAttributes($params, self::$key); list($style, $attributes) = self::getPosition($params, self::$key); $attributes['data-offset'] = $params->get(self::$key . 'position-offset', 0); $barStyle = N2StyleRenderer::render($params->get(self::$key . 'style-bar'), 'simple', $slider->elementId, 'div#' . $slider->elementId . ' '); $slideStyle = N2StyleRenderer::render($params->get(self::$key . 'style-slides'), 'dot', $slider->elementId, 'div#' . $slider->elementId . ' '); $width = intval($slider->params->get(self::$key . 'width', 160)); $height = intval($slider->params->get(self::$key . 'height', 100)); $captionPlacement = $slider->params->get(self::$key . 'caption-placement', 'overlay'); if (!$showImage) { $captionPlacement = 'before'; } if (!$showTitle && !$showDescription) { $captionPlacement = 'overlay'; } $captionSize = intval($slider->params->get(self::$key . 'caption-size', 100)); $showCaption = $showTitle || $showDescription; if ($showCaption) { $captionStyle = N2StyleRenderer::render($params->get(self::$key . 'title-style'), 'simple', $slider->elementId, 'div#' . $slider->elementId . ' '); if ($showTitle) { $titleFont = N2FontRenderer::render($params->get(self::$key . 'title-font'), 'simple', $slider->elementId, 'div#' . $slider->elementId . ' '); } if ($showDescription) { $descriptionFont = N2FontRenderer::render($params->get(self::$key . 'description-font'), 'simple', $slider->elementId, 'div#' . $slider->elementId . ' '); } } $group = max(1, intval($params->get(self::$key . 'group'))); $orientation = self::getOrientationByPosition($params->get(self::$key . 'position-mode'), $params->get(self::$key . 'position-area'), $params->get(self::$key . 'orientation')); if ($orientation == 'auto') { $orientation = 'vertical'; } $slides = N2Html::openTag('table'); $containerStyle = ''; $captionClass = 'n2-caption-' . $captionPlacement; $captionExtraStyle = ''; switch ($captionPlacement) { case 'before': case 'after': switch ($orientation) { case 'vertical': if (!$showImage) { $width = 0; } $containerStyle = "width: " . ($width + $captionSize) . "px; height: {$height}px;"; $captionExtraStyle .= "width: {$captionSize}px"; break; default: if (!$showImage) { $height = 0; } $containerStyle = "width: {$width}px; height: " . ($height + $captionSize) . "px;"; $captionExtraStyle .= "height: {$captionSize}px"; } break; default: $containerStyle = "width: {$width}px; height: {$height}px;"; } $image = ''; $rows = array(); $i = 0; foreach ($slider->slides as $slide) { $active = ''; if ($slider->_activeSlide == $i) { $active = 'n2-active '; } if ($orientation == 'horizontal') { $row = $i % $group; } else { $row = intval($i / $group); } if (!isset($rows[$row])) { $rows[$row] = array(); } if ($showImage) { $image = N2Html::tag('div', array('class' => 'n2-ss-thumb-image', 'style' => "background-image: URL('" . $slide->getThumbnail() . "'); width: {$width}px; height: {$height}px;"), ''); } $inner = ''; if ($showCaption) { $html = ''; if ($showTitle) { $html .= N2Html::tag('div', array('class' => $titleFont), $slide->getTitle()); } $description = $slide->getDescription(); if ($showDescription && !empty($description)) { $html .= N2Html::tag('div', array('class' => $descriptionFont), $description); } $inner = N2Html::tag('div', array('class' => $captionStyle . 'n2-ss-caption ' . $captionClass, 'style' => $captionExtraStyle), $html); } switch ($captionPlacement) { case 'before': $inner .= $image; break; case 'after': default: $inner = $image . $inner; } $rows[$row][] = N2Html::tag('td', array(), N2Html::tag('div', array('class' => $slideStyle . $active, 'style' => $containerStyle), $inner)); $i++; } foreach ($rows as $row) { $slides .= N2Html::tag('tr', array(), implode('', $row)); } $slides .= N2Html::closeTag('table'); $parameters = array('overlay' => $params->get(self::$key . 'position-mode') != 'simple' || $params->get(self::$key . 'overlay'), 'area' => intval($params->get(self::$key . 'position-area')), 'orientation' => $orientation, 'group' => $group, 'action' => $params->get(self::$key . 'action')); N2JS::addInline('new NextendSmartSliderWidgetThumbnailDefault("' . $id . '", ' . json_encode($parameters) . ');'); $size = $params->get(self::$key . 'size'); if ($orientation == 'horizontal') { if (is_numeric($size) || substr($size, -1) == '%' || substr($size, -2) == 'px') { $style .= 'width:' . $size . ';'; } else { $attributes['data-sswidth'] = $size; } } else { if (is_numeric($size) || substr($size, -1) == '%' || substr($size, -2) == 'px') { $style .= 'height:' . $size . ';'; } else { $attributes['data-ssheight'] = $size; } } $previous = $next = ''; $showArrow = intval($slider->params->get(self::$key . 'arrow', 1)); if ($showArrow) { $previous = N2Html::image('data:image/svg+xml;base64,' . base64_encode(N2Filesystem::readFile(N2ImageHelper::fixed('$ss$/plugins/widgetthumbnail/default/default/thumbnail-up-arrow.svg', true))), '', array('class' => 'nextend-thumbnail-button nextend-thumbnail-previous')); $next = N2Html::image('data:image/svg+xml;base64,' . base64_encode(N2Filesystem::readFile(N2ImageHelper::fixed('$ss$/plugins/widgetthumbnail/default/default/thumbnail-down-arrow.svg', true))), '', array('class' => 'nextend-thumbnail-button nextend-thumbnail-next n2-active')); } if ($params->get(self::$key . 'position-mode') == 'simple' && $orientation == 'vertical') { $area = $params->get(self::$key . 'position-area'); switch ($area) { case '5': case '6': case '7': case '8': $attributes['data-sstop'] = '0'; break; } } return N2Html::tag('div', $displayAttributes + $attributes + array('class' => $displayClass . 'nextend-thumbnail nextend-thumbnail-default nextend-thumbnail-' . $orientation, 'style' => $style), $previous . $next . N2Html::tag('div', array('class' => 'nextend-thumbnail-inner'), N2Html::tag('div', array('class' => $barStyle . 'nextend-thumbnail-scroller'), $slides))); }
public static function base64($imagePath, $image) { $pathInfo = pathinfo(parse_url($imagePath, PHP_URL_PATH)); $extension = self::validateExtension($pathInfo['extension']); if ($extension) { return 'data:image/' . $extension . ';base64,' . base64_encode(N2Filesystem::readFile($imagePath)); } return N2ImageHelper::fixed($image); }
protected static function optimizeImage($image, $data, $slider) { $lazyLoad = $slider->features->lazyLoad; $imagePath = N2ImageHelper::fixed($image, true); if ($imagePath[0] == '/' && $imagePath[1] != '/' && $lazyLoad->layerImageSizeBase64 && $lazyLoad->layerImageSizeBase64Size && filesize($imagePath) < $lazyLoad->layerImageSizeBase64Size) { return array('src' => N2Image::base64($imagePath, $image)); } if (!$lazyLoad->layerImageOptimize || !$data->get('image-optimize', 1)) { return array('src' => N2ImageHelper::fixed($image)); } $tablet = N2Image::scaleImage('image', $image, $lazyLoad->layerImageTablet); $mobile = N2Image::scaleImage('image', $image, $lazyLoad->layerImageMobile); if ($image == $tablet && $image == $mobile) { return array('src' => N2ImageHelper::fixed($image)); } return array('src' => N2Image::base64Transparent(), 'data-desktop' => N2ImageHelper::fixed($image), 'data-tablet' => N2ImageHelper::fixed($tablet), 'data-mobile' => N2ImageHelper::fixed($mobile), 'data-device' => '1'); }
private static function getHTML($id, &$params, $animation, $side, $image, $displayClass, $displayAttributes, $styleClass, $color = 'ffffffcc', $hover = 0, $hoverColor = 'ffffffcc') { list($style, $attributes) = self::getPosition($params, self::$key . $side . '-'); $imageHover = null; $ext = pathinfo($image, PATHINFO_EXTENSION); if (substr($image, 0, 1) == '$' && $ext == 'svg') { list($color, $opacity) = N2Color::colorToSVG($color); $content = N2Filesystem::readFile(N2ImageHelper::fixed($image, true)); $image = 'data:image/svg+xml;base64,' . base64_encode(str_replace(array('fill="#FFF"', 'opacity="1"'), array('fill="#' . $color . '"', 'opacity="' . $opacity . '"'), $content)); if ($hover) { list($color, $opacity) = N2Color::colorToSVG($hoverColor); $imageHover = 'data:image/svg+xml;base64,' . base64_encode(str_replace(array('fill="#FFF"', 'opacity="1"'), array('fill="#' . $color . '"', 'opacity="' . $opacity . '"'), $content)); } } else { $image = N2ImageHelper::fixed($image); } if ($imageHover === null) { $image = N2Html::image($image, 'arrow'); } else { $image = N2Html::image($image, 'arrow', array('class' => 'n2-arrow-normal-img')) . N2Html::image($imageHover, 'arrow', array('class' => 'n2-arrow-hover-img')); } if ($animation == 'none' || $animation == 'fade') { return N2Html::tag('div', $displayAttributes + $attributes + array('id' => $id . '-arrow-' . $side, 'class' => $displayClass . $styleClass . 'nextend-arrow n2-ib nextend-arrow-' . $side . ' nextend-arrow-animated-' . $animation, 'style' => $style), $image); } return N2Html::tag('div', $displayAttributes + $attributes + array('id' => $id . '-arrow-' . $side, 'class' => $displayClass . 'nextend-arrow n2-ib nextend-arrow-animated nextend-arrow-animated-' . $animation . ' nextend-arrow-' . $side, 'style' => $style), N2Html::tag('div', array('class' => $styleClass . ' n2-resize'), $image) . N2Html::tag('div', array('class' => $styleClass . ' n2-active n2-resize'), $image)); }
public static function fixPreviewImages($matches) { return "url(" . N2ImageHelper::fixed($matches[1]) . ")"; }
?> ]</div></code> </div> <div class="n2-td"> <div class="n2-h2"><?php n2_e('Page or Post editor'); ?> </div> <div class="n2-h4"><?php n2_e('Insert it into an existing post with the icon:'); ?> </div> <img src="<?php echo N2ImageHelper::fixed('$ss$/admin/images/wordpress-publish.png'); ?> "/> </div> <div class="n2-td n2-last"> <div class="n2-h2"><?php n2_e('PHP code'); ?> </div> <div class="n2-h4"><?php n2_e('Paste the PHP code into your template file:'); ?> </div> <code><div onclick="return selectText(this);"> <?php <br />
public static function addButtonDialog() { global $wpdb; $query = 'SELECT sliders.title, sliders.id, slides.thumbnail FROM ' . $wpdb->prefix . 'nextend2_smartslider3_sliders AS sliders LEFT JOIN ' . $wpdb->prefix . 'nextend2_smartslider3_slides AS slides ON slides.id = (SELECT id FROM ' . $wpdb->prefix . 'nextend2_smartslider3_slides WHERE slider = sliders.id AND published = 1 AND generator_id = 0 AND thumbnail NOT LIKE \'\' ORDER BY ordering DESC LIMIT 1) ORDER BY time DESC'; $sliders = $wpdb->get_results($query, ARRAY_A); ?> <div id='n2-ss-editor-modal' title='Select a Slider'> <div class="n2-ss-editor-inner"> <div class="n2-ss-editor-header">Select a Slider<div class="n2-ss-editor-header-close"></div></div> <div class="n2-ss-editor-boxes"> <?php $router = N2Base::getApplication('smartslider')->router; $token = N2Form::tokenizeUrl(); foreach ($sliders as $slider) { if (empty($slider['thumbnail'])) { $slider['thumbnail'] = '$system$/images/placeholder/image.png'; } ?> <div class="n2-ss-editor-box" data-sliderid="<?php echo $slider['id']; ?> " style="background-image: url(<?php echo N2ImageHelper::fixed($slider['thumbnail']); ?> ); "> <div class="n2-ss-editor-box-actions"> <a target="_blank" href="<?php echo $router->createUrl(array('slider/edit', array('sliderid' => $slider["id"]))); ?> ">Edit</a> <a target="_blank" href="<?php echo $router->createUrl(array('preview/index', array('sliderid' => $slider["id"]) + $token)); ?> ">Preview</a> </div> <div class="n2-ss-editor-box-title"><?php echo $slider['title']; ?> </div> </div> <?php } ?> </div> <div class="n2-ss-editor-buttons"> <a href="#" class="n2-ss-editor-insert">Insert slider</a> <a target="_blank" href="<?php echo $router->createUrl(array('sliders/index')); ?> " class="n2-ss-editor-create-slider">Create slider</a> </div> </div> </div> <script type="text/javascript"> jQuery(document).ready(function ($) { var modal = $('#n2-ss-editor-modal'), inner = $('.n2-ss-editor-inner'), boxes = inner.find('.n2-ss-editor-boxes'), $window = $(window), active = null, callback = function () { }, watchResize = function () { boxes.height(inner.height() - 116); $window.on('resize.ss', function () { boxes.height(inner.height() - 116); }); }, unWatchResize = function () { $window.off('resize.ss'); }, show = function () { modal.addClass('n2-active'); watchResize(); }, hide = function () { unWatchResize(); modal.removeClass('n2-active'); }; boxes.find('.n2-ss-editor-box').on('click', function () { if (active !== null) { active.removeClass('n2-active'); } active = $(this).addClass('n2-active'); }); modal.on('click', function (e) { if (e.target == modal.get(0)) { hide(); } }); $('.n2-ss-editor-header-close').on('click', function (e) { e.preventDefault(); hide(); }); $('.n2-ss-editor-insert').on('click', function (e) { e.preventDefault(); if (active !== null) { callback(active.data('sliderid')); hide(); } else { alert('Please select a slider!'); } }); window.NextendSmartSliderWPTinyMCEModal = function (ed) { callback = function (id) { ed.execCommand('mceInsertContent', false, '<div>[smartslider3 slider=' + id + ']</div>'); }; show(); }; if (typeof QTags !== 'undefined') { QTags.addButton('smart-slider-3', 'Smart Slider', function () { callback = function (id) { QTags.insertContent('<div>[smartslider3 slider=' + id + ']</div>'); }; show(); }); } }); </script> <?php }
function n2GetBox($class, $image, $html, $hasBorder = true) { echo N2Html::tag('div', array('class' => 'n2-box n2-box-title ' . $class . ($hasBorder ? ' n2-box-border' : '')), N2Html::image(N2ImageHelper::fixed('$ss$/admin/images/' . $image)) . N2Html::tag("div", array('class' => 'n2-box-placeholder'), N2Html::tag("table", array(), N2Html::tag("tr", array(), N2Html::tag("td", array('class' => 'n2-box-button'), $html))))); }
/** * @author Roland Soos * @copyright (C) 2015 Nextendweb.com * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html **/ defined('_JEXEC') or die('Restricted access'); echo N2Html::openTag('div', $attributes); if ($image[0] == '<') { ?> <?php echo $image; } else { ?> <img src="<?php echo N2ImageHelper::fixed($image); ?> "/> <?php } ?> <?php if ($lt) { echo N2Html::tag('div', $ltAttributes, $lt); } if ($rt) { echo N2Html::tag('div', $rtAttributes, $rt); } if ($lb) {
function _renderAdmin($data, $itemId, $slider, $slide) { return N2Html::tag('div', array("style" => 'width: 100%; height: 100%; background: url(' . N2ImageHelper::fixed($data->getIfEmpty('image', '$system$/images/placeholder/video.png')) . ') no-repeat 50% 50%; background-size: cover;'), '<img class="n2-video-play n2-ow" src="' . N2ImageHelperAbstract::SVGToBase64('$ss$/images/play.svg') . '"/>'); }
/** * @param $slide N2SmartSliderSlide * @param $slider N2SmartSliderAbstract * @param $widget * @param $appType * * @throws Exception */ public static function box($slide, $slider, $widget, $appType) { $lt = array(); if ($slide->isStatic()) { $lt[] = N2Html::tag('div', array('class' => 'n2-button-tag n2-button n2-button-x-small n2-sidebar-list-bg n2-uc n2-h5'), n2_('Static slide')); } else { $lt[] = N2Html::tag('div', array('class' => 'n2-button-tag n2-button n2-button-x-small n2-button-green n2-uc n2-h5 n2-slide-is-first'), n2_('First')); $lt[] = N2Html::tag('a', array('class' => 'n2-button n2-button-x-small n2-sidebar-list-bg n2-uc n2-h5 n2-slide-first', 'href' => $appType->router->createUrl(array('slides/first', array('sliderid' => $slider->sliderId, 'slideid' => $slide->id) + N2Form::tokenizeUrl()))), n2_('Set First')); } $rt = array(); $rt[] = N2Html::tag('a', array('class' => 'n2-button n2-button-small n2-sidebar-list-bg n2-sidebar-list-bg n2-slide-duplicate', 'href' => $appType->router->createUrl(array('slides/duplicate', array('sliderid' => $slider->sliderId, 'slideid' => $slide->id) + N2Form::tokenizeUrl()))), N2Html::tag('i', array('class' => 'n2-i n2-it n2-i-duplicate'), '')); $rt[] = N2Html::tag('a', array('class' => 'n2-button n2-button-small n2-sidebar-list-bg n2-slide-delete', 'href' => $appType->router->createUrl(array('slides/delete', array('sliderid' => $slider->sliderId, 'slideid' => $slide->id) + N2Form::tokenizeUrl()))), N2Html::tag('i', array('class' => 'n2-i n2-it n2-i-delete'), '')); $rt[] = N2Html::tag('div', array('class' => 'n2-button n2-button-small n2-button-blue n2-slide-selected'), N2Html::tag('i', array('class' => 'n2-i n2-it n2-i-tick'), '')); $rb = array(); if ($slide->hasGenerator()) { $rb[] = N2Html::tag('a', array('class' => 'n2-button n2-button-x-small n2-sidebar-list-bg n2-uc n2-h5 n2-slide-generator' . (N2Request::getVar('generator_id') == $slide->generator_id ? ' n2-button-blue' : ''), 'href' => $appType->router->createUrl(array('generator/edit', array('generator_id' => $slide->generator_id)))), 'Edit generator'); } $image = $slide->getThumbnail(); if (empty($image)) { $image = '$system$/images/placeholder/image.png'; } $editUrl = $appType->router->createUrl(array('slides/edit', array('sliderid' => $slider->sliderId, 'slideid' => $slide->id))); $widget->init("box", array('attributes' => array('class' => 'n2-box-slide n2-box-overflow' . ($slide->isFirst() ? ' n2-first-slide' : '') . ($slide->isCurrentlyEdited() ? ' n2-ss-slide-active' : ''), 'data-slideid' => $slide->id, 'data-title' => $slide->getRawTitle(), 'data-description' => $slide->getRawDescription(), 'data-link' => $slide->getRawLink(), 'data-image' => N2ImageHelper::fixed($image), 'data-editUrl' => $editUrl), 'image' => N2ImageHelper::fixed($image), 'firstCol' => N2Html::link($slide->getTitle() . ($slide->hasGenerator() ? ' [' . $slide->getSlideStat() . ']' : ''), $editUrl, array('class' => 'n2-h4')), 'lt' => implode('', $lt), 'rt' => implode('', $rt), 'rtAttributes' => array('class' => 'n2-on-hover'), 'rb' => implode('', $rb), 'placeholderContent' => N2Html::tag('a', array('class' => 'n2-slide-published' . ($slide->published ? ' n2-active' : ''), 'href' => $appType->router->createUrl(array('slides/publish', array('sliderid' => $slider->sliderId, 'slideid' => $slide->id) + N2Form::tokenizeUrl()))), N2Html::tag('i', array('class' => 'n2-i n2-it n2-i-unpublished'), '')))); }
function _renderAdmin($data, $itemId, $slider, $slide) { return N2Html::tag('div', array("style" => 'width: 100%; height: 100%; background: url(' . N2ImageHelper::fixed($data->getIfEmpty('image', '$system$/images/placeholder/video.png')) . ') no-repeat 50% 50%; background-size: cover;')); }
public static function SVGToBase64($image) { $ext = pathinfo($image, PATHINFO_EXTENSION); if (substr($image, 0, 1) == '$' && $ext == 'svg') { return 'data:image/svg+xml;base64,' . base64_encode(N2Filesystem::readFile(N2ImageHelper::fixed($image, true))); } return N2ImageHelper::fixed($image); }
public function create($saveAsFile = false) { $this->backup = new N2SmartSliderBackup(); $slidersModel = new N2SmartsliderSlidersModel(); if ($this->backup->slider = $slidersModel->get($this->sliderId)) { $this->backup->slider['params'] = new N2Data($this->backup->slider['params'], true); $slidesModel = new N2SmartsliderSlidesModel(); $this->backup->slides = $slidesModel->getAll($this->backup->slider['id']); if (empty($this->backup->slider['type'])) { $this->backup->slider['type'] = 'simple'; } $class = 'N2SSPluginType' . $this->backup->slider['type']; N2Loader::importPath(call_user_func(array($class, "getPath")) . NDS . 'backup'); $class = 'N2SmartSliderBackup' . $this->backup->slider['type']; call_user_func_array(array($class, 'export'), array($this, $this->backup->slider)); $enabledWidgets = array(); $plugins = array(); N2Plugin::callPlugin('sswidget', 'onWidgetList', array(&$plugins)); $params = $this->backup->slider['params']; foreach ($plugins as $k => $v) { $widget = $params->get('widget' . $k); if ($widget && $widget != 'disabled') { $enabledWidgets[$k] = $widget; } } foreach ($enabledWidgets as $k => $v) { $class = 'N2SSPluginWidget' . $k . $v; if (class_exists($class, false)) { $params->fillDefault(call_user_func(array($class, 'getDefaults'))); call_user_func_array(array($class, 'prepareExport'), array($this, &$params)); } else { unset($enabledWidgets); } } for ($i = 0; $i < count($this->backup->slides); $i++) { $slide = $this->backup->slides[$i]; self::addImage($slide['thumbnail']); $slide['params'] = new N2Data($slide['params'], true); self::addImage($slide['params']->get('backgroundImage')); self::addLightbox($slide['params']->get('link')); N2SmartSliderLayer::prepareExport($this, $slide['slide']); if (!empty($slide['generator_id'])) { N2Loader::import("models.generator", "smartslider"); $generatorModel = new N2SmartsliderGeneratorModel(); $this->backup->generators[] = $generatorModel->get($slide['generator_id']); } } $zip = new N2ZipFile(); $this->images = array_unique($this->images); $this->visuals = array_unique($this->visuals); foreach ($this->images as $image) { $this->backup->NextendImageManager_ImageData[$image] = N2ImageManager::getImageData($image, true); if ($this->backup->NextendImageManager_ImageData[$image]) { self::addImage($this->backup->NextendImageManager_ImageData[$image]['tablet']['image']); self::addImage($this->backup->NextendImageManager_ImageData[$image]['mobile']['image']); } else { unset($this->backup->NextendImageManager_ImageData[$image]); } } $this->images = array_unique($this->images); $usedNames = array(); foreach ($this->images as $image) { $file = N2ImageHelper::fixed($image, true); if (N2Filesystem::fileexists($file)) { $fileName = strtolower(basename($file)); while (in_array($fileName, $usedNames)) { $fileName = $this->uniqueCounter . $fileName; $this->uniqueCounter++; } $usedNames[] = $fileName; $this->backup->imageTranslation[$image] = $fileName; $zip->addFile(file_get_contents($file), 'images/' . $fileName); } } foreach ($this->visuals as $visual) { $this->backup->visuals[] = N2StorageSectionAdmin::getById($visual); } $zip->addFile(serialize($this->backup), 'data'); if (!$saveAsFile) { ob_end_clean(); header('Content-disposition: attachment; filename=' . preg_replace('/[^a-zA-Z0-9_-]/', '', $this->backup->slider['title']) . '.ss3'); header('Content-type: application/zip'); echo $zip->file(); n2_exit(true); } else { $file = preg_replace('/[^a-zA-Z0-9_-]/', '', $this->backup->slider['title']) . '.ss3'; $folder = N2Platform::getPublicDir(); $folder .= '/export/'; if (!N2Filesystem::existsFolder($folder)) { N2Filesystem::createFolder($folder); } N2Filesystem::createFile($folder . $file, $zip->file()); } } }
public function getThumbnail() { $image = $this->thumbnail; if (empty($image)) { $image = $this->parameters->get('backgroundImage'); } return N2ImageHelper::fixed($this->fill($image)); }
private function getDefaultImage($src, $deviceAttributes) { if (count($deviceAttributes) > 2 || $this->slider->features->lazyLoad->isEnabled > 0) { return N2Image::base64Transparent(); } else { return N2ImageHelper::fixed($src); } }