Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402]
1 <?php 2 /* vim: set expandtab tabstop=4 shiftwidth=4: */ 3 // +----------------------------------------------------------------------+ 4 // | PHP version 4.0 | 5 // +----------------------------------------------------------------------+ 6 // | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group | 7 // +----------------------------------------------------------------------+ 8 // | This source file is subject to version 2.0 of the PHP license, | 9 // | that is bundled with this package in the file LICENSE, and is | 10 // | available at through the world-wide-web at | 11 // | http://www.php.net/license/2_02.txt. | 12 // | If you did not receive a copy of the PHP license and are unable to | 13 // | obtain it through the world-wide-web, please send a note to | 14 // | license@php.net so we can mail you a copy immediately. | 15 // +----------------------------------------------------------------------+ 16 // | Authors: Adam Daniel <adaniel1@eesus.jnj.com> | 17 // | Bertrand Mansion <bmansion@mamasam.com> | 18 // +----------------------------------------------------------------------+ 19 // 20 // $Id$ 21 22 require_once("HTML/QuickForm/element.php"); 23 24 /** 25 * HTML class for a textarea type field 26 * 27 * @author Adam Daniel <adaniel1@eesus.jnj.com> 28 * @author Bertrand Mansion <bmansion@mamasam.com> 29 * @version 1.0 30 * @since PHP4.04pl1 31 * @access public 32 */ 33 class HTML_QuickForm_textarea extends HTML_QuickForm_element 34 { 35 // {{{ properties 36 37 /** 38 * Field value 39 * @var string 40 * @since 1.0 41 * @access private 42 */ 43 var $_value = null; 44 45 // }}} 46 // {{{ constructor 47 48 /** 49 * Class constructor 50 * 51 * @param string Input field name attribute 52 * @param mixed Label(s) for a field 53 * @param mixed Either a typical HTML attribute string or an associative array 54 * @since 1.0 55 * @access public 56 * @return void 57 */ 58 public function __construct($elementName=null, $elementLabel=null, $attributes=null) { 59 parent::__construct($elementName, $elementLabel, $attributes); 60 $this->_persistantFreeze = true; 61 $this->_type = 'textarea'; 62 } //end constructor 63 64 /** 65 * Old syntax of class constructor. Deprecated in PHP7. 66 * 67 * @deprecated since Moodle 3.1 68 */ 69 public function HTML_QuickForm_textarea($elementName=null, $elementLabel=null, $attributes=null) { 70 debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); 71 self::__construct($elementName, $elementLabel, $attributes); 72 } 73 74 // }}} 75 // {{{ setName() 76 77 /** 78 * Sets the input field name 79 * 80 * @param string $name Input field name attribute 81 * @since 1.0 82 * @access public 83 * @return void 84 */ 85 function setName($name) 86 { 87 $this->updateAttributes(array('name'=>$name)); 88 } //end func setName 89 90 // }}} 91 // {{{ getName() 92 93 /** 94 * Returns the element name 95 * 96 * @since 1.0 97 * @access public 98 * @return string 99 */ 100 function getName() 101 { 102 return $this->getAttribute('name'); 103 } //end func getName 104 105 // }}} 106 // {{{ setValue() 107 108 /** 109 * Sets value for textarea element 110 * 111 * @param string $value Value for textarea element 112 * @since 1.0 113 * @access public 114 * @return void 115 */ 116 function setValue($value) 117 { 118 $this->_value = $value; 119 } //end func setValue 120 121 // }}} 122 // {{{ getValue() 123 124 /** 125 * Returns the value of the form element 126 * 127 * @since 1.0 128 * @access public 129 * @return string 130 */ 131 function getValue() 132 { 133 return $this->_value; 134 } // end func getValue 135 136 // }}} 137 // {{{ setWrap() 138 139 /** 140 * Sets wrap type for textarea element 141 * 142 * @param string $wrap Wrap type 143 * @since 1.0 144 * @access public 145 * @return void 146 */ 147 function setWrap($wrap) 148 { 149 $this->updateAttributes(array('wrap' => $wrap)); 150 } //end func setWrap 151 152 // }}} 153 // {{{ setRows() 154 155 /** 156 * Sets height in rows for textarea element 157 * 158 * @param string $rows Height expressed in rows 159 * @since 1.0 160 * @access public 161 * @return void 162 */ 163 function setRows($rows) 164 { 165 $this->updateAttributes(array('rows' => $rows)); 166 } //end func setRows 167 168 // }}} 169 // {{{ setCols() 170 171 /** 172 * Sets width in cols for textarea element 173 * 174 * @param string $cols Width expressed in cols 175 * @since 1.0 176 * @access public 177 * @return void 178 */ 179 function setCols($cols) 180 { 181 $this->updateAttributes(array('cols' => $cols)); 182 } //end func setCols 183 184 // }}} 185 // {{{ toHtml() 186 187 /** 188 * Returns the textarea element in HTML 189 * 190 * @since 1.0 191 * @access public 192 * @return string 193 */ 194 function toHtml() 195 { 196 if ($this->_flagFrozen) { 197 return $this->getFrozenHtml(); 198 } else { 199 return $this->_getTabs() . 200 '<textarea' . $this->_getAttrString($this->_attributes) . '>' . 201 // because we wrap the form later we don't want the text indented 202 preg_replace("/(\r\n|\n|\r)/", '
', htmlspecialchars($this->_value ?? '')) . 203 '</textarea>'; 204 } 205 } //end func toHtml 206 207 // }}} 208 // {{{ getFrozenHtml() 209 210 /** 211 * Returns the value of field without HTML tags (in this case, value is changed to a mask) 212 * 213 * @since 1.0 214 * @access public 215 * @return string 216 */ 217 function getFrozenHtml() 218 { 219 $value = htmlspecialchars($this->getValue()); 220 if ($this->getAttribute('wrap') == 'off') { 221 $html = $this->_getTabs() . '<pre>' . $value."</pre>\n"; 222 } else { 223 $html = nl2br($value)."\n"; 224 } 225 return $html . $this->_getPersistantData(); 226 } //end func getFrozenHtml 227 228 // }}} 229 230 } //end class HTML_QuickForm_textarea 231 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body