Esempio n. 1
0
 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')));
 }
Esempio n. 2
0
 /**
  * @param $slider N2SmartSliderAbstract
  * @param $id
  * @param $params
  *
  * @return string
  */
 static function render($slider, $id, $params)
 {
     N2CSS::addFile(N2Filesystem::translate(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'horizontal' . DIRECTORY_SEPARATOR . 'style.css'), $id);
     N2JS::addFile(N2Filesystem::translate(dirname(__FILE__) . '/horizontal/bar.js'), $id);
     list($displayClass, $displayAttributes) = self::getDisplayAttributes($params, self::$key);
     $styleClass = N2StyleRenderer::render($params->get(self::$key . 'style'), 'simple', $slider->elementId, 'div#' . $slider->elementId . ' ');
     $fontTitle = N2FontRenderer::render($params->get(self::$key . 'font-title'), 'simple', $slider->elementId, 'div#' . $slider->elementId . ' ', $slider->fontSize);
     $fontDescription = N2FontRenderer::render($params->get(self::$key . 'font-description'), 'simple', $slider->elementId, 'div#' . $slider->elementId . ' ', $slider->fontSize);
     list($style, $attributes) = self::getPosition($params, self::$key);
     $attributes['data-offset'] = $params->get(self::$key . 'position-offset');
     $style .= 'text-align: ' . $params->get(self::$key . 'align') . ';';
     $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;
     }
     $innerStyle = '';
     if (!$params->get(self::$key . 'full-width')) {
         $innerStyle = 'display: inline-block;';
     }
     $separator = $params->get(self::$key . 'separator');
     $showDescription = intval($params->get(self::$key . 'show-description'));
     $slides = array();
     for ($i = 0; $i < count($slider->slides); $i++) {
         $slides[$i] = N2Html::tag('span', array('class' => $fontTitle), $slider->slides[$i]->getTitle());
         $description = $slider->slides[$i]->getDescription();
         if ($showDescription && !empty($description)) {
             $slides[$i] .= N2Html::tag('span', array('class' => $fontDescription), $separator . $description);
         }
     }
     $parameters = array('overlay' => $params->get(self::$key . 'position-mode') != 'simple' || $params->get(self::$key . 'overlay'), 'area' => intval($params->get(self::$key . 'position-area')), 'animate' => intval($params->get(self::$key . 'animate')));
     N2JS::addInline('new NextendSmartSliderWidgetBarHorizontal("' . $id . '", ' . json_encode($slides) . ', ' . json_encode($parameters) . ');');
     return N2Html::tag("div", $displayAttributes + $attributes + array("class" => $displayClass . "nextend-bar nextend-bar-horizontal", "style" => $style), N2Html::tag("div", array("class" => $styleClass, "style" => $innerStyle), $slides[$slider->_activeSlide]));
 }
Esempio n. 3
0
 protected function clearCurrentGroup()
 {
     self::clearGroup($this->group);
     if (!N2Filesystem::existsFolder($this->currentPath)) {
         N2Filesystem::createFolder($this->currentPath);
     }
 }
Esempio n. 4
0
 function generateOptions(&$xml)
 {
     $this->values = array();
     $html = '';
     foreach ($xml->option as $option) {
         $v = N2XmlHelper::getAttribute($option, 'value');
         $image = N2Uri::pathToUri($v);
         $selected = $this->isSelected($v);
         if ($v != -1) {
             $value = $this->parseValue($image);
             $this->values[] = $value;
             $html .= N2Html::openTag("div", array("class" => "n2-radio-option n2-imagelist-option" . ($selected ? ' n2-active' : '')));
             $ext = pathinfo($image, PATHINFO_EXTENSION);
             if ($ext == 'svg') {
                 $image = 'data:image/svg+xml;base64,' . base64_encode(N2Filesystem::readFile(N2Filesystem::getBasePath() . $v));
             }
             $html .= N2Html::image($image, (string) $option, array('data-image' => $value));
             $html .= N2Html::closeTag("div");
         } else {
             $this->values[] = -1;
             $html .= N2Html::tag("div", array("class" => "n2-radio-option" . ($selected ? ' n2-active' : '')), (string) $option);
         }
     }
     return $html;
 }
