示例#1
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);
 }
示例#2
0
 protected function _getData($count, $startIndex)
 {
     global $post;
     $tmpPost = $post;
     list($orderBy, $order) = N2Parse::parse($this->data->get('postscategoryorder', 'post_date|*|desc'));
     $postsFilter = array('include' => '', 'exclude' => '', 'meta_key' => '', 'meta_value' => '', 'post_type' => 'post', 'post_mime_type' => '', 'post_parent' => '', 'post_status' => 'publish', 'suppress_filters' => false, 'offset' => $startIndex, 'posts_per_page' => $count, 'orderby' => $orderBy, 'order' => $order);
     $categories = (array) N2Parse::parse($this->data->get('postscategory'));
     if (!in_array(0, $categories)) {
         $postsFilter['category'] = implode(',', $categories);
     }
     $posts = get_posts($postsFilter);
     $data = array();
     for ($i = 0; $i < count($posts); $i++) {
         $record = array();
         $post = $posts[$i];
         setup_postdata($post);
         $record['id'] = $post->ID;
         $record['url'] = get_permalink();
         $record['title'] = apply_filters('the_title', get_the_title());
         $record['description'] = $record['content'] = get_the_content();
         $record['author_name'] = $record['author'] = get_the_author();
         $record['author_url'] = get_the_author_meta('url');
         $record['date'] = get_the_date();
         $record['excerpt'] = get_the_excerpt();
         $record['modified'] = get_the_modified_date();
         $category = get_the_category($post->ID);
         if (isset($category[0])) {
             $record['category_name'] = $category[0]->name;
             $record['category_link'] = get_category_link($category[0]->cat_ID);
         } else {
             $record['category_name'] = '';
             $record['category_link'] = '';
         }
         $record['featured_image'] = wp_get_attachment_url(get_post_thumbnail_id($post->ID));
         if (!$record['featured_image']) {
             $record['featured_image'] = '';
         }
         $record['thumbnail'] = $record['image'] = $record['featured_image'];
         $record['url_label'] = 'View post';
         if (class_exists('acf')) {
             $fields = get_fields($post->ID);
             if (count($fields)) {
                 foreach ($fields as $k => $v) {
                     $record[$k] = $v;
                 }
             }
         }
         $data[$i] =& $record;
         unset($record);
     }
     wp_reset_postdata();
     $post = $tmpPost;
     if ($post) {
         setup_postdata($post);
     }
     return $data;
 }
示例#3
0
 private function getHtml($data, $id, $slider, $slide)
 {
     $size = (array) N2Parse::parse($data->get('size', ''));
     if (!isset($size[0])) {
         $size[0] = 'auto';
     }
     if (!isset($size[1])) {
         $size[1] = 'auto';
     }
     $html = N2Html::tag('img', self::optimizeImage($slide->fill($data->get('image', '')), $data, $slider) + array("id" => $id, "alt" => htmlspecialchars($slide->fill($data->get('alt', ''))), "style" => "display: inline-block; max-width: 100%; width: {$size[0]};height: {$size[1]};", "class" => $data->get('cssclass', '') . ' n2-ow', "title" => htmlspecialchars($slide->fill($data->get('title', '')))), false);
     $style = N2StyleRenderer::render($data->get('style'), 'heading', $slider->elementId, 'div#' . $slider->elementId . ' ');
     return N2Html::tag("div", array("class" => $style, 'style' => 'overflow:hidden;'), $this->getLink($slide, $data, $html, array('class' => 'n2-ow')));
 }
 private function getSize($image, $imageData)
 {
     $size = N2Parse::parse($imageData['desktop']['size']);
     if ($size[0] > 0 && $size[1] > 0) {
         return $size;
     } else {
         list($width, $height) = @getimagesize($image);
         if ($width != null && $height != null) {
             $imageData['desktop']['size'] = $width . '|*|' . $height;
             N2ImageManager::setImageData($image, $imageData);
             return array($width, $height);
         }
     }
     return null;
 }
示例#5
0
 public function __construct($slider)
 {
     $this->slider = $slider;
     $params = $slider->params;
     $this->isEnabled = intval($params->get('autoplay', 0));
     $this->isStart = intval($params->get('autoplayStart', 1));
     $this->duration = intval($params->get('autoplayDuration', 8000));
     if ($this->duration < 1) {
         $this->duration = 1500;
     }
     list($this->interval, $this->intervalModifier, $this->intervalSlide) = (array) N2Parse::parse($slider->params->get('autoplayfinish', '0|*|loop|*|current'));
     $this->interval = intval($this->interval);
     $this->stopOnClick = intval($params->get('autoplayStopClick', 1));
     $this->stopOnMouse = $params->get('autoplayStopMouse', 'enter');
     $this->stopOnMediaStarted = intval($params->get('autoplayStopMedia', 1));
     $this->resumeOnClick = intval($params->get('autoplayResumeClick', 0));
     $this->resumeOnMouse = $params->get('autoplayResumeMouse', 0);
     $this->resumeOnMediaEnded = intval($params->get('autoplayResumeMedia', 1));
 }
