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