Esempio n. 5
0
 protected function renderType(&$context)
 {
     $params = $this->slider->params;
     N2Loader::import('libraries.image.color');
     $width = intval($context['width']);
     $height = intval($context['height']);
     $context['backgroundSize'] = $params->get('background-size');
     $context['backgroundAttachment'] = $params->get('background-fixed') ? 'fixed' : 'scroll';
     $borderWidth = $params->get('border-width');
     $borderColor = $params->get('border-color');
     $context['borderRadius'] = $params->get('border-radius') . 'px';
     $padding = N2Parse::parse($params->get('padding'));
     $context['paddingt'] = $padding[0] . 'px';
     $context['paddingr'] = $padding[1] . 'px';
     $context['paddingb'] = $padding[2] . 'px';
     $context['paddingl'] = $padding[3] . 'px';
     if ($context['canvas']) {
         $width += 2 * $borderWidth + $padding[1] + $padding[3];
         $height += 2 * $borderWidth + $padding[0] + $padding[2];
         $context['width'] = $width . "px";
         $context['height'] = $height . "px";
     }
     $context['border'] = $borderWidth . 'px';
     $rgba = N2Color::hex2rgba($borderColor);
     $context['borderrgba'] = 'RGBA(' . $rgba[0] . ',' . $rgba[1] . ',' . $rgba[2] . ',' . round($rgba[3] / 127, 2) . ')';
     $context['borderhex'] = '#' . substr($borderColor, 0, 6);
     $width = $width - ($padding[1] + $padding[3]) - $borderWidth * 2;
     $height = $height - ($padding[0] + $padding[2]) - $borderWidth * 2;
     $context['inner1height'] = $height . 'px';
     $context['canvaswidth'] = $width . "px";
     $context['canvasheight'] = $height . "px";
     N2LESS::addFile(N2Filesystem::translate(dirname(__FILE__) . NDS . 'style.less'), $this->slider->cacheId, $context, NEXTEND_SMARTSLIDER_ASSETS . '/less' . NDS);
 }
Esempio n. 6
0
 public function actionEdit()
 {
     $this->validateToken();
     $this->validatePermission('smartslider_edit');
     $slidersModel = new N2SmartsliderSlidersModel();
     $sliderId = N2Request::getInt('sliderid');
     $slider = $slidersModel->get($sliderId);
     $this->validateDatabase($slider);
     $slidesModel = new N2SmartsliderSlidesModel();
     $this->validateDatabase($slidesModel->get(N2Request::getInt('slideid')));
     $response = array();
     if (N2Request::getInt('save')) {
         if (N2SmartSliderSettings::get('slide-as-file', 0) && isset($_FILES['slide']) && isset(N2Request::$storage['slide'])) {
             N2Request::$storage['slide']['slide'] = N2Filesystem::readFile($_FILES['slide']['tmp_name']);
         }
         if ($slideId = $slidesModel->save(N2Request::getInt('slideid'), N2Request::getVar('slide'))) {
             N2Message::success(n2_('Slide saved.'));
             if (N2Request::getInt('static') == 1) {
                 $slideCount = $slidesModel->makeStatic(N2Request::getInt('slideid'));
                 if ($slideCount) {
                     N2Message::success(sprintf(n2_('%d static slides generated.'), $slideCount));
                     $this->response->redirect(array("slider/edit", array("sliderid" => $sliderId)));
                 }
             }
         }
     }
     $this->response->respond($response);
 }
Esempio n. 7
0
 protected function setCurrentPath()
 {
     $this->currentPath = N2Filesystem::getImagesFolder() . NDS . $this->group;
     if (!N2Filesystem::existsFolder($this->currentPath)) {
         N2Filesystem::createFolder($this->currentPath);
     }
 }
Esempio n. 8
0
 public function renderInline($fileName, $params = array(), $path = null, $absolutePathInFilename = false)
 {
     if ($absolutePathInFilename) {
         $path = "";
     } elseif (is_null($path)) {
         $path = $this->appType->path . NDS . "inline" . NDS;
     }
     if (!strpos($fileName, ".php")) {
         $fileName = $fileName . ".php";
     }
     /**
      * Hack for something
      *
      * @todo write an example, maybe a bug
      */
     /*
     if (strlen($path) < 3 && $path != '') {
         $path = "";
     }
     */
     if (!N2Filesystem::existsFile($path . $fileName)) {
         throw new N2ViewException("View file ({$fileName}) not found in {$path}");
     }
     extract($params);
     /** @noinspection PhpIncludeInspection */
     include $path . $fileName;
 }
Esempio n. 9
0
 private function isCached($file)
 {
     if (N2Filesystem::existsFile($file)) {
         return true;
     }
     return false;
 }
Esempio n. 10
0
 public function subform($appType, $configurationXmlFile, $values, $control_name, $name)
 {
     if (N2Filesystem::fileexists($configurationXmlFile)) {
         N2Loader::import('libraries.form.form');
         $form = new N2Form($appType);
         $form->loadArray($values);
         //$subformValue = array();
         //$subformValue[N2Post::getVar('name')] = N2Post::getVar('value');
         //$form->loadArray($subformValue);
         $form->loadXMLFile($configurationXmlFile);
         ob_end_clean();
         // To clear the output of the platform
         ob_start();
         $subform = $form->getSubFormAjax(N2Post::getVar('tab'), $name);
         $subform->initAjax($control_name);
         echo $subform->renderForm();
         //echo N2AssetsManager::generateAjaxCSS();
         $scripts = N2AssetsManager::generateAjaxJS();
         $html = ob_get_clean();
         $response = array('html' => $html, 'scripts' => $scripts);
     } else {
         $response = array('error' => 'Configuration file not found: ' . $configurationXmlFile);
     }
     return $response;
 }
