Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
url.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 URL text field
17  *
18  * @package Joomla.Platform
19  * @subpackage Form
20  * @link http://www.w3.org/TR/html-markup/input.url.html#input.url
21  * @see JFormRuleUrl for validation of full urls
22  * @since 11.1
23  */
25 {
26  /**
27  * The form field type.
28  *
29  * @var string
30  * @since 11.1
31  */
32  protected $type = 'Url';
33 
34  /**
35  * Method to get the field input markup.
36  *
37  * @return string The field input markup.
38  *
39  * @since 3.1.2 (CMS)
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="' . $this->class . '"' : '';
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  $spellcheck = $this->spellcheck ? '' : ' spellcheck="false"';
58 
59  // Initialize JavaScript field attributes.
60  $onchange = !empty($this->onchange) ? ' onchange="' . $this->onchange . '"' : '';
61 
62  // Including fallback code for HTML5 non supported browsers.
63  JHtml::_('jquery.framework');
64  JHtml::_('script', 'system/html5fallback.js', false, true);
65 
66  return '<input type="url" name="' . $this->name . '"' . $class . ' id="' . $this->id . '" value="'
67  . JStringPunycode::urlToUTF8($this->value, ENT_COMPAT, 'UTF-8') . '"' . $size . $disabled . $readonly
68  . $hint . $autocomplete . $autofocus . $spellcheck . $onchange . $maxLength . $required . ' />';
69  }
70 }