Example #1
0
 /**
  * @param $id
  * @param $tags
  * @return string
  */
 public function getRelatedAsHtml($id, $catid, $access, $tags)
 {
     $count = CedTagsHelper::param('RelatedArticlesCountByTags', 10);
     $relatedArticlesTitle = CedTagsHelper::param('RelatedArticlesTitleByTags', "Related Articles");
     //$max=max(intval($relatedArticlesCount),array_count_values($termIds));
     //find the unique article ids
     $contentIds = $this->getUniqueArticleId($tags, $id);
     $html = "";
     if (is_array($contentIds) && sizeof($contentIds) > 0) {
         $rows = $this->getModel($contentIds, $count);
         if (empty($rows)) {
             return '';
         }
         $user = JFactory::getUser();
         $aid = JVERSION < 1.6 ? $user->get('aid', 0) : max($user->getAuthorisedViewLevels());
         $html = '<div class="relateditemsbytags">' . $relatedArticlesTitle . '</div>
                     <div>
                     <ul class="relateditems">';
         foreach ($rows as $row) {
             if ($row->access <= $aid) {
                 $link = JVERSION < 1.6 ? JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid)) : JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug));
             } else {
                 $link = JRoute::_('index.php?option=com_user&view=login');
             }
             $html .= '<li> <a href="' . $link . '">' . htmlspecialchars($row->title) . '</a></li>';
         }
         $html .= '</ul></div>';
     }
     return $html;
 }
Example #2
0
 public function getActionForm($formAction, $formData, &$return)
 {
     switch ($formAction) {
         case 1:
             $return->actionForm = "url";
             $return->actionFormData = $formData;
             break;
         case 2:
             $this->_db->setQuery($this->_db->getQuery(true)->select('link')->from("#__menu")->where("id = " . (int) $formData));
             $menuItem = $this->_db->loadObject();
             $return->actionForm = "url";
             $return->actionFormData = isset($menuItem->link) ? $menuItem->link : '';
             break;
         case 3:
             require_once JPATH_SITE . '/components/com_content/helpers/route.php';
             $this->_db->setQuery($this->_db->getQuery(true)->select('a.catid,CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug')->from("#__content AS a")->join("LEFT", "#__categories AS cc ON a.catid = cc.id")->where('a.id = ' . (int) $formData));
             $article = $this->_db->loadObject();
             $return->actionForm = "url";
             $return->actionFormData = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catid));
             break;
         case 4:
             $return->actionForm = "message";
             $return->actionFormData = $formData;
             break;
     }
 }
Example #3
0
 /**
  *  Funkce pro načtení dat 1 článku z databáze
  */
 function getArticle($articleId, $text = 'all', $skipPlugins = false)
 {
     $db =& JFactory::getDBO();
     $db->setQuery("SELECT * FROM #__content WHERE id='{$articleId}' LIMIT 1;");
     $rows = $db->loadObjectList();
     if (count($rows) == 1) {
         $article = $rows[0]->introtext . $rows[0]->fulltext;
     } else {
         return false;
     }
     //připravíme text
     if ($text == 'introtext') {
         $rows[0]->text = $rows[0]->introtext;
     } elseif ($text == 'fulltext') {
         $rows[0]->text = $rows[0]->fulltext;
     } else {
         $rows[0]->text = $rows[0]->introtext . $rows[0]->fulltext;
     }
     if (!$skipPlugins) {
         $dispatcher =& JDispatcher::getInstance();
         JPluginHelper::importPlugin("content");
         //naimportujeme všechny pluginy pro zpracování obsahu
         $rows[0]->parameters = new JParameter($rows[0]->attribs);
         //vytvoříme objekt s parametry článku
         $results = $dispatcher->trigger('onPrepareContent', array(&$rows[0], &$rows[0]->parameters, 0));
         //načtení pluginů
     }
     //doplnime uri na clanek
     $rows[0]->uri = JRoute::_(JURI::root() . ContentHelperRoute::getArticleRoute($rows[0]->id), true, -1);
     return $rows[0];
 }
