Example #1
0
 public static function debug($message)
 {
     JLog::addLogger(array('text_file' => 'cedtag.php'), JLog::ALL, 'com_cedtag');
     if (CedTagLog::param('debug', 0)) {
         JLog::add($message, JLog::DEBUG, 'com_cedtag');
     }
 }
Example #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;
 }