Source for file categories.php

Documentation is available at categories.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.  * This models supports retrieving lists of contact categories.
  14.  *
  15.  * @package     Joomla.Site
  16.  * @subpackage  com_contact
  17.  * @since       1.6
  18.  */
  19. {
  20.     /**
  21.      * Model context string.
  22.      *
  23.      * @var        string 
  24.      */
  25.     public $_context = 'com_contact.categories';
  26.  
  27.     /**
  28.      * The category context (allows other extensions to derived from this model).
  29.      *
  30.      * @var        string 
  31.      */
  32.     protected $_extension = 'com_contact';
  33.  
  34.     private $_parent null;
  35.  
  36.     private $_items null;
  37.  
  38.     /**
  39.      * Method to auto-populate the model state.
  40.      *
  41.      * Note. Calling getState in this method will result in recursion.
  42.      *
  43.      * @since   1.6
  44.      */
  45.     protected function populateState($ordering null$direction null)
  46.     {
  47.         $app JFactory::getApplication();
  48.         $this->setState('filter.extension'$this->_extension);
  49.  
  50.         // Get the parent id if defined.
  51.         $parentId $app->input->getInt('id');
  52.         $this->setState('filter.parentId'$parentId);
  53.  
  54.         $params $app->getParams();
  55.         $this->setState('params'$params);
  56.  
  57.         $this->setState('filter.published',    1);
  58.         $this->setState('filter.access',    true);
  59.     }
  60.  
  61.     /**
  62.      * Method to get a store id based on model configuration state.
  63.      *
  64.      * This is necessary because the model is used by the component and
  65.      * different modules that might need different sets of data or different
  66.      * ordering requirements.
  67.      *
  68.      * @param   string  $id    A prefix for the store id.
  69.      *
  70.      * @return  string  A store id.
  71.      */
  72.     protected function getStoreId($id '')
  73.     {
  74.         // Compile the store id.
  75.         $id    .= ':'.$this->getState('filter.extension');
  76.         $id    .= ':'.$this->getState('filter.published');
  77.         $id    .= ':'.$this->getState('filter.access');
  78.         $id    .= ':'.$this->getState('filter.parentId');
  79.  
  80.         return parent::getStoreId($id);
  81.     }
  82.  
  83.     /**
  84.      * redefine the function an add some properties to make the styling more easy
  85.      *
  86.      * @return mixed An array of data items on success, false on failure.
  87.      */
  88.     public function getItems()
  89.     {
  90.         if (!count($this->_items))
  91.         {
  92.             $app JFactory::getApplication();
  93.             $menu $app->getMenu();
  94.             $active $menu->getActive();
  95.             $params new JRegistry;
  96.             if ($active)
  97.             {
  98.                 $params->loadString($active->params);
  99.             }
  100.             $options array();
  101.             $options['countItems'$params->get('show_cat_items_cat'1|| !$params->get('show_empty_categories_cat'0);
  102.             $categories JCategories::getInstance('Contact'$options);
  103.             $this->_parent $categories->get($this->getState('filter.parentId''root'));
  104.             if (is_object($this->_parent))
  105.             {
  106.                 $this->_items $this->_parent->getChildren();
  107.             else {
  108.                 $this->_items false;
  109.             }
  110.         }
  111.  
  112.         return $this->_items;
  113.     }
  114.  
  115.     public function getParent()
  116.     {
  117.         if (!is_object($this->_parent))
  118.         {
  119.             $this->getItems();
  120.         }
  121.         return $this->_parent;
  122.     }
  123. }

Documentation generated on Tue, 19 Nov 2013 14:55:05 +0100 by phpDocumentor 1.4.3