Example #4
0
 function getList(&$params)
 {
     global $mainframe;
     $db =& JFactory::getDBO();
     $user =& JFactory::getUser();
     $userId = (int) $user->get('id');
     $count = (int) $params->get('count', 5);
     $catid = trim($params->get('catid'));
     $secid = trim($params->get('secid'));
     $show_front = $params->get('show_front', 1);
     $aid = $user->get('aid', 0);
     $contentConfig =& JComponentHelper::getParams('com_content');
     $access = !$contentConfig->get('shownoauth');
     $nullDate = $db->getNullDate();
     jimport('joomla.utilities.date');
     $date = new JDate();
     $now = $date->toMySQL();
     $where = 'a.state = 1' . ' 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) . ' )';
     // User Filter
     switch ($params->get('user_id')) {
         case 'by_me':
             $where .= ' AND (created_by = ' . (int) $userId . ' OR modified_by = ' . (int) $userId . ')';
             break;
         case 'not_me':
             $where .= ' AND (created_by <> ' . (int) $userId . ' AND modified_by <> ' . (int) $userId . ')';
             break;
     }
     // Ordering
     switch ($params->get('ordering')) {
         case 'm_dsc':
             $ordering = 'a.modified DESC, a.created DESC';
             break;
         case 'c_dsc':
         default:
             $ordering = 'a.created DESC';
             break;
     }
     if ($catid) {
         $ids = explode(',', $catid);
         JArrayHelper::toInteger($ids);
         $catCondition = ' AND (cc.id=' . implode(' OR cc.id=', $ids) . ')';
     }
     if ($secid) {
         $ids = explode(',', $secid);
         JArrayHelper::toInteger($ids);
         $secCondition = ' AND (s.id=' . implode(' OR s.id=', $ids) . ')';
     }
     // Content Items only
     $query = 'SELECT a.*, ' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,' . ' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END as catslug' . ' FROM #__content AS a' . ($show_front == '0' ? ' LEFT JOIN #__content_frontpage AS f ON f.content_id = a.id' : '') . ' INNER JOIN #__categories AS cc ON cc.id = a.catid' . ' INNER JOIN #__sections AS s ON s.id = a.sectionid' . ' WHERE ' . $where . ' AND s.id > 0' . ($access ? ' AND a.access <= ' . (int) $aid . ' AND cc.access <= ' . (int) $aid . ' AND s.access <= ' . (int) $aid : '') . ($catid ? $catCondition : '') . ($secid ? $secCondition : '') . ($show_front == '0' ? ' AND f.content_id IS NULL ' : '') . ' AND s.published = 1' . ' AND cc.published = 1' . ' ORDER BY ' . $ordering;
     $db->setQuery($query, 0, $count);
     $rows = $db->loadObjectList();
     $i = 0;
     $lists = array();
     foreach ($rows as $row) {
         $lists[$i]->link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid));
         $lists[$i]->text = htmlspecialchars($row->title);
         $i++;
     }
     return $lists;
 }
Example #5
0
function getRelatedItemsJumpList()
{
    $cids = func_get_args();
    $groups = count($cids) > 1 ? true : false;
    $list = '<select class="relatedtech" name="data[related][]" onchange="window.location=this.value;return false;">' . "\n";
    $list .= '<option value="" selection="selected">Velg...</option>' . "\n";
    foreach ($cids as $catID) {
        if (!is_numeric($catID)) {
            continue;
        }
        $db =& JFactory::getDBO();
        $sql = "SELECT c.id, c.title, c.catid, c.sectionid, cat.title AS cat_title FROM #__content c " . "LEFT JOIN #__categories cat ON c.catid = cat.id " . "WHERE catid='{$catID}' AND c.state > 0 ORDER BY title";
        $db->setQuery($sql);
        $items = $db->loadObjectList();
        if ($groups && count($items) > 1) {
            $list .= '<optgroup label="' . $items[0]->cat_title . '">' . "\n";
        }
        require_once JPATH_SITE . DS . 'components' . DS . 'com_content' . DS . 'helpers' . DS . 'route.php';
        foreach ($items as $item) {
            $listinglink = ContentHelperRoute::getArticleRoute($item->id, $item->catid, $item->sectionid);
            $list .= '<option value="' . $listinglink . '">' . $item->title . '</option>' . "\n";
        }
        if ($groups && count($items) > 1) {
            $list .= '</optgroup>' . "\n";
        }
    }
    $list .= '</select>' . "\n";
    return $list;
}
Example #6
0
 function renderItem(&$item, &$params, &$access)
 {
     global $mainframe;
     $user =& JFactory::getUser();
     $item->text = $item->introtext;
     $item->groups = '';
     $item->readmore = trim($item->fulltext) != '';
     $item->metadesc = '';
     $item->metakey = '';
     $item->access = '';
     $item->created = '';
     $item->modified = '';
     if ($params->get('readmore') || $params->get('link_titles')) {
         if ($params->get('intro_only')) {
             // Check to see if the user has access to view the full article
             if ($item->access <= $user->get('aid', 0)) {
                 $linkOn = ContentHelperRoute::getArticleRoute($item->slug, $item->catslug);
             } else {
                 $linkOn = JRoute::_('index.php?option=com_user&task=register');
             }
         }
         $item->linkOn = $linkOn;
     }
     $results = $mainframe->triggerEvent('onAfterDisplayTitle', array(&$item, &$params, 1));
     $item->afterDisplayTitle = trim(implode("\n", $results));
     $results = $mainframe->triggerEvent('onBeforeDisplayContent', array(&$item, &$params, 1));
     $item->beforeDisplayContent = trim(implode("\n", $results));
     require JModuleHelper::getLayoutPath('mod_yoo_drawer', '_item');
 }
 /**
  * Generate content
  * @param   object      The article object.  Note $article->text is also available
  * @param   object      The article params
  * @param   boolean     Modules context
  * @return  string      Returns html code or empty string.
  */
 private function getContent(&$article, &$params, $moduleContext = false)
 {
     $doc = JFactory::getDocument();
     /* @var $doc JDocumentHtml */
     $doc->addStyleSheet(JURI::root() . "plugins/content/fastsocialshare/style/style.css");
     $uriInstance = JURI::getInstance();
     if (!$moduleContext) {
         if (!class_exists('ContentHelperRoute')) {
             include_once JPATH_SITE . '/components/com_content/helpers/route.php';
         }
         $url = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catslug), false);
         $root = rtrim($uriInstance->getScheme() . '://' . $uriInstance->getHost(), '/');
         $url = $root . $url;
         $title = htmlentities($article->title, ENT_QUOTES, "UTF-8");
     } else {
         $url = JURI::current();
         $title = htmlentities($doc->title, ENT_QUOTES, "UTF-8");
     }
     $html = $this->getFacebookLike($this->params, $url, $title);
     $html .= $this->getFacebookShareMe($this->params, $url, $title);
     $html .= $this->getTwitter($this->params, $url, $title);
     $html .= $this->getGooglePlusOne($this->params, $url, $title);
     $html .= $this->getLinkedIn($this->params, $url, $title);
     $html .= $this->getPinterest($this->params, $url, $title);
     return '<div class="fastsocialshare_container">' . $html . '<div class="fastsocialshare_clearer"></div></div>';
 }
