1<?php
2/**
3 * @package     Joomla.Platform
4 * @subpackage  Form
5 *
6 * @copyright   Copyright (C) 2005 - 2020 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
12JFormHelper::loadFieldClass('list');
13
14/**
15 * Form Field class for the Joomla Platform.
16 * Provides a list of access levels. Access levels control what users in specific
17 * groups can see.
18 *
19 * @see    JAccess
20 * @since  1.7.0
21 */
22class JFormFieldAccessLevel extends JFormFieldList
23{
24	/**
25	 * The form field type.
26	 *
27	 * @var    string
28	 * @since  1.7.0
29	 */
30	protected $type = 'AccessLevel';
31
32	/**
33	 * Method to get the field input markup.
34	 *
35	 * @return  string  The field input markup.
36	 *
37	 * @since   1.7.0
38	 */
39	protected function getInput()
40	{
41		$attr = '';
42
43		// Initialize some field attributes.
44		$attr .= !empty($this->class) ? ' class="' . $this->class . '"' : '';
45		$attr .= $this->disabled ? ' disabled' : '';
46		$attr .= !empty($this->size) ? ' size="' . $this->size . '"' : '';
47		$attr .= $this->multiple ? ' multiple' : '';
48		$attr .= $this->required ? ' required aria-required="true"' : '';
49		$attr .= $this->autofocus ? ' autofocus' : '';
50
51		// Initialize JavaScript field attributes.
52		$attr .= $this->onchange ? ' onchange="' . $this->onchange . '"' : '';
53
54		// Get the field options.
55		$options = $this->getOptions();
56
57		return JHtml::_('access.level', $this->name, $this->value, $attr, $options, $this->id);
58	}
59}
60