Example #1
0
 public static function backend($force = false)
 {
     static $once;
     if ($once != null && !$force) {
         return;
     }
     $once = true;
     $family = n2_x('Montserrat', 'Default Google font family for admin');
     foreach (explode(',', n2_x('latin', 'Default Google font charset for admin')) as $subset) {
         N2GoogleFonts::addSubset($subset);
     }
     N2GoogleFonts::addFont($family);
     N2CSS::addInline('.n2,html[dir="rtl"] .n2,.n2 td,.n2 th,.n2 select, .n2 textarea, .n2 input{font-family: "' . $family . '", Arial, sans-serif;}');
     N2CSS::addFiles(N2LIBRARYASSETS . "/css", array('nextend-font.css', 'font.css', 'admin.css', 'form.css', 'notificationcenter.css', 'spectrum.css', 'contextMenu.css'), 'nextend-backend');
     foreach (glob(N2LIBRARYASSETS . "/css/tabs/*.css") as $file) {
         N2CSS::addFile($file, 'nextend-backend');
     }
     foreach (glob(N2LIBRARYASSETS . "/css/jquery/*.css") as $file) {
         N2CSS::addFile($file, 'nextend-backend');
     }
     N2JS::addFiles(N2LIBRARYASSETS . "/js", array('json2.js', 'admin.js', 'color.js', 'query-string.js', 'md5.js', 'css.js', 'imagehelper.js', 'modal.js', 'notificationcenter.js', 'spectrum.js', 'expert.js'), 'nextend-backend');
     N2Localization::addJS(array('Cancel', 'Delete', 'Delete and never show again', 'Are you sure you want to delete?', 'Documentation'));
     self::form($force);
     N2JS::addFiles(N2LIBRARYASSETS . "/js/core/jquery", array("fixto.js", "jstorage.js", "jquery.datetimepicker.js", "jquery.tinyscrollbar.min.js", "jquery.unique-element-id.js", "vertical-pane.js"), "nextend-backend");
     wp_enqueue_script('nextend-ui', N2Uri::pathToUri(N2LIBRARYASSETS . "/js/core/jquery/ui/jquery-ui.nextend.js"), array('jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-autocomplete', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-resizable', 'jquery-ui-sortable', 'jquery-ui-slider'), '1.0', 1);
     wp_enqueue_script('nextend-ui-iframe-transport', N2Uri::pathToUri(N2LIBRARYASSETS . "/js/core/jquery/ui/jquery.iframe-transport.js"), array('jquery-ui-core', 'jquery-ui-widget'), '1.0', 1);
     wp_enqueue_script('nextend-ui-fileupload', N2Uri::pathToUri(N2LIBRARYASSETS . "/js/core/jquery/ui/jquery.fileupload.js"), array('jquery-ui-core', 'jquery-ui-widget'), '1.0', 1);
     N2JS::addFiles(N2LIBRARYASSETS . "/js/core/jquery/ui", array('jquery.contextMenu.js'), "nextend-backend");
     N2Base::getApplication('system')->info->assetsBackend();
     N2JS::addFirstCode("NextendAjaxHelper.addAjaxArray(" . json_encode(N2Form::tokenizeUrl()) . ");");
     N2Plugin::callPlugin('fontservices', 'onFontManagerLoadBackend');
 }
Example #2
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;
 }
Example #3
0
 public static function getNextendElementUrlParameters()
 {
     $params = array('hasPosts' => N2Platform::$hasPosts);
     $params['imageUrl'] = N2Uri::pathToUri(N2LIBRARYASSETS . "/images");
     $params['url'] = N2Base::getApplication('system')->getApplicationType('backend')->router->createUrl("link/search");
     return json_encode(N2ElementUrlParams::extend($params));
 }
Example #4
0
 function __construct()
 {
     $this->_baseuri = WP_CONTENT_URL;
     if (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') {
         $this->_baseuri = str_replace('http://', 'https://', $this->_baseuri);
     }
     self::$scheme = parse_url($this->_baseuri, PHP_URL_SCHEME);
 }
Example #5
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') . '");
     ');
 }
 static function render($slider, $id, $params)
 {
     $html = '';
     $previous = $params->get(self::$key . 'previous-image');
     $previousColor = $params->get(self::$key . 'previous-color');
     $previousHover = $params->get(self::$key . 'previous-hover');
     $previousHoverColor = $params->get(self::$key . 'previous-hover-color');
     if (empty($previous)) {
         $previous = $params->get(self::$key . 'previous');
         if ($previous == -1) {
             $previous = null;
         } elseif ($previous[0] != '$') {
             $previous = N2Uri::pathToUri(dirname(__FILE__) . '/image/previous/' . $previous);
         }
     }
     if ($params->get(self::$key . 'mirror')) {
         $next = str_replace('image/previous/', 'image/next/', $previous);
         $nextColor = $previousColor;
         $nextHover = $previousHover;
         $nextHoverColor = $previousHoverColor;
     } else {
         $next = $params->get(self::$key . 'next-image');
         $nextColor = $params->get(self::$key . 'next-color');
         $nextHover = $params->get(self::$key . 'next-hover');
         $nextHoverColor = $params->get(self::$key . 'next-hover-color');
         if (empty($next)) {
             $next = $params->get(self::$key . 'next');
             if ($next == -1) {
                 $next = null;
             } elseif ($next[0] != '$') {
                 $next = N2Uri::pathToUri(dirname(__FILE__) . '/image/next/' . $next);
             }
         }
     }
     if ($previous || $next) {
         N2LESS::addFile(N2Filesystem::translate(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'image' . DIRECTORY_SEPARATOR . 'style.less'), $slider->cacheId, array("sliderid" => $slider->elementId), NEXTEND_SMARTSLIDER_ASSETS . '/less' . NDS);
         N2JS::addFile(N2Filesystem::translate(dirname(__FILE__) . '/image/arrow.js'), $id);
         list($displayClass, $displayAttributes) = self::getDisplayAttributes($params, self::$key);
         $animation = $params->get(self::$key . 'animation');
         if ($animation == 'none' || $animation == 'fade') {
             $styleClass = N2StyleRenderer::render($params->get(self::$key . 'style'), 'heading', $slider->elementId, 'div#' . $slider->elementId . ' ');
         } else {
             $styleClass = N2StyleRenderer::render($params->get(self::$key . 'style'), 'heading-active', $slider->elementId, 'div#' . $slider->elementId . ' ');
         }
         if ($previous) {
             $html .= self::getHTML($id, $params, $animation, 'previous', $previous, $displayClass, $displayAttributes, $styleClass, $previousColor, $previousHover, $previousHoverColor);
         }
         if ($next) {
             $html .= self::getHTML($id, $params, $animation, 'next', $next, $displayClass, $displayAttributes, $styleClass, $nextColor, $nextHover, $nextHoverColor);
         }
         N2JS::addInline('new NextendSmartSliderWidgetArrowImage("' . $id . '", ' . floatval($params->get(self::$key . 'responsive-desktop')) . ', ' . floatval($params->get(self::$key . 'responsive-tablet')) . ', ' . floatval($params->get(self::$key . 'responsive-mobile')) . ');');
     }
     return $html;
 }