Example #8
0
 function renderItem(&$item, &$params, &$access)
 {
     global $mainframe;
     $user =& JFactory::getUser();
     $item->text = $item->introtext;
     $item->groups = '';
     $item->readmore = trim($item->fulltext) != '';
     $item->metadesc = '';
     $item->metakey = '';
     $item->created = '';
     $item->modified = '';
     if ($params->get('readmore') || $params->get('link_titles')) {
         if ($params->get('intro_only')) {
             // Check to see if the user has access to view the full article
             if ($item->access <= $user->get('aid', 0)) {
                 $itemparams = new JParameter($item->attribs);
                 $readmoretxt = $itemparams->get('readmore', JText::_('Read more text'));
                 $item->linkOn = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, $item->sectionid));
                 $item->linkText = $readmoretxt;
             } else {
                 $item->linkOn = JRoute::_('index.php?option=com_user&view=login');
                 $item->linkText = JText::_('Login To Read More');
             }
         }
     }
     if (!$params->get('image')) {
         $item->text = preg_replace('/<img[^>]*>/', '', $item->text);
     }
     $results = $mainframe->triggerEvent('onAfterDisplayTitle', array(&$item, &$params, 1));
     $item->afterDisplayTitle = trim(implode("\n", $results));
     $results = $mainframe->triggerEvent('onBeforeDisplayContent', array(&$item, &$params, 1));
     $item->beforeDisplayContent = trim(implode("\n", $results));
     require JModuleHelper::getLayoutPath('mod_newsflash', '_item');
 }
Example #9
0
		protected function _getList($params, $module){
			$this->params = $params;
			$list = array();
			$source_category = $params->get('source');
			
			$items = $this->getCategoryItems($source_category, $params);	
			
			if(!empty($items)) {
				include_once JPATH_SITE . DS . 'components' . DS . 'com_content' . DS . 'helpers' . DS . 'route.php';											
				$custom = $this->_getCustomUrl($params);
				foreach($items as $key => $item){
					$category = $this->getCategory($item->catid);
					$item->catitle = $category->title;
					if(!$this->getItemImage($item)){
						$item->image = 'modules/'.Ytools::getModule()->module . '/assets/images/nophoto.png';
					}
					if(array_key_exists($item->id, $custom)){
						$item->link=  trim($custom[$item->id]->url);
					}else{						
						$item->link = JRoute::_(ContentHelperRoute::getArticleRoute($item->id, $item->catid));
					}												
						$item->description = strip_tags($item->introtext);
				}
			}	
			return $items;
		}
Example #10
0
    function getData($ids)
    {
        // prepare an array
        $results = array();
        // prepare an query part
        $query_ids = implode(',', $ids);
        // generate the query
        $database = JFactory::getDBO();
        // SQL query for slides
        $query = '
		SELECT 
			`c`.`id` AS `id`,
			`c`.`catid` AS `cid`,
			`c`.`title` AS `title`
		FROM 
			#__content AS `c` 
		WHERE 
			`c`.`id` IN (' . $query_ids . ')
		;';
        // running query
        $database->setQuery($query);
        // if results exists
        if ($datas = $database->loadObjectList()) {
            // parsing data
            foreach ($datas as $item) {
                // array with prepared image
                $results[$item->id] = array('id' => $item->id, 'cid' => $item->cid, 'title' => stripslashes($item->title), 'link' => JRoute::_(ContentHelperRoute::getArticleRoute($item->id, $item->cid)));
            }
        }
        // return the results
        return $results;
    }
