Source for file usergroup.php

Documentation is available at usergroup.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Platform
  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.  * Form Field class for the Joomla Platform.
  14.  * Supports a nested check box field listing user groups.
  15.  * Multiselect is available by default.
  16.  *
  17.  * @package     Joomla.Platform
  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.     protected $type = 'Usergroup';
  29.  
  30.     /**
  31.      * Method to get the user group field input markup.
  32.      *
  33.      * @return  string  The field input markup.
  34.      *
  35.      * @since   11.1
  36.      */
  37.     protected function getInput()
  38.     {
  39.         $options = array();
  40.         $attr = '';
  41.  
  42.         // Initialize some field attributes.
  43.         $attr .= !empty($this->class) ? ' class="' . $this->class . '"' : '';
  44.         $attr .= $this->disabled ? ' disabled' : '';
  45.         $attr .= $this->size ? ' size="' . $this->size . '"' : '';
  46.         $attr .= $this->multiple ? ' multiple' : '';
  47.         $attr .= $this->required ? ' required aria-required="true"' : '';
  48.         $attr .= $this->autofocus ? ' autofocus' : '';
  49.  
  50.         // Initialize JavaScript field attributes.
  51.         $attr .= !empty($this->onchange) ? ' onchange="' . $this->onchange . '"' : '';
  52.         $attr .= !empty($this->onclick) ? ' onclick="' . $this->onclick . '"' : '';
  53.  
  54.         // Iterate through the children and build an array of options.
  55.         foreach ($this->element->children() as $option)
  56.         {
  57.             // Only add <option /> elements.
  58.             if ($option->getName() != 'option')
  59.             {
  60.                 continue;
  61.             }
  62.  
  63.             $disabled = (string) $option['disabled'];
  64.             $disabled = ($disabled == 'true' || $disabled == 'disabled' || $disabled == '1');
  65.  
  66.             // Create a new option object based on the <option /> element.
  67.             $tmp = JHtml::_(
  68.                 'select.option', (string) $option['value'], trim((string) $option), 'value', 'text',
  69.                 $disabled
  70.             );
  71.  
  72.             // Set some option attributes.
  73.             $tmp->class = (string) $option['class'];
  74.  
  75.             // Set some JavaScript option attributes.
  76.             $tmp->onclick = (string) $option['onclick'];
  77.  
  78.             // Add the option object to the result set.
  79.             $options[] = $tmp;
  80.         }
  81.  
  82.         return JHtml::_('access.usergroup', $this->name, $this->value, $attr, $options, $this->id);
  83.     }
  84. }

Documentation generated on Tue, 19 Nov 2013 15:16:35 +0100 by phpDocumentor 1.4.3