PageRenderTime 21ms CodeModel.GetById 15ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/libraries/joomla/form/fields/email.php

https://gitlab.com/vitaliylukin91/text
PHP | 69 lines | 29 code | 8 blank | 32 comment | 1 complexity | 9e6ce038e15f01a9e5ff0f1b1ac76b53 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
10defined('JPATH_PLATFORM') or die;
11
12JFormHelper::loadFieldClass('text');
13
14/**
15 * Form Field class for the Joomla Platform.
16 * Provides and input field for e-mail addresses
17 *
18 * @link   http://www.w3.org/TR/html-markup/input.email.html#input.email
19 * @see    JFormRuleEmail
20 * @since  11.1
21 */
22class JFormFieldEMail extends JFormFieldText
23{
24	/**
25	 * The form field type.
26	 *
27	 * @var    string
28	 * @since  11.1
29	 */
30	protected $type = 'Email';
31
32	/**
33	 * Method to get the field input markup for e-mail addresses.
34	 *
35	 * @return  string  The field input markup.
36	 *
37	 * @since   11.1
38	 */
39	protected function getInput()
40	{
41		// Translate placeholder text
42		$hint = $this->translateHint ? JText::_($this->hint) : $this->hint;
43
44		// Initialize some field attributes.
45		$size         = !empty($this->size) ? ' size="' . $this->size . '"' : '';
46		$maxLength    = !empty($this->maxLength) ? ' maxlength="' . $this->maxLength . '"' : '';
47		$class        = !empty($this->class) ? ' class="validate-email ' . $this->class . '"' : ' class="validate-email"';
48		$readonly     = $this->readonly ? ' readonly' : '';
49		$disabled     = $this->disabled ? ' disabled' : '';
50		$required     = $this->required ? ' required aria-required="true"' : '';
51		$hint         = $hint ? ' placeholder="' . $hint . '"' : '';
52		$autocomplete = !$this->autocomplete ? ' autocomplete="off"' : ' autocomplete="' . $this->autocomplete . '"';
53		$autocomplete = $autocomplete == ' autocomplete="on"' ? '' : $autocomplete;
54		$autofocus    = $this->autofocus ? ' autofocus' : '';
55		$multiple     = $this->multiple ? ' multiple' : '';
56		$spellcheck   = $this->spellcheck ? '' : ' spellcheck="false"';
57
58		// Initialize JavaScript field attributes.
59		$onchange = $this->onchange ? ' onchange="' . $this->onchange . '"' : '';
60
61		// Including fallback code for HTML5 non supported browsers.
62		JHtml::_('jquery.framework');
63		JHtml::_('script', 'system/html5fallback.js', false, true);
64
65		return '<input type="email" name="' . $this->name . '"' . $class . ' id="' . $this->id . '" value="'
66			. htmlspecialchars(JStringPunycode::emailToUTF8($this->value), ENT_COMPAT, 'UTF-8') . '"' . $spellcheck . $size . $disabled . $readonly
67			. $onchange . $autocomplete . $multiple . $maxLength . $hint . $required . $autofocus . ' />';
68	}
69}