Example #11
0
function getBacklink($id, $type, $category = true)
{
    $db =& JFactory::getDBO();
    if (!$category) {
        $query = "SELECT articleid from #__fieldsattach_values WHERE (value LIKE '%," . $id . ",%' OR value LIKE '" . $id . ",%' OR value LIKE '%," . $id . "' OR value LIKE '" . $id . "') AND fieldsid = 23";
    } else {
        $query = "SELECT catid from #__fieldsattach_categories_values WHERE (value LIKE '%," . $id . ",%' OR value LIKE '" . $id . ",%' OR value LIKE '%," . $id . "' OR value LIKE '" . $id . "') AND fieldsid = 22";
    }
    $db->setQuery($query);
    $result = $db->loadObjectList();
    $function = '';
    foreach ($result as $item) {
        if (!$category) {
            $parent = getParent(getCategory($item->articleid));
        } else {
            $parent = getParent($item->catid);
        }
        if ($parent == $type) {
            if (!$category) {
                $function .= '<li><a href="' . ContentHelperRoute::getArticleRoute($item->articleid, $parent) . '">' . getTitle($item->articleid, $category) . '</a></li>';
            } else {
                $function .= '<li><a href="' . ContentHelperRoute::getCategoryRoute($item->catid, $parent) . '">' . getTitle($item->catid, $category) . '</a></li>';
            }
        }
    }
    return $function;
}
Example #12
0
 function display($tpl = null)
 {
     global $mainframe;
     // parameters
     $db =& JFactory::getDBO();
     $document =& JFactory::getDocument();
     $params =& $mainframe->getParams();
     $document->link = JRoute::_('index.php?option=com_content&view=frontpage');
     // Get some data from the model
     JRequest::setVar('limit', $mainframe->getCfg('feed_limit'));
     $rows =& $this->get('Data');
     foreach ($rows as $row) {
         // strip html from feed item title
         $title = $this->escape($row->title);
         $title = html_entity_decode($title);
         // url link to article
         $link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid));
         // strip html from feed item description text
         $description = $params->get('feed_summary', 0) ? $row->introtext . $row->fulltext : $row->introtext;
         $author = $row->created_by_alias ? $row->created_by_alias : $row->author;
         // load individual item creator class
         $item = new JFeedItem();
         $item->title = $title;
         $item->link = $link;
         $item->description = $description;
         $item->date = $row->created;
         $item->category = 'frontpage';
         // loads item info into rss array
         $document->addItem($item);
     }
 }
Example #13
0
 function display()
 {
     global $mainframe;
     $doc =& JFactory::getDocument();
     $params =& $mainframe->getParams();
     // Get some data from the model
     JRequest::setVar('limit', $mainframe->getCfg('feed_limit'));
     // Lets get our data from the model
     $rows =& $this->get('Data');
     $section =& $this->get('Section');
     $doc->link = JRoute::_(ContentHelperRoute::getSectionRoute($section->id));
     foreach ($rows as $row) {
         // strip html from feed item title
         $title = $this->escape($row->title);
         $title = html_entity_decode($title);
         // url link to article
         // & used instead of &amp; as this is converted by feed creator
         $link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid));
         // strip html from feed item description text
         $description = $params->get('feed_summary', 0) ? $row->introtext . $row->fulltext : $row->introtext;
         $author = $row->created_by_alias ? $row->created_by_alias : $row->author;
         // load individual item creator class
         $item = new JFeedItem();
         $item->title = $title;
         $item->link = $link;
         $item->description = $description;
         $item->date = $row->created;
         $item->category = $row->category;
         // loads item info into rss array
         $doc->addItem($item);
     }
 }
	/**
	 * Icon for email
	 *
	 * @param   object     $member   Member info
	 * @param   JRegistry  $params   HTML Params
	 * @param   array      $attribs  Member attribs
	 *
	 * @return string
	 *
	 * @since    1.5
	 */
	public static function email($member, $params, $attribs = [])
	{
		require_once JPATH_SITE . '/components/com_mailto/helpers/mailto.php';
		$uri  = JUri::getInstance();
		$base = $uri->toString(['scheme', 'host', 'port']);
		$link = $base . JRoute::_(ContentHelperRoute::getArticleRoute($member->slug, $member->catid), false);
		$url  = 'index.php?option=com_mailto&tmpl=component&link=' . MailtoHelper::addLink($link);

		$status = 'width=400,height=350,menubar=yes,resizable=yes';

		if ($params->get('show_icons'))
		{
			$text = JHtml::_('image', 'system/emailButton.png', JText::_('JGLOBAL_EMAIL'), null, true);
		}
		else
		{
			$text = '&#160;' . JText::_('JGLOBAL_EMAIL');
		}

		$attribs['title']   = JText::_('JGLOBAL_EMAIL');
		$attribs['onclick'] = "window.open(this.href,'win2','" . $status . "'); return false;";

		$output = JHtml::_('link', JRoute::_($url), $text, $attribs);

		return $output;
	}
