Source for file predefinedlist.php

Documentation is available at predefinedlist.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Libraries
  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 to load a list of predefined values
  15.  *
  16.  * @package     Joomla.Libraries
  17.  * @subpackage  Form
  18.  * @since       3.2
  19.  */
  20. abstract class JFormFieldPredefinedList extends JFormFieldList
  21. {
  22.     /**
  23.      * The form field type.
  24.      *
  25.      * @var    string 
  26.      * @since  3.2
  27.      */
  28.     protected $type = 'PredefinedList';
  29.  
  30.     /**
  31.      * Cached array of the category items.
  32.      *
  33.      * @var    array 
  34.      * @since  3.2
  35.      */
  36.     protected static $options array();
  37.  
  38.     /**
  39.      * Available predefined options
  40.      *
  41.      * @var  array 
  42.      * @since  3.2
  43.      */
  44.     protected $predefinedOptions = array();
  45.  
  46.     /**
  47.      * Translate options labels ?
  48.      *
  49.      * @var  boolean 
  50.      * @since  3.2
  51.      */
  52.     protected $translate = true;
  53.  
  54.     /**
  55.      * Method to get the options to populate list
  56.      *
  57.      * @return  array  The field option objects.
  58.      *
  59.      * @since   3.2
  60.      */
  61.     protected function getOptions()
  62.     {
  63.         // Hash for caching
  64.         $hash md5($this->element);
  65.         $type strtolower($this->type);
  66.  
  67.         if (!isset(static::$options[$type][$hash]&& !empty($this->predefinedOptions))
  68.         {
  69.             static::$options[$type][$hashparent::getOptions();
  70.  
  71.             $options array();
  72.  
  73.             // Allow to only use specific values of the predefined list
  74.             $filter = isset($this->element['filter']explode(','$this->element['filter']array();
  75.  
  76.             foreach ($this->predefinedOptions as $value => $text)
  77.             {
  78.                 if (empty($filter|| in_array($value$filter))
  79.                 {
  80.                     $text $this->translate ? JText::_($text$text;
  81.  
  82.                     $options[= (object) array(
  83.                         'value' => $value,
  84.                         'text'  => $text
  85.                     );
  86.                 }
  87.             }
  88.  
  89.             static::$options[$type][$hasharray_merge(static::$options[$type][$hash]$options);
  90.         }
  91.  
  92.         return static::$options[$type][$hash];
  93.     }
  94. }

Documentation generated on Tue, 19 Nov 2013 15:11:12 +0100 by phpDocumentor 1.4.3