/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. defined('JPATH_PLATFORM') or die;
  10. /**
  11. * Form Field class for the Joomla Platform.
  12. * Supports a nested check box field listing user groups.
  13. * Multiselect is available by default.
  14. *
  15. * @since 11.1
  16. * @deprecated 3.5
  17. */
  18. class JFormFieldUsergroup extends JFormField
  19. {
  20. /**
  21. * The form field type.
  22. *
  23. * @var string
  24. * @since 11.1
  25. */
  26. protected $type = 'Usergroup';
  27. /**
  28. * Method to get the user group field input markup.
  29. *
  30. * @return string The field input markup.
  31. *
  32. * @since 11.1
  33. */
  34. protected function getInput()
  35. {
  36. JLog::add('JFormFieldUsergroup is deprecated. Use JFormFieldUserGroupList instead.', JLog::WARNING, 'deprecated');
  37. $options = array();
  38. $attr = '';
  39. // Initialize some field attributes.
  40. $attr .= !empty($this->class) ? ' class="' . $this->class . '"' : '';
  41. $attr .= $this->disabled ? ' disabled' : '';
  42. $attr .= $this->size ? ' size="' . $this->size . '"' : '';
  43. $attr .= $this->multiple ? ' multiple' : '';
  44. $attr .= $this->required ? ' required aria-required="true"' : '';
  45. $attr .= $this->autofocus ? ' autofocus' : '';
  46. // Initialize JavaScript field attributes.
  47. $attr .= !empty($this->onchange) ? ' onchange="' . $this->onchange . '"' : '';
  48. $attr .= !empty($this->onclick) ? ' onclick="' . $this->onclick . '"' : '';
  49. // Iterate through the children and build an array of options.
  50. foreach ($this->element->children() as $option)
  51. {
  52. // Only add <option /> elements.
  53. if ($option->getName() != 'option')
  54. {
  55. continue;
  56. }
  57. $disabled = (string) $option['disabled'];
  58. $disabled = ($disabled == 'true' || $disabled == 'disabled' || $disabled == '1');
  59. // Create a new option object based on the <option /> element.
  60. $tmp = JHtml::_(
  61. 'select.option', (string) $option['value'], trim((string) $option), 'value', 'text',
  62. $disabled
  63. );
  64. // Set some option attributes.
  65. $tmp->class = (string) $option['class'];
  66. // Set some JavaScript option attributes.
  67. $tmp->onclick = (string) $option['onclick'];
  68. // Add the option object to the result set.
  69. $options[] = $tmp;
  70. }
  71. return JHtml::_('access.usergroup', $this->name, $this->value, $attr, $options, $this->id);
  72. }
  73. }