Example #15
0
 /**
  * onContentPrepare
  *
  * Replaces IMG H5P placeholder with an iFrame.
  */
 public function onContentPrepare($context, &$article, &$params, $page = 0)
 {
     $matches = array();
     if (preg_match_all($this->h5p_re, $article->text, $matches, PREG_SET_ORDER)) {
         // We need to add a little script
         $doc = JFactory::getDocument();
         $doc->addScript(JURI::root(true) . '/libraries/h5pcore/core/js/jquery.js' . $this->fileSuffix);
         $doc->addScript(JURI::root(true) . '/libraries/h5pcore/core/js/h5p.js' . $this->fileSuffix);
         $doc->addScript(JURI::root(true) . '/libraries/h5pcore/js/h5piframeresize.js' . $this->fileSuffix);
         $doc->addStyleSheet(JURI::root(true) . '/libraries/h5pcore/core/styles/h5p.css' . $this->fileSuffix);
         $doc->addStyleSheet(JURI::root(true) . '/libraries/h5pcore/media/h5pdisplay.css' . $this->fileSuffix);
         $html = '<div class="h5p-iframe-wrapper" id="iframe-wrapper-##h5pId##">';
         $html .= '<iframe id="iframe-##h5pId##" class="h5p-iframe" src="##iframeSrc##" style="width: 100%; height: 400px; border: none;"></iframe>';
         $html .= '</div>';
         $article_url = JRoute::_(ContentHelperRoute::getArticleRoute($article->id, $article->catid, $article->itemid)) . "-{$article->alias}";
         foreach ($matches as $key => $match) {
             $h5pId = $match[1];
             $h5pDomId = str_replace('.', '_', $h5pId);
             // Periods make jQuery unhappy.
             if ($context === 'com_content.article') {
                 $iframeSrc = 'index.php?option=com_h5p&view=h5p&layout=view&tmpl=component&cid=' . $h5pId;
                 $replacement = str_replace(array('##h5pId##', '##iframeSrc##'), array($h5pDomId, $iframeSrc), $html);
                 $article->text = preg_replace('/\\<img.*?h5p-placeholder-image.*?data-content-id\\=\\"' . $h5pId . '\\".*?\\>/', $replacement, $article->text, 1);
                 $this->registerStartTime($h5pId);
             } elseif (isset($article->id)) {
                 $article->text = preg_replace('/\\<img.*?h5p-placeholder-image.*?data-content-id\\=\\"' . $h5pId . '\\".*?\\>/', '<a href="' . $article_url . '">$0</a>', $article->text, 1);
             } else {
                 $article->text = preg_replace('/\\<img.*?h5p-placeholder-image.*?data-content-id\\=\\"' . $h5pId . '\\".*?\\>/', '', $article->text, 1);
             }
         }
     }
 }
Example #16
0
 /**
  * 
  * @param object $item
  * @return object
  */
 protected function _prepareItem($item)
 {
     $item->link = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug));
     $item->introtext = JHtml::_('string.truncate', $item->introtext, $this->_params->get('intro_length', 200));
     $item->cat_link = JRoute::_(ContentHelperRoute::getCategoryRoute($item->catid));
     return $item;
 }
Example #17
0
 public function go()
 {
     $url = JRequest::getVar('url');
     $id = JRequest::getVar('id');
     if ($url == 'category') {
         $link = 'index.php?option=com_content&view=category&id=' . $id;
         //find item id
         $needles = array('category' => array($id));
         if ($item = self::_findItem($needles)) {
             $link .= '&Itemid=' . $item;
         } elseif ($item = self::_findItem()) {
             $link .= '&Itemid=' . $item;
         }
         $start = JRequest::getVar('start', null);
         if ($start) {
             $link .= '&start=' . $start;
         }
     } else {
         //find category id via article id
         $model = $this->getModel('Url', 'TTOL_HomeModel');
         $article = $model->getArticle($id);
         require_once JPATH_SITE . '/components/com_content/helpers/route.php';
         $article->slug = $article->id . ':' . $article->alias;
         $article->catslug = $article->catid ? $article->catid . ':' . $article->category_alias : $article->catid;
         $link = ContentHelperRoute::getArticleRoute($article->slug, $article->catslug);
     }
     $this->setRedirect(JRoute::_($link));
     return true;
 }
Example #18
0
 private function format(&$articles, $params)
 {
     if (!$articles) {
         return;
     }
     foreach ($articles as $article) {
         $category = JTable::getInstance('Category');
         $category->load($article->catid);
         $article->category = $category;
         $article->permalink = ContentHelperRoute::getArticleRoute($article->id . ':' . $article->alias, $article->catid);
         $article->permalink = JRoute::_($article->permalink);
         $article->category->permalink = ContentHelperRoute::getCategoryRoute($category->id . ':' . $category->alias);
         $article->category->permalink = JRoute::_($article->category->permalink);
         $article->content = empty($article->introtext) ? $article->fulltext : $article->introtext;
         $titleLength = $params->get('title_length');
         $contentLength = $params->get('content_length');
         if ($titleLength) {
             $article->title = JString::substr($article->title, 0, $titleLength);
         }
         // Try to get image of the article
         $image = $this->processContentImage($article->content);
         if ($image) {
             $article->image = $image;
         }
         if ($contentLength) {
             $article->content = JString::substr(strip_tags($article->content), 0, $contentLength) . ' ...';
         } else {
             $base = JURI::base(true) . '/';
             $protocols = '[a-zA-Z0-9]+:';
             //To check for all unknown protocals (a protocol must contain at least one alpahnumeric fillowed by :
             $regex = '#(src|href|poster)="(?!/|' . $protocols . '|\\#|\')([^"]*)"#m';
             $article->content = preg_replace($regex, "\$1=\"{$base}\$2\"", $article->content);
         }
     }
 }
