/** * Method to get the associations for a given item * * @param integer $id Id of the item * @param string $view Name of the view * * @return array Array of associations for the item * * @since 3.0 */ public static function getAssociations($id = 0, $view = null) { jimport('helper.route', JPATH_COMPONENT_SITE); $app = JFactory::getApplication(); $jinput = $app->input; $view = is_null($view) ? $jinput->get('view') : $view; $id = empty($id) ? $jinput->getInt('id') : $id; if ($view == 'article') { if ($id) { $associations = JLanguageAssociations::getAssociations('com_content', '#__content', 'com_content.item', $id); $return = array(); foreach ($associations as $tag => $item) { $return[$tag] = TZ_PortfolioHelperRoute::getArticleRoute($item->id, $item->catid, $item->language); } return $return; } } elseif ($view == 'p_article') { if ($id) { $associations = JLanguageAssociations::getAssociations('com_content', '#__content', 'com_content.item', $id); $return = array(); foreach ($associations as $tag => $item) { $return[$tag] = TZ_PortfolioHelperRoute::getPortfolioArticleRoute($item->id, $item->catid, $item->language); } return $return; } } if ($view == 'category' || $view == 'categories') { return self::getCategoryAssociations($id, 'com_content'); } return array(); }
function getObjectInfo($id, $language = null) { $info = new JCommentsObjectInfo(); $routerHelper = JPATH_ROOT . '/components/com_tz_portfolio/helpers/route.php'; if (is_file($routerHelper)) { require_once $routerHelper; $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('a.id, a.title, a.created_by, a.access, a.alias, a.catid'); $query->from('#__content AS a'); $query->select('c.alias AS category_alias'); $query->join('LEFT', '#__categories AS c ON c.id = a.catid'); $query->where('a.id = ' . (int) $id); $db->setQuery($query); $row = $db->loadObject(); if (!empty($row)) { $row->slug = $row->alias ? $row->id . ':' . $row->alias : $row->id; $row->catslug = $row->category_alias ? $row->catid . ':' . $row->category_alias : $row->catid; $info->category_id = $row->category_id; $info->title = $row->title; $info->userid = $row->created_by; $info->link = JRoute::_(TZ_PortfolioHelperRoute::getArticleRoute($row->slug, $row->catslug)); } } return $info; }
public static function getList(&$params) { $db = JFactory::getDbo(); $content = $params->get('manager'); $order = $params->get('order'); $orderby = $params->get('orderby'); $limit = $params->get('limit'); $catids = $params->get('catid'); $img = $params->get('image'); $typenews = $params->get('views'); $featureol = $params->get('show_featured'); $redirect = $params->get('redirect_page'); $show_audio = $params->get('show_audio'); $show_quote = $params->get('show_quote'); $show_link = $params->get('show_link'); $dispatcher = JDispatcher::getInstance(); $li = array(); if ($show_audio == 0) { $li[] = "'audio'"; } if ($show_quote == 0) { $li[] = "'quote'"; } if ($show_link == 0) { $li[] = "'link'"; } $li_arr = implode(",", $li); $where_a = '(tz_xc.type not in(' . $li_arr . ') or tz_xc.type is null)'; // portfolio and content if ($typenews == "featured") { if (isset($catids) && !empty($catids)) { $catid = implode(",", $catids); $where = " ct.catid IN({$catid}) and ct.state = 1 and ct.featured = 1 ORDER BY ct.{$orderby} {$order} LIMIT {$limit}"; } else { $where = " ct.state = 1 and ct.featured = 1 ORDER BY ct.{$orderby} {$order} LIMIT {$limit}"; } } else { if (isset($catids) && !empty($catids)) { $catid = implode(",", $catids); if ($featureol == 1) { $where = " ct.catid IN({$catid}) and ct.state = 1 and ct.featured = 1 ORDER BY ct.{$orderby} {$order} LIMIT {$limit}"; } else { $where = " ct.catid IN({$catid}) and ct.state = 1 ORDER BY ct.{$orderby} {$order} LIMIT {$limit}"; } } else { $where = " ct.state = 1 ORDER BY ct.{$orderby} {$order} LIMIT {$limit}"; } } if ($content == 'tz_portfolio') { $jquery = $db->getQuery(true); $jquery->select('ct.*'); $jquery->from('#__content as ct'); $jquery->select('cat.title as category_title,cat.id, cat.alias as category_alias'); $jquery->join('left', '#__categories as cat on cat.id = ct.catid'); $jquery->select('us.id,us.name as author'); $jquery->join('left', '#__users as us on us.id = ct.created_by'); $jquery->select('tz_xc.type as type_media,tz_xc.*'); $jquery->join('left', '#__tz_portfolio_xref_content as tz_xc on tz_xc.contentid = ct.id'); if ($li) { $jquery->where($where_a); } $jquery->where($where); $db->setQuery($jquery); $items = $db->loadObjectList(); $param_com = JComponentHelper::getComponent('com_content')->params; if ($items) { foreach ($items as $i => $item) { $item->text = $item->introtext; JPluginHelper::importPlugin('content'); $results = $dispatcher->trigger('onContentPrepare', array('com_tz_portfolio.article', &$item, &$param_com, 0)); $item->introtext = $item->text; $item->event = new stdClass(); $results = $dispatcher->trigger('onContentAfterTitle', array('com_tz_portfolio.article', &$item, &$param_com, 0)); $item->event->afterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_tz_portfolio.article', &$item, &$param_com, 0)); $item->event->beforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentAfterDisplay', array('com_tz_portfolio.article', &$item, &$param_com, 0)); $item->event->afterDisplayContent = trim(implode("\n", $results)); //Get Plugins Model $pmodel = JModelLegacy::getInstance('Plugins', 'TZ_PortfolioModel', array('ignore_request' => true)); //Get plugin Params for this article $pmodel->setState('filter.contentid', $item->id); $pluginParams = $pmodel->getParams(); $item->pluginparams = clone $pluginParams; JPluginHelper::importPlugin('tz_portfolio'); $results = $dispatcher->trigger('onTZPluginPrepare', array('com_tz_portfolio.article', &$item, &$param_com, &$pluginParams, 0)); $results = $dispatcher->trigger('onTZPluginAfterTitle', array('com_tz_portfolio.article', &$item, &$param_com, &$pluginParams, 0)); $item->event->TZafterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onTZPluginBeforeDisplay', array('com_tz_portfolio.article', &$item, &$param_com, &$pluginParams, 0)); $item->event->TZbeforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onTZPluginAfterDisplay', array('com_tz_portfolio.article', &$item, &$param_com, &$pluginParams, 0)); $item->event->TZafterDisplayContent = trim(implode("\n", $results)); $item->media = null; $item->tztitle = $item->title; $item->hit = $item->hits; echo $item->event->beforeDisplayContent; echo $item->event->TZbeforeDisplayContent; $item->intro = $item->introtext; echo $item->event->afterDisplayContent; echo $item->event->TZafterDisplayContent; $item->slug = $item->contentid . ':' . $item->alias; $item->catslug = $item->catid . ':' . $item->category_alias; $item->category = $item->category_title; $item->author = $item->author; if ($redirect == 0) { $item->link = JRoute::_(TZ_PortfolioHelperRoute::getArticleRoute($item->slug, $item->catslug)); } if ($redirect == 1) { $item->link = JRoute::_(TZ_PortfolioHelperRoute::getPortfolioArticleRoute($item->slug, $item->catslug)); } if (isset($item->type_media) and $item->type_media and $item->type_media != 'none') { if ($item->type_media == 'image') { $images = $item->images; if ($images) { $nameimg = JFile::getExt($images); $count = strlen($nameimg); $image_name = substr($images, 0, -($count + 1)); $item->image = $image_name . '_' . $img . '.' . $nameimg; } else { $item->image = ''; } } if ($item->type_media == 'imageGallery') { $images = $item->gallery; if ($images) { $arrimages = explode("///", $images); if ($arrimages[0]) { $nameimg = JFile::getExt($arrimages[0]); $count = strlen($nameimg); $image_name = substr($arrimages[0], 0, -($count + 1)); $item->image = $image_name . '_' . $img . '.' . $nameimg; } } else { $item->image = ''; } } if ($item->type_media == 'video') { $images = $item->videothumb; if ($images) { $nameimg = JFile::getExt($images); $count = strlen($nameimg); $image_name = substr($images, 0, -($count + 1)); $item->image = $image_name . '_' . $img . '.' . $nameimg; } else { $item->image = ''; } } if ($item->type_media == 'audio') { $images = $item->audiothumb; if ($images) { $nameimg = JFile::getExt($images); $count = strlen($nameimg); $image_name = substr($images, 0, -($count + 1)); $item->image = $image_name . '_' . $img . '.' . $nameimg; } else { $item->image = ''; } } } else { $item->image = ''; } } return $items; } } if ($content == 'joomla_content') { $query = "SELECT ct.*,ct.id as arid, ct.hits as hit, ct.title as artitle, ct.alias as aralias, cat.title as category_title, us.name as created_by_user, cat.alias as category_alias\n FROM #__content ct LEFT JOIN #__categories cat ON(ct.catid = cat.id)\n LEFT JOIN #__users us On(ct.created_by = us.id) where\n {$where} "; $db->setQuery($query); $items = $db->loadObjectList(); $param_com = JComponentHelper::getComponent('com_content')->params; if ($items) { if ($content == 'joomla_content') { foreach ($items as $item) { $item->text = $item->introtext; JPluginHelper::importPlugin('content'); $results = $dispatcher->trigger('onContentPrepare', array('com_content.article', &$item, &$param_com, 0)); $item->introtext = $item->text; $item->event = new stdClass(); $results = $dispatcher->trigger('onContentAfterTitle', array('com_content.article', &$item, &$param_com, 0)); $item->event->afterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_content.article', &$item, &$param_com, 0)); $item->event->beforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentAfterDisplay', array('com_content.article', &$item, &$param_com, 0)); $item->event->afterDisplayContent = trim(implode("\n", $results)); $item->title = $item->artitle; $item->media = null; $item->hit = $item->hits; $item->intro = $item->introtext; $item->category = $item->category_title; $item->author = $item->created_by_user; $item->slug = $item->arid . ':' . $item->aralias; $item->catslug = $item->catid . ':' . $item->category_alias; $item->link = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug)); if ($item->images) { $images = new JRegistry(); $images->loadString($item->images); $images = json_decode($item->images); $item->image = $images->image_intro; $item->image_full = $images->image_fulltext; } else { $item->image = null; } } return $items; } } } return false; }
?> <?php if ($this->params->get('show_empty_categories_cat') || $item->numitems || count($item->getChildren())) { if (!isset($this->items[$this->parent->id][$id + 1])) { $class = ' class="last"'; } ?> <div<?php echo $class; ?> > <?php $class = ''; ?> <h3 class="page-header item-title"><a href="<?php echo JRoute::_(TZ_PortfolioHelperRoute::getCategoryRoute($item->id)); ?> "> <?php echo $this->escape($item->title); ?> </a> <?php if ($this->params->get('show_cat_num_articles_cat') == 1) { ?> <span class="badge badge-info hasTooltip" title="<?php echo JText::_('COM_CONTENT_NUM_ITEMS'); ?> "> <?php echo $item->numitems;
# copyright Copyright (C) 2012 templaza.com. All Rights Reserved. # @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL # Websites: http://www.templaza.com # Technical Support: Forum - http://templaza.com/Forum -------------------------------------------------------------------------*/ // no direct access defined('_JEXEC') or die('Restricted access'); $params = $this->item->params; $doc = JFactory::getDocument(); $socialInfos = $this->socialInfo; $url = JRoute::_(TZ_PortfolioHelperRoute::getPortfolioArticleRoute($this->item->slug, $this->item->catid), true, -1); //$url = 'http://www.templaza.com'; if ($params->get('show_twitter_button', 1) == 1 or $params->get('show_facebook_button', 1) == 1 or $params->get('show_google_button', 1) == 1 or $params->get('show_pinterest_button', 1) or $params->get('show_linkedin_button', 1)) { ?> <div class="breadcrumb tz_portfolio_like_button"> <span class="icon-plus-2 label-info TzAdd"></span> <div class="TzLikeButtonInner"> <span class="TzLikeQuestion"><?php echo JText::_('COM_TZ_PORTFOLIO_SOCIAL_QUESTION'); ?> </span> <?php if ($params->get('show_facebook_button', 1) == 1) { ?>
/** * @since 1.6 */ public function onContentBeforeDisplay($context, &$row, &$params, $page = 0) { $view = JRequest::getCmd('view'); $print = JRequest::getBool('print'); if ($print) { return false; } if ($params->get('show_item_navigation') == 1 && ($context == 'com_tz_portfolio.article' && $view == 'article' || $context == 'com_tz_portfolio.p_article' && $view == 'p_article')) { $html = ''; $db = JFactory::getDbo(); $user = JFactory::getUser(); $app = JFactory::getApplication(); $lang = JFactory::getLanguage(); $nullDate = $db->getNullDate(); $date = JFactory::getDate(); $config = JFactory::getConfig(); $now = $date->toSql(); $uid = $row->id; $option = 'com_tz_portfolio'; $canPublish = $user->authorise('core.edit.state', $option . '.article.' . $row->id); // The following is needed as different menu items types utilise a different param to control ordering. // For Blogs the `orderby_sec` param is the order controlling param. // For Table and List views it is the `orderby` param. $params_list = $params->toArray(); if (array_key_exists('orderby_sec', $params_list)) { $order_method = $params->get('orderby_sec', ''); } else { $order_method = $params->get('orderby', ''); } // Additional check for invalid sort ordering. if ($order_method == 'front') { $order_method = ''; } // Determine sort order. switch ($order_method) { case 'date': $orderby = 'a.created'; break; case 'rdate': $orderby = 'a.created DESC'; break; case 'alpha': $orderby = 'a.title'; break; case 'ralpha': $orderby = 'a.title DESC'; break; case 'hits': $orderby = 'a.hits'; break; case 'rhits': $orderby = 'a.hits DESC'; break; case 'order': $orderby = 'a.ordering'; break; case 'author': $orderby = 'a.created_by_alias, u.name'; break; case 'rauthor': $orderby = 'a.created_by_alias DESC, u.name DESC'; break; case 'front': $orderby = 'f.ordering'; break; default: $orderby = 'a.ordering'; break; } $xwhere = ' AND (a.state = 1 OR a.state = -1)' . ' AND (publish_up = ' . $db->Quote($nullDate) . ' OR publish_up <= ' . $db->Quote($now) . ')' . ' AND (publish_down = ' . $db->Quote($nullDate) . ' OR publish_down >= ' . $db->Quote($now) . ')'; // Array of articles in same category correctly ordered. $query = $db->getQuery(true); //sqlsrv changes $case_when = ' CASE WHEN '; $case_when .= $query->charLength('a.alias'); $case_when .= ' THEN '; $a_id = $query->castAsChar('a.id'); $case_when .= $query->concatenate(array($a_id, 'a.alias'), ':'); $case_when .= ' ELSE '; $case_when .= $a_id . ' END as slug'; $case_when1 = ' CASE WHEN '; $case_when1 .= $query->charLength('cc.alias'); $case_when1 .= ' THEN '; $c_id = $query->castAsChar('cc.id'); $case_when1 .= $query->concatenate(array($c_id, 'cc.alias'), ':'); $case_when1 .= ' ELSE '; $case_when1 .= $c_id . ' END as catslug'; $query->select('a.id,' . $case_when . ',' . $case_when1); $query->from('#__content AS a'); $query->leftJoin('#__categories AS cc ON cc.id = a.catid'); $query->where('a.catid = ' . (int) $row->catid . ' AND a.state = ' . (int) $row->state . ($canPublish ? '' : ' AND a.access = ' . (int) $row->access) . $xwhere); $query->order($orderby); if ($app->isSite() && $app->getLanguageFilter()) { $query->where('a.language in (' . $db->quote($lang->getTag()) . ',' . $db->quote('*') . ')'); } $db->setQuery($query); $list = $db->loadObjectList('id'); // This check needed if incorrect Itemid is given resulting in an incorrect result. if (!is_array($list)) { $list = array(); } reset($list); // Location of current content item in array list. $location = array_search($uid, array_keys($list)); $rows = array_values($list); $row->prev = null; $row->next = null; if ($location - 1 >= 0) { // The previous content item cannot be in the array position -1. $row->prev = $rows[$location - 1]; } if ($location + 1 < count($rows)) { // The next content item cannot be in an array position greater than the number of array postions. $row->next = $rows[$location + 1]; } $pnSpace = ""; if (JText::_('JGLOBAL_LT') || JText::_('JGLOBAL_GT')) { $pnSpace = " "; } $tmpl = null; if ($params->get('tz_use_lightbox')) { $tmpl = '&tmpl=component'; } if ($row->prev) { if ($view == 'p_article') { $row->prev = JRoute::_(TZ_PortfolioHelperRoute::getPortfolioArticleRoute($row->prev->slug, $row->prev->catslug) . $tmpl); } else { $row->prev = JRoute::_(TZ_PortfolioHelperRoute::getArticleRoute($row->prev->slug, $row->prev->catslug) . $tmpl); } } else { $row->prev = ''; } if ($row->next) { if ($view == 'p_article') { $row->next = JRoute::_(TZ_PortfolioHelperRoute::getPortfolioArticleRoute($row->next->slug, $row->next->catslug) . $tmpl); } else { $row->next = JRoute::_(TZ_PortfolioHelperRoute::getArticleRoute($row->next->slug, $row->next->catslug) . $tmpl); } } else { $row->next = ''; } // Output. if ($row->prev || $row->next) { $html = ' <ul class="pager pagenav">'; if ($row->prev) { $html .= ' <li class="previous"> <a href="' . $row->prev . '" rel="prev">' . JText::_('JGLOBAL_LT') . $pnSpace . JText::_('JPREV') . '</a> </li>'; } if ($row->next) { $html .= ' <li class="next"> <a href="' . $row->next . '" rel="next">' . JText::_('JNEXT') . $pnSpace . JText::_('JGLOBAL_GT') . '</a> </li>'; } $html .= ' </ul>'; $row->pagination = $html; $row->paginationposition = $this->params->get('position', 1); // This will default to the 1.5 and 1.6-1.7 behavior. $row->paginationrelative = $this->params->get('relative', 0); } } return; }
function display() { $app = JFactory::getApplication(); $doc = JFactory::getDocument(); $params = $app->getParams(); $feedEmail = @$app->getCfg('feed_email') ? $app->getCfg('feed_email') : 'author'; $siteEmail = $app->getCfg('mailfrom'); // Get some data from the model JRequest::setVar('limit', $app->getCfg('feed_limit')); $rows = $this->get('Article'); $doc->setLink(JURI::current()); //JRoute::_(TZ_PortfolioHelperRoute::getCategoryRoute(9)); $model = JModelLegacy::getInstance('Media', 'TZ_PortfolioModel', array('ignore_request' => true)); foreach ($rows as $row) { // strip html from feed item title $title = $this->escape($row->title); $title = html_entity_decode($title, ENT_COMPAT, 'UTF-8'); // Compute the article slug $row->slug = $row->alias ? $row->id . ':' . $row->alias : $row->id; $tzRedirect = $params->get('tz_portfolio_redirect', 'p_article'); //Set params for $tzRedirect $itemParams = new JRegistry($row->attribs); //Get Article's Params //Check redirect to view article if ($itemParams->get('tz_portfolio_redirect')) { $tzRedirect = $itemParams->get('tz_portfolio_redirect'); } // url link to article if ($tzRedirect == 'article') { $link = JRoute::_(TZ_PortfolioHelperRoute::getArticleRoute($row->slug, $row->catid)); } else { $link = JRoute::_(TZ_PortfolioHelperRoute::getPortfolioArticleRoute($row->slug, $row->catid)); } // image to article $image = null; if ($params->get('show_feed_image', 1) == 1) { $media = $model->getMedia($row->id); $size = $params->get('feed_image_size', 'S'); if (strtolower($media[0]->type) == 'video' || strtolower($media[0]->type) == 'audio') { $image = $media[0]->thumb; } else { $image = $media[0]->images; } if ($image) { $image = str_replace('.' . JFile::getExt($image), '_' . $size . '.' . JFile::getExt($image), $image); $_link = $link; if (!preg_match('/' . JURI::base() . '/', $link)) { $_link = str_replace(JURI::base(true) . '/', JURI::base(), $link); } $image = '<a href="' . $_link . '"><img src="' . $image . '" alt="' . $title . '"/></a>'; } } // strip html from feed item description text // TODO: Only pull fulltext if necessary (actually, just get the necessary fields). $description = $params->get('feed_summary', 0) ? $row->introtext : $row->introtext; $author = $row->created_by_alias ? $row->created_by_alias : $row->author; @($date = $row->created ? date('r', strtotime($row->created)) : ''); if (isset($media[0]->type) && strtolower($media[0]->type) == 'quote') { $author = $media[0]->quote_author; } if (isset($media[0]->type) && (strtolower($media[0]->type) == 'quote' || strtolower($media[0]->type) == 'link')) { if (strtolower($media[0]->type) == 'quote') { $description = $media[0]->quote_text . '<span class="author">' . $author . '</span>'; } } // load individual item creator class $item = new JFeedItem(); if (isset($media[0]->type) && (strtolower($media[0]->type) != 'quote' && strtolower($media[0]->type) != 'link') || !isset($media[0]->type)) { $item->title = $title; $item->link = $link; } else { if (strtolower($media[0]->type) == 'link') { $item->title = $media[0]->link_title; $item->link = $media[0]->link_url; } } $item->description = $image . $description; $item->date = $date; $item->category = $row->category; $item->author = $author; if ($feedEmail == 'site') { $item->authorEmail = $siteEmail; } else { $item->authorEmail = $row->author_email; } // loads item info into rss array $doc->addItem($item); } }
protected function _prepareDocument() { $app = JFactory::getApplication(); $menus = $app->getMenu(); $pathway = $app->getPathway(); $title = null; // Because the application sets a default page title, // we need to get it from the menu item itself $menu = $menus->getActive(); if ($menu) { $this->params->def('page_heading', $this->params->get('page_title', $menu->title)); } else { $this->params->def('page_heading', JText::_('JGLOBAL_ARTICLES')); } $id = (int) @$menu->query['id']; if ($menu && ($menu->query['option'] != 'com_tz_portfolio' || $menu->query['view'] == 'article' || $id != $this->category->id)) { $path = array(array('title' => $this->category->title, 'link' => '')); $category = $this->category->getParent(); while (($menu->query['option'] != 'com_tz_portfolio' || $menu->query['view'] == 'article' || $id != $category->id) && $category->id > 1) { $path[] = array('title' => $category->title, 'link' => TZ_PortfolioHelperRoute::getCategoryRoute($category->id)); $category = $category->getParent(); } $path = array_reverse($path); foreach ($path as $item) { $pathway->addItem($item['title'], $item['link']); } } $title = $this->params->get('page_title', ''); if (empty($title)) { $title = $app->getCfg('sitename'); } elseif ($app->getCfg('sitename_pagetitles', 0) == 1) { $title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title); } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) { $title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename')); } $this->document->setTitle($title); if ($this->category->metadesc) { $this->document->setDescription($this->category->metadesc); } elseif (!$this->category->metadesc && $this->params->get('menu-meta_description')) { $this->document->setDescription($this->params->get('menu-meta_description')); } if ($this->category->metakey) { $this->document->setMetadata('keywords', $this->category->metakey); } elseif (!$this->category->metakey && $this->params->get('menu-meta_keywords')) { $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); } if ($this->params->get('robots')) { $this->document->setMetadata('robots', $this->params->get('robots')); } if ($app->getCfg('MetaAuthor') == '1') { $this->document->setMetaData('author', $this->category->getMetadata()->get('author')); } $mdata = $this->category->getMetadata()->toArray(); foreach ($mdata as $k => $v) { if ($v) { $this->document->setMetadata($k, $v); } } // Add feed links if ($this->params->get('show_feed_link', 1)) { $link = '&format=feed&limitstart='; $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'); $this->document->addHeadLink(JRoute::_($link . '&type=rss'), 'alternate', 'rel', $attribs); $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'); $this->document->addHeadLink(JRoute::_($link . '&type=atom'), 'alternate', 'rel', $attribs); } }
<div class="TzArticle-info"> <!-- <dt class="article-info-term">--><?php //echo JText::_('COM_CONTENT_ARTICLE_INFO'); ?> <!--</dt>--> <?php } ?> <?php if ($params->get('show_category')) { ?> <span class="TZcategory-name"> <?php $title = $this->escape($row->category_title); $url = '<a href="' . JRoute::_(TZ_PortfolioHelperRoute::getCategoryRoute($row->catid)) . '">' . $title . '</a>'; ?> <?php if ($params->get('link_category')) { ?> <?php echo JText::sprintf('COM_CONTENT_CATEGORY', $url); ?> <?php } else { ?> <?php echo JText::sprintf('COM_CONTENT_CATEGORY', $title); ?> <?php }
public static function getList(&$params) { $app = JFactory::getApplication(); $db = JFactory::getDbo(); // Get an instance of the generic articles model $model = JModelLegacy::getInstance('Articles', 'TZ_PortfolioModel', array('ignore_request' => true)); // Set application parameters in model $appParams = JFactory::getApplication()->getParams(); $model->setState('params', $appParams); // Set the filters based on the module params $model->setState('list.start', 0); $model->setState('list.limit', (int) $params->get('count', 5)); $model->setState('filter.published', 1); $model->setState('list.select', 'a.fulltext, a.id, a.title, a.alias, a.introtext, a.state, a.catid, a.created, a.created_by, a.created_by_alias,' . ' a.modified, a.modified_by,a.publish_up, a.publish_down, a.attribs, a.metadata, a.metakey, a.metadesc, a.access,' . ' a.hits, a.featured,' . ' LENGTH(a.fulltext) AS readmore'); // Access filter $access = !JComponentHelper::getParams('com_tz_portfolio')->get('show_noauth'); $authorised = JAccess::getAuthorisedViewLevels(JFactory::getUser()->get('id')); $model->setState('filter.access', $access); // Category filter $model->setState('filter.category_id', $params->get('catid', array())); // Filter by language $model->setState('filter.language', $app->getLanguageFilter()); // Set ordering $ordering = $params->get('ordering', 'a.publish_up'); $model->setState('list.ordering', $ordering); if (trim($ordering) == 'rand()') { $model->setState('list.direction', ''); } else { $model->setState('list.direction', 'DESC'); } // Retrieve Content if ($items = $model->getItems()) { $model2 = JModelLegacy::getInstance('Media', 'TZ_PortfolioModel', array('ignore_request' => true)); foreach ($items as &$item) { $model2->setState('article.id', $item->id); $item->media = null; if ($media = $model2->getMedia()) { $item->media = $media[0]; if ($media[0]->type != 'video' && $media[0]->type != 'audio') { if (!empty($media[0]->images)) { if ($params->get('tz_image_size', 'S')) { $imageName = $media[0]->images; $item->media->images = JURI::root() . str_replace('.' . JFile::getExt($imageName), '_' . $params->get('tz_image_size', 'S') . '.' . JFile::getExt($imageName), $imageName); } } } else { if (!empty($media[0]->thumb)) { if ($params->get('tz_image_size', 'S')) { $imageName = $media[0]->thumb; $item->media->images = JURI::root() . str_replace('.' . JFile::getExt($imageName), '_' . $params->get('tz_image_size', 'S') . '.' . JFile::getExt($imageName), $imageName); } } } if ($media[0]->type == 'quote' and !$params->get('show_quote', 1) or $media[0]->type == 'link' and !$params->get('show_link', 1)) { $item->media = null; } } $item->readmore = trim($item->fulltext) != ''; $item->slug = $item->id . ':' . $item->alias; $item->catslug = $item->catid . ':' . $item->category_alias; if ($access || in_array($item->access, $authorised)) { // We know that user has the privilege to view the article $item->link = JRoute::_(TZ_PortfolioHelperRoute::getArticleRoute($item->slug, $item->catid)); $item->linkText = JText::_('MOD_ARTICLES_NEWS_READMORE'); } else { $item->link = JRoute::_('index.php?option=com_users&view=login'); $item->linkText = JText::_('MOD_ARTICLES_NEWS_READMORE_REGISTER'); } $item->introtext = JHtml::_('content.prepare', $item->introtext, '', 'mod_tz_portfolio_articles_news.content'); //new if (!$params->get('image')) { $item->introtext = preg_replace('/<img[^>]*>/', '', $item->introtext); } $results = $app->triggerEvent('onContentAfterDisplay', array('com_tz_portfolio.article', &$item, &$params, 1)); $item->afterDisplayTitle = trim(implode("\n", $results)); $results = $app->triggerEvent('onContentBeforeDisplay', array('com_tz_portfolio.article', &$item, &$params, 1)); $item->beforeDisplayContent = trim(implode("\n", $results)); } return $items; } return null; }
public static function print_popup($article, $params, $attribs = array()) { if ($params->get('tz_portfolio_redirect') == 'p_article') { $url = TZ_PortfolioHelperRoute::getPortfolioArticleRoute($article->slug, $article->catid); } else { $url = TZ_PortfolioHelperRoute::getArticleRoute($article->slug, $article->catid); } $url .= '&tmpl=component&print=1&layout=default&page=' . @$request->limitstart; $status = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no'; // checks template image directory for image, if non found default are loaded if ($params->get('show_icons')) { $text = '<i class="icon-print"></i> ' . JText::_('JGLOBAL_PRINT'); } else { $text = JText::_('JGLOBAL_PRINT'); } $attribs['title'] = JText::_('JGLOBAL_PRINT'); $attribs['onclick'] = "window.open(this.href,'win2','" . $status . "'); return false;"; $attribs['rel'] = 'nofollow'; return JHtml::_('link', JRoute::_($url), $text, $attribs); }
<td> <a style="cursor: pointer;" class="pointer" onclick="if (window.parent) window.parent.<?php echo $this->escape($function); ?> ('<?php echo $item->id; ?> ', '<?php echo $this->escape(addslashes($item->title)); ?> ', '<?php echo $this->escape($item->catid); ?> ', null, '<?php echo $this->escape(TZ_PortfolioHelperRoute::getArticleRoute($item->id)); ?> ');"> <?php echo $this->escape($item->title); ?> </a> </td> <td class="small hidden-phone"> <?php echo $item->type; ?> </td> <td class="center small"> <?php echo $this->escape($item->access_level);
<?php foreach ($lists as $i => $item) { ?> <?php $tzRedirect = $params->get('tz_portfolio_redirect', 'p_article'); //Set params for $tzRedirect $itemParams = new JRegistry($item->attribs); //Get Article's Params //Check redirect to view article if ($itemParams->get('tz_portfolio_redirect')) { $tzRedirect = $itemParams->get('tz_portfolio_redirect'); } if ($tzRedirect == 'article') { $item->_link = JRoute::_(TZ_PortfolioHelperRoute::getArticleRoute($item->slug, $item->catid) . $tmpl); } else { $item->_link = JRoute::_(TZ_PortfolioHelperRoute::getPortfolioArticleRoute($item->slug, $item->catid) . $tmpl); } $listMedia = $media->getMedia($item->id); $src = null; if ($listMedia) { if ($listMedia[0]->type != 'quote' && $listMedia[0]->type != 'link') { if ($listMedia[0]->type == 'video' || $listMedia[0]->type == 'audio') { $src = $listMedia[0]->thumb; } else { $src = $listMedia[0]->images; } } } ?> <?php if ($params->get('show_related_type', 'title_image') == 'image' and $src or $params->get('show_related_type', 'title_image') == 'title' or $params->get('show_related_type', 'title_image') == 'title_image') {
public static function getList(&$params) { // Get the dbo $db = JFactory::getDbo(); // Get an instance of the generic articles model $model = JModelLegacy::getInstance('Articles', 'TZ_PortfolioModel', array('ignore_request' => true)); // Set application parameters in model $app = JFactory::getApplication(); $appParams = $app->getParams(); $model->setState('params', $appParams); // Set the filters based on the module params $model->setState('list.start', 0); $model->setState('list.limit', (int) $params->get('count', 5)); $model->setState('filter.published', 1); // Access filter $access = !JComponentHelper::getParams('com_tz_portfolio')->get('show_noauth'); $authorised = JAccess::getAuthorisedViewLevels(JFactory::getUser()->get('id')); $model->setState('filter.access', $access); // Category filter $model->setState('filter.category_id', $params->get('catid', array())); // User filter $userId = JFactory::getUser()->get('id'); switch ($params->get('user_id')) { case 'by_me': $model->setState('filter.author_id', (int) $userId); break; case 'not_me': $model->setState('filter.author_id', $userId); $model->setState('filter.author_id.include', false); break; case '0': break; default: $model->setState('filter.author_id', (int) $params->get('user_id')); break; } // Filter by language $model->setState('filter.language', $app->getLanguageFilter()); // Featured switch switch ($params->get('show_featured')) { case '1': $model->setState('filter.featured', 'only'); break; case '0': $model->setState('filter.featured', 'hide'); break; default: $model->setState('filter.featured', 'show'); break; } // Set ordering $order_map = array('m_dsc' => 'a.modified DESC, a.created', 'mc_dsc' => 'CASE WHEN (a.modified = ' . $db->quote($db->getNullDate()) . ') THEN a.created ELSE a.modified END', 'c_dsc' => 'a.created', 'p_dsc' => 'a.publish_up'); $ordering = JArrayHelper::getValue($order_map, $params->get('ordering'), 'a.publish_up'); $dir = 'DESC'; $model->setState('list.ordering', $ordering); $model->setState('list.direction', $dir); $items = $model->getItems(); $model2 = JModelLegacy::getInstance('Media', 'TZ_PortfolioModel', array('ignore_request' => true)); if ($items) { $dispatcher = JDispatcher::getInstance(); foreach ($items as $i => &$item) { $item->text = $item->introtext; JPluginHelper::importPlugin('content'); $results = $dispatcher->trigger('onContentPrepare', array('mod_tz_portfolio_articles_latest.content', &$item, &$params, 0)); $item->introtext = $item->text; $item->event = new stdClass(); $results = $dispatcher->trigger('onContentAfterTitle', array('mod_tz_portfolio_articles_latest.content', &$item, &$params, 0)); $item->event->afterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentBeforeDisplay', array('mod_tz_portfolio_articles_latest.content', &$item, &$params, 0)); $item->event->beforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentAfterDisplay', array('mod_tz_portfolio_articles_latest.content', &$item, &$params, 0)); $item->event->afterDisplayContent = trim(implode("\n", $results)); //Get Plugins Model $pmodel = JModelLegacy::getInstance('Plugins', 'TZ_PortfolioModel', array('ignore_request' => true)); //Get plugin Params for this article $pmodel->setState('filter.contentid', $item->id); $pluginItems = $pmodel->getItems(); $pluginParams = $pmodel->getParams(); $item->pluginparams = clone $pluginParams; JPluginHelper::importPlugin('tz_portfolio'); $results = $dispatcher->trigger('onTZPluginPrepare', array('mod_tz_portfolio_articles_latest.content', &$item, &$params, &$pluginParams, 0)); $results = $dispatcher->trigger('onTZPluginAfterTitle', array('mod_tz_portfolio_articles_latest.content', &$item, &$params, &$pluginParams, 0)); $item->event->TZafterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onTZPluginBeforeDisplay', array('mod_tz_portfolio_articles_latest.content', &$item, &$params, &$pluginParams, 0)); $item->event->TZbeforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onTZPluginAfterDisplay', array('mod_tz_portfolio_articles_latest.content', &$item, &$params, &$pluginParams, 0)); $item->event->TZafterDisplayContent = trim(implode("\n", $results)); $item->media = null; $item->slug = $item->id . ':' . $item->alias; $item->catslug = $item->catid . ':' . $item->category_alias; if ($access || in_array($item->access, $authorised)) { // We know that user has the privilege to view the article $item->link = JRoute::_(TZ_PortfolioHelperRoute::getArticleRoute($item->slug, $item->catslug)); } else { $item->link = JRoute::_('index.php?option=com_users&view=login'); } $model2->setState('article.id', $item->id); if ($media = $model2->getMedia()) { $item->media = $media[0]; if ($media[0]->type == 'quote' and !$params->get('show_quote', 1) or $media[0]->type == 'link' and !$params->get('show_link', 1)) { unset($items[$i]); } } } } return array_reverse($items); }
<?php } ?> </div> </dd> <?php } ?> <?php if ($params->get('show_category')) { ?> <dd> <div class="category-name"> <?php $title = $this->escape($item->category_title); $url = '<a href="' . JRoute::_(TZ_PortfolioHelperRoute::getCategoryRoute($item->catslug)) . '">' . $title . '</a>'; ?> <?php if ($params->get('link_category') and $item->catslug) { ?> <?php echo JText::sprintf('COM_CONTENT_CATEGORY', $url); ?> <?php } else { ?> <?php echo JText::sprintf('COM_CONTENT_CATEGORY', $title); ?> <?php }
public static function getList(&$params) { // Get an instance of the generic articles model $model = JModelLegacy::getInstance('Articles', 'TZ_PortfolioModel', array('ignore_request' => true)); // Set application parameters in model $app = JFactory::getApplication(); $appParams = $app->getParams(); $model->setState('params', $appParams); // Set the filters based on the module params $model->setState('list.start', 0); $model->setState('list.limit', (int) $params->get('count', 5)); $model->setState('filter.published', 1); // Access filter $access = !JComponentHelper::getParams('com_content')->get('show_noauth'); $authorised = JAccess::getAuthorisedViewLevels(JFactory::getUser()->get('id')); $model->setState('filter.access', $access); // Category filter $model->setState('filter.category_id', $params->get('catid', '')); // Filter by language $model->setState('filter.language', $app->getLanguageFilter()); // Ordering $model->setState('list.ordering', 'a.hits'); $model->setState('list.direction', 'DESC'); $model->setState('filter.featured', 'only'); if ($items = $model->getItems()) { $dispatcher = JDispatcher::getInstance(); $model2 = JModelLegacy::getInstance('Media', 'TZ_PortfolioModel', array('ignore_request' => true)); foreach ($items as &$item) { $item->slug = $item->id . ':' . $item->alias; $item->catslug = $item->catid . ':' . $item->category_alias; if ($access || in_array($item->access, $authorised)) { // We know that user has the privilege to view the article $item->link = JRoute::_(TZ_PortfolioHelperRoute::getArticleRoute($item->slug, $item->catslug)); } else { $item->link = JRoute::_('index.php?option=com_users&view=login'); } if ($params->get('tz_show_title') == '0') { $item->title = ''; } if ($params->get('tz_show_introtext') == '1') { $item->text = $item->introtext; JPluginHelper::importPlugin('content'); $results = $dispatcher->trigger('onContentPrepare', array('mod_tz_portfolio_articles_features.content', &$item, &$params, 0)); $item->introtext = $item->text; $item->event = new stdClass(); $results = $dispatcher->trigger('onContentAfterTitle', array('mod_tz_portfolio_articles_features.content', &$item, &$params, 0)); $item->event->afterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentBeforeDisplay', array('mod_tz_portfolio_articles_features.content', &$item, &$params, 0)); $item->event->beforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentAfterDisplay', array('mod_tz_portfolio_articles_features.content', &$item, &$params, 0)); $item->event->afterDisplayContent = trim(implode("\n", $results)); //Get Plugins Model $pmodel = JModelLegacy::getInstance('Plugins', 'TZ_PortfolioModel', array('ignore_request' => true)); //Get plugin Params for this article $pmodel->setState('filter.contentid', $item->id); $pluginItems = $pmodel->getItems(); $pluginParams = $pmodel->getParams(); $item->pluginparams = clone $pluginParams; JPluginHelper::importPlugin('tz_portfolio'); $results = $dispatcher->trigger('onTZPluginPrepare', array('mod_tz_portfolio_articles_features.content', &$item, &$params, &$pluginParams, 0)); $results = $dispatcher->trigger('onTZPluginAfterTitle', array('mod_tz_portfolio_articles_features.content', &$item, &$params, &$pluginParams, 0)); $item->event->TZafterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onTZPluginBeforeDisplay', array('mod_tz_portfolio_articles_features.content', &$item, &$params, &$pluginParams, 0)); $item->event->TZbeforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onTZPluginAfterDisplay', array('mod_tz_portfolio_articles_features.content', &$item, &$params, &$pluginParams, 0)); $item->event->TZafterDisplayContent = trim(implode("\n", $results)); if ($params->get('tz_counter')) { $text = strip_tags($item->introtext); $text = explode(' ', $text); $text = array_splice($text, 0, $params->get('tz_counter')); $text = implode(' ', $text); } else { $text = $item->introtext; } $item->text = $text; } $item->media = null; $model2->setState('article.id', $item->id); if ($media = $model2->getMedia()) { $item->media = $media[0]; if ($media[0]->type != 'video' && $media[0]->type != 'audio') { if (!empty($media[0]->images)) { if ($params->get('tz_image_size', 'S')) { $imageName = $media[0]->images; $item->media->images = JURI::root() . str_replace('.' . JFile::getExt($imageName), '_' . $params->get('tz_image_size', 'S') . '.' . JFile::getExt($imageName), $imageName); } } } else { if (!empty($media[0]->thumb)) { if ($params->get('tz_image_size', 'S')) { $imageName = $media[0]->thumb; $item->media->images = JURI::root() . str_replace('.' . JFile::getExt($imageName), '_' . $params->get('tz_image_size', 'S') . '.' . JFile::getExt($imageName), $imageName); } } } if ($media[0]->type == 'quote' and !$params->get('show_quote', 1) or $media[0]->type == 'link' and !$params->get('show_link', 1)) { $item->media = null; } } if ($model2 && $params->get('show_tz_image') == '1') { if ($image = $model2->getMedia($item->id)) { if ($image[0]->type != 'quote' && $image[0]->type != 'link') { if ($image[0]->type != 'video' && $image[0]->type != 'audio') { if (!empty($image[0]->images)) { if ($params->get('tz_image_size', 'S')) { $imageName = $image[0]->images; $item->tz_image = JURI::root() . str_replace('.' . JFile::getExt($imageName), '_' . $params->get('tz_image_size', 'S') . '.' . JFile::getExt($imageName), $imageName); } $item->tz_image_title = $image[0]->imagetitle; } } else { if (!empty($image[0]->thumb)) { if ($params->get('tz_image_size', 'S')) { $imageName = $image[0]->thumb; $item->tz_image = JURI::root() . str_replace('.' . JFile::getExt($imageName), '_' . $params->get('tz_image_size', 'S') . '.' . JFile::getExt($imageName), $imageName); } $item->tz_image_title = $image[0]->imagetitle; } } } else { $item->quote_author = null; if (isset($image[0]->quote_author)) { $item->quote_author = $image[0]->quote_author; } if (isset($image[0]->quote_text)) { $item->quote_text = $image[0]->quote_text; } if (isset($image[0]->link_title)) { $item->link_title = $image[0]->link_title; } if (isset($image[0]->link_url)) { $item->link_url = $image[0]->link_url; } if (isset($image[0]->link_target)) { $item->link_target = $image[0]->link_target; } if (isset($image[0]->link_follow)) { $item->link_follow = $image[0]->link_follow; } } } } } return $items; } return false; }
public static function getList(&$params) { // Get an instance of the generic articles model $articles = JModelLegacy::getInstance('Articles', 'TZ_PortfolioModel', array('ignore_request' => true)); // Set application parameters in model $app = JFactory::getApplication(); $appParams = $app->getParams(); $articles->setState('params', $appParams); // Set the filters based on the module params $articles->setState('list.start', 0); $articles->setState('list.limit', (int) $params->get('count', 0)); $articles->setState('filter.published', 1); // Access filter $access = !JComponentHelper::getParams('com_content')->get('show_noauth'); $authorised = JAccess::getAuthorisedViewLevels(JFactory::getUser()->get('id')); $articles->setState('filter.access', $access); // Prep for Normal or Dynamic Modes $mode = $params->get('mode', 'normal'); switch ($mode) { case 'dynamic': $option = JRequest::getCmd('option'); $view = JRequest::getCmd('view'); if ($option === 'com_tz_portfolio') { switch ($view) { case 'category': $catids = array(JRequest::getInt('id')); break; case 'categories': $catids = array(JRequest::getInt('id')); break; case 'article': if ($params->get('show_on_article_page', 1)) { $article_id = JRequest::getInt('id'); $catid = JRequest::getInt('catid'); if (!$catid) { // Get an instance of the generic article model $article = JModelLegacy::getInstance('Article', 'TZ_PortfolioModel', array('ignore_request' => true)); $article->setState('params', $appParams); $article->setState('filter.published', 1); $article->setState('article.id', (int) $article_id); $item = $article->getItem(); $catids = array($item->catid); } else { $catids = array($catid); } } else { // Return right away if show_on_article_page option is off return; } break; case 'featured': default: // Return right away if not on the category or article views return; } } else { // Return right away if not on a com_content page return; } break; case 'normal': default: $catids = $params->get('catid'); $articles->setState('filter.category_id.include', (bool) $params->get('category_filtering_type', 1)); break; } // Category filter if ($catids) { if ($params->get('show_child_category_articles', 0) && (int) $params->get('levels', 0) > 0) { // Get an instance of the generic categories model $categories = JModelLegacy::getInstance('Categories', 'TZ_PortfolioModel', array('ignore_request' => true)); $categories->setState('params', $appParams); $levels = $params->get('levels', 1) ? $params->get('levels', 1) : 9999; $categories->setState('filter.get_children', $levels); $categories->setState('filter.published', 1); $categories->setState('filter.access', $access); $additional_catids = array(); foreach ($catids as $catid) { $categories->setState('filter.parentId', $catid); $recursive = true; $items = $categories->getItems($recursive); if ($items) { foreach ($items as $category) { $condition = $category->level - $categories->getParent()->level <= $levels; if ($condition) { $additional_catids[] = $category->id; } } } } $catids = array_unique(array_merge($catids, $additional_catids)); } $articles->setState('filter.category_id', $catids); } // Ordering $articles->setState('list.ordering', $params->get('article_ordering', 'a.ordering')); $articles->setState('list.direction', $params->get('article_ordering_direction', 'ASC')); // New Parameters $articles->setState('filter.featured', $params->get('show_front', 'show')); $articles->setState('filter.author_id', $params->get('created_by', "")); $articles->setState('filter.author_id.include', $params->get('author_filtering_type', 1)); $articles->setState('filter.author_alias', $params->get('created_by_alias', "")); $articles->setState('filter.author_alias.include', $params->get('author_alias_filtering_type', 1)); $excluded_articles = $params->get('excluded_articles', ''); if ($excluded_articles) { $excluded_articles = explode("\r\n", $excluded_articles); $articles->setState('filter.article_id', $excluded_articles); $articles->setState('filter.article_id.include', false); // Exclude } $date_filtering = $params->get('date_filtering', 'off'); if ($date_filtering !== 'off') { $articles->setState('filter.date_filtering', $date_filtering); $articles->setState('filter.date_field', $params->get('date_field', 'a.created')); $articles->setState('filter.start_date_range', $params->get('start_date_range', '1000-01-01 00:00:00')); $articles->setState('filter.end_date_range', $params->get('end_date_range', '9999-12-31 23:59:59')); $articles->setState('filter.relative_date', $params->get('relative_date', 30)); } // Filter by language $articles->setState('filter.language', $app->getLanguageFilter()); $items = $articles->getItems(); // Display options $show_date = $params->get('show_date', 0); $show_date_field = $params->get('show_date_field', 'created'); $show_date_format = $params->get('show_date_format', 'Y-m-d H:i:s'); $show_category = $params->get('show_category', 0); $show_hits = $params->get('show_hits', 0); $show_author = $params->get('show_author', 0); $show_introtext = $params->get('show_introtext', 0); $introtext_limit = $params->get('introtext_limit', 100); // Find current Article ID if on an article page $option = JRequest::getCmd('option'); $view = JRequest::getCmd('view'); if ($option === 'com_tz_portfolio' && $view === 'article') { $active_article_id = JRequest::getInt('id'); } else { $active_article_id = 0; } // Prepare data for display using display options if ($items) { foreach ($items as &$item) { $item->slug = $item->id . ':' . $item->alias; $item->catslug = $item->catid ? $item->catid . ':' . $item->category_alias : $item->catid; if ($access || in_array($item->access, $authorised)) { // We know that user has the privilege to view the article $item->link = JRoute::_(TZ_PortfolioHelperRoute::getArticleRoute($item->slug, $item->catslug)); } else { // Angie Fixed Routing $app = JFactory::getApplication(); $menu = $app->getMenu(); $menuitems = $menu->getItems('link', 'index.php?option=com_users&view=login'); if (isset($menuitems[0])) { $Itemid = $menuitems[0]->id; } elseif (JRequest::getInt('Itemid') > 0) { //use Itemid from requesting page only if there is no existing menu $Itemid = JRequest::getInt('Itemid'); } $item->link = JRoute::_('index.php?option=com_users&view=login&Itemid=' . $Itemid); } // Used for styling the active article $item->active = $item->id == $active_article_id ? 'active' : ''; $item->displayDate = ''; if ($show_date) { $item->displayDate = JHTML::_('date', $item->{$show_date_field}, $show_date_format); } if ($item->catid) { $item->displayCategoryLink = JRoute::_(TZ_PortfolioHelperRoute::getCategoryRoute($item->catid)); $item->displayCategoryTitle = $show_category ? '<a href="' . $item->displayCategoryLink . '">' . $item->category_title . '</a>' : ''; } else { $item->displayCategoryTitle = $show_category ? $item->category_title : ''; } $item->displayHits = $show_hits ? $item->hits : ''; $item->displayAuthorName = $show_author ? $item->author : ''; if ($show_introtext) { $item->introtext = JHtml::_('content.prepare', $item->introtext, '', 'mod_tz_portfolio_articles_category.content'); $item->introtext = self::_cleanIntrotext($item->introtext); } $item->displayIntrotext = $show_introtext ? self::truncate($item->introtext, $introtext_limit) : ''; // added Angie show_unauthorizid $item->displayReadmore = $item->alternative_readmore; } } return $items; }
/** * Content Search method * The sql must return the following fields that are used in a common display * routine: href, title, section, created, text, browsernav * @param string Target search string * @param string mathcing option, exact|any|all * @param string ordering option, newest|oldest|popular|alpha|category * @param mixed An array if the search it to be restricted to areas, null if search all */ function onContentSearch($text, $phrase = '', $ordering = '', $areas = null) { $db = JFactory::getDbo(); $app = JFactory::getApplication(); $user = JFactory::getUser(); $groups = implode(',', $user->getAuthorisedViewLevels()); $tag = JFactory::getLanguage()->getTag(); require_once JPATH_SITE . '/components/com_tz_portfolio/helpers/route.php'; require_once JPATH_ADMINISTRATOR . '/components/com_search/helpers/search.php'; $searchText = $text; if (is_array($areas)) { if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) { return array(); } } $sContent = $this->params->get('search_content', 1); $sArchived = $this->params->get('search_archived', 1); $limit = $this->params->def('search_limit', 50); $nullDate = $db->getNullDate(); $date = JFactory::getDate(); $now = $date->toSql(); $text = trim($text); if ($text == '') { return array(); } $wheres = array(); switch ($phrase) { case 'exact': $text = $db->Quote('%' . $db->escape($text, true) . '%', false); $wheres2 = array(); $wheres2[] = 'a.title LIKE ' . $text; $wheres2[] = 'a.introtext LIKE ' . $text; $wheres2[] = 'a.fulltext LIKE ' . $text; $wheres2[] = 'a.metakey LIKE ' . $text; $wheres2[] = 'a.metadesc LIKE ' . $text; $where = '(' . implode(') OR (', $wheres2) . ')'; break; case 'all': case 'any': default: $words = explode(' ', $text); $wheres = array(); foreach ($words as $word) { $word = $db->Quote('%' . $db->escape($word, true) . '%', false); $wheres2 = array(); $wheres2[] = 'a.title LIKE ' . $word; $wheres2[] = 'a.introtext LIKE ' . $word; $wheres2[] = 'a.fulltext LIKE ' . $word; $wheres2[] = 'a.metakey LIKE ' . $word; $wheres2[] = 'a.metadesc LIKE ' . $word; $wheres[] = implode(' OR ', $wheres2); } $where = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')'; break; } $morder = ''; switch ($ordering) { case 'oldest': $order = 'a.created ASC'; break; case 'popular': $order = 'a.hits DESC'; break; case 'alpha': $order = 'a.title ASC'; break; case 'category': $order = 'c.title ASC, a.title ASC'; $morder = 'a.title ASC'; break; case 'newest': default: $order = 'a.created DESC'; break; } $rows = array(); $query = $db->getQuery(true); // search articles if ($sContent && $limit > 0) { $query->clear(); //sqlsrv changes $case_when = ' CASE WHEN '; $case_when .= $query->charLength('a.alias'); $case_when .= ' THEN '; $a_id = $query->castAsChar('a.id'); $case_when .= $query->concatenate(array($a_id, 'a.alias'), ':'); $case_when .= ' ELSE '; $case_when .= $a_id . ' END as slug'; $case_when1 = ' CASE WHEN '; $case_when1 .= $query->charLength('c.alias'); $case_when1 .= ' THEN '; $c_id = $query->castAsChar('c.id'); $case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':'); $case_when1 .= ' ELSE '; $case_when1 .= $c_id . ' END as catslug'; $query->select('a.title AS title, a.metadesc, a.metakey, a.created AS created'); $query->select($query->concatenate(array('a.introtext', 'a.fulltext')) . ' AS text'); $query->select('c.title AS section, ' . $case_when . ',' . $case_when1 . ', ' . '\'2\' AS browsernav'); $query->from('#__content AS a'); $query->innerJoin('#__categories AS c ON c.id=a.catid'); $query->where('(' . $where . ')' . 'AND a.state=1 AND c.published = 1 AND a.access IN (' . $groups . ') ' . 'AND c.access IN (' . $groups . ') ' . 'AND (a.publish_up = ' . $db->Quote($nullDate) . ' OR a.publish_up <= ' . $db->Quote($now) . ') ' . 'AND (a.publish_down = ' . $db->Quote($nullDate) . ' OR a.publish_down >= ' . $db->Quote($now) . ')'); $query->group('a.id, a.title, a.metadesc, a.metakey, a.created, a.introtext, a.fulltext, c.title, a.alias, c.alias, c.id'); $query->order($order); // Filter by language if ($app->isSite() && $app->getLanguageFilter()) { $query->where('a.language in (' . $db->Quote($tag) . ',' . $db->Quote('*') . ')'); $query->where('c.language in (' . $db->Quote($tag) . ',' . $db->Quote('*') . ')'); } $db->setQuery($query, 0, $limit); $list = $db->loadObjectList(); $limit -= count($list); if (isset($list)) { foreach ($list as $key => $item) { $needles = array('article' => array((int) $item->slug)); $needles['category'] = array($item->catslug); $itemType = $this->_findType($item->catslug); $list[$key]->href = $itemType ? TZ_PortfolioHelperRoute::getPortfolioArticleRoute($item->slug, $item->catslug) : TZ_PortfolioHelperRoute::getArticleRoute($item->slug, $item->catslug); } } $rows[] = $list; } // search archived content if ($sArchived && $limit > 0) { $searchArchived = JText::_('JARCHIVED'); $query->clear(); //sqlsrv changes $case_when = ' CASE WHEN '; $case_when .= $query->charLength('a.alias'); $case_when .= ' THEN '; $a_id = $query->castAsChar('a.id'); $case_when .= $query->concatenate(array($a_id, 'a.alias'), ':'); $case_when .= ' ELSE '; $case_when .= $a_id . ' END as slug'; $case_when1 = ' CASE WHEN '; $case_when1 .= $query->charLength('c.alias'); $case_when1 .= ' THEN '; $c_id = $query->castAsChar('c.id'); $case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':'); $case_when1 .= ' ELSE '; $case_when1 .= $c_id . ' END as catslug'; $query->select('a.title AS title, a.metadesc, a.metakey, a.created AS created, ' . $query->concatenate(array("a.introtext", "a.fulltext")) . ' AS text,' . $case_when . ',' . $case_when1 . ', ' . 'c.title AS section, \'2\' AS browsernav'); //.'CONCAT_WS("/", c.title) AS section, \'2\' AS browsernav' ); $query->from('#__content AS a'); $query->innerJoin('#__categories AS c ON c.id=a.catid AND c.access IN (' . $groups . ')'); $query->where('(' . $where . ') AND a.state = 2 AND c.published = 1 AND a.access IN (' . $groups . ') AND c.access IN (' . $groups . ') ' . 'AND (a.publish_up = ' . $db->Quote($nullDate) . ' OR a.publish_up <= ' . $db->Quote($now) . ') ' . 'AND (a.publish_down = ' . $db->Quote($nullDate) . ' OR a.publish_down >= ' . $db->Quote($now) . ')'); $query->order($order); // Filter by language if ($app->isSite() && $app->getLanguageFilter()) { $query->where('a.language in (' . $db->Quote($tag) . ',' . $db->Quote('*') . ')'); $query->where('c.language in (' . $db->Quote($tag) . ',' . $db->Quote('*') . ')'); } $db->setQuery($query, 0, $limit); $list3 = $db->loadObjectList(); // find an itemid for archived to use if there isn't another one $item = $app->getMenu()->getItems('link', 'index.php?option=com_tz_portfolio&view=archive', true); $itemid = isset($item->id) ? '&Itemid=' . $item->id : ''; if (isset($list3)) { foreach ($list3 as $key => $item) { $date = JFactory::getDate($item->created); $created_month = $date->format("n"); $created_year = $date->format("Y"); $list3[$key]->href = JRoute::_('index.php?option=com_tz_portfolio&view=archive&year=' . $created_year . '&month=' . $created_month . $itemid); } } $rows[] = $list3; } $results = array(); if (count($rows)) { foreach ($rows as $row) { $new_row = array(); foreach ($row as $key => $article) { if (searchHelper::checkNoHTML($article, $searchText, array('text', 'title', 'metadesc', 'metakey'))) { $new_row[] = $article; } } $results = array_merge($results, (array) $new_row); } } return $results; }
public function getItems() { if ($items = parent::getItems()) { $user = JFactory::getUser(); $userId = $user->get('id'); $guest = $user->get('guest'); $params = $this->getState('params'); $contentId = array(); $tzDate = array(); $content_ids = array(); $_params = null; $categories = JCategories::getInstance('Content'); $threadLink = null; $comments = null; foreach ($items as &$item) { $content_ids[] = $item->id; $_params = clone $params; $temp = clone $params; // Get the global params $globalParams = JComponentHelper::getParams('com_tz_portfolio', true); /*** New source ***/ $category = $categories->get($item->catid); $catParams = new JRegistry($category->params); if ($this->parameter_merge_fields) { foreach ($this->parameter_merge_fields as $value) { if ($catParams->get($value) != '') { $_params->set($value, $catParams->get($value)); } } } $item->params = clone $_params; $articleParams = new JRegistry(); $articleParams->loadString($item->attribs); // create an array of just the params set to 'use_article' $menuParamsArray = $temp->toArray(); $articleArray = array(); foreach ($menuParamsArray as $key => $value) { if ($value === 'use_article') { // if the article has a value, use it if ($articleParams->get($key) != '') { // get the value from the article $articleArray[$key] = $articleParams->get($key); } else { if ($_params->get($key) != '') { $articleArray[$key] = $_params->get($key); } else { if (!$_params->get($key) || $_params->get($key) == '') { // otherwise, use the global value $articleArray[$key] = $globalParams->get($key); } } } if (count($this->parameter_fields)) { $parameter_fields = $this->parameter_fields; if (in_array($key, array_keys($this->parameter_fields))) { if (count($parameter_fields[$key])) { foreach ($parameter_fields[$key] as $value_field) { $articleArray[$value_field] = $articleParams->get($value_field); } } } } } } // merge the selected article params if (count($articleArray) > 0) { $articleParams = new JRegistry(); $articleParams->loadArray($articleArray); $item->params->merge($articleParams); } if ($params->get('comment_function_type', 'default') != 'js') { /*** New source ***/ //Check redirect to view article if ($item->params->get('tz_portfolio_redirect', 'p_article') == 'article') { $contentUrl = JRoute::_(TZ_PortfolioHelperRoute::getArticleRoute($item->slug, $item->catid), true, -1); } else { $contentUrl = JRoute::_(TZ_PortfolioHelperRoute::getPortfolioArticleRoute($item->slug, $item->catid), true, -1); } /*** End New Source ***/ if ($params->get('tz_show_count_comment', 1) == 1) { if ($params->get('tz_comment_type', 'disqus') == 'disqus') { $threadLink .= '&thread[]=link:' . $contentUrl; } elseif ($params->get('tz_comment_type', 'disqus') == 'facebook') { $threadLink .= '&urls[]=' . $contentUrl; } } } } if ($params->get('comment_function_type', 'default') != 'js') { if ($params->get('tz_show_count_comment', 1) == 1) { require_once JPATH_COMPONENT_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'HTTPFetcher.php'; require_once JPATH_COMPONENT_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'readfile.php'; $fetch = new Services_Yadis_PlainHTTPFetcher(); } // Get comment counts for all items(articles) if ($params->get('tz_show_count_comment', 1) == 1) { // From Disqus if ($params->get('tz_comment_type', 'disqus') == 'disqus') { if ($threadLink) { $url = 'https://disqus.com/api/3.0/threads/list.json?api_secret=' . $params->get('disqusApiSecretKey', '4sLbLjSq7ZCYtlMkfsG7SS5muVp7DsGgwedJL5gRsfUuXIt6AX5h6Ae6PnNREMiB') . '&forum=' . $params->get('disqusSubDomain', 'templazatoturials') . $threadLink . '&include=open'; $content = $fetch->get($url); if ($content) { if ($body = json_decode($content->body)) { if ($responses = $body->response) { if (!is_array($responses)) { JError::raiseNotice('300', JText::_('COM_TZ_PORTFOLIO_DISQUS_INVALID_SECRET_KEY')); } if (is_array($responses) && count($responses)) { foreach ($responses as $response) { $comments[$response->link] = $response->posts; } } } } } } } // From Facebook if ($params->get('tz_comment_type', 'disqus') == 'facebook') { if ($threadLink) { $url = 'http://api.facebook.com/restserver.php?method=links.getStats' . $threadLink; $content = $fetch->get($url); if ($content) { if ($bodies = $content->body) { if (preg_match_all('/\\<link_stat\\>(.*?)\\<\\/link_stat\\>/ims', $bodies, $matches)) { if (isset($matches[1]) && !empty($matches[1])) { foreach ($matches[1] as $val) { $match = null; if (preg_match('/\\<url\\>(.*?)\\<\\/url\\>.*?\\<comment_count\\>(.*?)\\<\\/comment_count\\>/msi', $val, $match)) { if (isset($match[1]) && isset($match[2])) { $comments[$match[1]] = $match[2]; } } } } } } } } } } // End Get comment counts for all items(articles) } $tags = null; if (count($content_ids) && $params->get('show_tags', 1)) { $m_tag = JModelLegacy::getInstance('Tag', 'TZ_PortfolioModel', array('ignore_request' => true)); $m_tag->setState('params', $params); $m_tag->setState('article.id', $content_ids); $m_tag->setState('list.ordering', 'x.contentid'); $tags = $m_tag->getArticleTags(); } //Get Plugins Model $pmodel = JModelLegacy::getInstance('Plugins', 'TZ_PortfolioModel', array('ignore_request' => true)); foreach ($items as $i => &$item) { if ($tags && count($tags) && isset($tags[$item->id])) { $item->tags = $tags[$item->id]; } /*** Start New Source ***/ $tmpl = null; if ($item->params->get('tz_use_lightbox', 1) == 1) { $tmpl = '&tmpl=component'; } //Check redirect to view article if ($item->params->get('tz_portfolio_redirect') == 'p_article') { $item->link = JRoute::_(TZ_PortfolioHelperRoute::getPortfolioArticleRoute($item->slug, $item->catid) . $tmpl); $item->fullLink = JRoute::_(TZ_PortfolioHelperRoute::getPortfolioArticleRoute($item->slug, $item->catid), true, -1); } else { $item->link = JRoute::_(TZ_PortfolioHelperRoute::getArticleRoute($item->slug, $item->catid) . $tmpl); $item->fullLink = JRoute::_(TZ_PortfolioHelperRoute::getArticleRoute($item->slug, $item->catid), true, -1); } /*** End New Source ***/ if ($params->get('comment_function_type', 'default') != 'js') { if ($params->get('tz_show_count_comment', 1) == 1) { if ($params->get('tz_comment_type', 'disqus') == 'disqus' || $params->get('tz_comment_type', 'disqus') == 'facebook') { if ($comments) { if (array_key_exists($item->fullLink, $comments)) { $item->commentCount = $comments[$item->fullLink]; } else { $item->commentCount = 0; } } else { $item->commentCount = 0; } } } } else { $item->commentCount = 0; } // Compute the asset access permissions. // Technically guest could edit an article, but lets not check that to improve performance a little. if (!$guest) { $asset = 'com_content.article.' . $item->id; // Check general edit permission first. if ($user->authorise('core.edit', $asset)) { $item->params->set('access-edit', true); } elseif (!empty($userId) && $user->authorise('core.edit.own', $asset)) { // Check for a valid user and that they are the owner. if ($userId == $item->created_by) { $item->params->set('access-edit', true); } } } //Get plugin Params for this article $pmodel->setState('filter.contentid', $item->id); $pluginItems = $pmodel->getItems(); $pluginParams = $pmodel->getParams(); $item->pluginparams = clone $pluginParams; // Add feed links if (!JRequest::getCmd('format', null) and !JRequest::getCmd('type', null)) { $dispatcher = JDispatcher::getInstance(); // Old plugins: Ensure that text property is available if (!isset($item->text)) { $item->text = $item->introtext; } // // Process the content plugins. // JPluginHelper::importPlugin('content'); $results = $dispatcher->trigger('onContentPrepare', array('com_tz_portfolio.timeline', &$item, &$params, $this->getState('list.start'))); $item->introtext = $item->text; $item->event = new stdClass(); $results = $dispatcher->trigger('onContentAfterTitle', array('com_tz_portfolio.timeline', &$item, &$params, $this->getState('list.start'))); $item->event->afterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_tz_portfolio.timeline', &$item, &$params, $this->getState('list.start'))); $item->event->beforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentAfterDisplay', array('com_tz_portfolio.timeline', &$item, &$params, $this->getState('list.start'))); $item->event->afterDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentTZPortfolioVote', array('com_tz_portfolio.timeline', &$item, &$params, 0)); $item->event->TZPortfolioVote = trim(implode("\n", $results)); JPluginHelper::importPlugin('tz_portfolio'); $results = $dispatcher->trigger('onTZPluginPrepare', array('com_tz_portfolio.timeline', &$item, &$this->params, &$pluginParams, $this->getState('list.start'))); $results = $dispatcher->trigger('onTZPluginAfterTitle', array('com_tz_portfolio.timeline', &$item, &$params, &$pluginParams, $this->getState('list.start'))); $item->event->TZafterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onTZPluginBeforeDisplay', array('com_tz_portfolio.timeline', &$item, &$params, &$pluginParams, $this->getState('list.start'))); $item->event->TZbeforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onTZPluginAfterDisplay', array('com_tz_portfolio.timeline', &$item, &$params, &$pluginParams, $this->getState('list.start'))); $item->event->TZafterDisplayContent = trim(implode("\n", $results)); } if ($introLimit = $params->get('tz_article_intro_limit')) { $text = new AutoCutText($item->introtext, $introLimit); $item->introtext = $text->getIntro(); } $this->articles[] = $item->id; $model = null; if (!empty($item->tagName)) { $contentId[] = $item->id; if ($tagsName = $this->getTagName($item->id)) { $item->tagName = $tagsName; } } //Get Catid $this->categories[] = $item->catid; if ($model = JModelLegacy::getInstance('Media', 'TZ_PortfolioModel')) { if ($media = $model->getMedia($item->id)) { if ($media[0]->type != 'video' && $media[0]->type != 'audio') { if ($params->get('portfolio_image_size', 'M')) { } if (!empty($media[0]->images)) { $item->tz_image = JURI::root() . str_replace('.' . JFile::getExt($media[0]->images), '_' . $params->get('portfolio_image_size', 'M') . '.' . JFile::getExt($media[0]->images), $media[0]->images); $item->tz_image_title = $media[0]->imagetitle; } else { $item->tz_image = null; } } else { if (!empty($media[0]->thumb)) { $item->tz_image = JURI::root() . str_replace('.' . JFile::getExt($media[0]->thumb), '_' . $params->get('portfolio_image_size', 'M') . '.' . JFile::getExt($media[0]->thumb), $media[0]->thumb); $item->tz_image_title = $media[0]->imagetitle; } else { $item->tz_image = null; } } } else { $item->tz_image = null; } } if ($params->get('tz_filter_type', 'tags') == 'tags') { $item->allTags = $this->_getAllTags($item->created); } } $this->_getTags($contentId); return $items; } return false; }
/** * Categories Search method * * The sql must return the following fields that are * used in a common display routine: href, title, section, created, text, * browsernav * @param string Target search string * @param string mathcing option, exact|any|all * @param string ordering option, newest|oldest|popular|alpha|category * @param mixed An array if restricted to areas, null if search all */ function onContentSearch($text, $phrase = '', $ordering = '', $areas = null) { $db = JFactory::getDbo(); $user = JFactory::getUser(); $app = JFactory::getApplication(); $groups = implode(',', $user->getAuthorisedViewLevels()); $searchText = $text; if (is_array($areas)) { if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) { return array(); } } $sContent = $this->params->get('search_content', 1); $sArchived = $this->params->get('search_archived', 1); $limit = $this->params->def('search_limit', 50); $state = array(); if ($sContent) { $state[] = 1; } if ($sArchived) { $state[] = 2; } $text = trim($text); if ($text == '') { return array(); } switch ($phrase) { case 'exact': $text = $db->Quote('%' . $db->escape($text, true) . '%', false); $wheres2 = array(); $wheres2[] = 'a.title LIKE ' . $text; $wheres2[] = 'a.description LIKE ' . $text; $where = '(' . implode(') OR (', $wheres2) . ')'; break; case 'any': case 'all': default: $words = explode(' ', $text); $wheres = array(); foreach ($words as $word) { $word = $db->Quote('%' . $db->escape($word, true) . '%', false); $wheres2 = array(); $wheres2[] = 'a.title LIKE ' . $word; $wheres2[] = 'a.description LIKE ' . $word; $wheres[] = implode(' OR ', $wheres2); } $where = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')'; break; } switch ($ordering) { case 'alpha': $order = 'a.title ASC'; break; case 'category': case 'popular': case 'newest': case 'oldest': default: $order = 'a.title DESC'; } $text = $db->Quote('%' . $db->escape($text, true) . '%', false); $query = $db->getQuery(true); $return = array(); if (!empty($state)) { //sqlsrv changes $case_when = ' CASE WHEN '; $case_when .= $query->charLength('a.alias'); $case_when .= ' THEN '; $a_id = $query->castAsChar('a.id'); $case_when .= $query->concatenate(array($a_id, 'a.alias'), ':'); $case_when .= ' ELSE '; $case_when .= $a_id . ' END as slug'; $query->select('a.title, a.description AS text, "" AS created, "2" AS browsernav, a.id AS catid, ' . $case_when); $query->from('#__categories AS a'); $query->where('(a.title LIKE ' . $text . ' OR a.description LIKE ' . $text . ') AND a.published IN (' . implode(',', $state) . ') AND a.extension = \'com_content\'' . 'AND a.access IN (' . $groups . ')'); $query->group('a.id'); $query->order($order); if ($app->isSite() && $app->getLanguageFilter()) { $query->where('a.language in (' . $db->Quote(JFactory::getLanguage()->getTag()) . ',' . $db->Quote('*') . ')'); } $db->setQuery($query, 0, $limit); $rows = $db->loadObjectList(); if ($rows) { $count = count($rows); for ($i = 0; $i < $count; $i++) { $rows[$i]->href = TZ_PortfolioHelperRoute::getCategoryRoute($rows[$i]->slug); $rows[$i]->section = JText::_('JCATEGORY'); } foreach ($rows as $key => $category) { if (searchHelper::checkNoHTML($category, $searchText, array('name', 'title', 'text'))) { $return[] = $category; } } } } return $return; }
public function getItems() { if ($items = parent::getItems()) { $categories = JCategories::getInstance('Content'); foreach ($items as &$item) { $params = clone $this->getState('params'); $temp = clone $this->getState('params'); // Get the global params $globalParams = JComponentHelper::getParams('com_tz_portfolio', true); /*** Merge category params to menu params ***/ $category = $categories->get($item->catid); $catParams = new JRegistry($category->params); if ($this->parameter_merge_fields) { foreach ($this->parameter_merge_fields as $value) { if ($catParams->get($value) != '') { $params->set($value, $catParams->get($value)); } } } $item->params = clone $params; $articleParams = new JRegistry(); $articleParams->loadString($item->attribs); // create an array of just the params set to 'use_article' $menuParamsArray = $temp->toArray(); $articleArray = array(); foreach ($menuParamsArray as $key => $value) { if ($value === 'use_article') { // if the article has a value, use it if ($articleParams->get($key) != '') { // get the value from the article $articleArray[$key] = $articleParams->get($key); } else { if ($articleParams->get($key) != '') { $articleArray[$key] = $params->get($key); } else { if (!$params->get($key) || $params->get($key) == '') { // otherwise, use the global value $articleArray[$key] = $globalParams->get($key); } } } if (count($this->parameter_fields)) { $parameter_fields = $this->parameter_fields; if (in_array($key, array_keys($this->parameter_fields))) { if (count($parameter_fields[$key])) { foreach ($parameter_fields[$key] as $value_field) { $articleArray[$value_field] = $articleParams->get($value_field); } } } } } } // merge the selected article params if (count($articleArray) > 0) { $articleParams = new JRegistry(); $articleParams->loadArray($articleArray); $item->params->merge($articleParams); } // Create new options "link" and "fullLink" for article $tmpl = null; if ($item->params->get('tz_use_lightbox', 1) == 1) { $tmpl = '&tmpl=component'; } //Check redirect to view article if ($item->params->get('tz_portfolio_redirect') == 'p_article') { $item->link = JRoute::_(TZ_PortfolioHelperRoute::getPortfolioArticleRoute($item->slug, $item->catid) . $tmpl); $item->fullLink = JRoute::_(TZ_PortfolioHelperRoute::getPortfolioArticleRoute($item->slug, $item->catid), true, -1); } else { $item->link = JRoute::_(TZ_PortfolioHelperRoute::getArticleRoute($item->slug, $item->catid) . $tmpl); $item->fullLink = JRoute::_(TZ_PortfolioHelperRoute::getArticleRoute($item->slug, $item->catid), true, -1); } /** End Create new options **/ } return $items; } return false; }
/** * Prepares the document */ protected function _prepareDocument() { $app = JFactory::getApplication(); $menus = $app->getMenu(); $pathway = $app->getPathway(); $title = null; // Because the application sets a default page title, // we need to get it from the menu item itself $menu = $menus->getActive(); if ($menu) { $this->params->def('page_heading', $this->params->get('page_title', $menu->title)); } else { $this->params->def('page_heading', JText::_('JGLOBAL_ARTICLES')); } $title = $this->params->get('page_title', ''); $id = (int) @$menu->query['id']; // if the menu item does not concern this article if ($menu && ($menu->query['option'] != 'com_tz_portfolio' || $menu->query['view'] != 'article' || $id != $this->item->id)) { // If this is not a single article menu item, set the page title to the article title if ($this->item->title) { $title = $this->item->title; } $path = array(array('title' => $this->item->title, 'link' => '')); $category = JCategories::getInstance('Content')->get($this->item->catid); while ($category && ($menu->query['option'] != 'com_tz_portfolio' || $menu->query['view'] == 'article' || $id != $category->id) && $category->id > 1) { $path[] = array('title' => $category->title, 'link' => TZ_PortfolioHelperRoute::getCategoryRoute($category->id)); $category = $category->getParent(); } $path = array_reverse($path); foreach ($path as $item) { $pathway->addItem($item['title'], $item['link']); } } // Check for empty title and add site name if param is set if (empty($title)) { $title = $app->getCfg('sitename'); } elseif ($app->getCfg('sitename_pagetitles', 0) == 1) { $title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title); } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) { $title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename')); } if (empty($title)) { $title = $this->item->title; } if (!empty($title)) { $title = htmlspecialchars($title); } $this->document->setTitle($title); $description = null; if ($this->item->metadesc) { $description = $this->item->metadesc; } elseif (!$this->item->metadesc && $this->params->get('menu-meta_description')) { $description = $this->params->get('menu-meta_description'); } elseif (!empty($this->item->introtext)) { $description = strip_tags($this->item->introtext); $description = explode(' ', $description); $description = array_splice($description, 0, 25); $description = trim(implode(' ', $description)); if (!strpos($description, '...')) { $description .= '...'; } } if ($description) { $description = htmlspecialchars($description); $this->document->setDescription($description); } $tags = null; if ($this->item->metakey) { $tags = $this->item->metakey; } elseif (!$this->item->metakey && $this->params->get('menu-meta_keywords')) { $tags = $this->params->get('menu-meta_keywords'); } elseif ($this->listTags) { foreach ($this->listTags as $tag) { $tags[] = $tag->name; } $tags = implode(',', $tags); } if ($this->params->get('robots')) { $this->document->setMetadata('robots', $this->params->get('robots')); } if ($app->getCfg('MetaAuthor') == '1') { $this->document->setMetaData('author', $this->item->author); } $metaImage = null; if ($metaMedia = $this->listMedia) { $metaImageSize = $this->params->get('detail_article_image_size', 'L'); if ($metaMedia[0]->type == 'image' || $metaMedia[0]->type == 'imagegallery') { if (isset($metaMedia[0]->images) and !empty($metaMedia[0]->images)) { $metaImage = $metaMedia[0]->images; $metaImage = JUri::root() . str_replace('.' . JFile::getExt($metaImage), '_' . $metaImageSize . '.' . JFile::getExt($metaImage), $metaImage); } } elseif ($metaMedia[0]->type == 'video' || $metaMedia[0]->type == 'audio') { if (isset($metaMedia[0]->thumb) and !empty($metaMedia[0]->thumb)) { $metaImage = $metaMedia[0]->thumb; $metaImage = JUri::root() . str_replace('.' . JFile::getExt($metaImage), '_' . $metaImageSize . '.' . JFile::getExt($metaImage), $metaImage); } } } $socialInfo = new stdClass(); $socialInfo->title = $title; $socialInfo->image = $metaImage; $socialInfo->description = $description; $this->assign('socialInfo', $socialInfo); // $this -> document -> setMetaData('copyright','Copyright © '.date('Y',time()).' TemPlaza. All Rights Reserved.'); // Set metadata tags with prefix property "og:" $this->document->addCustomTag('<meta property="og:title" content="' . $title . '"/>'); $this->document->addCustomTag('<meta property="og:url" content="' . JRoute::_(TZ_PortfolioHelperRoute::getArticleRoute($this->item->slug, $this->item->catid), true, -1) . '"/>'); $this->document->addCustomTag('<meta property="og:type" content="article"/>'); if ($metaImage) { $this->document->addCustomTag('<meta property="og:image" content="' . $metaImage . '"/>'); } if ($description) { $this->document->addCustomTag('<meta property="og:description" content="' . $description . '"/>'); } //// End set meta tags with prefix property "og:" //// // Set meta tags with prefix property "article:" $this->document->addCustomTag('<meta property="article:author" content="' . $this->item->author . '"/>'); $this->document->addCustomTag('<meta property="article:published_time" content="' . $this->item->created . '"/>'); $this->document->addCustomTag('<meta property="article:modified_time" content="' . $this->item->modified . '"/>'); $this->document->addCustomTag('<meta property="article:section" content="' . $this->escape($this->item->category_title) . '"/>'); if ($tags) { $tags = htmlspecialchars($tags); $this->document->setMetaData('keywords', $tags); $this->document->addCustomTag('<meta property="article:tag" content="' . $tags . '"/>'); } ///// End set meta tags with prefix property "article:" //// // Set meta tags with prefix name "twitter:" if ($author = $this->listAuthor) { if (isset($author->twitter) && !empty($author->twitter)) { $this->document->setMetaData('twitter:card', 'summary'); if (preg_match('/(https)?(:\\/\\/www\\.)?twitter\\.com\\/(#!\\/)?@?([^\\/]*)/i', $author->twitter, $match)) { if (count($match) > 1) { $this->document->setMetaData('twitter:site', '@' . $match[count($match) - 1]); $this->document->setMetaData('twitter:creator', '@' . $match[count($match) - 1]); } } if ($metaImage) { $this->document->setMetaData('twitter:image', $metaImage); } if ($description) { $this->document->setMetaData('twitter:description', $description); } } } //// End set meta tags with prefix name "twitter:" //// $mdata = $this->item->metadata->toArray(); foreach ($mdata as $k => $v) { if ($v) { $this->document->setMetadata($k, $v); } } // If there is a pagebreak heading or title, add it to the page title if (!empty($this->item->page_title)) { $this->item->title = $this->item->title . ' - ' . $this->item->page_title; $this->document->setTitle($this->item->page_title . ' - ' . JText::sprintf('PLG_CONTENT_PAGEBREAK_PAGE_NUM', $this->state->get('list.offset') + 1)); } if ($this->print) { $this->document->setMetaData('robots', 'noindex, nofollow'); } }
function display($tpl = null) { // parameters $app = JFactory::getApplication(); $db = JFactory::getDbo(); $document = JFactory::getDocument(); $params = $app->getParams(); $feedEmail = @$app->getCfg('feed_email') ? $app->getCfg('feed_email') : 'author'; $siteEmail = $app->getCfg('mailfrom'); $document->link = JRoute::_('index.php?option=com_tz_portfolio&view=featured'); // Get some data from the model JRequest::setVar('limit', $app->getCfg('feed_limit')); $categories = JCategories::getInstance('Content'); $rows = $this->get('Items'); if ($params->get('show_feed_image', 1) == 1) { $model = JModelLegacy::getInstance('Media', 'TZ_PortfolioModel'); } $blogItemParams = $params; foreach ($rows as $row) { $media = $model->getMedia($row->id); // strip html from feed item title $title = $this->escape($row->title); $title = html_entity_decode($title, ENT_COMPAT, 'UTF-8'); // Compute the article slug $row->slug = $row->alias ? $row->id . ':' . $row->alias : $row->id; // url link to article $blogItemParams->merge($row->params); if ($blogItemParams->get('tz_portfolio_redirect') == 'p_article') { $link = JRoute::_(TZ_PortfolioHelperRoute::getPortfolioArticleRoute($row->slug, $row->catid)); } else { $link = JRoute::_(TZ_PortfolioHelperRoute::getArticleRoute($row->slug, $row->catid)); } // image to article $image = null; if ($params->get('show_feed_image', 1) == 1) { $size = $params->get('feed_image_size', 'S'); if (strtolower($media[0]->type) == 'video') { $image = $media[0]->thumb; } else { $image = $media[0]->images; } if ($image) { $image = str_replace('.' . JFile::getExt($image), '_' . $size . '.' . JFile::getExt($image), $image); $_link = $link; if (!preg_match('/' . JURI::base() . '/', $link)) { $_link = str_replace(JURI::base(true) . '/', JURI::base(), $link); } $image = '<a href="' . $_link . '"><img src="' . $image . '" alt="' . $title . '"/></a>'; } } // strip html from feed item description text // TODO: Only pull fulltext if necessary (actually, just get the necessary fields). $description = $params->get('feed_summary', 0) ? $row->introtext : $row->introtext; $author = $row->created_by_alias ? $row->created_by_alias : $row->author; if (isset($media[0]->type) && strtolower($media[0]->type) == 'quote') { $author = $media[0]->quote_author; } if (isset($media[0]->type) && (strtolower($media[0]->type) == 'quote' || strtolower($media[0]->type) == 'link')) { if (strtolower($media[0]->type) == 'quote') { $description = $media[0]->quote_text . '<span class="author">' . $author . '</span>'; } } // load individual item creator class $item = new JFeedItem(); if (isset($media[0]->type) && (strtolower($media[0]->type) != 'quote' && strtolower($media[0]->type) != 'link') || !isset($media[0]->type)) { $item->title = $title; $item->link = $link; } else { if (strtolower($media[0]->type) == 'link') { $item->title = $media[0]->link_title; $item->link = $media[0]->link_url; } } $item->description = $image . $description; $item->date = $row->created; $item_category = $categories->get($row->catid); $item->category = array(); $item->category[] = JText::_('JFEATURED'); // All featured articles are categorized as "Featured" for ($item_category = $categories->get($row->catid); $item_category !== null; $item_category = $item_category->getParent()) { if ($item_category->id > 1) { // Only add non-root categories $item->category[] = $item_category->title; } } $item->author = $author; if ($feedEmail == 'site') { $item->authorEmail = $siteEmail; } else { $item->authorEmail = $row->author_email; } // loads item info into rss array $document->addItem($item); } }
public static function getList(&$params) { //print_r($params); $db = JFactory::getDbo(); $content = $params->get('manager'); $order = $params->get('order'); $orderby = $params->get('orderby'); // $limit = 10; $limit = $params->get('limit'); $catids = $params->get('catid'); $img = $params->get('image'); $typenews = $params->get('views'); $featureol = $params->get('show_featured'); $redirect = $params->get('redirect_page'); $dispatcher = JDispatcher::getInstance(); // portfolio and content $userQuery = "SELECT * FROM ras_categories as ab right join ras_content as ac on ab.id = ac.catid where ab.id = '11'"; $userQuery11 = mysql_query($userQuery); //$userData = $db->loadObjectList(); $total_records = mysql_num_rows($userQuery11); $number = $_REQUEST['page']; if (!isset($number) || ($number == "" || $number == 0)) { $page = 1; } else { $page = $number; } $num_pages = ceil($total_records / $limit); $start = $limit * ($page - 1); $end = $limit; $limit1 = $start . ',' . $end; if ($typenews == "featured") { if (isset($catids) && !empty($catids)) { $catid = implode(",", $catids); $where = "WHERE ct.catid IN({$catid}) and ct.state = 1 and featured = 1 ORDER BY ct.{$orderby} {$order} LIMIT {$limit1}"; } else { $where = "WHERE ct.state = 1 and featured = 1 ORDER BY ct.{$orderby} {$order} LIMIT {$limit1}"; } } else { if (isset($catids) && !empty($catids)) { $catid = implode(",", $catids); if ($featureol == 1) { $where = "WHERE ct.catid IN({$catid}) and ct.state = 1 and featured = 1 ORDER BY ct.{$orderby} {$order} LIMIT {$limit1}"; } else { $where = "WHERE ct.catid IN({$catid}) and ct.state = 1 ORDER BY ct.{$orderby} {$order} LIMIT {$limit1}"; //dining-in-singapore //echo $where = "WHERE cat.alias IN ('dining-in-singapore') and ct.state = 1 ORDER BY ct.$orderby $order LIMIT $limit"; } } else { $where = "WHERE ct.state = 1 ORDER BY ct.{$orderby} {$order} LIMIT {$limit1}"; } } if ($content == 'tz_portfolio') { $model = JModelLegacy::getInstance('Articles', 'TZ_PortfolioModel', array('ignore_request' => true)); $model2 = JModelLegacy::getInstance('Media', 'TZ_PortfolioModel', array('ignore_request' => true)); $app = JFactory::getApplication(); $appParams = $app->getParams(); $model->setState('params', $appParams); $model->setState('list.start', 0); $model->setState('list.limit', (int) $params->get('limit')); $model->setState('filter.published', 1); $model->setState('filter.category_id', $params->get('catid', array())); $order_map = array('m_dsc' => 'a.modified DESC, a.created', 'mc_dsc' => 'CASE WHEN (a.modified = ' . $db->quote($db->getNullDate()) . ') THEN a.created ELSE a.modified END', 'c_dsc' => 'a.created', 'p_dsc' => 'a.publish_up'); $ordering = JArrayHelper::getValue($order_map, $params->get('ordering'), 'a.publish_up'); $dir = 'DESC'; $model->setState('list.ordering', $ordering); $model->setState('list.direction', $dir); $items = $model->getItems(); $param_com = JComponentHelper::getComponent('com_content')->params; if ($items) { foreach ($items as $i => $item) { $item->text = $item->introtext; JPluginHelper::importPlugin('content'); $results = $dispatcher->trigger('onContentPrepare', array('com_tz_portfolio.article', &$item, &$param_com, 0)); $item->introtext = $item->text; $item->event = new stdClass(); $results = $dispatcher->trigger('onContentAfterTitle', array('com_tz_portfolio.article', &$item, &$param_com, 0)); $item->event->afterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_tz_portfolio.article', &$item, &$param_com, 0)); $item->event->beforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentAfterDisplay', array('com_tz_portfolio.article', &$item, &$param_com, 0)); $item->event->afterDisplayContent = trim(implode("\n", $results)); //Get Plugins Model $pmodel = JModelLegacy::getInstance('Plugins', 'TZ_PortfolioModel', array('ignore_request' => true)); //Get plugin Params for this article $pmodel->setState('filter.contentid', $item->id); $pluginItems = $pmodel->getItems(); $pluginParams = $pmodel->getParams(); $item->pluginparams = clone $pluginParams; JPluginHelper::importPlugin('tz_portfolio'); $results = $dispatcher->trigger('onTZPluginPrepare', array('com_tz_portfolio.article', &$item, &$param_com, &$pluginParams, 0)); $results = $dispatcher->trigger('onTZPluginAfterTitle', array('com_tz_portfolio.article', &$item, &$param_com, &$pluginParams, 0)); $item->event->TZafterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onTZPluginBeforeDisplay', array('com_tz_portfolio.article', &$item, &$param_com, &$pluginParams, 0)); $item->event->TZbeforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onTZPluginAfterDisplay', array('com_tz_portfolio.article', &$item, &$param_com, &$pluginParams, 0)); $item->event->TZafterDisplayContent = trim(implode("\n", $results)); $item->media = null; $model2->setState('article.id', $item->id); if ($media = $model2->getMedia()) { $item->media = $media[0]; } $item->tztitle = $item->title; $item->hit = $item->hits; echo $item->event->beforeDisplayContent; echo $item->event->TZbeforeDisplayContent; $item->intro = $item->introtext; echo $item->event->afterDisplayContent; echo $item->event->TZafterDisplayContent; $item->slug = $item->id . ':' . $item->alias; $item->catslug = $item->catid . ':' . $item->category_alias; $item->category = $item->category_title; $item->author = $item->author; if ($redirect == 0) { $item->link = JRoute::_(TZ_PortfolioHelperRoute::getArticleRoute($item->slug, $item->catslug)); } if ($redirect == 1) { $item->link = JRoute::_(TZ_PortfolioHelperRoute::getPortfolioArticleRoute($item->slug, $item->catslug)); } $item->media = $item->media; if ($item->media) { if ($item->media->type == 'image') { $images = $item->media->images; $nameimg = JFile::getExt($images); $count = strlen($nameimg); $image_name = substr($images, 0, -($count + 1)); $item->image = $image_name . '_' . $img . '.' . $nameimg; } if ($item->media->type == 'imagegallery') { $images = $item->media->images; $arrimages = explode("///", $images); if ($arrimages[0]) { $nameimg = JFile::getExt($arrimages[0]); $count = strlen($nameimg); $image_name = substr($arrimages[0], 0, -($count + 1)); $item->image = $image_name . '_' . $img . '.' . $nameimg; } } if ($item->media->type == 'video') { $images = $item->media->thumb; $nameimg = JFile::getExt($images); $count = strlen($nameimg); $image_name = substr($images, 0, -($count + 1)); $item->image = $image_name . '_' . $img . '.' . $nameimg; } if ($item->media->type == 'audio') { $images = $item->media->thumb; $nameimg = JFile::getExt($images); $count = strlen($nameimg); $image_name = substr($images, 0, -($count + 1)); $item->image = $image_name . '_' . $img . '.' . $nameimg; } } else { $item->image = null; } } return $items; } } if ($content == 'joomla_content') { $query = "SELECT ct.*,ct.id as arid, ct.hits as hit, ct.title as artitle, ct.alias as aralias, cat.title as category_title, us.name as created_by_user, cat.alias as category_alias\n FROM #__content ct LEFT JOIN #__categories cat ON(ct.catid = cat.id)\n LEFT JOIN #__users us On(ct.created_by = us.id)\n {$where} "; $db->setQuery($query); $items = $db->loadObjectList(); $param_com = JComponentHelper::getComponent('com_content')->params; if ($items) { if ($content == 'joomla_content') { foreach ($items as $item) { // print_r($item); $item->text = $item->introtext; JPluginHelper::importPlugin('content'); $results = $dispatcher->trigger('onContentPrepare', array('com_content.article', &$item, &$param_com, 0)); $item->introtext = $item->text; $item->event = new stdClass(); $results = $dispatcher->trigger('onContentAfterTitle', array('com_content.article', &$item, &$param_com, 0)); $item->event->afterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_content.article', &$item, &$param_com, 0)); $item->event->beforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentAfterDisplay', array('com_content.article', &$item, &$param_com, 0)); $item->event->afterDisplayContent = trim(implode("\n", $results)); $item->title = $item->artitle; $item->media = null; $item->hit = $item->hits; $item->intro = $item->introtext; //category_alias $item->category = $item->category_title; $item->author = $item->created_by_user; // $item->slug = $item->aralias; $item->slug = $item->arid . ':' . $item->aralias; $item->catslug = $item->category_alias; // $item->catslug = $item->catid . ':' . $item->category_alias; $item->link = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug)); //$item->link = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug)); if ($item->images) { $images = new JRegistry(); $images->loadString($item->images); $images = json_decode($item->images); $item->image = $images->image_intro; $item->image_full = $images->image_fulltext; } else { $item->image = null; } } return $items; } } } return false; }
function TZPortfolioDisQusComment($context, &$article, $params, $page = 0) { if (version_compare(COM_TZ_PORTFOLIO_VERSION, '3.1.7', '<')) { if ($params->get('tz_portfolio_redirect') == 'p_article') { $link = JRoute::_(TZ_PortfolioHelperRoute::getPortfolioArticleRoute($article->slug, $article->catid), true, -1); } else { $link = JRoute::_(TZ_PortfolioHelperRoute::getArticleRoute($article->slug, $article->catid), true, -1); } } else { $link = $article->fullLink; } $html = null; $html = '<div class="tz_portfolio_comment">'; $html .= '<div id="disqus_thread"></div>'; $html .= '<script type="text/javascript"> var disqus_shortname = "' . $params->get('disqusSubDomain', 'templazatoturials') . '"; var disqus_url = "' . $link . '"; var disqus_developer = "' . $params->get('disqusDevMode', 1) . '"; (function() { var dsq = document.createElement("script"); dsq.type = "text/javascript"; dsq.async = true; dsq.src = "http://" + disqus_shortname + ".disqus.com/embed.js"; (document.getElementsByTagName("head")[0] || document.getElementsByTagName("body")[0]).appendChild(dsq); })(); </script>'; $html .= '</div>'; return $html; }
<div id="PortfolioGallery"> <div id="ib-main-wrapper" class="ib-main-wrapper"> <div class="ib-main"> <?php foreach ($list as $row) { ?> <?php $itemParams = $params; $itemParams->merge(new JRegistry($row->attribs)); $mediaParams = null; $media = JModelLegacy::getInstance('Media', 'TZ_PortfolioModel'); $mediaParams = $params; $mediaParams->merge(new JRegistry($row->attribs)); $media->setParams($mediaParams); $listMedia = $media->getMedia($row->id); $row->link = JRoute::_(TZ_PortfolioHelperRoute::getArticleRoute($row->slug, $row->catid)); $this->assign('listMedia', $listMedia); $this->assign('mediaParams', $mediaParams); $this->assign('item', $row); $html = null; if ($listMedia) { $html = trim($this->loadTemplate('media')); } if ($html and !empty($html)) { echo $html; } else { ?> <?php if ($params->get('show_article_not_image', 1)) { ?> <a href="<?php
# Technical Support: Forum - http://templaza.com/Forum -------------------------------------------------------------------------*/ // no direct access defined('_JEXEC') or die; ?> <h3><?php echo JText::_('COM_CONTENT_MORE_ARTICLES'); ?> </h3> <ol> <?php foreach ($this->link_items as &$item) { ?> <li> <a href="<?php echo JRoute::_(TZ_PortfolioHelperRoute::getArticleRoute($item->slug, $item->catslug)); ?> "> <?php echo $item->title; ?> </a> </li> <?php } ?> </ol>
static function getList(&$params) { if ($params) { $catId = $params->get('catid', array()); if (empty($catId[0])) { array_shift($catId); } $catId = implode(',', $catId); $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('c.*'); $query->select('CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(":", c.id, c.alias) ELSE c.id END as slug'); $query->select('CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END as catslug'); $query->from('#__content AS c'); $query->join('LEFT', '#__categories AS cc ON cc.id=c.catid'); $query->where('c.state=1'); if ($catId) { $query->where('c.catid IN(' . $catId . ')'); } $query->order('RAND()'); $query->order('c.id ASC'); $db->setQuery($query, 0, $params->get('count', 5)); if (!$db->query()) { var_dump($db->getErrorMsg()); die; } if ($rows = $db->loadObjectList()) { $model = new TZ_PortfolioModelMedia(); foreach ($rows as $item) { if ($params->get('redirect', 'article') == 'p_article') { $item->link = JRoute::_(TZ_PortfolioHelperRoute::getPortfolioArticleRoute($item->slug, $item->catslug)); } else { $item->link = JRoute::_(TZ_PortfolioHelperRoute::getArticleRoute($item->slug, $item->catslug)); } if ($model && $params->get('show_tz_image', 1)) { if ($image = $model->getMedia($item->id)) { if ($image[0]->type != 'quote' && $image[0]->type != 'link') { if ($image[0]->type != 'video') { if (!empty($image[0]->images)) { if ($params->get('tz_image_size', 'S')) { $imageName = $image[0]->images; $item->tz_image = str_replace('.' . JFile::getExt($imageName), '_' . $params->get('tz_image_size') . '.' . JFile::getExt($imageName), $imageName); } } } else { if (!empty($image[0]->thumb)) { if ($params->get('tz_image_size', 'S')) { $imageName = $image[0]->thumb; $item->tz_image = str_replace('.' . JFile::getExt($imageName), '_' . $params->get('tz_image_size') . '.' . JFile::getExt($imageName), $imageName); } } } $item->tz_imagetitle = $image[0]->imagetitle; } else { $item->quote_author = null; if (isset($image[0]->quote_author)) { $item->quote_author = $image[0]->quote_author; } if (isset($image[0]->quote_text)) { $item->quote_text = $image[0]->quote_text; } if (isset($image[0]->link_title)) { $item->link_title = $image[0]->link_title; } if (isset($image[0]->link_url)) { $item->link_url = $image[0]->link_url; } if (isset($image[0]->link_target)) { $item->link_target = $image[0]->link_target; } if (isset($image[0]->link_follow)) { $item->link_follow = $image[0]->link_follow; } } } } } return $rows; } return false; } return false; }
<?php } ?> </span> <?php } ?> <?php if ($params->get('show_category', 1)) { ?> <span class="TzLine">|</span> <span class="TzBlogCategory"> <?php $title = $this->escape($this->item->category_title); $url = '<a href="' . JRoute::_(TZ_PortfolioHelperRoute::getCategoryRoute($this->item->catid)) . '" itemprop="genre">' . $title . '</a>'; ?> <?php if ($params->get('link_category', 1)) { ?> <?php echo JText::sprintf('COM_CONTENT_CATEGORY', $url); ?> <?php } else { ?> <?php echo JText::sprintf('COM_CONTENT_CATEGORY', '<span itemprop="genre">' . $title . '</span>'); ?> <?php }
/** * Display the view * * @return mixed False on error, null otherwise. */ function display($tpl = null) { // Initialise variables. $user = JFactory::getUser(); $app = JFactory::getApplication(); $doc = JFactory::getDocument(); // $doc -> addCustomTag('<script type="text/javascript" src="components/com_tz_portfolio/js/jquery-1.7.2.min.js"></script>'); $state = $this->get('State'); $items = $this->get('Items'); $pagination = $this->get('Pagination'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseWarning(500, implode("\n", $errors)); return false; } $params =& $state->params; if ($params->get('fields_option_order')) { switch ($params->get('fields_option_order')) { case 'alpha': $fieldsOptionOrder = 't.value ASC'; break; case 'ralpha': $fieldsOptionOrder = 't.value DESC'; break; case 'ordering': $fieldsOptionOrder = 't.ordering ASC'; break; } if (isset($fieldsOptionOrder)) { $this->extraFields->setState('filter.option.order', $fieldsOptionOrder); } } $csscompress = null; if ($params->get('css_compression', 0)) { $csscompress = '.min'; } $jscompress = new stdClass(); $jscompress->extfile = null; $jscompress->folder = null; if ($params->get('js_compression', 1)) { $jscompress->extfile = '.min'; $jscompress->folder = '/packed'; } // PREPARE THE DATA // Get the metrics for the structural page layout. $numLeading = $params->def('num_leading_articles', 1); $numIntro = $params->def('num_intro_articles', 4); $numLinks = $params->def('num_links', 4); //Get Plugins Model $pmodel = JModelLegacy::getInstance('Plugins', 'TZ_PortfolioModel', array('ignore_request' => true)); if ($params->get('comment_function_type', 'default') != 'js') { // Compute the article slugs and prepare introtext (runs content plugins). if ($params->get('tz_show_count_comment', 1) == 1) { require_once JPATH_COMPONENT_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'HTTPFetcher.php'; require_once JPATH_COMPONENT_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'readfile.php'; $fetch = new Services_Yadis_PlainHTTPFetcher(); } $threadLink = null; $comments = null; if ($items) { foreach ($items as $key => $item) { $slug = $item->alias ? $item->id . ':' . $item->alias : $item->id; /*** New source ***/ //Check redirect to view article if ($item->params->get('tz_portfolio_redirect') == 'p_article') { $contentUrl = JRoute::_(TZ_PortfolioHelperRoute::getPortfolioArticleRoute($slug, $item->catid), true, -1); } else { $contentUrl = JRoute::_(TZ_PortfolioHelperRoute::getArticleRoute($slug, $item->catid), true, -1); } /*** End New Source ***/ if ($params->get('tz_show_count_comment', 1) == 1) { if ($params->get('tz_comment_type', 'disqus') == 'disqus') { $threadLink .= '&thread[]=link:' . $contentUrl; } elseif ($params->get('tz_comment_type', 'disqus') == 'facebook') { $threadLink .= '&urls[]=' . $contentUrl; } } } } // Get comment counts for all items(articles) if ($params->get('tz_show_count_comment', 1) == 1) { // From Disqus if ($params->get('tz_comment_type', 'disqus') == 'disqus') { if ($threadLink) { $url = 'https://disqus.com/api/3.0/threads/list.json?api_secret=' . $params->get('disqusApiSecretKey', '4sLbLjSq7ZCYtlMkfsG7SS5muVp7DsGgwedJL5gRsfUuXIt6AX5h6Ae6PnNREMiB') . '&forum=' . $params->get('disqusSubDomain', 'templazatoturials') . $threadLink . '&include=open'; $content = $fetch->get($url); if ($content) { if ($body = json_decode($content->body)) { if ($responses = $body->response) { if (is_array($responses) && count($responses)) { foreach ($responses as $response) { $comments[$response->link] = $response->posts; } } } } } } } // From Facebook if ($params->get('tz_comment_type', 'disqus') == 'facebook') { if ($threadLink) { $url = 'http://api.facebook.com/restserver.php?method=links.getStats' . $threadLink; $content = $fetch->get($url); if ($content) { if ($bodies = $content->body) { if (preg_match_all('/\\<link_stat\\>(.*?)\\<\\/link_stat\\>/ims', $bodies, $matches)) { if (isset($matches[1]) && !empty($matches[1])) { foreach ($matches[1] as $val) { $match = null; if (preg_match('/\\<url\\>(.*?)\\<\\/url\\>.*?\\<comment_count\\>(.*?)\\<\\/comment_count\\>/msi', $val, $match)) { if (isset($match[1]) && isset($match[2])) { $comments[$match[1]] = $match[2]; } } } } } } } } } } // End Get comment counts for all items(articles) } else { // Add facebook script api if ($params->get('tz_show_count_comment', 1) == 1) { if ($params->get('tz_comment_type', 'disqus') == 'facebook') { $doc->addScriptDeclaration(' (function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, \'script\', \'facebook-jssdk\')); '); } // Add disqus script api if ($params->get('tz_comment_type', 'disqus') == 'disqus') { $doc->addScriptDeclaration(' /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */ var disqus_shortname = \'templazatoturials\'; // required: replace example with your forum shortname /* * * DON\'T EDIT BELOW THIS LINE * * */ (function () { var s = document.createElement(\'script\'); s.async = true; s.type = \'text/javascript\'; s.src = \'http://\' + disqus_shortname + \'.disqus.com/count.js\'; (document.getElementsByTagName(\'HEAD\')[0] || document.getElementsByTagName(\'BODY\')[0]).appendChild(s); }()); '); $doc->addCustomTag(' <script type="text/javascript"> window.addEvent("load",function(){ var a=document.getElementsByTagName("A"); for(var h=0;h<a.length;h++){ if(a[h].href.indexOf("#disqus_thread")>=0){ var span = document.createElement("span"); span.innerHTML = a[h].innerHTML; a[h].parentNode.appendChild(span); a[h].remove(); } } }); </script> '); } } } if ($items) { $content_ids = array(); for ($i = 0, $n = count($items); $i < $n; $i++) { $content_ids[] = $items[$i]->id; } $tags = null; if (count($content_ids) && $params->get('show_tags', 1)) { $m_tag = JModelLegacy::getInstance('Tag', 'TZ_PortfolioModel', array('ignore_request' => true)); $m_tag->setState('params', $params); $m_tag->setState('article.id', $content_ids); $m_tag->setState('list.ordering', 'x.contentid'); $tags = $m_tag->getArticleTags(); } foreach ($items as $i => &$item) { if ($tags && count($tags) && isset($tags[$item->id])) { $item->tags = $tags[$item->id]; } $item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id; /*** New source ***/ $tmpl = null; if ($item->params->get('tz_use_lightbox', 1) == 1) { $tmpl = '&tmpl=component'; } //Check redirect to view article if ($item->params->get('tz_portfolio_redirect') == 'p_article') { $item->link = JRoute::_(TZ_PortfolioHelperRoute::getPortfolioArticleRoute($item->slug, $item->catid) . $tmpl); $item->fullLink = JRoute::_(TZ_PortfolioHelperRoute::getPortfolioArticleRoute($item->slug, $item->catid), true, -1); } else { $item->link = JRoute::_(TZ_PortfolioHelperRoute::getArticleRoute($item->slug, $item->catid) . $tmpl); $item->fullLink = JRoute::_(TZ_PortfolioHelperRoute::getArticleRoute($item->slug, $item->catid), true, -1); } /*** End New Source ***/ if ($params->get('comment_function_type', 'default') != 'js') { if ($params->get('tz_show_count_comment', 1) == 1) { if ($params->get('tz_comment_type', 'disqus') == 'disqus' || $params->get('tz_comment_type', 'disqus') == 'facebook') { if ($comments) { if (array_key_exists($item->fullLink, $comments)) { $item->commentCount = $comments[$item->fullLink]; } else { $item->commentCount = 0; } } else { $item->commentCount = 0; } } } } else { $item->commentCount = 0; } $model = JModelLegacy::getInstance('Category', 'TZ_PortfolioModel', array('ignore_request' => true)); $model->setState('category.id', $item->catid); $category = $model->getCategory(); $catParams2 = new JRegistry(); $catParams = new JRegistry(); if ($category) { $catParams->loadString($category->params); } $catParams = $catParams->toArray(); $this->category = $category; if (count($catParams) > 0) { foreach ($catParams as $key => $val) { if (preg_match('/.*?article.*?/', $key)) { $catParams2->set($key, $val); } } } $item->catslug = $item->category_alias ? $item->catid . ':' . $item->category_alias : $item->catid; $item->parent_slug = $item->parent_alias ? $item->parent_id . ':' . $item->parent_alias : $item->parent_id; // No link for ROOT category if ($item->parent_alias == 'root') { $item->parent_slug = null; } $item->event = new stdClass(); $dispatcher = JDispatcher::getInstance(); //Get plugin Params for this article $pmodel->setState('filter.contentid', $item->id); $pluginItems = $pmodel->getItems(); $pluginParams = $pmodel->getParams(); $item->pluginparams = clone $pluginParams; // Ignore content plugins on links. if ($i < $numLeading + $numIntro) { // Old plugins: Ensure that text property is available if (!isset($item->text)) { $item->text = $item->introtext; } //Call trigger in group content JPluginHelper::importPlugin('content'); $results = $dispatcher->trigger('onContentPrepare', array('com_tz_portfolio.category', &$item, &$params, 0)); $item->introtext = $item->text; $results = $dispatcher->trigger('onContentAfterTitle', array('com_tz_portfolio.featured', &$item, &$item->params, 0)); $item->event->afterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_tz_portfolio.featured', &$item, &$item->params, 0)); $item->event->beforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentAfterDisplay', array('com_tz_portfolio.featured', &$item, &$item->params, 0)); $item->event->afterDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentTZPortfolioVote', array('com_tz_portfolio.category', &$item, &$item->params, 0)); $item->event->TZPortfolioVote = trim(implode("\n", $results)); //Call trigger in group tz_portfolio JPluginHelper::importPlugin('tz_portfolio'); $item->introtext = JHtml::_('article.tzprepare', $item->introtext, '', $pluginParams, 'com_tz_portfolio.featured'); $results = $dispatcher->trigger('onTZPluginAfterTitle', array('com_tz_portfolio.featured', &$item, &$params, &$pluginParams, 0)); $item->event->TZafterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onTZPluginBeforeDisplay', array('com_tz_portfolio.featured', &$item, &$params, &$pluginParams, 0)); $item->event->TZbeforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onTZPluginAfterDisplay', array('com_tz_portfolio.featured', &$item, &$params, &$pluginParams, 0)); $item->event->TZafterDisplayContent = trim(implode("\n", $results)); } } } // Preprocess the breakdown of leading, intro and linked articles. // This makes it much easier for the designer to just interogate the arrays. $max = count($items); // The first group is the leading articles. $limit = $numLeading; for ($i = 0; $i < $limit && $i < $max; $i++) { $this->lead_items[$i] =& $items[$i]; if ($items[$i]->params->get('article_leading_image_size')) { $items[$i]->params->set('article_leading_image_resize', $items[$i]->params->get('article_leading_image_size', 'L')); } if ($items[$i]->params->get('article_leading_image_gallery_size')) { $items[$i]->params->set('article_leading_image_gallery_resize', $items[$i]->params->get('article_leading_image_gallery_size', 'L')); } } // The second group is the intro articles. $limit = $numLeading + $numIntro; // Order articles across, then down (or single column mode) for ($i = $numLeading; $i < $limit && $i < $max; $i++) { $this->intro_items[$i] =& $items[$i]; if ($items[$i]->params->get('article_secondary_image_size')) { $items[$i]->params->set('article_secondary_image_resize', $items[$i]->params->get('article_secondary_image_size', 'M')); } if ($items[$i]->params->get('article_secondary_image_gallery_size')) { $items[$i]->params->set('article_secondary_image_gallery_resize', $items[$i]->params->get('article_secondary_image_gallery_size', 'M')); } } $this->columns = max(1, $params->def('num_columns', 1)); $order = $params->def('multi_column_order', 1); if ($order == 0 && $this->columns > 1) { // call order down helper $this->intro_items = TZ_PortfolioHelperQuery::orderDownColumns($this->intro_items, $this->columns); } // The remainder are the links. for ($i = $numLeading + $numIntro; $i < $max; $i++) { $this->link_items[$i] =& $items[$i]; } //Escape strings for HTML output $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); $this->assignRef('params', $params); $this->assignRef('items', $items); $this->assignRef('pagination', $pagination); $this->assignRef('user', $user); $model = JModelLegacy::getInstance('Portfolio', 'TZ_PortfolioModel', array('ignore_request' => true)); $pParams = clone $params; $pParams->set('tz_catid', $params->get('featured_categories')); $model->setState('params', $pParams); $model->setState('filter.featured', 1); $this->assign('char', $state->get('char')); $this->assign('availLetter', $model->getAvailableLetter()); // if(isset($catParams2)){ // if($catParams2){ // if($catParams2 -> get('article_leading_image_size')){ // $catParams2 -> set('article_leading_image_resize' // ,strtolower($catParams2 -> get('article_leading_image_size'))); // } // if($catParams2 -> get('article_secondary_image_size')){ // $catParams2 -> set('article_secondary_image_resize' // ,strtolower($catParams2 -> get('article_leading_image_size'))); // } // if($catParams2 -> get('article_leading_image_gallery_size')){ // $catParams2 -> set('article_leading_image_gallery_resize' // ,strtolower($catParams2 -> get('article_leading_image_gallery_size'))); // } // if($catParams2 -> get('article_secondary_image_gallery_size')){ // $catParams2 -> set('article_secondary_image_gallery_resize' // ,strtolower($catParams2 -> get('article_secondary_image_gallery_size'))); // } // // $params -> merge($catParams2); // } // } $this->assign('mediaParams', $params); $doc = JFactory::getDocument(); if ($params->get('tz_use_image_hover', 1) == 1) { $doc->addStyleDeclaration(' .tz_image_hover{ opacity: 0; position: absolute; top:0; left: 0; transition: opacity ' . $params->get('tz_image_timeout', 0.35) . 's ease-in-out; -moz-transition: opacity ' . $params->get('tz_image_timeout', 0.35) . 's ease-in-out; -webkit-transition: opacity ' . $params->get('tz_image_timeout', 0.35) . 's ease-in-out; } .tz_image_hover:hover{ opacity: 1; margin: 0; } '); } if ($params->get('tz_use_lightbox', 1) == 1) { $doc->addCustomTag('<script type="text/javascript" src="components/com_tz_portfolio/js' . '/jquery.fancybox.pack.js"></script>'); $doc->addStyleSheet('components/com_tz_portfolio/css/fancybox.min.css'); $width = null; $height = null; $autosize = null; if ($params->get('tz_lightbox_width')) { if (preg_match('/%|px/', $params->get('tz_lightbox_width'))) { $width = 'width:\'' . $params->get('tz_lightbox_width') . '\','; } else { $width = 'width:' . $params->get('tz_lightbox_width') . ','; } } if ($params->get('tz_lightbox_height')) { if (preg_match('/%|px/', $params->get('tz_lightbox_height'))) { $height = 'height:\'' . $params->get('tz_lightbox_height') . '\','; } else { $height = 'height:' . $params->get('tz_lightbox_height') . ','; } } if ($width || $height) { $autosize = 'fitToView: false,autoSize: false,'; } $scrollHidden = null; if ($params->get('use_custom_scrollbar', 1)) { $scrollHidden = ',scrolling: "no" ,iframe: { scrolling : "no", }'; } $doc->addCustomTag('<script type="text/javascript"> jQuery(\'.fancybox\').fancybox({ type:\'iframe\', openSpeed:' . $params->get('tz_lightbox_speed', 350) . ', openEffect: "' . $params->get('tz_lightbox_transition', 'elastic') . '", ' . $width . $height . $autosize . ' helpers: { title : { type : "inside" }, overlay : { opacity:' . $params->get('tz_lightbox_opacity', 0.75) . ', } }' . $scrollHidden . ' }); </script> '); } $doc->addStyleSheet('components/com_tz_portfolio/css/tzportfolio.min.css'); $this->_prepareDocument(); parent::display($tpl); }