Example #7
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;
 }
Example #8
0
 public function getOutput()
 {
     N2GoogleFonts::build();
     N2LESS::build();
     $output = "";
     foreach ($this->urls as $url) {
         $output .= N2Html::style($url, true, array('media' => 'screen, print')) . "\n";
     }
     foreach ($this->getFiles() as $file) {
         $output .= N2Html::style(N2Uri::pathToUri($file) . '?' . filemtime($file), true, array('media' => 'screen, print')) . "\n";
     }
     $inline = implode("\n", $this->inline);
     if (!empty($inline)) {
         $output .= N2Html::style($inline);
     }
     return $output;
 }
 function generateOptions(&$xml)
 {
     $this->values = array();
     $html = '';
     foreach ($xml->option as $option) {
         $v = N2XmlHelper::getAttribute($option, 'value');
         $image = N2Uri::pathToUri($v);
         $selected = $this->isSelected($this->parseValue($v));
         if ($v != -1) {
             $this->values[] = $this->parseValue($image);
             $html .= N2Html::openTag("div", array("class" => "n2-radio-option n2-imagelist-option" . ($selected ? ' n2-active' : '')));
             $html .= N2Html::image($image, (string) $option);
             $html .= N2Html::closeTag("div");
         } else {
             $this->values[] = -1;
             $html .= N2Html::tag("div", array("class" => "n2-radio-option" . ($selected ? ' n2-active' : '')), (string) $option);
         }
     }
     return $html;
 }
