/libraries/joomla/form/fields/range.php

https://gitlab.com/vitaliylukin91/lavka · PHP · 64 lines · 25 code · 9 blank · 30 comment · 0 complexity · 18ee8339a7dd9aa224b3285b755823d6 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. JFormHelper::loadFieldClass('number');
  11. /**
  12. * Form Field class for the Joomla Platform.
  13. * Provides a horizontal scroll bar to specify a value in a range.
  14. *
  15. * @link http://www.w3.org/TR/html-markup/input.text.html#input.text
  16. * @since 3.2
  17. */
  18. class JFormFieldRange extends JFormFieldNumber
  19. {
  20. /**
  21. * The form field type.
  22. *
  23. * @var string
  24. * @since 3.2
  25. */
  26. protected $type = 'Range';
  27. /**
  28. * Method to get the field input markup.
  29. *
  30. * @return string The field input markup.
  31. *
  32. * @since 3.2
  33. */
  34. protected function getInput()
  35. {
  36. // Initialize some field attributes.
  37. $max = !empty($this->max) ? ' max="' . $this->max . '"' : '';
  38. $min = !empty($this->min) ? ' min="' . $this->min . '"' : '';
  39. $step = !empty($this->step) ? ' step="' . $this->step . '"' : '';
  40. $class = !empty($this->class) ? ' class="' . $this->class . '"' : '';
  41. $readonly = $this->readonly ? ' readonly' : '';
  42. $disabled = $this->disabled ? ' disabled' : '';
  43. $autofocus = $this->autofocus ? ' autofocus' : '';
  44. $value = (float) $this->value;
  45. $value = empty($value) ? $this->min : $value;
  46. // Initialize JavaScript field attributes.
  47. $onchange = !empty($this->onchange) ? ' onchange="' . $this->onchange . '"' : '';
  48. // Including fallback code for HTML5 non supported browsers.
  49. JHtml::_('jquery.framework');
  50. JHtml::_('script', 'system/html5fallback.js', false, true);
  51. return '<input type="range" name="' . $this->name . '" id="' . $this->id . '"' . ' value="'
  52. . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '"' . $class . $disabled . $readonly
  53. . $onchange . $max . $step . $min . $autofocus . ' />';
  54. }
  55. }