Example #19
0
 function display()
 {
     $app = JFactory::getApplication();
     $doc =& JFactory::getDocument();
     $params =& $app->getParams();
     // Get some data from the model
     JRequest::setVar('limit', $app->getCfg('feed_limit'));
     $category =& $this->get('Category');
     $rows =& $this->get('Data');
     $doc->link = JRoute::_(ContentHelperRoute::getCategoryRoute($category->id, $cagtegory->sectionid));
     foreach ($rows as $row) {
         // strip html from feed item title
         $title = $this->escape($row->title);
         $title = html_entity_decode($title);
         // url link to article
         // & used instead of &amp; as this is converted by feed creator
         $link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid));
         // 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)) : '');
         // load individual item creator class
         $item = new JFeedItem();
         $item->title = $title;
         $item->link = $link;
         $item->description = $description;
         $item->date = $date;
         $item->category = $row->category;
         // loads item info into rss array
         $doc->addItem($item);
     }
 }
Example #20
0
 function getList()
 {
     ///var_dump ($this->id);
     global $mainframe;
     JPluginHelper::importPlugin('content');
     $dispatcher =& JDispatcher::getInstance();
     $params =& JComponentHelper::getParams('com_content');
     $limitstart = $this->limit;
     $rows = $this->getDataFromCate();
     if (count($rows) > 0) {
         for ($i = 0; $i < count($rows); $i++) {
             $rows[$i]['text'] = $rows[$i]['introtext'];
             $results = $dispatcher->trigger('onPrepareContent', array(&$rows[$i], &$params, $limitstart));
             $items[$i]['introtext'] = $rows[$i]['text'];
             $items[$i]['id'] = $rows[$i]['id'];
             $items[$i]['img'] = $this->getImage($rows[$i]['text']);
             $items[$i]['title'] = $rows[$i]['title'];
             $items[$i]['content'] = $this->removeImage($rows[$i]['text']);
             $link = JRoute::_(ContentHelperRoute::getArticleRoute($rows[$i]['slug'], $rows[$i]['catslug'], $rows[$i]['sectionid']));
             $items[$i]['link'] = $link;
         }
     }
     $items = $this->update($items);
     /*   Process Images*/
     return $items;
 }
Example #21
0
 function display()
 {
     global $mainframe;
     // 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');
     // Get some data from the model
     JRequest::setVar('limit', $app->getCfg('feed_limit'));
     $article =& $this->get('Article');
     $rows =& $this->get('Data');
     $document->link = JRoute::_(ContentHelperRoute::getArticleRoute($article->id, $article->catid));
     foreach ($rows as $row) {
         // strip html from feed item title
         $title = $this->escape($row->title);
         $title = html_entity_decode($title, ENT_COMPAT, 'UTF-8');
         // url link to article
         // & used instead of &amp; as this is converted by feed creator
         $link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid));
         // strip html from feed item description text
         $description = $params->get('feed_summary', 0) ? $row->introtext . $row->fulltext : $row->introtext;
         $author = $row->created_by_alias ? $row->created_by_alias : $row->author;
         // load individual item creator class
         $item = new JFeedItem();
         $item->title = $title;
         $item->link = $link;
         $item->description = $description;
         $item->date = $row->created;
         // loads item info into rss array
         $document->addItem($item);
     }
 }
 function display($tpl = null)
 {
     // Parameters
     $app = JFactory::getApplication();
     $doc = JFactory::getDocument();
     $params = $app->getParams();
     $feedEmail = $app->getCfg('feed_email', 'author');
     $siteEmail = $app->getCfg('mailfrom');
     $doc->link = JRoute::_('index.php?option=com_content&view=featured');
     // Get some data from the model
     JRequest::setVar('limit', $app->getCfg('feed_limit'));
     $categories = JCategories::getInstance('Content');
     $rows = $this->get('Items');
     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;
         // Url link to article
         $link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid));
         // Get row fulltext
         $db = JFactory::getDBO();
         $query = 'SELECT' . $db->quoteName('fulltext') . 'FROM #__content WHERE id =' . $row->id;
         $db->setQuery($query);
         $row->fulltext = $db->loadResult();
         $description = $params->get('feed_summary', 0) ? $row->introtext . $row->fulltext : $row->introtext;
         $author = $row->created_by_alias ? $row->created_by_alias : $row->author;
         // Load individual item creator class
         $item = new JFeedItem();
         $item->title = $title;
         $item->link = $link;
         $item->date = $row->publish_up;
         $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;
         } elseif ($feedEmail === 'author') {
             $item->authorEmail = $row->author_email;
         }
         // Add readmore link to description if introtext is shown, show_readmore is true and fulltext exists
         if (!$params->get('feed_summary', 0) && $params->get('feed_show_readmore', 0) && $row->fulltext) {
             $description .= '<p class="feed-readmore"><a target="_blank" href ="' . $item->link . '">' . JText::_('COM_CONTENT_FEED_READMORE') . '</a></p>';
         }
         // Load item description and add div
         $item->description = '<div class="feed-description">' . $description . '</div>';
         // Loads item info into rss array
         $doc->addItem($item);
     }
 }