Example #10
0
 public function getOutput()
 {
     $output = "";
     $globalInline = $this->getGlobalInlineScripts();
     if (!empty($globalInline)) {
         $output .= N2Html::script($globalInline . "\n");
     }
     foreach ($this->urls as $url) {
         $output .= N2Html::script($url, true) . "\n";
     }
     if (!N2Platform::$isAdmin && N2Settings::get('async', '0')) {
         $jsCombined = new N2CacheCombine('js', N2Settings::get('minify-js', '0') ? 'N2MinifierJS::minify' : false);
         foreach ($this->getFiles() as $file) {
             if (basename($file) == 'n2.js') {
                 $output .= N2Html::script(N2Uri::pathToUri($file) . '?' . filemtime($file), true) . "\n";
             } else {
                 $jsCombined->add($file);
             }
         }
         $combinedFile = $jsCombined->make();
         $scripts = 'nextend.loadScript("' . N2Uri::pathToUri($combinedFile) . '?' . filemtime($combinedFile) . '");';
         $output .= N2Html::script($scripts . "\n");
     } else {
         if (!N2Platform::$isAdmin && N2Settings::get('combine-js', '0')) {
             $jsCombined = new N2CacheCombine('js', N2Settings::get('minify-js', '0') ? 'N2MinifierJS::minify' : false);
             foreach ($this->getFiles() as $file) {
                 $jsCombined->add($file);
             }
             $combinedFile = $jsCombined->make();
             $output .= N2Html::script(N2Uri::pathToUri($combinedFile) . '?' . filemtime($combinedFile), true) . "\n";
         } else {
             foreach ($this->getFiles() as $file) {
                 $output .= N2Html::script(N2Uri::pathToUri($file) . '?' . filemtime($file), true) . "\n";
             }
         }
     }
     $output .= N2Html::script(N2Localization::toJS() . "\n" . $this->getInlineScripts() . "\n");
     return $output;
 }
Example #11
0
 public static function scaleImage($group, $imageUrl, $scale = 1, $resizeRemote = false)
 {
     $originalImageUrl = $imageUrl;
     $imageUrl = N2ImageHelper::fixed($imageUrl);
     if ($scale > 0 && function_exists('exif_imagetype') && function_exists('imagecreatefrompng')) {
         if (substr($imageUrl, 0, 2) == '//') {
             $imageUrl = parse_url(N2Uri::getBaseuri(), PHP_URL_SCHEME) . ':' . $imageUrl;
         }
         $imageUrl = N2Uri::relativetoabsolute($imageUrl);
         $imagePath = N2Filesystem::absoluteURLToPath($imageUrl);
         $cache = new self($group);
         if ($imagePath == $imageUrl) {
             // The image is not local
             if (!$resizeRemote) {
                 return $originalImageUrl;
             }
             $pathInfo = pathinfo(parse_url($imageUrl, PHP_URL_PATH));
             $extension = self::validateExtension($pathInfo['extension']);
             if (!$extension) {
                 return $originalImageUrl;
             }
             return N2ImageHelper::dynamic(N2Filesystem::pathToAbsoluteURL($cache->makeCache($extension, array($cache, '_scaleRemoteImage'), array($extension, $imageUrl, $scale))));
         } else {
             $extension = false;
             $imageType = @exif_imagetype($imagePath);
             switch ($imageType) {
                 case IMAGETYPE_JPEG:
                     $extension = 'jpg';
                     break;
                 case IMAGETYPE_PNG:
                     $extension = 'png';
                     $fp = fopen($imagePath, 'r');
                     fseek($fp, 25);
                     $data = fgets($fp, 2);
                     fclose($fp);
                     if (ord($data) == 3) {
                         // GD cannot resize palette PNG so we return the original image
                         return $originalImageUrl;
                     }
                     break;
             }
             if (!$extension) {
                 throw new Exception('Filtype of the image is not supported: #' . $imageType . ' code  ' . $imagePath);
             }
             return N2ImageHelper::dynamic(N2Filesystem::pathToAbsoluteURL($cache->makeCache($extension, array($cache, '_scaleImage'), array($extension, $imagePath, $scale, filemtime($imagePath)))));
         }
     }
 }
