Source for file url.php

Documentation is available at url.php

  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.  
  13. /**
  14.  * Form Field class for the Joomla Platform.
  15.  * Supports a URL text field
  16.  *
  17.  * @package     Joomla.Platform
  18.  * @subpackage  Form
  19.  * @link        http://www.w3.org/TR/html-markup/input.url.html#input.url
  20.  * @see         JFormRuleUrl for validation of full urls
  21.  * @since       11.1
  22.  */
  23. class JFormFieldUrl extends JFormFieldText
  24. {
  25.     /**
  26.      * The form field type.
  27.      *
  28.      * @var    string 
  29.      * @since  11.1
  30.      */
  31.     protected $type = 'Url';
  32.  
  33.     /**
  34.      * Method to get the field input markup.
  35.      *
  36.      * @return  string  The field input markup.
  37.      *
  38.      * @since   3.1.2 (CMS)
  39.      */
  40.     protected function getInput()
  41.     {
  42.         // Translate placeholder text
  43.         $hint = $this->translateHint ? JText::_($this->hint) : $this->hint;
  44.  
  45.         // Initialize some field attributes.
  46.         $size         = !empty($this->size) ? ' size="' . $this->size . '"' : '';
  47.         $maxLength    = !empty($this->maxLength) ? ' maxlength="' . $this->maxLength . '"' : '';
  48.         $class        = !empty($this->class) ? ' class="' . $this->class . '"' : '';
  49.         $readonly     = $this->readonly ? ' readonly' : '';
  50.         $disabled     = $this->disabled ? ' disabled' : '';
  51.         $required     = $this->required ? ' required aria-required="true"' : '';
  52.         $hint         = $hint ? ' placeholder="' . $hint . '"' : '';
  53.         $autocomplete = !$this->autocomplete ? ' autocomplete="off"' : ' autocomplete="' . $this->autocomplete . '"';
  54.         $autocomplete = $autocomplete == ' autocomplete="on"' ? '' : $autocomplete;
  55.         $autofocus    = $this->autofocus ? ' autofocus' : '';
  56.         $spellcheck   = $this->spellcheck ? '' : ' spellcheck="false"';
  57.  
  58.         // Initialize JavaScript field attributes.
  59.         $onchange = !empty($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="url" name="' . $this->name . '"' . $class . ' id="' . $this->id . '" value="'
  66.             . JStringPunycode::urlToUTF8($this->value, ENT_COMPAT, 'UTF-8') . '"' . $size . $disabled . $readonly
  67.             . $hint . $autocomplete . $autofocus . $spellcheck . $onchange . $maxLength . $required . ' />';
  68.     }
  69. }

Documentation generated on Tue, 19 Nov 2013 15:16:17 +0100 by phpDocumentor 1.4.3