Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
tel.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('text');
13 
14 /**
15  * Form Field class for the Joomla Platform.
16  * Supports a text field telephone numbers.
17  *
18  * @package Joomla.Platform
19  * @subpackage Form
20  * @link http://www.w3.org/TR/html-markup/input.tel.html
21  * @see JFormRuleTel for telephone number validation
22  * @see JHtmlTel for rendering of telephone numbers
23  * @since 11.1
24  */
26 {
27  /**
28  * The form field type.
29  *
30  * @var string
31  * @since 11.1
32  */
33  protected $type = 'Tel';
34 
35  /**
36  * Method to get the field input markup.
37  *
38  * @return string The field input markup.
39  *
40  * @since 3.2
41  */
42  protected function getInput()
43  {
44  // Translate placeholder text
45  $hint = $this->translateHint ? JText::_($this->hint) : $this->hint;
46 
47  // Initialize some field attributes.
48  $size = !empty($this->size) ? ' size="' . $this->size . '"' : '';
49  $maxLength = !empty($this->maxLength) ? ' maxlength="' . $this->maxLength . '"' : '';
50  $class = !empty($this->class) ? ' class="' . $this->class . '"' : '';
51  $readonly = $this->readonly ? ' readonly' : '';
52  $disabled = $this->disabled ? ' disabled' : '';
53  $required = $this->required ? ' required aria-required="true"' : '';
54  $hint = $hint ? ' placeholder="' . $hint . '"' : '';
55  $autocomplete = !$this->autocomplete ? ' autocomplete="off"' : ' autocomplete="' . $this->autocomplete . '"';
56  $autocomplete = $autocomplete == ' autocomplete="on"' ? '' : $autocomplete;
57  $autofocus = $this->autofocus ? ' autofocus' : '';
58  $spellcheck = $this->spellcheck ? '' : ' spellcheck="false"';
59 
60  // Initialize JavaScript field attributes.
61  $onchange = $this->onchange ? ' onchange="' . $this->onchange . '"' : '';
62 
63  // Including fallback code for HTML5 non supported browsers.
64  JHtml::_('jquery.framework');
65  JHtml::_('script', 'system/html5fallback.js', false, true);
66 
67  return '<input type="tel" name="' . $this->name . '"' . $class . ' id="' . $this->id . '" value="'
68  . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '"' . $size . $disabled . $readonly
69  . $hint . $autocomplete . $autofocus . $spellcheck . $onchange . $maxLength . $required . ' />';
70  }
71 }