Example #12
0
                    controlsClass: "n2-modal-controls-side",
                    controls: [\'<a href="#" class="n2-button n2-button-big n2-button-green n2-uc n2-h4">' . n2_('Select') . '</a>\'],
                    content: \'\',
                    fn: {
                        show: function () {
                            this.content.append(nextend.browse.getNode("folder"));
                            this.controls.find(".n2-button-green")
                                .on("click", $.proxy(function (e) {
                                    e.preventDefault();
                                    this.hide(e);
                                    callback(nextend.browse.getCurrentFolder());
                                }, this));
                        }
                    }
                }
            }, true);
        }';
    }
    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);
    }
}
N2Loader::import('libraries.image.helper', 'platform');
N2ImageHelper::$protocolRelative = N2Settings::get('protocol-relative', '1');
N2ImageHelper::addKeyword('$', N2Filesystem::getBasePath(), N2Uri::getBaseUri());
Example #13
0
 protected function _getData($count, $startIndex)
 {
     N2Loader::import('nextend.database.database');
     $db = JFactory::getDbo();
     $categories = array_map('intval', explode('||', $this->data->get('sourcecategories', '')));
     $tags = array_map('intval', explode('||', $this->data->get('sourcetags', '0')));
     $query = 'SELECT ';
     $query .= 'con.id, ';
     $query .= 'con.title, ';
     $query .= 'con.alias, ';
     $query .= 'con.introtext, ';
     $query .= 'con.fulltext, ';
     $query .= 'con.catid, ';
     $query .= 'cat.title AS cat_title, ';
     $query .= 'cat.alias AS cat_alias, ';
     $query .= 'con.created_by, con.state, ';
     $query .= 'usr.name AS created_by_alias, ';
     $query .= 'con.images ';
     $query .= 'FROM #__content AS con ';
     $query .= 'LEFT JOIN #__users AS usr ON usr.id = con.created_by ';
     $query .= 'LEFT JOIN #__categories AS cat ON cat.id = con.catid ';
     $jNow = JFactory::getDate();
     $now = $jNow->toSql();
     $where = array('con.state = 1 ', "(con.publish_up = '0000-00-00 00:00:00' OR con.publish_up < '" . $now . "') AND (con.publish_down = '0000-00-00 00:00:00' OR con.publish_down > '" . $now . "') ");
     if (!in_array(0, $categories)) {
         $where[] = 'con.catid IN (' . implode(',', $categories) . ') ';
     }
     if (!in_array(0, $tags)) {
         $where[] = 'con.id IN (SELECT content_item_id FROM #__contentitem_tag_map WHERE type_alias = \'com_content.article\' AND tag_id IN (' . implode(',', $tags) . ')) ';
     }
     $sourceUserID = intval($this->data->get('sourceuserid', ''));
     if ($sourceUserID) {
         $where[] = 'con.created_by = ' . $sourceUserID . ' ';
     }
     switch ($this->data->get('sourcefeatured', 0)) {
         case 1:
             $where[] = 'con.featured = 1 ';
             break;
         case -1:
             $where[] = 'con.featured = 0 ';
             break;
     }
     $language = $this->data->get('sourcelanguage', '*');
     if ($language) {
         $where[] = 'con.language = ' . $db->quote($language) . ' ';
     }
     if (count($where) > 0) {
         $query .= 'WHERE ' . implode(' AND ', $where) . ' ';
     }
     $order = N2Parse::parse($this->data->get('joomlaorder', 'con.title|*|asc'));
     if ($order[0]) {
         $query .= 'ORDER BY ' . $order[0] . ' ' . $order[1] . ' ';
     }
     $query .= 'LIMIT ' . $startIndex . ', ' . $count;
     $db->setQuery($query);
     $result = $db->loadAssocList();
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('content');
     $uri = N2Uri::getBaseUri();
     $data = array();
     for ($i = 0; $i < count($result); $i++) {
         $r = array('title' => $result[$i]['title']);
         $article = new stdClass();
         $article->text = N2SmartSlider::removeShortcode($result[$i]['introtext']);
         $_p = array();
         $dispatcher->trigger('onContentPrepare', array('com_smartslider3', &$article, &$_p, 0));
         if (!empty($article->text)) {
             $r['description'] = $article->text;
         }
         $article->text = $result[$i]['fulltext'];
         $_p = array();
         $dispatcher->trigger('onContentPrepare', array('com_smartslider3', &$article, &$_p, 0));
         if (!empty($article->text)) {
             $result[$i]['fulltext'] = $article->text;
             if (!isset($r['description'])) {
                 $r['description'] = $result[$i]['fulltext'];
             } else {
                 $r['fulltext'] = $result[$i]['fulltext'];
             }
         }
         $images = (array) json_decode($result[$i]['images'], true);
         $r['image'] = $r['thumbnail'] = NextendImageFallBack::fallback($uri . "/", array(@$images['image_intro'], @$images['image_fulltext']), array(@$r['description']));
         $r += array('url' => ContentHelperRoute::getArticleRoute($result[$i]['id'] . ':' . $result[$i]['alias'], $result[$i]['catid'] . ':' . $result[$i]['cat_alias']), 'url_label' => sprintf(n2_('View %s'), n2_('article')), 'category_list_url' => 'index.php?option=com_content&view=category&id=' . $result[$i]['catid'], 'category_blog_url' => 'index.php?option=com_content&view=category&layout=blog&id=' . $result[$i]['catid'], 'fulltext_image' => !empty($images['image_fulltext']) ? N2ImageHelper::dynamic($uri . "/" . $images['image_fulltext']) : '', 'category_title' => $result[$i]['cat_title'], 'created_by' => $result[$i]['created_by_alias'], 'id' => $result[$i]['id']);
         $data[] = $r;
     }
     return $data;
 }
