Source for file textarea.php

Documentation is available at textarea.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.  * Form Field class for the Joomla Platform.
  14.  * Supports a multi line area for entry of plain text
  15.  *
  16.  * @package     Joomla.Platform
  17.  * @subpackage  Form
  18.  * @link        http://www.w3.org/TR/html-markup/textarea.html#textarea
  19.  * @since       11.1
  20.  */
  21. {
  22.     /**
  23.      * The form field type.
  24.      *
  25.      * @var    string 
  26.      * @since  11.1
  27.      */
  28.     protected $type = 'Textarea';
  29.  
  30.     /**
  31.      * The number of rows in textarea.
  32.      *
  33.      * @var    mixed 
  34.      * @since  3.2
  35.      */
  36.     protected $rows;
  37.  
  38.     /**
  39.      * The number of columns in textarea.
  40.      *
  41.      * @var    mixed 
  42.      * @since  3.2
  43.      */
  44.     protected $columns;
  45.  
  46.     /**
  47.      * Method to get certain otherwise inaccessible properties from the form field object.
  48.      *
  49.      * @param   string  $name  The property name for which to the the value.
  50.      *
  51.      * @return  mixed  The property value or null.
  52.      *
  53.      * @since   3.2
  54.      */
  55.     public function __get($name)
  56.     {
  57.         switch ($name)
  58.         {
  59.             case 'rows':
  60.             case 'columns':
  61.                 return $this->$name;
  62.         }
  63.  
  64.         return parent::__get($name);
  65.     }
  66.  
  67.     /**
  68.      * Method to set certain otherwise inaccessible properties of the form field object.
  69.      *
  70.      * @param   string  $name   The property name for which to the the value.
  71.      * @param   mixed   $value  The value of the property.
  72.      *
  73.      * @return  void 
  74.      *
  75.      * @since   3.2
  76.      */
  77.     public function __set($name$value)
  78.     {
  79.         switch ($name)
  80.         {
  81.             case 'rows':
  82.             case 'columns':
  83.                 $this->name = (int) $value;
  84.                 break;
  85.  
  86.             default:
  87.                 parent::__set($name$value);
  88.         }
  89.     }
  90.  
  91.     /**
  92.      * Method to attach a JForm object to the field.
  93.      *
  94.      * @param   SimpleXMLElement  $element  The SimpleXMLElement object representing the <field /> tag for the form field object.
  95.      * @param   mixed             $value    The form field value to validate.
  96.      * @param   string            $group    The field name group control value. This acts as as an array container for the field.
  97.      *                                       For example if the field has name="foo" and the group value is set to "bar" then the
  98.      *                                       full field name would end up being "bar[foo]".
  99.      *
  100.      * @return  boolean  True on success.
  101.      *
  102.      * @see     JFormField::setup()
  103.      * @since   3.2
  104.      */
  105.     public function setup(SimpleXMLElement $element$value$group null)
  106.     {
  107.         $return parent::setup($element$value$group);
  108.  
  109.         if ($return)
  110.         {
  111.             $this->rows    = isset($this->element['rows']? (int) $this->element['rows'false;
  112.             $this->columns = isset($this->element['cols']? (int) $this->element['cols'false;
  113.         }
  114.  
  115.         return $return;
  116.     }
  117.  
  118.     /**
  119.      * Method to get the textarea field input markup.
  120.      * Use the rows and columns attributes to specify the dimensions of the area.
  121.      *
  122.      * @return  string  The field input markup.
  123.      *
  124.      * @since   11.1
  125.      */
  126.     protected function getInput()
  127.     {
  128.         // Translate placeholder text
  129.         $hint $this->translateHint ? JText::_($this->hint$this->hint;
  130.  
  131.         // Initialize some field attributes.
  132.         $class        !empty($this->class' class="' $this->class . '"' '';
  133.         $disabled     $this->disabled ? ' disabled' '';
  134.         $readonly     $this->readonly ? ' readonly' '';
  135.         $columns      $this->columns ? ' cols="' $this->columns . '"' '';
  136.         $rows         $this->rows ? ' rows="' $this->rows . '"' '';
  137.         $required     $this->required ? ' required aria-required="true"' '';
  138.         $hint         $hint ' placeholder="' $hint '"' '';
  139.         $autocomplete !$this->autocomplete ? ' autocomplete="off"' ' autocomplete="' $this->autocomplete . '"';
  140.         $autocomplete $autocomplete == ' autocomplete="on"' '' $autocomplete;
  141.         $autofocus    $this->autofocus ? ' autofocus' '';
  142.         $spellcheck   $this->spellcheck ? '' ' spellcheck="false"';
  143.  
  144.         // Initialize JavaScript field attributes.
  145.         $onchange $this->onchange ? ' onchange="' $this->onchange . '"' '';
  146.         $onclick $this->onclick ? ' onclick="' $this->onclick . '"' '';
  147.  
  148.         // Including fallback code for HTML5 non supported browsers.
  149.         JHtml::_('jquery.framework');
  150.         JHtml::_('script''system/html5fallback.js'falsetrue);
  151.  
  152.         return '<textarea name="' $this->name . '" id="' $this->id . '"' $columns $rows $class
  153.             . $hint $disabled $readonly $onchange $onclick $required $autocomplete $autofocus $spellcheck ' >'
  154.             . htmlspecialchars($this->valueENT_COMPAT'UTF-8''</textarea>';
  155.     }
  156. }

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