示例#6
0
 private function getHtml($data, $id, $slider, $slide)
 {
     $attributes = array();
     $font = N2FontRenderer::render($data->get('font'), 'hover', $slider->elementId, 'div#' . $slider->elementId . ' ', $slider->fontSize);
     $style = N2StyleRenderer::render($data->get('style'), 'heading', $slider->elementId, 'div#' . $slider->elementId . ' ');
     $linkAttributes = array();
     if ($this->isEditor) {
         $linkAttributes['onclick'] = 'return false;';
     }
     $title = $data->get('title', '');
     if (!empty($title)) {
         $attributes['title'] = $title;
     }
     list($link) = (array) N2Parse::parse($data->get('link', '#|*|'));
     if (!empty($link) && $link != '#') {
         $linkAttributes['class'] = $font;
         $font = '';
     }
     return $this->heading($data->get('priority', 2), $attributes + array("id" => $id, "class" => $font . $style . " " . $data->get('class', ''), "style" => "display:" . ($data->get('fullwidth', 1) ? 'block' : 'inline-block') . ";" . ($data->get('nowrap', 1) ? 'white-space:nowrap;' : '')), $this->getLink($slide, $data, str_replace("\n", '<br />', strip_tags($slide->fill($data->get('heading', '')))), $linkAttributes));
 }
示例#7
0
 protected function addSlideLink()
 {
     list($url, $target) = (array) N2Parse::parse($this->parameters->getIfEmpty('link', '|*|'));
     if (!empty($url) && $url != '#') {
         if (empty($target)) {
             $target = '_self';
         }
         $url = $this->fill($url);
         $this->containerAttributes['onclick'] = '';
         if (strpos($url, 'javascript:') === 0) {
             $this->containerAttributes['onclick'] = $url;
         } else {
             N2Loader::import('libraries.link.link');
             $url = N2LinkParser::parse($url, $this->containerAttributes);
             $this->containerAttributes['data-href'] = N2Platform::$isJoomla ? JRoute::_($url, false) : $url;
             if (empty($this->containerAttributes['onclick'])) {
                 if ($target == '_blank') {
                     $this->containerAttributes['n2click'] = "window.open(this.getAttribute('data-href'),'_blank');";
                 } else {
                     $this->containerAttributes['n2click'] = "window.location=this.getAttribute('data-href')";
                 }
                 $this->containerAttributes['n2middleclick'] = "window.open(this.getAttribute('data-href'),'_blank');";
             }
         }
         $this->containerAttributes['style'] .= 'cursor:pointer;';
     }
 }
示例#8
0
 /**
  * @param $v
  *
  * @return string
  */
 public function parseTshadow($v)
 {
     $v = N2Parse::parse($v);
     $rgba = N2Color::hex2rgba($v[3]);
     if ($v[0] == 0 && $v[1] == 0 && $v[2] == 0) {
         return 'text-shadow: none;';
     }
     return 'text-shadow: ' . $v[0] . 'px ' . $v[1] . 'px ' . $v[2] . 'px RGBA(' . $rgba[0] . ',' . $rgba[1] . ',' . $rgba[2] . ',' . round($rgba[3] / 127, 2) . ');';
 }
 protected function getLink($slide, $data, $content, $attributes = array(), $renderEmpty = false)
 {
     N2Loader::import('libraries.link.link');
     list($link, $target) = (array) N2Parse::parse($data->get('link', '#|*|'));
     if (!$target) {
         $target = '';
     }
     if ($link != '#' || $renderEmpty === true) {
         $link = N2LinkParser::parse($slide->fill($link), $attributes, $this->isEditor);
         return N2Html::link($content, $link, $attributes + array("target" => $target));
     }
     return $content;
 }
示例#10
0
 protected function setDevices()
 {
     if (intval($this->_data->get('showmobile', 1)) == 0) {
         if (!$this->device->isTablet() && $this->device->isMobile()) {
             $this->norender = true;
             return;
         }
     }
     $custommobile = N2Parse::parse($this->_data->get('showcustommobile', '0|*|'));
     if ($custommobile[0] == 1) {
         if (!$this->device->isTablet() && $this->device->isMobile()) {
             $this->_data->set('slider', $custommobile[1]);
         }
     }
     if (intval($this->_data->get('showtablet', 1)) == 0) {
         if ($this->device->isTablet()) {
             $this->norender = true;
             return;
         }
     }
     $customtablet = N2Parse::parse($this->_data->get('showcustomtablet', '0|*|'));
     if ($customtablet[0] == 1) {
         if ($this->device->isTablet()) {
             $this->_data->set('slider', $customtablet[1]);
         }
     }
 }
示例#11
0
 public function __construct($slider)
 {
     $this->slider = $slider;
     list($this->from, $this->to) = (array) N2Parse::parse(N2SmartSliderSettings::get('translate-url', '||'));
 }
示例#12
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;
 }
示例#13
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;
 }