Example #14
0
 static function ajaxUri($query = '', $magento = 'nextendlibrary')
 {
     $i = N2Uri::getInstance();
     return $i->_baseuri;
 }
 function getImage($path, $key)
 {
     return N2Uri::pathToUri(N2Filesystem::translate($path . $key . '.png'));
 }
Example #16
0
 public function _renderGroupOption($group, $sources)
 {
     $options = array();
     foreach ($sources as $type => $info) {
         /**
          * @var $info N2GeneratorInfo
          */
         $options[$type] = $info->title;
         if ($info->hasConfiguration) {
             $button = N2Html::link("Next", $this->appType->router->createUrl(array("generator/checkConfiguration", array("sliderid" => N2Request::getInt('sliderid'), "group" => $group))), array("onclick" => "var el = n2(this); el.attr('href', el.attr('href') + '&type='+el.parents('.n2-box-placeholder').find('select').val());", "class" => "n2-button n2-button-small n2-button-blue"));
         } elseif (!$info->installed) {
             $button = N2Html::link("Check extension", $info->readMore, array("target" => "_blank", "class" => "n2-button n2-button-small n2-button-grey"));
         } else {
             $button = N2Html::link("Next", $this->appType->router->createUrl(array("generator/createSettings", array("sliderid" => N2Request::getInt('sliderid'), "group" => $group))), array("onclick" => "var el = n2(this); el.attr('href', el.attr('href') + '&type='+el.parents('.n2-box-placeholder').find('select').val());", "class" => "n2-button n2-button-small n2-button-blue"));
         }
     }
     $optionsHTML = '';
     foreach ($options as $k => $v) {
         $optionsHTML .= N2Html::tag('option', array('value' => $k), $v);
     }
     echo N2Html::tag('div', array('class' => 'n2-box'), N2Html::image(N2Uri::pathToUri(N2Filesystem::translate($info->path . '/../dynamic.png'))) . N2Html::tag("div", array('class' => 'n2-box-placeholder'), N2Html::tag("table", array(), N2Html::tag("tr", array(), N2Html::tag("td", array('class' => 'n2-box-label'), N2Html::tag('select', array('name' => 'generator-type'), $optionsHTML)) . N2Html::tag("td", array('class' => 'n2-box-button'), $button)))));
 }
