Source for file category.php

Documentation is available at category.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Legacy
  4.  * @subpackage  Form
  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
  8.  */
  9.  
  10. defined('JPATH_PLATFORM'or die;
  11.  
  12.  
  13. /**
  14.  * Form Field class for the Joomla Platform.
  15.  * Supports an HTML select list of categories
  16.  *
  17.  * @package     Joomla.Legacy
  18.  * @subpackage  Form
  19.  * @since       11.1
  20.  */
  21. {
  22.     /**
  23.      * The form field type.
  24.      *
  25.      * @var    string 
  26.      * @since  11.1
  27.      */
  28.     public $type = 'Category';
  29.  
  30.     /**
  31.      * Method to get the field options for category
  32.      * Use the extension attribute in a form to specify the.specific extension for
  33.      * which categories should be displayed.
  34.      * Use the show_root attribute to specify whether to show the global category root in the list.
  35.      *
  36.      * @return  array    The field option objects.
  37.      *
  38.      * @since   11.1
  39.      */
  40.     protected function getOptions()
  41.     {
  42.         $options array();
  43.         $extension $this->element['extension'? (string) $this->element['extension': (string) $this->element['scope'];
  44.         $published = (string) $this->element['published'];
  45.  
  46.         // Load the category options for a given extension.
  47.         if (!empty($extension))
  48.         {
  49.             // Filter over published state or not depending upon if it is present.
  50.             if ($published)
  51.             {
  52.                 $options JHtml::_('category.options'$extensionarray('filter.published' => explode(','$published)));
  53.             }
  54.             else
  55.             {
  56.                 $options JHtml::_('category.options'$extension);
  57.             }
  58.  
  59.             // Verify permissions.  If the action attribute is set, then we scan the options.
  60.             if ((string) $this->element['action'])
  61.             {
  62.  
  63.                 // Get the current user object.
  64.                 $user JFactory::getUser();
  65.  
  66.                 foreach ($options as $i => $option)
  67.                 {
  68.                     /*
  69.                      * To take save or create in a category you need to have create rights for that category
  70.                      * unless the item is already in that category.
  71.                      * Unset the option if the user isn't authorised for it. In this field assets are always categories.
  72.                      */
  73.                     if ($user->authorise('core.create'$extension '.category.' $option->value!= true)
  74.                     {
  75.                         unset($options[$i]);
  76.                     }
  77.                 }
  78.  
  79.             }
  80.  
  81.             if (isset($this->element['show_root']))
  82.             {
  83.                 array_unshift($optionsJHtml::_('select.option''0'JText::_('JGLOBAL_ROOT')));
  84.             }
  85.         }
  86.         else
  87.         {
  88.             JLog::add(JText::_('JLIB_FORM_ERROR_FIELDS_CATEGORY_ERROR_EXTENSION_EMPTY')JLog::WARNING'jerror');
  89.         }
  90.  
  91.         // Merge any additional options in the XML definition.
  92.         $options array_merge(parent::getOptions()$options);
  93.  
  94.         return $options;
  95.     }
  96. }

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