Example #23
0
 public function onJSolrSearchURIGet($document)
 {
     if ($this->get('context') == $document->context) {
         require_once JPATH_ROOT . "/components/com_content/helpers/route.php";
         return ContentHelperRoute::getArticleRoute($document->id, $document->parent_id);
     }
     return null;
 }
Example #24
0
 function __construct($component, $componentParams, $article, $articleParams)
 {
     parent::__construct($component, $componentParams, $article, $articleParams);
     $this->category = $this->_articleParams->get('show_category') ? $this->_article->category_title : '';
     $this->categoryLink = $this->_articleParams->get('link_category') ? JRoute::_(ContentHelperRoute::getCategoryRoute($this->_article->catid)) : '';
     $this->parentCategory = $this->_articleParams->get('show_parent_category') && $this->_article->parent_id != 1 ? $this->_article->parent_title : '';
     $this->parentCategoryLink = $this->_articleParams->get('link_parent_category') ? JRoute::_(ContentHelperRoute::getCategoryRoute($this->_article->parent_id)) : '';
 }
 /**
  * Get a list of the latest articles from the article model
  *
  * @param   \Joomla\Registry\Registry  &$params  object holding the models parameters
  *
  * @return  mixed
  *
  * @since 1.6
  */
 public static function getList(&$params)
 {
     // Get an instance of the generic articles model
     $model = JModelLegacy::getInstance('Articles', 'ContentModel', 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', 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.ordering', JFactory::getDbo()->getQuery(true)->Rand());
     } else {
         $direction = $params->get('direction', 1) ? 'DESC' : 'ASC';
         $model->setState('list.direction', $direction);
         $model->setState('list.ordering', $ordering);
     }
     // Retrieve Content
     $items = $model->getItems();
     foreach ($items as &$item) {
         $item->readmore = strlen(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::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catid, $item->language));
             $item->linkText = JText::_('MOD_ARTICLES_NEWS_READMORE');
         } else {
             $item->link = new JUri(JRoute::_('index.php?option=com_users&view=login', false));
             $item->link->setVar('return', base64_encode(ContentHelperRoute::getArticleRoute($item->slug, $item->catid, $item->language)));
             $item->linkText = JText::_('MOD_ARTICLES_NEWS_READMORE_REGISTER');
         }
         $item->introtext = JHtml::_('content.prepare', $item->introtext, '', 'mod_articles_news.content');
         if (!$params->get('image')) {
             $item->introtext = preg_replace('/<img[^>]*>/', '', $item->introtext);
         }
         $results = $app->triggerEvent('onContentAfterTitle', array('com_content.article', &$item, &$params, 1));
         $item->afterDisplayTitle = trim(implode("\n", $results));
         $results = $app->triggerEvent('onContentBeforeDisplay', array('com_content.article', &$item, &$params, 1));
         $item->beforeDisplayContent = trim(implode("\n", $results));
         $results = $app->triggerEvent('onContentAfterDisplay', array('com_content.article', &$item, &$params, 1));
         $item->afterDisplayContent = trim(implode("\n", $results));
     }
     return $items;
 }
Example #26
0
 public static function getList($params, $start, $limit)
 {
     $app = JFactory::getApplication();
     $db = JFactory::getDbo();
     //Parameters
     $catids = self::categories($params->get('catid'));
     //Get an instance of the generic articles model
     $model = JModelLegacy::getInstance('Articles', 'ContentModel', array('ignore_request' => true));
     //Set application parameters in model
     $appParams = $app->getParams();
     $model->setState('params', $appParams);
     // Set the filters based on the module params
     $model->setState('list.start', $start);
     $model->setState('list.limit', $limit);
     $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', $catids);
     // 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
     $orderby = $params->get('orderby', 'a.ordering');
     $ordering = $params->get('ordering', 'DESC');
     $model->setState('list.ordering', $orderby);
     $model->setState('list.direction', $ordering);
     $items = $model->getItems();
     foreach ($items as &$item) {
         $item->slug = $item->id . ':' . $item->alias;
         $item->catslug = $item->catid . ':' . $item->category_alias;
         $item->tag = $item->category_title;
         $item->image = JURI::base() . self::getImage($item->introtext, $item->images);
         $item->video = self::getVideo($item->images);
         $image_full = JURI::base() . self::getFullImage($item->introtext, $item->images);
         $item->image_full = $image_full ? $image_full : $item->image;
         $item->title = htmlspecialchars($item->title);
         $item->urls = json_decode($item->urls);
         $item->introtext = JHtml::_('content.prepare', $item->introtext);
         $nonsefurl = ContentHelperRoute::getArticleRoute($item->slug, $item->catslug);
         $nonsefurl = preg_replace('/Itemid=(.+)/', 'Itemid=0', $nonsefurl);
         $item->link = JRoute::_($nonsefurl);
     }
     return $items;
 }