Example #17
0
 /**
  * @param $url
  *
  * @return mixed
  */
 public static function absoluteURLToPath($url)
 {
     $baseUri = N2Uri::getBaseUri();
     if (substr($url, 0, strlen($baseUri)) == $baseUri) {
         $i = N2Filesystem::getInstance();
         return str_replace($baseUri, $i->_basepath, $url);
     }
     return $url;
 }
Example #18
0
 public function import($filePathOrData, $imageImportMode = 'clone', $linkedVisuals = 1, $isFilePath = true)
 {
     $zip = new N2ZipRead();
     $importData = $zip->read_zip($filePathOrData, $isFilePath);
     if (!isset($importData['data'])) {
         if (array_key_exists("slider.ss2", $importData)) {
             N2Message::error(n2_('You can\'t import sliders from Smart Slider 2.'));
         }
         return false;
     }
     $this->backup = unserialize($importData['data']);
     $this->sectionTranslation = array();
     $this->importVisuals($this->backup->visuals, $linkedVisuals);
     $sliderModel = new N2SmartsliderSlidersModel();
     if ($this->restore) {
         $this->sliderId = $sliderModel->restore($this->backup->slider);
     } else {
         $this->sliderId = $sliderModel->import($this->backup->slider);
     }
     if (!$this->sliderId) {
         return false;
     }
     switch ($imageImportMode) {
         case 'clone':
             $images = $importData['images'];
             $imageStore = new N2StoreImage('slider' . $this->sliderId, true);
             foreach ($images as $file => $content) {
                 $localImage = $imageStore->makeCache($file, $content);
                 if ($localImage) {
                     $this->imageTranslation[$file] = N2ImageHelper::dynamic(N2Uri::pathToUri($localImage));
                 } else {
                     $this->imageTranslation[$file] = $file;
                 }
                 if (!$this->imageTranslation[$file]) {
                     $this->imageTranslation[$file] = array_search($file, $this->backup->imageTranslation);
                 }
             }
             break;
         case 'update':
             $keys = array_keys($this->backup->NextendImageHelper_Export);
             $values = array_values($this->backup->NextendImageHelper_Export);
             foreach ($this->backup->imageTranslation as $image => $value) {
                 $this->imageTranslation[$value] = str_replace($keys, $values, $image);
             }
             break;
         default:
             break;
     }
     foreach ($this->backup->NextendImageManager_ImageData as $image => $data) {
         $data['tablet']['image'] = $this->fixImage($data['tablet']['image']);
         $data['mobile']['image'] = $this->fixImage($data['mobile']['image']);
         N2ImageManager::addImageData($this->fixImage($image), $data);
     }
     unset($importData);
     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, 'import'), 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, 'prepareImport'), array($this, $params));
         } else {
             unset($enabledWidgets);
         }
     }
     $sliderModel->importUpdate($this->sliderId, $params);
     $generatorTranslation = array();
     N2Loader::import("models.generator", "smartslider");
     $generatorModel = new N2SmartsliderGeneratorModel();
     foreach ($this->backup->generators as $generator) {
         $generatorTranslation[$generator['id']] = $generatorModel->import($generator);
     }
     $slidesModel = new N2SmartsliderSlidesModel();
     for ($i = 0; $i < count($this->backup->slides); $i++) {
         $slide = $this->backup->slides[$i];
         $slide['params'] = new N2Data($slide['params'], true);
         $slide['thumbnail'] = $this->fixImage($slide['thumbnail']);
         $slide['params']->set('backgroundImage', $this->fixImage($slide['params']->get('backgroundImage')));
         $slide['params']->set('link', $this->fixLightbox($slide['params']->get('link')));
         $slide['slide'] = N2SmartSliderLayer::prepareImport($this, $slide['slide']);
         if (isset($generatorTranslation[$slide['generator_id']])) {
             $slide['generator_id'] = $generatorTranslation[$slide['generator_id']];
         }
         $slidesModel->import($slide, $this->sliderId);
     }
     return $this->sliderId;
 }
