Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
email.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  * Provides and input field for e-mail addresses
17  *
18  * @package Joomla.Platform
19  * @subpackage Form
20  * @link http://www.w3.org/TR/html-markup/input.email.html#input.email
21  * @see JFormRuleEmail
22  * @since 11.1
23  */
25 {
26  /**
27  * The form field type.
28  *
29  * @var string
30  * @since 11.1
31  */
32  protected $type = 'Email';
33 
34  /**
35  * Method to get the field input markup for e-mail addresses.
36  *
37  * @return string The field input markup.
38  *
39  * @since 11.1
40  */
41  protected function getInput()
42  {
43  // Translate placeholder text
44  $hint = $this->translateHint ? JText::_($this->hint) : $this->hint;
45 
46  // Initialize some field attributes.
47  $size = !empty($this->size) ? ' size="' . $this->size . '"' : '';
48  $maxLength = !empty($this->maxLength) ? ' maxlength="' . $this->maxLength . '"' : '';
49  $class = !empty($this->class) ? ' class="validate-email ' . $this->class . '"' : ' class="validate-email"';
50  $readonly = $this->readonly ? ' readonly' : '';
51  $disabled = $this->disabled ? ' disabled' : '';
52  $required = $this->required ? ' required aria-required="true"' : '';
53  $hint = $hint ? ' placeholder="' . $hint . '"' : '';
54  $autocomplete = !$this->autocomplete ? ' autocomplete="off"' : ' autocomplete="' . $this->autocomplete . '"';
55  $autocomplete = $autocomplete == ' autocomplete="on"' ? '' : $autocomplete;
56  $autofocus = $this->autofocus ? ' autofocus' : '';
57  $multiple = $this->multiple ? ' multiple' : '';
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="email" name="' . $this->name . '"' . $class . ' id="' . $this->id . '" value="'
68  . JStringPunycode::emailToUTF8($this->value, ENT_COMPAT, 'UTF-8') . '"' . $spellcheck . $size . $disabled . $readonly . $onchange . $autocomplete
69  . $multiple . $maxLength . $hint . $required . $autofocus . ' />';
70  }
71 }