Example #27
0
 public function __construct($component, $componentParams, $article, $articleParams)
 {
     parent::__construct($component, $componentParams, $article, $articleParams);
     $this->titleLink = $this->_articleParams->get('link_titles') ? JRoute::_(ContentHelperRoute::getArticleRoute($this->_article->slug, $this->_article->catslug)) : '';
     $this->category = $this->_articleParams->get('show_category') ? $this->_article->category_title : '';
     $this->categoryLink = $this->_articleParams->get('link_category') && $this->_article->catslug ? JRoute::_(ContentHelperRoute::getCategoryRoute($this->_article->catslug)) : '';
     $this->parentCategoryLink = $this->_articleParams->get('link_parent_category') && $this->_article->parent_slug ? JRoute::_(ContentHelperRoute::getCategoryRoute($this->_article->parent_slug)) : '';
     $this->intro = $this->_articleParams->get('show_intro') ? $this->_article->introtext : '';
 }
Example #28
0
 public function renderItem($item, $params)
 {
     $result = $item->introtext;
     if ($params->get('readmore') && $item->readmore) {
         $link = JRoute::_(ContentHelperRoute::getArticleRoute($item->id, $item->catid));
         $result .= '<a class="readmore" href="' . $link . '">' . JText::_('COM_CONTENT_READ_MORE_TITLE') . '</a>';
     }
     return $result;
 }
Example #29
0
 public static function getPhocaPDFContentIcon($item, $params, $attribs = array())
 {
     $lang = JFactory::getLanguage();
     $lang->load('plg_phocapdf_content', JPATH_ADMINISTRATOR, $lang->getDefault(), false, false);
     // Plugin Parameters
     jimport('joomla.html.parameter');
     //$pluginP 	= new JParameter( $plugin->params );
     $plugin = JPluginHelper::getPlugin('phocapdf', 'content');
     $pluginP = new JRegistry();
     $pluginP->loadString($plugin->params);
     $include_articles = $pluginP->get('include_articles', '');
     $include_categories = $pluginP->get('include_categories', '');
     $include_articles = explode(',', $include_articles);
     $include_categories = explode(',', $include_categories);
     $include_articles = array_filter($include_articles);
     $include_categories = array_filter($include_categories);
     if (!empty($include_articles)) {
         if (isset($item->id) && !in_array($item->id, $include_articles)) {
             return "";
         }
     }
     if (!empty($include_categories)) {
         if (isset($item->catid) && !in_array($item->catid, $include_categories)) {
             return "";
         }
     }
     $exclude_articles = $pluginP->get('exclude_articles', '');
     $exclude_categories = $pluginP->get('exclude_categories', '');
     $exclude_articles = explode(',', $exclude_articles);
     $exclude_categories = explode(',', $exclude_categories);
     if (isset($item->catid) && in_array($item->catid, $exclude_categories)) {
         return "";
     }
     if (isset($item->id) && in_array($item->id, $exclude_articles)) {
         return "";
     }
     $pdfDest = $pluginP->get('pdf_destination', 'S');
     $status = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,' . 'resizable=yes,width=820,height=480,directories=no,location=no';
     if ($pdfDest == 'I' || $pdfDest == 'D') {
         $attribs['onclick'] = '';
     } else {
         $browser = PhocaPDFHelperBrowser::browserDetection('browser');
         if ($browser == 'msie7' || $browser == 'msie8') {
             $attribs['onclick'] = '';
             $attribs['target'] = '_blank';
         } else {
             $attribs['onclick'] = "window.open(this.href,'win2','" . $status . "'); return false;";
         }
     }
     $url = ContentHelperRoute::getArticleRoute($item->slug, $item->catid);
     $url .= '&tmpl=component&format=pdf';
     //&page='.@ $request->limitstart;
     $attribs['title'] = JText::_('PLG_PHOCAPDF_CONTENT_PDF');
     $attribs['rel'] = 'nofollow';
     $output = JHTML::_('link', JRoute::_($url), JText::_('PLG_PHOCAPDF_CONTENT_PDF'), $attribs);
     return $output;
 }
Example #30
0
 public static function getList(&$params)
 {
     $app = JFactory::getApplication();
     $db = JFactory::getDbo();
     // Get an instance of the generic articles model
     $model = JModel::getInstance('Articles', 'ContentModel', 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.title_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_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', 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
     $items = $model->getItems();
     foreach ($items as &$item) {
         $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::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catid));
             $item->linkText = JText::_('MOD_ARTICLES_NEWS_READMORE');
         } else {
             $item->link = JRoute::_('index.php?option=com_user&view=login');
             $item->linkText = JText::_('MOD_ARTICLES_NEWS_READMORE_REGISTER');
         }
         $item->introtext = JHtml::_('content.prepare', $item->introtext);
         //new
         if (!$params->get('image')) {
             $item->introtext = preg_replace('/<img[^>]*>/', '', $item->introtext);
         }
         $results = $app->triggerEvent('onContentAfterDisplay', array('com_content.article', &$item, &$params, 1));
         $item->afterDisplayTitle = trim(implode("\n", $results));
         $results = $app->triggerEvent('onContentBeforeDisplay', array('com_content.article', &$item, &$params, 1));
         $item->beforeDisplayContent = trim(implode("\n", $results));
     }
     return $items;
 }