Source for file helper.php

Documentation is available at helper.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Site
  4.  * @subpackage  mod_weblinks
  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_weblinks/helpers/route.php';
  13. require_once JPATH_SITE '/components/com_weblinks/helpers/category.php';
  14.  
  15. JModelLegacy::addIncludePath(JPATH_SITE '/components/com_weblinks/models''WeblinksModel');
  16.  
  17. /**
  18.  * Helper for mod_weblinks
  19.  *
  20.  * @package     Joomla.Site
  21.  * @subpackage  mod_weblinks
  22.  * @since       1.5.0
  23.  */
  24. {
  25.     /**
  26.      * Show online member names
  27.      *
  28.      * @param   mixed  &$params  The parameters set in the administrator backend
  29.      *
  30.      * @return  mixed   Null if no weblinks based on input parameters else an array containing all the weblinks.
  31.      *
  32.      * @since   1.5.0
  33.      ***/
  34.     public static function getList(&$params)
  35.     {
  36.         // Get an instance of the generic articles model
  37.         $model JModelLegacy::getInstance('Category''WeblinksModel'array('ignore_request' => true));
  38.  
  39.         // Set application parameters in model
  40.         $app JFactory::getApplication();
  41.         $appParams $app->getParams();
  42.         $model->setState('params'$appParams);
  43.  
  44.         // Set the filters based on the module params
  45.         $model->setState('list.start'0);
  46.         $model->setState('list.limit'(int) $params->get('count'5));
  47.  
  48.         $model->setState('filter.state'1);
  49.         $model->setState('filter.publish_date'true);
  50.  
  51.         // Access filter
  52.         $access !JComponentHelper::getParams('com_weblinks')->get('show_noauth');
  53.         $model->setState('filter.access'$access);
  54.  
  55.         $ordering $params->get('ordering''ordering');
  56.         $model->setState('list.ordering'$ordering == 'order' 'ordering' $ordering);
  57.         $model->setState('list.direction'$params->get('direction''asc'));
  58.  
  59.         $catid    = (int) $params->get('catid'0);
  60.         $model->setState('category.id'$catid);
  61.  
  62.         // Create query object
  63.         $db JFactory::getDbo();
  64.         $query $db->getQuery(true);
  65.  
  66.         $case_when1 ' CASE WHEN ';
  67.         $case_when1 .= $query->charLength('a.alias''!=''0');
  68.         $case_when1 .= ' THEN ';
  69.         $a_id $query->castAsChar('a.id');
  70.         $case_when1 .= $query->concatenate(array($a_id'a.alias')':');
  71.         $case_when1 .= ' ELSE ';
  72.         $case_when1 .= $a_id ' END as slug';
  73.  
  74.         $case_when2 ' CASE WHEN ';
  75.         $case_when2 .= $query->charLength('c.alias''!=''0');
  76.         $case_when2 .= ' THEN ';
  77.         $c_id $query->castAsChar('c.id');
  78.         $case_when2 .= $query->concatenate(array($c_id'c.alias')':');
  79.         $case_when2 .= ' ELSE ';
  80.         $case_when2 .= $c_id ' END as catslug';
  81.  
  82.         $model->setState(
  83.             'list.select',
  84.             'a.*, c.published AS c_published,' $case_when1 ',' $case_when2 ',' 'DATE_FORMAT(a.created, "%Y-%m-%d") AS created'
  85.         );
  86.  
  87.         $model->setState('filter.c.published'1);
  88.  
  89.         // Filter by language
  90.         $model->setState('filter.language'$app->getLanguageFilter());
  91.  
  92.         $items $model->getItems();
  93.  
  94.         if ($items)
  95.         {
  96.             foreach ($items as $item)
  97.             {
  98.                 if ($item->params->get('count_clicks'$params->get('count_clicks')) == 1)
  99.                 {
  100.                     $item->link    JRoute::_('index.php?option=com_weblinks&task=weblink.go&catid=' $item->catslug '&id=' $item->slug);
  101.                 }
  102.                 else
  103.                 {
  104.                     $item->link $item->url;
  105.                 }
  106.             }
  107.  
  108.             return $items;
  109.         }
  110.         else
  111.         {
  112.             return;
  113.         }
  114.     }
  115. }

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