Source for file featured.php

Documentation is available at featured.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Site
  4.  * @subpackage  com_contact
  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. /**
  13.  * @package     Joomla.Site
  14.  * @subpackage  com_contact
  15.  */
  16. {
  17.     /**
  18.      * Category items data
  19.      *
  20.      * @var array 
  21.      */
  22.     protected $_item = null;
  23.  
  24.     protected $_articles = null;
  25.  
  26.     protected $_siblings = null;
  27.  
  28.     protected $_children = null;
  29.  
  30.     protected $_parent = null;
  31.  
  32.     /**
  33.      * The category that applies.
  34.      *
  35.      * @access    protected
  36.      * @var        object 
  37.      */
  38.     protected $_category = null;
  39.  
  40.     /**
  41.      * The list of other cotnact categories.
  42.      *
  43.      * @access    protected
  44.      * @var        array 
  45.      */
  46.     protected $_categories = null;
  47.  
  48.     /**
  49.      * Constructor.
  50.      *
  51.      * @param   array  An optional associative array of configuration settings.
  52.      * @see     JController
  53.      * @since   1.6
  54.      */
  55.     public function __construct($config array())
  56.     {
  57.         if (empty($config['filter_fields']))
  58.         {
  59.             $config['filter_fields'array(
  60.                 'id''a.id',
  61.                 'name''a.name',
  62.                 'con_position''a.con_position',
  63.                 'suburb''a.suburb',
  64.                 'state''a.state',
  65.                 'country''a.country',
  66.                 'ordering''a.ordering',
  67.             );
  68.         }
  69.  
  70.         parent::__construct($config);
  71.     }
  72.  
  73.     /**
  74.      * Method to get a list of items.
  75.      *
  76.      * @return  mixed  An array of objects on success, false on failure.
  77.      */
  78.     public function getItems()
  79.     {
  80.         // Invoke the parent getItems method to get the main list
  81.         $items parent::getItems();
  82.  
  83.         // Convert the params field into an object, saving original in _params
  84.         for ($i 0$n count($items)$i $n$i++)
  85.         {
  86.             $item $items[$i];
  87.             if (!isset($this->_params))
  88.             {
  89.                 $params new JRegistry;
  90.                 $params->loadString($item->params);
  91.                 $item->params $params;
  92.             }
  93.         }
  94.  
  95.         return $items;
  96.     }
  97.  
  98.     /**
  99.      * Method to build an SQL query to load the list data.
  100.      *
  101.      * @return  string    An SQL query
  102.      * @since   1.6
  103.      */
  104.     protected function getListQuery()
  105.     {
  106.         $user JFactory::getUser();
  107.         $groups implode(','$user->getAuthorisedViewLevels());
  108.  
  109.         // Create a new query object.
  110.         $db $this->getDbo();
  111.         $query $db->getQuery(true);
  112.  
  113.         // Select required fields from the categories.
  114.         $query->select($this->getState('list.select''a.*'))
  115.             ->from($db->quoteName('#__contact_details'' AS a')
  116.             ->where('a.access IN (' $groups ')')
  117.             ->where('a.featured=1')
  118.             ->join('INNER''#__categories AS c ON c.id = a.catid')
  119.             ->where('c.access IN (' $groups ')');
  120.         // Filter by category.
  121.         if ($categoryId $this->getState('category.id'))
  122.         {
  123.             $query->where('a.catid = ' . (int) $categoryId);
  124.         }
  125.         //sqlsrv change... aliased c.published to cat_published
  126.         // Join to check for category published state in parent categories up the tree
  127.         $query->select('c.published as cat_published, CASE WHEN badcats.id is null THEN c.published ELSE 0 END AS parents_published');
  128.         $subquery 'SELECT cat.id as id FROM #__categories AS cat JOIN #__categories AS parent ';
  129.         $subquery .= 'ON cat.lft BETWEEN parent.lft AND parent.rgt ';
  130.         $subquery .= 'WHERE parent.extension = ' $db->quote('com_contact');
  131.         // Find any up-path categories that are not published
  132.         // If all categories are published, badcats.id will be null, and we just use the contact state
  133.         $subquery .= ' AND parent.published != 1 GROUP BY cat.id ';
  134.         // Select state to unpublished if up-path category is unpublished
  135.         $publishedWhere 'CASE WHEN badcats.id is null THEN a.published ELSE 0 END';
  136.         $query->join('LEFT OUTER''(' $subquery ') AS badcats ON badcats.id = c.id');
  137.  
  138.         // Filter by state
  139.         $state $this->getState('filter.published');
  140.         if (is_numeric($state))
  141.         {
  142.             $query->where('a.published = ' . (int) $state);
  143.  
  144.             // Filter by start and end dates.
  145.             $nullDate $db->quote($db->getNullDate());
  146.             $date JFactory::getDate();
  147.             $nowDate $db->quote($date->toSql());
  148.             $query->where('(a.publish_up = ' $nullDate ' OR a.publish_up <= ' $nowDate ')')
  149.                 ->where('(a.publish_down = ' $nullDate ' OR a.publish_down >= ' $nowDate ')')
  150.                 ->where($publishedWhere ' = ' . (int) $state);
  151.         }
  152.  
  153.         // Filter by language
  154.         if ($this->getState('filter.language'))
  155.         {
  156.             $query->where('a.language in (' $db->quote(JFactory::getLanguage()->getTag()) ',' $db->quote('*'')');
  157.         }
  158.  
  159.         // Add the list ordering clause.
  160.         $query->order($db->escape($this->getState('list.ordering''a.ordering')) ' ' $db->escape($this->getState('list.direction''ASC')));
  161.  
  162.         return $query;
  163.     }
  164.  
  165.     /**
  166.      * Method to auto-populate the model state.
  167.      *
  168.      * Note. Calling getState in this method will result in recursion.
  169.      *
  170.      * @since   1.6
  171.      */
  172.     protected function populateState($ordering null$direction null)
  173.     {
  174.         $app JFactory::getApplication();
  175.         $params JComponentHelper::getParams('com_contact');
  176.  
  177.         // List state information
  178.         $limit $app->getUserStateFromRequest('global.list.limit''limit'$app->getCfg('list_limit')'uint');
  179.         $this->setState('list.limit'$limit);
  180.  
  181.         $limitstart $app->input->get('limitstart'0'uint');
  182.         $this->setState('list.start'$limitstart);
  183.  
  184.         $orderCol $app->input->get('filter_order''ordering');
  185.         if (!in_array($orderCol$this->filter_fields))
  186.         {
  187.             $orderCol 'ordering';
  188.         }
  189.         $this->setState('list.ordering'$orderCol);
  190.  
  191.         $listOrder $app->input->get('filter_order_Dir''ASC');
  192.         if (!in_array(strtoupper($listOrder)array('ASC''DESC''')))
  193.         {
  194.             $listOrder 'ASC';
  195.         }
  196.         $this->setState('list.direction'$listOrder);
  197.  
  198.         $user JFactory::getUser();
  199.         if ((!$user->authorise('core.edit.state''com_contact')) && (!$user->authorise('core.edit''com_contact')))
  200.         {
  201.             // Limit to published for people who can't edit or edit.state.
  202.             $this->setState('filter.published'1);
  203.  
  204.             // Filter by start and end dates.
  205.             $this->setState('filter.publish_date'true);
  206.         }
  207.  
  208.         $this->setState('filter.language'JLanguageMultilang::isEnabled());
  209.  
  210.         // Load the parameters.
  211.         $this->setState('params'$params);
  212.     }
  213. }

Documentation generated on Tue, 19 Nov 2013 15:02:54 +0100 by phpDocumentor 1.4.3