usergroup.php
2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Form Field class for the Joomla Platform.
* Supports a nested checkbox field listing user groups.
* Multiselect is available by default.
*
* @since 1.7.0
* @deprecated 3.5
*/
class JFormFieldUsergroup extends JFormField
{
/**
* The form field type.
*
* @var string
* @since 1.7.0
*/
protected $type = 'Usergroup';
/**
* Method to get the user group field input markup.
*
* @return string The field input markup.
*
* @since 1.7.0
*/
protected function getInput()
{
JLog::add('JFormFieldUsergroup is deprecated. Use JFormFieldUserGroupList instead.', JLog::WARNING, 'deprecated');
$options = array();
$attr = '';
// Initialize some field attributes.
$attr .= !empty($this->class) ? ' class="' . $this->class . '"' : '';
$attr .= $this->disabled ? ' disabled' : '';
$attr .= $this->size ? ' size="' . $this->size . '"' : '';
$attr .= $this->multiple ? ' multiple' : '';
$attr .= $this->required ? ' required aria-required="true"' : '';
$attr .= $this->autofocus ? ' autofocus' : '';
// Initialize JavaScript field attributes.
$attr .= !empty($this->onchange) ? ' onchange="' . $this->onchange . '"' : '';
$attr .= !empty($this->onclick) ? ' onclick="' . $this->onclick . '"' : '';
// Iterate through the children and build an array of options.
foreach ($this->element->children() as $option)
{
// Only add <option /> elements.
if ($option->getName() != 'option')
{
continue;
}
$disabled = (string) $option['disabled'];
$disabled = ($disabled == 'true' || $disabled == 'disabled' || $disabled == '1');
// Create a new option object based on the <option /> element.
$tmp = JHtml::_(
'select.option', (string) $option['value'], trim((string) $option), 'value', 'text',
$disabled
);
// Set some option attributes.
$tmp->class = (string) $option['class'];
// Set some JavaScript option attributes.
$tmp->onclick = (string) $option['onclick'];
// Add the option object to the result set.
$options[] = $tmp;
}
return JHtml::_('access.usergroup', $this->name, $this->value, $attr, $options, $this->id);
}
}