Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
range.php
Aller à la documentation de ce fichier.
1 <?php
2 /**
3  * @package Joomla.Platform
4  * @subpackage Form
5  *
6  * @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
7  * @license GNU General Public License version 2 or later; see LICENSE
8  */
9 
10 defined('JPATH_PLATFORM') or die;
11 
12 JFormHelper::loadFieldClass('number');
13 
14 /**
15  * Form Field class for the Joomla Platform.
16  * Provides a horizontal scroll bar to specify a value in a range.
17  *
18  * @package Joomla.Platform
19  * @subpackage Form
20  * @link http://www.w3.org/TR/html-markup/input.text.html#input.text
21  * @since 3.2
22  */
24 {
25  /**
26  * The form field type.
27  *
28  * @var string
29  * @since 3.2
30  */
31  protected $type = 'Range';
32 
33  /**
34  * Method to get the field input markup.
35  *
36  * @return string The field input markup.
37  *
38  * @since 3.2
39  */
40  protected function getInput()
41  {
42  // Initialize some field attributes.
43  $max = !empty($this->max) ? ' max="' . $this->max . '"' : '';
44  $min = !empty($this->min) ? ' min="' . $this->min . '"' : '';
45  $step = !empty($this->step) ? ' step="' . $this->step . '"' : '';
46  $class = !empty($this->class) ? ' class="' . $this->class . '"' : '';
47  $readonly = $this->readonly ? ' readonly' : '';
48  $disabled = $this->disabled ? ' disabled' : '';
49 
50  $autofocus = $this->autofocus ? ' autofocus' : '';
51 
52  $value = (float) $this->value;
53  $value = empty($value) ? $this->min : $value;
54 
55  // Initialize JavaScript field attributes.
56  $onchange = !empty($this->onchange) ? ' onchange="' . $this->onchange . '"' : '';
57 
58  // Including fallback code for HTML5 non supported browsers.
59  JHtml::_('jquery.framework');
60  JHtml::_('script', 'system/html5fallback.js', false, true);
61 
62  return '<input type="range" name="' . $this->name . '" id="' . $this->id . '"' . ' value="'
63  . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '"' . $class . $disabled . $readonly
64  . $onchange . $max . $step . $min . $autofocus . ' />';
65  }
66 }