PageRenderTime 17ms CodeModel.GetById 12ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/libraries/joomla/form/fields/usergroup.php

https://gitlab.com/vitaliylukin91/text
PHP | 86 lines | 37 code | 13 blank | 36 comment | 7 complexity | 1c6031efcab5f71a5038a4f630d63e27 MD5 | raw file
 1<?php
 2/**
 3 * @package     Joomla.Platform
 4 * @subpackage  Form
 5 *
 6 * @copyright   Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
 7 * @license     GNU General Public License version 2 or later; see LICENSE
 8 */
 9
10defined('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 * @since       11.1
18 * @deprecated  3.5
19 */
20class JFormFieldUsergroup extends JFormField
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		JLog::add('JFormFieldUsergroup is deprecated. Use JFormFieldUserGroupList instead.', JLog::WARNING, 'deprecated');
40
41		$options = array();
42		$attr = '';
43
44		// Initialize some field attributes.
45		$attr .= !empty($this->class) ? ' class="' . $this->class . '"' : '';
46		$attr .= $this->disabled ? ' disabled' : '';
47		$attr .= $this->size ? ' size="' . $this->size . '"' : '';
48		$attr .= $this->multiple ? ' multiple' : '';
49		$attr .= $this->required ? ' required aria-required="true"' : '';
50		$attr .= $this->autofocus ? ' autofocus' : '';
51
52		// Initialize JavaScript field attributes.
53		$attr .= !empty($this->onchange) ? ' onchange="' . $this->onchange . '"' : '';
54		$attr .= !empty($this->onclick) ? ' onclick="' . $this->onclick . '"' : '';
55
56		// Iterate through the children and build an array of options.
57		foreach ($this->element->children() as $option)
58		{
59			// Only add <option /> elements.
60			if ($option->getName() != 'option')
61			{
62				continue;
63			}
64
65			$disabled = (string) $option['disabled'];
66			$disabled = ($disabled == 'true' || $disabled == 'disabled' || $disabled == '1');
67
68			// Create a new option object based on the <option /> element.
69			$tmp = JHtml::_(
70				'select.option', (string) $option['value'], trim((string) $option), 'value', 'text',
71				$disabled
72			);
73
74			// Set some option attributes.
75			$tmp->class = (string) $option['class'];
76
77			// Set some JavaScript option attributes.
78			$tmp->onclick = (string) $option['onclick'];
79
80			// Add the option object to the result set.
81			$options[] = $tmp;
82		}
83
84		return JHtml::_('access.usergroup', $this->name, $this->value, $attr, $options, $this->id);
85	}
86}