Source for file helper.php

Documentation is available at helper.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Site
  4.  * @subpackage  mod_articles_popular
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  8.  */
  9.  
  10. defined('_JEXEC'or die;
  11.  
  12. require_once JPATH_SITE.'/components/com_content/helpers/route.php';
  13.  
  14. JModelLegacy::addIncludePath(JPATH_SITE.'/components/com_content/models''ContentModel');
  15.  
  16. /**
  17.  * Helper for mod_articles_popular
  18.  *
  19.  * @package     Joomla.Site
  20.  * @subpackage  mod_articles_popular
  21.  */
  22. abstract class ModArticlesPopularHelper
  23. {
  24.     public static function getList(&$params)
  25.     {
  26.         // Get an instance of the generic articles model
  27.         $model JModelLegacy::getInstance('Articles''ContentModel'array('ignore_request' => true));
  28.  
  29.         // Set application parameters in model
  30.         $app JFactory::getApplication();
  31.         $appParams $app->getParams();
  32.         $model->setState('params'$appParams);
  33.  
  34.         // Set the filters based on the module params
  35.         $model->setState('list.start'0);
  36.         $model->setState('list.limit'(int) $params->get('count'5));
  37.         $model->setState('filter.published'1);
  38.         $model->setState('filter.featured'$params->get('show_front'1== 'show' 'hide');
  39.  
  40.         // Access filter
  41.         $access !JComponentHelper::getParams('com_content')->get('show_noauth');
  42.         $authorised JAccess::getAuthorisedViewLevels(JFactory::getUser()->get('id'));
  43.         $model->setState('filter.access'$access);
  44.  
  45.         // Category filter
  46.         $model->setState('filter.category_id'$params->get('catid'array()));
  47.  
  48.         // Filter by language
  49.         $model->setState('filter.language'$app->getLanguageFilter());
  50.  
  51.         // Ordering
  52.         $model->setState('list.ordering''a.hits');
  53.         $model->setState('list.direction''DESC');
  54.  
  55.         $items $model->getItems();
  56.  
  57.         foreach ($items as &$item)
  58.         {
  59.             $item->slug $item->id.':'.$item->alias;
  60.             $item->catslug $item->catid.':'.$item->category_alias;
  61.  
  62.             if ($access || in_array($item->access$authorised))
  63.             {
  64.                 // We know that user has the privilege to view the article
  65.                 $item->link JRoute::_(ContentHelperRoute::getArticleRoute($item->slug$item->catslug));
  66.             else {
  67.                 $item->link JRoute::_('index.php?option=com_users&view=login');
  68.             }
  69.         }
  70.  
  71.         return $items;
  72.     }
  73. }

Documentation generated on Tue, 19 Nov 2013 15:04:16 +0100 by phpDocumentor 1.4.3