Esempio n. 11
0
 public static function getImagesFolder()
 {
     $i = N2Filesystem::getInstance();
     if (defined('JPATH_NEXTEND_IMAGES')) {
         return $i->_basepath . JPATH_NEXTEND_IMAGES;
     }
     return $i->_basepath . '/images';
 }
Esempio n. 12
0
 public function clean($fileName)
 {
     if (N2Filesystem::existsFile($this->getManifestFilePath($fileName))) {
         unlink($this->getManifestFilePath($fileName));
     }
     if (N2Filesystem::existsFile($this->getStorageFilePath($fileName))) {
         unlink($this->getStorageFilePath($fileName));
     }
 }
Esempio n. 13
0
    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);
 }
 protected function autoload()
 {
     N2Loader::import("libraries.slider.helper", "smartslider");
     N2Loader::import("libraries.slider.manager", "smartslider");
     N2Form::$importPaths[] = dirname(__FILE__) . '/form';
     N2Filesystem::registerTranslate(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'plugins', $this->info->getAssetsPath() . '/plugins');
     require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . 'loadplugin.php';
     N2Loader::import('plugins.loadplugin', 'smartslider.platform');
     N2Loader::import('libraries.link', 'smartslider');
 }
Esempio n. 16
0
 public function getCachedContent()
 {
     $fileContents = '';
     foreach ($this->files as $file) {
         $fileContents .= $this->parseFile(N2Filesystem::readFile($file), $file) . "\n";
     }
     foreach ($this->codes as $code) {
         $fileContents .= $code . "\n";
     }
     return $fileContents;
 }
Esempio n. 17
0
 public function render($xmlpath, $data)
 {
     N2Loader::import('libraries.form.form');
     $form = new N2Form(N2Base::getApplication('smartslider')->getApplicationType('backend'));
     $form->loadArray($data);
     $form->loadXMLFile($xmlpath);
     echo $form->render('settings');
     N2JS::addFirstCode('
         new NextendForm("smartslider-form", ' . json_encode($form->_data) . ', null, "' . N2Filesystem::toLinux(N2Filesystem::pathToRelativePath($xmlpath)) . '", "settings", "' . N2Uri::ajaxUri('nextend', 'smartslider') . '");
     ');
 }
Esempio n. 18
0
 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;
 }
Esempio n. 19
0
 function loadXMLFile($file)
 {
     if (!N2Filesystem::existsFile($file)) {
         echo "xml file not found ('{$file}')! <br /><strong>" . __FILE__ . ":" . __LINE__ . "</strong>";
         n2_exit(true);
         //throw new Exception("xml file not found ('{$file}')! <br /><strong>" . __FILE__ . ":" . __LINE__."</strong>");
     }
     // @fix Warning: simplexml_load_file(): I/O warning : failed to load external entity
     $this->_xml = simplexml_load_string(file_get_contents($file));
     $this->_xmlfile = $file;
     $this->xmlFolder = dirname($file);
 }
Esempio n. 20
0
 protected function addManifestData(&$manifestData)
 {
     $manifestData['nextCacheRefresh'] = N2Pluggable::applyFilters('SSNextCacheRefresh', $this->parameters['slider']->slidesBuilder->getNextCacheRefresh(), array($this->parameters['slider']));
     $variations = 1;
     $params = $this->parameters['slider']->params;
     if ($params->get('randomize', 0) || $params->get('randomizeFirst', 0)) {
         $variations = intval($params->get('variations', 5));
         if ($variations < 1) {
             $variations = 1;
         }
     }
     N2Filesystem::createFile($this->getManifestFilePath('variations'), $variations);
 }
Esempio n. 21
0
 public function render($params = array(), $layoutName = false)
 {
     $controller = strtolower($this->appType->controllerName);
     $path = $this->appType->path . NDS . "views" . NDS . $controller . NDS;
     $call = false;
     if (N2Filesystem::existsFile($path . NDS . "_view.php")) {
         require_once $path . NDS . "_view.php";
         $call = array("class" => "N2{$this->appType->app->name}{$this->appType->type}{$controller}View", "method" => $this->appType->actionName);
         $this->viewObject = $this->preCall($call, $this->appType);
     }
     if ($layoutName) {
         $this->renderLayout($layoutName, $params);
     }
 }
