Ejemplo n.º 1
0
 static function preHandle($tag)
 {
     $cedTagsHelper = new CedTagsHelper();
     $tag = $cedTagsHelper->tripChars($tag);
     $tag = JString::trim($tag);
     $tag = $cedTagsHelper->unUrlTagname($tag);
     $toLowerCase = CedTagsHelper::param('lowcase', 1);
     if ($toLowerCase) {
         $tag = JString::strtolower($tag);
     }
     return $tag;
 }
Ejemplo n.º 2
0
 private function _buildQuery()
 {
     //Has to be a string
     $input = JFactory::getApplication()->input;
     $tag = $input->get('tag', null, 'string');
     //Tag is in front, this should remove ?start= or ?limitstart=
     $tags = explode('?', $tag);
     $tag = $tags[0];
     $tag = URLDecode($tag);
     //filter the tag
     $cedTagsHelper = new CedTagsHelper();
     $tag = $cedTagsHelper->unUrlTagname($tag);
     $tag = CedTagsHelper::preHandle($tag);
     JFactory::getApplication()->input->set('tag', $tag);
     $tag = trim($tag);
     $tagObj = null;
     $ids = $this->_ids;
     if (!isset($this->_tagDescription)) {
         $tagObj = $this->getTagByTagName($tag);
         if (isset($tagObj) && $tagObj->id) {
             $this->_termExist = true;
         } else {
             $this->_termExist = false;
             return '';
         }
         $this->_tagDescription = $tagObj->description;
         $this->incrementHitsForTagId($tagObj->id);
         $this->_total = $this->countNumberOfArticleForTagId($tagObj->id);
         $contentIds = $this->getArticlesCidForTag($tagObj->id);
         $ids = implode(',', $contentIds);
         $this->_ids = $ids;
     }
     $this->setTermArticles(!empty($ids));
     $dbo = JFactory::getDBO();
     $query = $dbo->getQuery(true);
     $query->select('a.id');
     $query->select('a.title');
     $query->select('a.created');
     $query->select('a.alias');
     $query->select('a.modified');
     $query->select('a.images');
     $query->select('a.created_by as contactid');
     $query->select('u.name as author');
     $query->select('a.created_by_alias as created_by_alias');
     $query->select('COUNT(a.id) as total');
     $query->select('a.introtext');
     $query->select('a.fulltext');
     $query->select('a.access');
     $query->select('a.state');
     $query->select('a.publish_up');
     $query->select('a.hits');
     $query->select('a.parentid as parent_id');
     $query->select('a.catid as catid');
     $query->select('cc.title as category_title');
     $query->select('cc.title as section');
     $query->select('cc.alias as parent_alias');
     $query->select('CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.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->select('CHAR_LENGTH( a.`fulltext` ) AS readmore');
     $query->from('#__content AS a');
     $query->innerJoin('#__categories AS cc ON cc.id = a.catid');
     $query->innerJoin('#__users AS u ON u.id=a.created_by');
     $query->where('a.id in (' . $ids . ')');
     $query->where(sprintf('(%s)', implode(' AND ', $this->getAccessWhere(false))));
     $query->where('cc.published = ' . $dbo->quote(1));
     $query->group('(a.id)');
     $query->order($this->_buildOrderBy());
     // TODO
     //$this->setState('filter.language', $app->getLanguageFilter());
     CedTagLog::debug("tag.php::_buildQuery " . $query->dump());
     return $query;
 }
Ejemplo n.º 3
0
 /**
  * @param null $tpl
  * @return mixed
  */
 private function defaultTpl($tpl = null)
 {
     $params = JComponentHelper::getParams('com_cedtag');
     //Layout
     $defaultLayout = $params->get('layout', 'blog');
     $layout = JFactory::getApplication()->input->get('layout', $defaultLayout, 'STRING');
     $this->setLayout($layout);
     $tag = JFactory::getApplication()->input->get('tag', null, 'string');
     // create custom pathway
     $app = JFactory::getApplication();
     $pathway = $app->getPathway();
     $pathway->addItem(JText::_('COM_CEDTAG_PATHWAY_TITLE'), JURI::root() . 'index.php?option=com_cedtag&view=alltags');
     $pathway->addItem($tag, '');
     $cedTagsHelper = new CedTagsHelper();
     $tag = $cedTagsHelper->unUrlTagname($tag);
     JFactory::getApplication()->input->set('tag', $tag);
     $this->assign('tag', $tag);
     //Term do not exist
     $isTermExist = $this->get('TermExist');
     if (!$isTermExist) {
         $tagNotFoundUseWarningPage = CedTagsHelper::param('tagNotFoundUseWarningPage', true);
         if ($tagNotFoundUseWarningPage) {
             $this->assign('message', 'REQUEST_TAG_NOT_EXIST_WARNING');
             $this->setLayout('requested_tag_do_not_exist');
             return parent::display($tpl);
         }
         JError::raiseError(404, JText::_("Could not find tag \"{$tag}\""));
     }
     //No Articles found with that Term
     $hasTermArticles = $this->get('TermArticles');
     if (!$hasTermArticles) {
         $this->assign('message', 'NO_ARTICLES_WITH_TAG');
         $this->setLayout('no_articles_with_tag');
         return parent::display($tpl);
     }
     $items = $this->get('Data');
     $this->assignRef('results', $items);
     //switch off edit capabilities to reuse blog_item.php
     $comContentParams = clone JComponentHelper::getParams('com_content');
     //TODO not correct for sure for blog with editor
     $comContentParams->set('access-edit', false);
     $comContentParams->set('access-view', true);
     foreach ($items as $item) {
         $item->params = $comContentParams;
         //TODO switch this off for now
         $item->alternative_readmore = null;
     }
     $this->prepareData($items);
     $this->assign('total', $this->get('Total'));
     $this->assign('tagDescription', $this->get('TagDescription'));
     $this->assign('showDescription', $params->get('description', '1'));
     $this->assign('showMeta', $params->get('contentMeta', '1'));
     $this->assignRef('ads', $params->get('ads', ''));
     $this->assignRef('pagination', $this->get('Pagination'));
     $this->assign('show_pagination', $comContentParams->def('show_pagination', 1));
     $this->assign('show_pagination_results', $comContentParams->def('show_pagination_results', 1));
     $this->assign('ads_top_use', $params->get('ads_top_use', '0'));
     $this->assign('ads_top_content', $params->get('ads_top_content', '0'));
     $this->assign('ads_bottom_use', $params->get('ads_bottom_use', '0'));
     $this->assign('ads_bottom_content', $params->get('ads_bottom_content', '0'));
     $config = JFactory::getConfig();
     $this->assign('title', $this->get('Title') . ' | ' . $config->getValue('sitename'));
     parent::display($tpl);
 }