[ Index ]

PHP Cross Reference of Joomla 2.5.4 DE

title

Body

[close]

/modules/mod_articles_news/ -> helper.php (source)

   1  <?php
   2  /**
   3   * @package        Joomla.Site
   4   * @subpackage    mod_articles_news
   5   * @copyright    Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
   6   * @license        GNU General Public License version 2 or later; see LICENSE.txt
   7   */
   8  
   9  // no direct access
  10  defined('_JEXEC') or die;
  11  
  12  require_once  JPATH_SITE.'/components/com_content/helpers/route.php';
  13  
  14  jimport('joomla.application.component.model');
  15  
  16  JModel::addIncludePath(JPATH_SITE.'/components/com_content/models', 'ContentModel');
  17  
  18  abstract class modArticlesNewsHelper
  19  {
  20  	public static function getList(&$params)
  21      {
  22          $app    = JFactory::getApplication();
  23          $db        = JFactory::getDbo();
  24  
  25          // Get an instance of the generic articles model
  26          $model = JModel::getInstance('Articles', 'ContentModel', array('ignore_request' => true));
  27  
  28          // Set application parameters in model
  29          $appParams = JFactory::getApplication()->getParams();
  30          $model->setState('params', $appParams);
  31  
  32          // Set the filters based on the module params
  33          $model->setState('list.start', 0);
  34          $model->setState('list.limit', (int) $params->get('count', 5));
  35  
  36          $model->setState('filter.published', 1);
  37  
  38          $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,' .
  39              ' a.modified, a.modified_by, a.publish_up, a.publish_down, a.images, a.urls, a.attribs, a.metadata, a.metakey, a.metadesc, a.access,' .
  40              ' a.hits, a.featured,' .
  41              ' LENGTH(a.fulltext) AS readmore');
  42          // Access filter
  43          $access = !JComponentHelper::getParams('com_content')->get('show_noauth');
  44          $authorised = JAccess::getAuthorisedViewLevels(JFactory::getUser()->get('id'));
  45          $model->setState('filter.access', $access);
  46  
  47          // Category filter
  48          $model->setState('filter.category_id', $params->get('catid', array()));
  49  
  50          // Filter by language
  51          $model->setState('filter.language', $app->getLanguageFilter());
  52  
  53          // Set ordering
  54          $ordering = $params->get('ordering', 'a.publish_up');
  55          $model->setState('list.ordering', $ordering);
  56          if (trim($ordering) == 'rand()') {
  57              $model->setState('list.direction', '');
  58          } else {
  59              $model->setState('list.direction', 'DESC');
  60          }
  61  
  62          //    Retrieve Content
  63          $items = $model->getItems();
  64  
  65          foreach ($items as &$item) {
  66              $item->readmore = (trim($item->fulltext) != '');
  67              $item->slug = $item->id.':'.$item->alias;
  68              $item->catslug = $item->catid.':'.$item->category_alias;
  69  
  70              if ($access || in_array($item->access, $authorised))
  71              {
  72                  // We know that user has the privilege to view the article
  73                  $item->link = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catid));
  74                  $item->linkText = JText::_('MOD_ARTICLES_NEWS_READMORE');
  75              }
  76              else {
  77                  $item->link = JRoute::_('index.php?option=com_users&view=login');
  78                  $item->linkText = JText::_('MOD_ARTICLES_NEWS_READMORE_REGISTER');
  79              }
  80  
  81              $item->introtext = JHtml::_('content.prepare', $item->introtext, '', 'mod_articles_news.content');
  82  
  83              //new
  84              if (!$params->get('image')) {
  85                  $item->introtext = preg_replace('/<img[^>]*>/', '', $item->introtext);
  86              }
  87  
  88              $results = $app->triggerEvent('onContentAfterDisplay', array('com_content.article', &$item, &$params, 1));
  89              $item->afterDisplayTitle = trim(implode("\n", $results));
  90  
  91              $results = $app->triggerEvent('onContentBeforeDisplay', array('com_content.article', &$item, &$params, 1));
  92              $item->beforeDisplayContent = trim(implode("\n", $results));
  93          }
  94  
  95          return $items;
  96      }
  97  }


Generated: Tue Apr 3 11:40:28 2012 Cross-referenced by PHPXref 0.7.1