Esempio n. 22
0
 private function makeUrl($matches)
 {
     if (substr($matches[1], 0, 5) == 'data:') {
         return $matches[0];
     }
     if (substr($matches[1], 0, 4) == 'http') {
         return $matches[0];
     }
     if (substr($matches[1], 0, 2) == '//') {
         return $matches[0];
     }
     $exploded = explode('?', $matches[1]);
     $realPath = realpath($this->basePath . '/' . $exploded[0]);
     if ($realPath === false) {
         return 'url(' . str_replace(array('http://', 'https://'), '//', $this->baseUrl) . '/' . $matches[1] . ')';
     }
     $realPath = N2Filesystem::fixPathSeparator($realPath);
     $assetPath = N2Filesystem::fixPathSeparator($this->getAssetFileFolder());
     return 'url(' . N2Filesystem::toLinux($this->find_relative_path($assetPath, $realPath)) . (isset($exploded[1]) ? '?' . $exploded[1] : '') . ')';
 }
Esempio n. 23
0
 public function actionSaveImage()
 {
     $this->validateToken();
     N2Loader::import('libraries.image.aviary');
     $image = N2Request::getVar('aviaryUrl');
     $this->validateVariable(!empty($image), 'image');
     require_once dirname(__FILE__) . '/Browse.php';
     $root = N2Filesystem::getImagesFolder();
     $folder = 'aviary';
     $path = N2Filesystem::realpath($root . '/' . $folder);
     if ($path === false || $path == '') {
         N2Filesystem::createFolder($root . '/' . $folder);
         $path = N2Filesystem::realpath($root . '/' . $folder);
     }
     $tmp = tempnam(sys_get_temp_dir(), 'image-');
     file_put_contents($tmp, file_get_contents($image));
     $src = null;
     // Set variables for storage
     // fix file filename for query strings
     preg_match('/([^\\?]+)\\.(jpe?g|gif|png)\\b/i', $image, $matches);
     $file_array['name'] = basename($matches[1]);
     $file_array['tmp_name'] = $tmp;
     $file_array['size'] = filesize($tmp);
     $file_array['error'] = 0;
     try {
         $fileName = preg_replace('/[^a-zA-Z0-9_-]/', '', $file_array['name']);
         $upload = new N2BulletProof();
         $file = $upload->uploadDir($path)->upload($file_array, $fileName);
         $src = N2ImageHelper::dynamic(N2Filesystem::pathToAbsoluteURL($file));
     } catch (Exception $e) {
         N2Message::error($e->getMessage());
         $this->response->error();
     }
     if ($src) {
         $this->response->respond(array('image' => $src));
     } else {
         N2Message::error(sprintf(n2_('Unexpected error: %s'), $image));
         $this->response->error();
     }
 }
Esempio n. 24
0
 static function pathToUri($path)
 {
     $i = N2Uri::getInstance();
     return $i->_baseuri . str_replace(array(N2Filesystem::getBasePath(), DIRECTORY_SEPARATOR), array('', '/'), str_replace('/', DIRECTORY_SEPARATOR, $path));
 }
Esempio n. 25
0
 protected function parseFile($content, $originalFilePath)
 {
     $this->baseUrl = N2Filesystem::pathToAbsoluteURL(dirname($originalFilePath));
     return preg_replace_callback('#url\\([\'"]([^"\'\\)]+)[\'"]\\)#', array($this, 'makeUrl'), $content);
 }
 /**
  * @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)));
 }
Esempio n. 27
0
 private function createCacheFile($fileName, $content)
 {
     return N2Filesystem::createFile($this->getStorageFilePath($fileName), $content);
 }
Esempio n. 28
0
 public function getLogo()
 {
     return N2Filesystem::pathToAbsoluteURL($this->info->getAssetsPath() . "/admin/images/logo.png");
 }
Esempio n. 29
0
 public function __construct()
 {
     N2Loader::addPath($this->getName(), $this->getPath());
     $platformPath = N2Filesystem::realpath($this->getPath() . '/../' . N2Platform::getPlatform());
     if ($platformPath) {
         N2Loader::addPath($this->getName() . '.platform', $platformPath);
     }
     $this->loadLocale();
     $filterClass = 'N2' . ucfirst($this->getName()) . 'ApplicationInfoFilter';
     N2Loader::import($filterClass, $this->getName() . '.platform');
     $callable = $filterClass . '::filter';
     if (is_callable($callable)) {
         call_user_func($filterClass . '::filter', $this);
     }
     if (N2Base::$isReady) {
         $this->onNextendBaseReady();
     } else {
         N2Pluggable::addAction('nextendBaseReady', array($this, 'onNextendBaseReady'));
     }
 }
Esempio n. 30
0
 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);
 }