Example #19
0
 public function getUri()
 {
     return N2Uri::pathToUri($this->getAssetsPath());
 }
Example #20
0
 protected function _getData($count, $startIndex)
 {
     $model = new N2Model('categories');
     $category = array_map('intval', explode('||', $this->data->get('sourcecategory', '')));
     $tags = array_map('intval', explode('||', $this->data->get('sourcetags', '0')));
     $query = 'SELECT ';
     $query .= 'cat.id, ';
     $query .= 'cat.title, ';
     $query .= 'cat.alias, ';
     $query .= 'cat.description, ';
     $query .= 'cat.params, ';
     $query .= 'cat_parent.id AS parent_id, ';
     $query .= 'cat_parent.title AS parent_title ';
     $query .= 'FROM #__categories AS cat ';
     $query .= 'LEFT JOIN #__categories AS cat_parent ON cat_parent.id = cat.parent_id ';
     $where = array('cat.parent_id IN (' . implode(',', $category) . ') ', 'cat.published = 1 ');
     if (!in_array(0, $tags)) {
         $where[] = 'cat.id IN (SELECT content_item_id FROM #__contentitem_tag_map WHERE type_alias = \'com_content.category\'  AND tag_id IN (' . implode(',', $tags) . ')) ';
     }
     $language = $this->data->get('sourcelanguage', '*');
     if ($language) {
         $where[] = 'cat.language = ' . $model->db->quote($language) . ' ';
     }
     if (count($where) > 0) {
         $query .= 'WHERE ' . implode(' AND ', $where) . ' ';
     }
     $order = N2Parse::parse($this->data->get('joomlacartegoryorder', 'cat.title|*|asc'));
     if ($order[0]) {
         $query .= 'ORDER BY ' . $order[0] . ' ' . $order[1] . ' ';
     }
     $query .= 'LIMIT ' . $startIndex . ', ' . $count . ' ';
     $result = $model->db->queryAll($query);
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('content');
     $uri = N2Uri::getBaseUri();
     $uri .= "/";
     $data = array();
     for ($i = 0; $i < count($result); $i++) {
         $r = array('title' => $result[$i]['title']);
         $article = new stdClass();
         $article->text = N2SmartSlider::removeShortcode($result[$i]['description']);
         $_p = array();
         $dispatcher->trigger('onContentPrepare', array('com_smartslider3', &$article, &$_p, 0));
         if (!empty($article->text)) {
             $r['description'] = $article->text;
         } else {
             $r['description'] = '';
         }
         $params = (array) json_decode($result[$i]['params'], true);
         $r['image'] = $r['thumbnail'] = NextendImageFallBack::fallback($uri, array(@$params['image']), array($r['description']));
         $r += array('url' => 'index.php?option=com_content&view=category&id=' . $result[$i]['id'], 'url_label' => sprintf(n2_('View %s'), n2_('category')), 'url_blog' => 'index.php?option=com_content&view=category&layout=blog&id=' . $result[$i]['id']);
         if ($result[$i]['parent_title'] != 'ROOT') {
             $r += array('parent_title' => $result[$i]['parent_title'], 'parent_url' => 'index.php?option=com_content&view=category&id=' . $result[$i]['parent_id'], 'parent_url_blog' => 'index.php?option=com_content&view=category&layout=blog&id=' . $result[$i]['parent_id']);
         } else {
             $r += array('parent_title' => '', 'parent_url' => '', 'parent_url_blog' => '');
         }
         $r += array('alias' => $result[$i]['alias'], 'id' => $result[$i]['id'], 'parent_id' => $result[$i]['parent_id']);
         $data[] = $r;
     }
     return $data;
 }