@@ -137,6 +137,9 @@ |
||
| 137 | 137 | $this->_currentSection = $this->_sectionCount++; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | + /** |
|
| 141 | + * @param boolean $required |
|
| 142 | + */ |
|
| 140 | 143 | function renderElement(&$element, $required, $error) |
| 141 | 144 | { |
| 142 | 145 | $elObj = $this->_elementToObject($element, $required, $error); |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | class HTML_QuickForm_Renderer_Object extends HTML_QuickForm_Renderer |
| 36 | 36 | { |
| 37 | - /**#@+ |
|
| 37 | + /**#@+ |
|
| 38 | 38 | * @access private |
| 39 | 39 | */ |
| 40 | 40 | /** |
@@ -50,15 +50,15 @@ discard block |
||
| 50 | 50 | var $_sectionCount; |
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | - * Current section number |
|
| 54 | - * @var integer $_currentSection |
|
| 55 | - */ |
|
| 53 | + * Current section number |
|
| 54 | + * @var integer $_currentSection |
|
| 55 | + */ |
|
| 56 | 56 | var $_currentSection; |
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | - * Object representing current group |
|
| 60 | - * @var object $_currentGroup |
|
| 61 | - */ |
|
| 59 | + * Object representing current group |
|
| 60 | + * @var object $_currentGroup |
|
| 61 | + */ |
|
| 62 | 62 | var $_currentGroup = null; |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -68,17 +68,17 @@ discard block |
||
| 68 | 68 | var $_elementType = 'QuickFormElement'; |
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | - * Additional style information for different elements |
|
| 72 | - * @var array $_elementStyles |
|
| 73 | - */ |
|
| 71 | + * Additional style information for different elements |
|
| 72 | + * @var array $_elementStyles |
|
| 73 | + */ |
|
| 74 | 74 | var $_elementStyles = array(); |
| 75 | 75 | |
| 76 | 76 | /** |
| 77 | - * true: collect all hidden elements into string; false: process them as usual form elements |
|
| 78 | - * @var bool $_collectHidden |
|
| 79 | - */ |
|
| 77 | + * true: collect all hidden elements into string; false: process them as usual form elements |
|
| 78 | + * @var bool $_collectHidden |
|
| 79 | + */ |
|
| 80 | 80 | var $_collectHidden = false; |
| 81 | - /**#@-*/ |
|
| 81 | + /**#@-*/ |
|
| 82 | 82 | |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -270,73 +270,73 @@ discard block |
||
| 270 | 270 | */ |
| 271 | 271 | class QuickformForm |
| 272 | 272 | { |
| 273 | - /** |
|
| 274 | - * Whether the form has been frozen |
|
| 275 | - * @var boolean $frozen |
|
| 276 | - */ |
|
| 273 | + /** |
|
| 274 | + * Whether the form has been frozen |
|
| 275 | + * @var boolean $frozen |
|
| 276 | + */ |
|
| 277 | 277 | var $frozen; |
| 278 | 278 | |
| 279 | - /** |
|
| 280 | - * Javascript for client-side validation |
|
| 281 | - * @var string $javascript |
|
| 282 | - */ |
|
| 279 | + /** |
|
| 280 | + * Javascript for client-side validation |
|
| 281 | + * @var string $javascript |
|
| 282 | + */ |
|
| 283 | 283 | var $javascript; |
| 284 | 284 | |
| 285 | - /** |
|
| 286 | - * Attributes for form tag |
|
| 287 | - * @var string $attributes |
|
| 288 | - */ |
|
| 285 | + /** |
|
| 286 | + * Attributes for form tag |
|
| 287 | + * @var string $attributes |
|
| 288 | + */ |
|
| 289 | 289 | var $attributes; |
| 290 | 290 | |
| 291 | - /** |
|
| 292 | - * Note about required elements |
|
| 293 | - * @var string $requirednote |
|
| 294 | - */ |
|
| 291 | + /** |
|
| 292 | + * Note about required elements |
|
| 293 | + * @var string $requirednote |
|
| 294 | + */ |
|
| 295 | 295 | var $requirednote; |
| 296 | 296 | |
| 297 | - /** |
|
| 298 | - * Collected html of all hidden variables |
|
| 299 | - * @var string $hidden |
|
| 300 | - */ |
|
| 297 | + /** |
|
| 298 | + * Collected html of all hidden variables |
|
| 299 | + * @var string $hidden |
|
| 300 | + */ |
|
| 301 | 301 | var $hidden; |
| 302 | 302 | |
| 303 | - /** |
|
| 304 | - * Set if there were validation errors. |
|
| 305 | - * StdClass object with element names for keys and their |
|
| 306 | - * error messages as values |
|
| 307 | - * @var object $errors |
|
| 308 | - */ |
|
| 303 | + /** |
|
| 304 | + * Set if there were validation errors. |
|
| 305 | + * StdClass object with element names for keys and their |
|
| 306 | + * error messages as values |
|
| 307 | + * @var object $errors |
|
| 308 | + */ |
|
| 309 | 309 | var $errors; |
| 310 | 310 | |
| 311 | - /** |
|
| 312 | - * Array of QuickformElementObject elements. If there are headers in the form |
|
| 313 | - * this will be empty and the elements will be in the |
|
| 314 | - * separate sections |
|
| 315 | - * @var array $elements |
|
| 316 | - */ |
|
| 311 | + /** |
|
| 312 | + * Array of QuickformElementObject elements. If there are headers in the form |
|
| 313 | + * this will be empty and the elements will be in the |
|
| 314 | + * separate sections |
|
| 315 | + * @var array $elements |
|
| 316 | + */ |
|
| 317 | 317 | var $elements; |
| 318 | 318 | |
| 319 | - /** |
|
| 320 | - * Array of sections contained in the document |
|
| 321 | - * @var array $sections |
|
| 322 | - */ |
|
| 319 | + /** |
|
| 320 | + * Array of sections contained in the document |
|
| 321 | + * @var array $sections |
|
| 322 | + */ |
|
| 323 | 323 | var $sections; |
| 324 | 324 | |
| 325 | - /** |
|
| 326 | - * Output <form> header |
|
| 327 | - * {form.outputHeader():h} |
|
| 328 | - * @return string <form attributes> |
|
| 329 | - */ |
|
| 325 | + /** |
|
| 326 | + * Output <form> header |
|
| 327 | + * {form.outputHeader():h} |
|
| 328 | + * @return string <form attributes> |
|
| 329 | + */ |
|
| 330 | 330 | function outputHeader() |
| 331 | 331 | { |
| 332 | 332 | return "<form " . $this->attributes . ">\n"; |
| 333 | 333 | } |
| 334 | 334 | |
| 335 | - /** |
|
| 336 | - * Output form javascript |
|
| 337 | - * {form.outputJavaScript():h} |
|
| 338 | - * @return string Javascript |
|
| 339 | - */ |
|
| 335 | + /** |
|
| 336 | + * Output form javascript |
|
| 337 | + * {form.outputJavaScript():h} |
|
| 338 | + * @return string Javascript |
|
| 339 | + */ |
|
| 340 | 340 | function outputJavaScript() |
| 341 | 341 | { |
| 342 | 342 | return $this->javascript; |
@@ -441,9 +441,9 @@ discard block |
||
| 441 | 441 | } |
| 442 | 442 | |
| 443 | 443 | |
| 444 | - /** |
|
| 445 | - * XXX: why does it use Flexy when all other stuff here does not depend on it? |
|
| 446 | - */ |
|
| 444 | + /** |
|
| 445 | + * XXX: why does it use Flexy when all other stuff here does not depend on it? |
|
| 446 | + */ |
|
| 447 | 447 | function outputStyle() |
| 448 | 448 | { |
| 449 | 449 | ob_start(); |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * The object being generated |
| 42 | 42 | * @var QuickformForm |
| 43 | 43 | */ |
| 44 | - var $_obj= null; |
|
| 44 | + var $_obj = null; |
|
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | 47 | * Number of sections in the form (i.e. number of headers in it) |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | $this->_obj->requirednote = $form->getRequiredNote(); |
| 122 | 122 | $this->_obj->errors = new StdClass; |
| 123 | 123 | |
| 124 | - if($this->_collectHidden) { |
|
| 124 | + if ($this->_collectHidden) { |
|
| 125 | 125 | $this->_obj->hidden = ''; |
| 126 | 126 | } |
| 127 | 127 | $this->_elementIdx = 1; |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | function renderElement(&$element, $required, $error) |
| 141 | 141 | { |
| 142 | 142 | $elObj = $this->_elementToObject($element, $required, $error); |
| 143 | - if(!empty($error)) { |
|
| 143 | + if (!empty($error)) { |
|
| 144 | 144 | $name = $elObj->name; |
| 145 | 145 | $this->_obj->errors->$name = $error; |
| 146 | 146 | } |
@@ -149,8 +149,8 @@ discard block |
||
| 149 | 149 | |
| 150 | 150 | function renderHidden(&$element) |
| 151 | 151 | { |
| 152 | - if($this->_collectHidden) { |
|
| 153 | - $this->_obj->hidden .= $element->toHtml() . "\n"; |
|
| 152 | + if ($this->_collectHidden) { |
|
| 153 | + $this->_obj->hidden .= $element->toHtml()."\n"; |
|
| 154 | 154 | } else { |
| 155 | 155 | $this->renderElement($element, false, null); |
| 156 | 156 | } |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | function startGroup(&$group, $required, $error) |
| 160 | 160 | { |
| 161 | 161 | $this->_currentGroup = $this->_elementToObject($group, $required, $error); |
| 162 | - if(!empty($error)) { |
|
| 162 | + if (!empty($error)) { |
|
| 163 | 163 | $name = $this->_currentGroup->name; |
| 164 | 164 | $this->_obj->errors->$name = $error; |
| 165 | 165 | } |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | */ |
| 183 | 183 | function _elementToObject(&$element, $required, $error) |
| 184 | 184 | { |
| 185 | - if($this->_elementType) { |
|
| 185 | + if ($this->_elementType) { |
|
| 186 | 186 | $ret = new $this->_elementType; |
| 187 | 187 | } |
| 188 | 188 | $ret->name = $element->getName(); |
@@ -193,8 +193,8 @@ discard block |
||
| 193 | 193 | if (is_array($labels)) { |
| 194 | 194 | $ret->label = array_shift($labels); |
| 195 | 195 | foreach ($labels as $key => $label) { |
| 196 | - $key = is_int($key)? $key + 2: $key; |
|
| 197 | - $ret->{'label_' . $key} = $label; |
|
| 196 | + $key = is_int($key) ? $key + 2 : $key; |
|
| 197 | + $ret->{'label_'.$key} = $label; |
|
| 198 | 198 | } |
| 199 | 199 | } else { |
| 200 | 200 | $ret->label = $labels; |
@@ -202,11 +202,11 @@ discard block |
||
| 202 | 202 | $ret->required = $required; |
| 203 | 203 | $ret->error = $error; |
| 204 | 204 | |
| 205 | - if(isset($this->_elementStyles[$ret->name])) { |
|
| 205 | + if (isset($this->_elementStyles[$ret->name])) { |
|
| 206 | 206 | $ret->style = $this->_elementStyles[$ret->name]; |
| 207 | - $ret->styleTemplate = "styles/". $ret->style .".html"; |
|
| 207 | + $ret->styleTemplate = "styles/".$ret->style.".html"; |
|
| 208 | 208 | } |
| 209 | - if($ret->type == 'group') { |
|
| 209 | + if ($ret->type == 'group') { |
|
| 210 | 210 | $ret->separator = $element->_separator; |
| 211 | 211 | $ret->elements = array(); |
| 212 | 212 | } else { |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | function _storeObject($elObj) |
| 226 | 226 | { |
| 227 | 227 | $name = $elObj->name; |
| 228 | - if(is_object($this->_currentGroup) && $elObj->type != 'group') { |
|
| 228 | + if (is_object($this->_currentGroup) && $elObj->type != 'group') { |
|
| 229 | 229 | $this->_currentGroup->elements[] = $elObj; |
| 230 | 230 | } elseif (isset($this->_currentSection)) { |
| 231 | 231 | $this->_obj->sections[$this->_currentSection]->elements[] = $elObj; |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | |
| 237 | 237 | function setElementStyle($elementName, $styleName = null) |
| 238 | 238 | { |
| 239 | - if(is_array($elementName)) { |
|
| 239 | + if (is_array($elementName)) { |
|
| 240 | 240 | $this->_elementStyles = array_merge($this->_elementStyles, $elementName); |
| 241 | 241 | } else { |
| 242 | 242 | $this->_elementStyles[$elementName] = $styleName; |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | */ |
| 330 | 330 | function outputHeader() |
| 331 | 331 | { |
| 332 | - return "<form " . $this->attributes . ">\n"; |
|
| 332 | + return "<form ".$this->attributes.">\n"; |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | /** |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | function outputStyle() |
| 448 | 448 | { |
| 449 | 449 | ob_start(); |
| 450 | - HTML_Template_Flexy::staticQuickTemplate('styles/' . $this->style . '.html', $this); |
|
| 450 | + HTML_Template_Flexy::staticQuickTemplate('styles/'.$this->style.'.html', $this); |
|
| 451 | 451 | $ret = ob_get_contents(); |
| 452 | 452 | ob_end_clean(); |
| 453 | 453 | return $ret; |
@@ -71,7 +71,7 @@ |
||
| 71 | 71 | * |
| 72 | 72 | * @param mixed Options for the rule |
| 73 | 73 | * @access public |
| 74 | - * @return array first element is code to setup validation, second is the check itself |
|
| 74 | + * @return string[] first element is code to setup validation, second is the check itself |
|
| 75 | 75 | * @abstract |
| 76 | 76 | */ |
| 77 | 77 | function getValidationScript($options = null) |
@@ -33,34 +33,34 @@ |
||
| 33 | 33 | */ |
| 34 | 34 | class HTML_QuickForm_Rule |
| 35 | 35 | { |
| 36 | - /** |
|
| 37 | - * Name of the rule to use in validate method |
|
| 38 | - * |
|
| 39 | - * This property is used in more global rules like Callback and Regex |
|
| 40 | - * to determine which callback and which regex is to be used for validation |
|
| 41 | - * |
|
| 42 | - * @var string |
|
| 43 | - * @access public |
|
| 44 | - */ |
|
| 36 | + /** |
|
| 37 | + * Name of the rule to use in validate method |
|
| 38 | + * |
|
| 39 | + * This property is used in more global rules like Callback and Regex |
|
| 40 | + * to determine which callback and which regex is to be used for validation |
|
| 41 | + * |
|
| 42 | + * @var string |
|
| 43 | + * @access public |
|
| 44 | + */ |
|
| 45 | 45 | var $name; |
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * Validates a value |
|
| 49 | - * |
|
| 50 | - * @access public |
|
| 51 | - * @abstract |
|
| 52 | - */ |
|
| 47 | + /** |
|
| 48 | + * Validates a value |
|
| 49 | + * |
|
| 50 | + * @access public |
|
| 51 | + * @abstract |
|
| 52 | + */ |
|
| 53 | 53 | function validate($value, $options) |
| 54 | 54 | { |
| 55 | 55 | return true; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * Sets the rule name |
|
| 60 | - * |
|
| 61 | - * @param string rule name |
|
| 62 | - * @access public |
|
| 63 | - */ |
|
| 58 | + /** |
|
| 59 | + * Sets the rule name |
|
| 60 | + * |
|
| 61 | + * @param string rule name |
|
| 62 | + * @access public |
|
| 63 | + */ |
|
| 64 | 64 | function setName($ruleName) |
| 65 | 65 | { |
| 66 | 66 | $this->name = $ruleName; |
@@ -73,6 +73,9 @@ |
||
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | |
| 76 | + /** |
|
| 77 | + * @param integer[] $values |
|
| 78 | + */ |
|
| 76 | 79 | function validate($values, $operator = null) |
| 77 | 80 | { |
| 78 | 81 | $operator = $this->_findOperator($operator); |
@@ -35,11 +35,11 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | class HTML_QuickForm_Rule_Compare extends HTML_QuickForm_Rule |
| 37 | 37 | { |
| 38 | - /** |
|
| 39 | - * Possible operators to use |
|
| 40 | - * @var array |
|
| 41 | - * @access private |
|
| 42 | - */ |
|
| 38 | + /** |
|
| 39 | + * Possible operators to use |
|
| 40 | + * @var array |
|
| 41 | + * @access private |
|
| 42 | + */ |
|
| 43 | 43 | var $_operators = array( |
| 44 | 44 | 'eq' => '===', |
| 45 | 45 | 'neq' => '!==', |
@@ -51,13 +51,13 @@ discard block |
||
| 51 | 51 | '!=' => '!==' |
| 52 | 52 | ); |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Returns the operator to use for comparing the values |
|
| 56 | - * |
|
| 57 | - * @access private |
|
| 58 | - * @param string operator name |
|
| 59 | - * @return string operator to use for validation |
|
| 60 | - */ |
|
| 54 | + /** |
|
| 55 | + * Returns the operator to use for comparing the values |
|
| 56 | + * |
|
| 57 | + * @access private |
|
| 58 | + * @param string operator name |
|
| 59 | + * @return string operator to use for validation |
|
| 60 | + */ |
|
| 61 | 61 | function _findOperator($name) |
| 62 | 62 | { |
| 63 | 63 | $name = trim($name); |
@@ -78,9 +78,9 @@ |
||
| 78 | 78 | $operator = $this->_findOperator($operator); |
| 79 | 79 | |
| 80 | 80 | if ('===' != $operator && '!==' != $operator) { |
| 81 | - $compareFn = create_function('$a, $b', 'return floatval($a) ' . $operator . ' floatval($b);'); |
|
| 81 | + $compareFn = create_function('$a, $b', 'return floatval($a) '.$operator.' floatval($b);'); |
|
| 82 | 82 | } else { |
| 83 | - $compareFn = create_function('$a, $b', 'return strval($a) ' . $operator . ' strval($b);'); |
|
| 83 | + $compareFn = create_function('$a, $b', 'return strval($a) '.$operator.' strval($b);'); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | return $compareFn($values[0], $values[1]); |
@@ -9,7 +9,7 @@ |
||
| 9 | 9 | /** |
| 10 | 10 | * Function to check a date |
| 11 | 11 | * @see HTML_QuickForm_Rule |
| 12 | - * @param array $date An array with keys F (month), d (day) and Y (year) |
|
| 12 | + * @param string $date An array with keys F (month), d (day) and Y (year) |
|
| 13 | 13 | * @return boolean True if date is valid |
| 14 | 14 | */ |
| 15 | 15 | function validate($date, $options) |
@@ -6,15 +6,15 @@ |
||
| 6 | 6 | */ |
| 7 | 7 | class Html_Quickform_Rule_Date extends HTML_QuickForm_Rule |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Function to check a date |
|
| 11 | - * @see HTML_QuickForm_Rule |
|
| 12 | - * @param array $date An array with keys F (month), d (day) and Y (year) |
|
| 13 | - * @return boolean True if date is valid |
|
| 14 | - */ |
|
| 15 | - function validate($date, $options) |
|
| 16 | - { |
|
| 17 | - $compareDate = create_function('$a', 'return checkdate($a[\'M\'],$a[\'d\'],$a[\'Y\']);'); |
|
| 9 | + /** |
|
| 10 | + * Function to check a date |
|
| 11 | + * @see HTML_QuickForm_Rule |
|
| 12 | + * @param array $date An array with keys F (month), d (day) and Y (year) |
|
| 13 | + * @return boolean True if date is valid |
|
| 14 | + */ |
|
| 15 | + function validate($date, $options) |
|
| 16 | + { |
|
| 17 | + $compareDate = create_function('$a', 'return checkdate($a[\'M\'],$a[\'d\'],$a[\'Y\']);'); |
|
| 18 | 18 | return $compareDate($date); |
| 19 | - } |
|
| 19 | + } |
|
| 20 | 20 | } |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | * @param mixed $values Can be a scalar or an array of values |
| 175 | 175 | * to be validated |
| 176 | 176 | * @param mixed $options Options used by the rule |
| 177 | - * @param mixed $multiple Whether to validate an array of values altogether |
|
| 177 | + * @param boolean $multiple Whether to validate an array of values altogether |
|
| 178 | 178 | * @access public |
| 179 | 179 | * @return mixed true if no error found, int of valid values (when an array of values is given) or false if error |
| 180 | 180 | */ |
@@ -258,6 +258,7 @@ discard block |
||
| 258 | 258 | * the value |
| 259 | 259 | * @param integer value's index in the array (only used for |
| 260 | 260 | * multielement rules) |
| 261 | + * @param integer $index |
|
| 261 | 262 | * @return array first item is value javascript, second is reset |
| 262 | 263 | */ |
| 263 | 264 | function _getJsValue(&$element, $elementName, $reset = false, $index = null) |
@@ -225,41 +225,41 @@ discard block |
||
| 225 | 225 | list ($jsPrefix, $jsCheck) = $rule->getValidationScript($ruleData['format']); |
| 226 | 226 | if (!isset($ruleData['howmany'])) { |
| 227 | 227 | $js = $jsValue . "\n" . $jsPrefix . |
| 228 | - " if (" . str_replace('{jsVar}', 'value', $jsCheck) . " && !errFlag['{$jsField}']) {\n" . |
|
| 229 | - " errFlag['{$jsField}'] = true;\n" . |
|
| 230 | - " _qfMsg = _qfMsg + '\\n - {$ruleData['message']}';\n" . |
|
| 231 | - $jsReset . |
|
| 232 | - " }\n"; |
|
| 228 | + " if (" . str_replace('{jsVar}', 'value', $jsCheck) . " && !errFlag['{$jsField}']) {\n" . |
|
| 229 | + " errFlag['{$jsField}'] = true;\n" . |
|
| 230 | + " _qfMsg = _qfMsg + '\\n - {$ruleData['message']}';\n" . |
|
| 231 | + $jsReset . |
|
| 232 | + " }\n"; |
|
| 233 | 233 | } else { |
| 234 | 234 | $js = $jsValue . "\n" . $jsPrefix . |
| 235 | - " var res = 0;\n" . |
|
| 236 | - " for (var i = 0; i < value.length; i++) {\n" . |
|
| 237 | - " if (!(" . str_replace('{jsVar}', 'value[i]', $jsCheck) . ")) {\n" . |
|
| 238 | - " res++;\n" . |
|
| 239 | - " }\n" . |
|
| 240 | - " }\n" . |
|
| 241 | - " if (res < {$ruleData['howmany']} && !errFlag['{$jsField}']) {\n" . |
|
| 242 | - " errFlag['{$jsField}'] = true;\n" . |
|
| 243 | - " _qfMsg = _qfMsg + '\\n - {$ruleData['message']}';\n" . |
|
| 244 | - $jsReset . |
|
| 245 | - " }\n"; |
|
| 235 | + " var res = 0;\n" . |
|
| 236 | + " for (var i = 0; i < value.length; i++) {\n" . |
|
| 237 | + " if (!(" . str_replace('{jsVar}', 'value[i]', $jsCheck) . ")) {\n" . |
|
| 238 | + " res++;\n" . |
|
| 239 | + " }\n" . |
|
| 240 | + " }\n" . |
|
| 241 | + " if (res < {$ruleData['howmany']} && !errFlag['{$jsField}']) {\n" . |
|
| 242 | + " errFlag['{$jsField}'] = true;\n" . |
|
| 243 | + " _qfMsg = _qfMsg + '\\n - {$ruleData['message']}';\n" . |
|
| 244 | + $jsReset . |
|
| 245 | + " }\n"; |
|
| 246 | 246 | } |
| 247 | 247 | return $js; |
| 248 | 248 | } // end func getValidationScript |
| 249 | 249 | |
| 250 | 250 | |
| 251 | - /** |
|
| 252 | - * Returns JavaScript to get and to reset the element's value |
|
| 253 | - * |
|
| 254 | - * @access private |
|
| 255 | - * @param HTML_QuickForm_element element being processed |
|
| 256 | - * @param string element's name |
|
| 257 | - * @param bool whether to generate JavaScript to reset |
|
| 258 | - * the value |
|
| 259 | - * @param integer value's index in the array (only used for |
|
| 260 | - * multielement rules) |
|
| 261 | - * @return array first item is value javascript, second is reset |
|
| 262 | - */ |
|
| 251 | + /** |
|
| 252 | + * Returns JavaScript to get and to reset the element's value |
|
| 253 | + * |
|
| 254 | + * @access private |
|
| 255 | + * @param HTML_QuickForm_element element being processed |
|
| 256 | + * @param string element's name |
|
| 257 | + * @param bool whether to generate JavaScript to reset |
|
| 258 | + * the value |
|
| 259 | + * @param integer value's index in the array (only used for |
|
| 260 | + * multielement rules) |
|
| 261 | + * @return array first item is value javascript, second is reset |
|
| 262 | + */ |
|
| 263 | 263 | function _getJsValue(&$element, $elementName, $reset = false, $index = null) |
| 264 | 264 | { |
| 265 | 265 | $jsIndex = isset($index)? '[' . $index . ']': ''; |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | for ($i = 0, $count = count($elements); $i < $count; $i++) { |
| 271 | 271 | $append = ($elements[$i]->getType() == 'select' && $elements[$i]->getMultiple())? '[]': ''; |
| 272 | 272 | $value .= "'" . $element->getElementName($i) . $append . "': true" . |
| 273 | - ($i < $count - 1? ', ': ''); |
|
| 273 | + ($i < $count - 1? ', ': ''); |
|
| 274 | 274 | } |
| 275 | 275 | $value .= |
| 276 | 276 | "};\n" . |
@@ -363,17 +363,17 @@ discard block |
||
| 363 | 363 | |
| 364 | 364 | } elseif ($element->getType() == 'radio') { |
| 365 | 365 | $value = " value{$jsIndex} = '';\n" . |
| 366 | - // Fix for bug #5644 |
|
| 367 | - " var els = 'length' in frm.elements['$elementName']? frm.elements['$elementName']: [ frm.elements['$elementName'] ];\n" . |
|
| 368 | - " for (var i = 0; i < els.length; i++) {\n" . |
|
| 369 | - " if (els[i].checked) {\n" . |
|
| 370 | - " value{$jsIndex} = els[i].value;\n" . |
|
| 371 | - " }\n" . |
|
| 372 | - " }"; |
|
| 366 | + // Fix for bug #5644 |
|
| 367 | + " var els = 'length' in frm.elements['$elementName']? frm.elements['$elementName']: [ frm.elements['$elementName'] ];\n" . |
|
| 368 | + " for (var i = 0; i < els.length; i++) {\n" . |
|
| 369 | + " if (els[i].checked) {\n" . |
|
| 370 | + " value{$jsIndex} = els[i].value;\n" . |
|
| 371 | + " }\n" . |
|
| 372 | + " }"; |
|
| 373 | 373 | if ($reset) { |
| 374 | 374 | $tmp_reset .= " for (var i = 0; i < field.length; i++) {\n" . |
| 375 | - " field[i].checked = field[i].defaultChecked;\n" . |
|
| 376 | - " }"; |
|
| 375 | + " field[i].checked = field[i].defaultChecked;\n" . |
|
| 376 | + " }"; |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | } else { |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | $type = strtolower($type); |
| 90 | 90 | if ($type == 'regex') { |
| 91 | 91 | // Regular expression |
| 92 | - $rule =& $this->getRule('regex'); |
|
| 92 | + $rule = & $this->getRule('regex'); |
|
| 93 | 93 | $rule->addData($ruleName, $data1); |
| 94 | 94 | |
| 95 | 95 | } elseif ($type == 'function' || $type == 'callback') { |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | */ |
| 209 | 209 | function getValidationScript(&$element, $elementName, $ruleData) |
| 210 | 210 | { |
| 211 | - $reset = (isset($ruleData['reset'])) ? $ruleData['reset'] : false; |
|
| 211 | + $reset = (isset($ruleData['reset'])) ? $ruleData['reset'] : false; |
|
| 212 | 212 | $rule = $this->getRule($ruleData['type']); |
| 213 | 213 | if (!is_array($element)) { |
| 214 | 214 | list($jsValue, $jsReset) = $this->_getJsValue($element, $elementName, $reset, null); |
@@ -217,31 +217,31 @@ discard block |
||
| 217 | 217 | $jsReset = ''; |
| 218 | 218 | for ($i = 0; $i < count($element); $i++) { |
| 219 | 219 | list($tmp_value, $tmp_reset) = $this->_getJsValue($element[$i], $element[$i]->getName(), $reset, $i); |
| 220 | - $jsValue .= "\n" . $tmp_value; |
|
| 220 | + $jsValue .= "\n".$tmp_value; |
|
| 221 | 221 | $jsReset .= $tmp_reset; |
| 222 | 222 | } |
| 223 | 223 | } |
| 224 | - $jsField = isset($ruleData['group'])? $ruleData['group']: $elementName; |
|
| 224 | + $jsField = isset($ruleData['group']) ? $ruleData['group'] : $elementName; |
|
| 225 | 225 | list ($jsPrefix, $jsCheck) = $rule->getValidationScript($ruleData['format']); |
| 226 | 226 | if (!isset($ruleData['howmany'])) { |
| 227 | - $js = $jsValue . "\n" . $jsPrefix . |
|
| 228 | - " if (" . str_replace('{jsVar}', 'value', $jsCheck) . " && !errFlag['{$jsField}']) {\n" . |
|
| 229 | - " errFlag['{$jsField}'] = true;\n" . |
|
| 230 | - " _qfMsg = _qfMsg + '\\n - {$ruleData['message']}';\n" . |
|
| 231 | - $jsReset . |
|
| 227 | + $js = $jsValue."\n".$jsPrefix. |
|
| 228 | + " if (".str_replace('{jsVar}', 'value', $jsCheck)." && !errFlag['{$jsField}']) {\n". |
|
| 229 | + " errFlag['{$jsField}'] = true;\n". |
|
| 230 | + " _qfMsg = _qfMsg + '\\n - {$ruleData['message']}';\n". |
|
| 231 | + $jsReset. |
|
| 232 | 232 | " }\n"; |
| 233 | 233 | } else { |
| 234 | - $js = $jsValue . "\n" . $jsPrefix . |
|
| 235 | - " var res = 0;\n" . |
|
| 236 | - " for (var i = 0; i < value.length; i++) {\n" . |
|
| 237 | - " if (!(" . str_replace('{jsVar}', 'value[i]', $jsCheck) . ")) {\n" . |
|
| 238 | - " res++;\n" . |
|
| 239 | - " }\n" . |
|
| 240 | - " }\n" . |
|
| 241 | - " if (res < {$ruleData['howmany']} && !errFlag['{$jsField}']) {\n" . |
|
| 242 | - " errFlag['{$jsField}'] = true;\n" . |
|
| 243 | - " _qfMsg = _qfMsg + '\\n - {$ruleData['message']}';\n" . |
|
| 244 | - $jsReset . |
|
| 234 | + $js = $jsValue."\n".$jsPrefix. |
|
| 235 | + " var res = 0;\n". |
|
| 236 | + " for (var i = 0; i < value.length; i++) {\n". |
|
| 237 | + " if (!(".str_replace('{jsVar}', 'value[i]', $jsCheck).")) {\n". |
|
| 238 | + " res++;\n". |
|
| 239 | + " }\n". |
|
| 240 | + " }\n". |
|
| 241 | + " if (res < {$ruleData['howmany']} && !errFlag['{$jsField}']) {\n". |
|
| 242 | + " errFlag['{$jsField}'] = true;\n". |
|
| 243 | + " _qfMsg = _qfMsg + '\\n - {$ruleData['message']}';\n". |
|
| 244 | + $jsReset. |
|
| 245 | 245 | " }\n"; |
| 246 | 246 | } |
| 247 | 247 | return $js; |
@@ -262,72 +262,72 @@ discard block |
||
| 262 | 262 | */ |
| 263 | 263 | function _getJsValue(&$element, $elementName, $reset = false, $index = null) |
| 264 | 264 | { |
| 265 | - $jsIndex = isset($index)? '[' . $index . ']': ''; |
|
| 266 | - $tmp_reset = $reset? " var field = frm.elements['$elementName'];\n": ''; |
|
| 265 | + $jsIndex = isset($index) ? '['.$index.']' : ''; |
|
| 266 | + $tmp_reset = $reset ? " var field = frm.elements['$elementName'];\n" : ''; |
|
| 267 | 267 | if (is_a($element, 'html_quickform_group')) { |
| 268 | 268 | $value = " _qfGroups['{$elementName}'] = {"; |
| 269 | - $elements =& $element->getElements(); |
|
| 269 | + $elements = & $element->getElements(); |
|
| 270 | 270 | for ($i = 0, $count = count($elements); $i < $count; $i++) { |
| 271 | - $append = ($elements[$i]->getType() == 'select' && $elements[$i]->getMultiple())? '[]': ''; |
|
| 272 | - $value .= "'" . $element->getElementName($i) . $append . "': true" . |
|
| 273 | - ($i < $count - 1? ', ': ''); |
|
| 271 | + $append = ($elements[$i]->getType() == 'select' && $elements[$i]->getMultiple()) ? '[]' : ''; |
|
| 272 | + $value .= "'".$element->getElementName($i).$append."': true". |
|
| 273 | + ($i < $count - 1 ? ', ' : ''); |
|
| 274 | 274 | } |
| 275 | 275 | $value .= |
| 276 | - "};\n" . |
|
| 277 | - " value{$jsIndex} = new Array();\n" . |
|
| 278 | - " var valueIdx = 0;\n" . |
|
| 279 | - " for (var i = 0; i < frm.elements.length; i++) {\n" . |
|
| 280 | - " var _element = frm.elements[i];\n" . |
|
| 281 | - " if (_element.name in _qfGroups['{$elementName}']) {\n" . |
|
| 282 | - " switch (_element.type) {\n" . |
|
| 283 | - " case 'checkbox':\n" . |
|
| 284 | - " case 'radio':\n" . |
|
| 285 | - " if (_element.checked) {\n" . |
|
| 286 | - " value{$jsIndex}[valueIdx++] = _element.value;\n" . |
|
| 287 | - " }\n" . |
|
| 288 | - " break;\n" . |
|
| 289 | - " case 'select-one':\n" . |
|
| 290 | - " if (-1 != _element.selectedIndex) {\n" . |
|
| 291 | - " value{$jsIndex}[valueIdx++] = _element.options[_element.selectedIndex].value;\n" . |
|
| 292 | - " }\n" . |
|
| 293 | - " break;\n" . |
|
| 294 | - " case 'select-multiple':\n" . |
|
| 295 | - " var tmpVal = new Array();\n" . |
|
| 296 | - " var tmpIdx = 0;\n" . |
|
| 297 | - " for (var j = 0; j < _element.options.length; j++) {\n" . |
|
| 298 | - " if (_element.options[j].selected) {\n" . |
|
| 299 | - " tmpVal[tmpIdx++] = _element.options[j].value;\n" . |
|
| 300 | - " }\n" . |
|
| 301 | - " }\n" . |
|
| 302 | - " if (tmpIdx > 0) {\n" . |
|
| 303 | - " value{$jsIndex}[valueIdx++] = tmpVal;\n" . |
|
| 304 | - " }\n" . |
|
| 305 | - " break;\n" . |
|
| 306 | - " default:\n" . |
|
| 307 | - " value{$jsIndex}[valueIdx++] = _element.value;\n" . |
|
| 308 | - " }\n" . |
|
| 309 | - " }\n" . |
|
| 276 | + "};\n". |
|
| 277 | + " value{$jsIndex} = new Array();\n". |
|
| 278 | + " var valueIdx = 0;\n". |
|
| 279 | + " for (var i = 0; i < frm.elements.length; i++) {\n". |
|
| 280 | + " var _element = frm.elements[i];\n". |
|
| 281 | + " if (_element.name in _qfGroups['{$elementName}']) {\n". |
|
| 282 | + " switch (_element.type) {\n". |
|
| 283 | + " case 'checkbox':\n". |
|
| 284 | + " case 'radio':\n". |
|
| 285 | + " if (_element.checked) {\n". |
|
| 286 | + " value{$jsIndex}[valueIdx++] = _element.value;\n". |
|
| 287 | + " }\n". |
|
| 288 | + " break;\n". |
|
| 289 | + " case 'select-one':\n". |
|
| 290 | + " if (-1 != _element.selectedIndex) {\n". |
|
| 291 | + " value{$jsIndex}[valueIdx++] = _element.options[_element.selectedIndex].value;\n". |
|
| 292 | + " }\n". |
|
| 293 | + " break;\n". |
|
| 294 | + " case 'select-multiple':\n". |
|
| 295 | + " var tmpVal = new Array();\n". |
|
| 296 | + " var tmpIdx = 0;\n". |
|
| 297 | + " for (var j = 0; j < _element.options.length; j++) {\n". |
|
| 298 | + " if (_element.options[j].selected) {\n". |
|
| 299 | + " tmpVal[tmpIdx++] = _element.options[j].value;\n". |
|
| 300 | + " }\n". |
|
| 301 | + " }\n". |
|
| 302 | + " if (tmpIdx > 0) {\n". |
|
| 303 | + " value{$jsIndex}[valueIdx++] = tmpVal;\n". |
|
| 304 | + " }\n". |
|
| 305 | + " break;\n". |
|
| 306 | + " default:\n". |
|
| 307 | + " value{$jsIndex}[valueIdx++] = _element.value;\n". |
|
| 308 | + " }\n". |
|
| 309 | + " }\n". |
|
| 310 | 310 | " }\n"; |
| 311 | 311 | if ($reset) { |
| 312 | 312 | $tmp_reset = |
| 313 | - " for (var i = 0; i < frm.elements.length; i++) {\n" . |
|
| 314 | - " var _element = frm.elements[i];\n" . |
|
| 315 | - " if (_element.name in _qfGroups['{$elementName}']) {\n" . |
|
| 316 | - " switch (_element.type) {\n" . |
|
| 317 | - " case 'checkbox':\n" . |
|
| 318 | - " case 'radio':\n" . |
|
| 319 | - " _element.checked = _element.defaultChecked;\n" . |
|
| 320 | - " break;\n" . |
|
| 321 | - " case 'select-one':\n" . |
|
| 322 | - " case 'select-multiple':\n" . |
|
| 323 | - " for (var j = 0; j < _element.options.length; j++) {\n" . |
|
| 324 | - " _element.options[j].selected = _element.options[j].defaultSelected;\n" . |
|
| 325 | - " }\n" . |
|
| 326 | - " break;\n" . |
|
| 327 | - " default:\n" . |
|
| 328 | - " _element.value = _element.defaultValue;\n" . |
|
| 329 | - " }\n" . |
|
| 330 | - " }\n" . |
|
| 313 | + " for (var i = 0; i < frm.elements.length; i++) {\n". |
|
| 314 | + " var _element = frm.elements[i];\n". |
|
| 315 | + " if (_element.name in _qfGroups['{$elementName}']) {\n". |
|
| 316 | + " switch (_element.type) {\n". |
|
| 317 | + " case 'checkbox':\n". |
|
| 318 | + " case 'radio':\n". |
|
| 319 | + " _element.checked = _element.defaultChecked;\n". |
|
| 320 | + " break;\n". |
|
| 321 | + " case 'select-one':\n". |
|
| 322 | + " case 'select-multiple':\n". |
|
| 323 | + " for (var j = 0; j < _element.options.length; j++) {\n". |
|
| 324 | + " _element.options[j].selected = _element.options[j].defaultSelected;\n". |
|
| 325 | + " }\n". |
|
| 326 | + " break;\n". |
|
| 327 | + " default:\n". |
|
| 328 | + " _element.value = _element.defaultValue;\n". |
|
| 329 | + " }\n". |
|
| 330 | + " }\n". |
|
| 331 | 331 | " }\n"; |
| 332 | 332 | } |
| 333 | 333 | |
@@ -335,20 +335,20 @@ discard block |
||
| 335 | 335 | if ($element->getMultiple()) { |
| 336 | 336 | $elementName .= '[]'; |
| 337 | 337 | $value = |
| 338 | - " value{$jsIndex} = new Array();\n" . |
|
| 339 | - " var valueIdx = 0;\n" . |
|
| 340 | - " for (var i = 0; i < frm.elements['{$elementName}'].options.length; i++) {\n" . |
|
| 341 | - " if (frm.elements['{$elementName}'].options[i].selected) {\n" . |
|
| 342 | - " value{$jsIndex}[valueIdx++] = frm.elements['{$elementName}'].options[i].value;\n" . |
|
| 343 | - " }\n" . |
|
| 338 | + " value{$jsIndex} = new Array();\n". |
|
| 339 | + " var valueIdx = 0;\n". |
|
| 340 | + " for (var i = 0; i < frm.elements['{$elementName}'].options.length; i++) {\n". |
|
| 341 | + " if (frm.elements['{$elementName}'].options[i].selected) {\n". |
|
| 342 | + " value{$jsIndex}[valueIdx++] = frm.elements['{$elementName}'].options[i].value;\n". |
|
| 343 | + " }\n". |
|
| 344 | 344 | " }\n"; |
| 345 | 345 | } else { |
| 346 | 346 | $value = " value{$jsIndex} = frm.elements['{$elementName}'].selectedIndex == -1? '': frm.elements['{$elementName}'].options[frm.elements['{$elementName}'].selectedIndex].value;\n"; |
| 347 | 347 | } |
| 348 | 348 | if ($reset) { |
| 349 | 349 | $tmp_reset .= |
| 350 | - " for (var i = 0; i < field.options.length; i++) {\n" . |
|
| 351 | - " field.options[i].selected = field.options[i].defaultSelected;\n" . |
|
| 350 | + " for (var i = 0; i < field.options.length; i++) {\n". |
|
| 351 | + " field.options[i].selected = field.options[i].defaultSelected;\n". |
|
| 352 | 352 | " }\n"; |
| 353 | 353 | } |
| 354 | 354 | |
@@ -362,17 +362,17 @@ discard block |
||
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | } elseif ($element->getType() == 'radio') { |
| 365 | - $value = " value{$jsIndex} = '';\n" . |
|
| 365 | + $value = " value{$jsIndex} = '';\n". |
|
| 366 | 366 | // Fix for bug #5644 |
| 367 | - " var els = 'length' in frm.elements['$elementName']? frm.elements['$elementName']: [ frm.elements['$elementName'] ];\n" . |
|
| 368 | - " for (var i = 0; i < els.length; i++) {\n" . |
|
| 369 | - " if (els[i].checked) {\n" . |
|
| 370 | - " value{$jsIndex} = els[i].value;\n" . |
|
| 371 | - " }\n" . |
|
| 367 | + " var els = 'length' in frm.elements['$elementName']? frm.elements['$elementName']: [ frm.elements['$elementName'] ];\n". |
|
| 368 | + " for (var i = 0; i < els.length; i++) {\n". |
|
| 369 | + " if (els[i].checked) {\n". |
|
| 370 | + " value{$jsIndex} = els[i].value;\n". |
|
| 371 | + " }\n". |
|
| 372 | 372 | " }"; |
| 373 | 373 | if ($reset) { |
| 374 | - $tmp_reset .= " for (var i = 0; i < field.length; i++) {\n" . |
|
| 375 | - " field[i].checked = field[i].defaultChecked;\n" . |
|
| 374 | + $tmp_reset .= " for (var i = 0; i < field.length; i++) {\n". |
|
| 375 | + " field[i].checked = field[i].defaultChecked;\n". |
|
| 376 | 376 | " }"; |
| 377 | 377 | } |
| 378 | 378 | |
@@ -60,7 +60,7 @@ |
||
| 60 | 60 | * Freeze the element so that only its value is returned |
| 61 | 61 | * |
| 62 | 62 | * @access public |
| 63 | - * @return void |
|
| 63 | + * @return boolean |
|
| 64 | 64 | */ |
| 65 | 65 | function freeze() |
| 66 | 66 | { |
@@ -70,10 +70,10 @@ |
||
| 70 | 70 | // }}} |
| 71 | 71 | // {{{ exportValue() |
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * Only return the value if it is found within $submitValues (i.e. if |
|
| 75 | - * this particular submit button was clicked) |
|
| 76 | - */ |
|
| 73 | + /** |
|
| 74 | + * Only return the value if it is found within $submitValues (i.e. if |
|
| 75 | + * this particular submit button was clicked) |
|
| 76 | + */ |
|
| 77 | 77 | function exportValue(&$submitValues, $assoc = false) |
| 78 | 78 | { |
| 79 | 79 | return $this->_prepareValue($this->_findValue($submitValues), $assoc); |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | * @access public |
| 16 | 16 | * @return void |
| 17 | 17 | */ |
| 18 | - public function __construct($elementName=null, $value=null, $attributes=null) |
|
| 18 | + public function __construct($elementName = null, $value = null, $attributes = null) |
|
| 19 | 19 | { |
| 20 | 20 | parent::__construct($elementName, null, $attributes); |
| 21 | 21 | $this->setValue($value); |
@@ -54,6 +54,8 @@ |
||
| 54 | 54 | * @param string Input field name attribute |
| 55 | 55 | * @param mixed Label(s) for a field |
| 56 | 56 | * @param mixed Either a typical HTML attribute string or an associative array |
| 57 | + * @param string $elementName |
|
| 58 | + * @param string $elementLabel |
|
| 57 | 59 | * @since 1.0 |
| 58 | 60 | * @access public |
| 59 | 61 | * @return void |
@@ -194,13 +194,13 @@ |
||
| 194 | 194 | return $this->getFrozenHtml(); |
| 195 | 195 | } else { |
| 196 | 196 | return $this->_getTabs() . |
| 197 | - '<textarea' . $this->_getAttrString($this->_attributes) . '>' . |
|
| 198 | - // because we wrap the form later we don't want the text indented |
|
| 199 | - // Modified by Ivan Tcholakov, 16-MAR-2010. |
|
| 200 | - //preg_replace("/(\r\n|\n|\r)/", '
', htmlspecialchars($this->_value)) . |
|
| 201 | - preg_replace("/(\r\n|\n|\r)/", '
', @htmlspecialchars($this->_value, ENT_COMPAT, HTML_Common::charset())) . |
|
| 202 | - // |
|
| 203 | - '</textarea>'; |
|
| 197 | + '<textarea' . $this->_getAttrString($this->_attributes) . '>' . |
|
| 198 | + // because we wrap the form later we don't want the text indented |
|
| 199 | + // Modified by Ivan Tcholakov, 16-MAR-2010. |
|
| 200 | + //preg_replace("/(\r\n|\n|\r)/", '
', htmlspecialchars($this->_value)) . |
|
| 201 | + preg_replace("/(\r\n|\n|\r)/", '
', @htmlspecialchars($this->_value, ENT_COMPAT, HTML_Common::charset())) . |
|
| 202 | + // |
|
| 203 | + '</textarea>'; |
|
| 204 | 204 | } |
| 205 | 205 | } |
| 206 | 206 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * @access public |
| 59 | 59 | * @return void |
| 60 | 60 | */ |
| 61 | - public function __construct($elementName=null, $elementLabel=null, $attributes=null) |
|
| 61 | + public function __construct($elementName = null, $elementLabel = null, $attributes = null) |
|
| 62 | 62 | { |
| 63 | 63 | $attributes['class'] = isset($attributes['class']) ? $attributes['class'] : 'form-control'; |
| 64 | 64 | $columnsSize = isset($attributes['cols-size']) ? $attributes['cols-size'] : null; |
@@ -193,12 +193,12 @@ discard block |
||
| 193 | 193 | if ($this->_flagFrozen) { |
| 194 | 194 | return $this->getFrozenHtml(); |
| 195 | 195 | } else { |
| 196 | - return $this->_getTabs() . |
|
| 197 | - '<textarea' . $this->_getAttrString($this->_attributes) . '>' . |
|
| 196 | + return $this->_getTabs(). |
|
| 197 | + '<textarea'.$this->_getAttrString($this->_attributes).'>'. |
|
| 198 | 198 | // because we wrap the form later we don't want the text indented |
| 199 | 199 | // Modified by Ivan Tcholakov, 16-MAR-2010. |
| 200 | 200 | //preg_replace("/(\r\n|\n|\r)/", '
', htmlspecialchars($this->_value)) . |
| 201 | - preg_replace("/(\r\n|\n|\r)/", '
', @htmlspecialchars($this->_value, ENT_COMPAT, HTML_Common::charset())) . |
|
| 201 | + preg_replace("/(\r\n|\n|\r)/", '
', @htmlspecialchars($this->_value, ENT_COMPAT, HTML_Common::charset())). |
|
| 202 | 202 | // |
| 203 | 203 | '</textarea>'; |
| 204 | 204 | } |
@@ -218,11 +218,11 @@ discard block |
||
| 218 | 218 | $value = @htmlspecialchars($this->getValue(), ENT_COMPAT, HTML_Common::charset()); |
| 219 | 219 | // |
| 220 | 220 | if ($this->getAttribute('wrap') == 'off') { |
| 221 | - $html = $this->_getTabs() . '<pre>' . $value."</pre>\n"; |
|
| 221 | + $html = $this->_getTabs().'<pre>'.$value."</pre>\n"; |
|
| 222 | 222 | } else { |
| 223 | 223 | $html = nl2br($value)."\n"; |
| 224 | 224 | } |
| 225 | - return $html . $this->_getPersistantData(); |
|
| 225 | + return $html.$this->_getPersistantData(); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | /** |
@@ -665,7 +665,7 @@ discard block |
||
| 665 | 665 | * Adds a table row and returns the row identifier |
| 666 | 666 | * @param array $contents (optional) Must be a indexed array of |
| 667 | 667 | * valid cell contents |
| 668 | - * @param mixed $attributes (optional) Associative array or string |
|
| 668 | + * @param string $attributes (optional) Associative array or string |
|
| 669 | 669 | * of table row attributes. This can also |
| 670 | 670 | * be an array of attributes, in which |
| 671 | 671 | * case the attributes will be repeated |
@@ -719,7 +719,7 @@ discard block |
||
| 719 | 719 | /** |
| 720 | 720 | * Updates the row attributes for an existing row |
| 721 | 721 | * @param int $row Row index |
| 722 | - * @param mixed $attributes Associative array or string of table row |
|
| 722 | + * @param string $attributes Associative array or string of table row |
|
| 723 | 723 | * attributes |
| 724 | 724 | * @param bool $inTR false if attributes are to be applied in |
| 725 | 725 | * TD tags; true if attributes are to be |
@@ -164,8 +164,8 @@ discard block |
||
| 164 | 164 | */ |
| 165 | 165 | function HTML_Table($attributes = null, $tabOffset = 0, $useTGroups = false) |
| 166 | 166 | { |
| 167 | - parent::__construct($attributes, (int)$tabOffset); |
|
| 168 | - $this->_useTGroups = (boolean)$useTGroups; |
|
| 167 | + parent::__construct($attributes, (int) $tabOffset); |
|
| 168 | + $this->_useTGroups = (boolean) $useTGroups; |
|
| 169 | 169 | $this->addBody(); |
| 170 | 170 | if ($this->_useTGroups) { |
| 171 | 171 | $this->_thead = new HTML_Table_Storage($tabOffset, $this->_useTGroups); |
@@ -272,12 +272,12 @@ discard block |
||
| 272 | 272 | function _adjustTbodyCount($body, $method) |
| 273 | 273 | { |
| 274 | 274 | if ($this->_autoGrow) { |
| 275 | - while ($this->_tbodyCount <= (int)$body) { |
|
| 275 | + while ($this->_tbodyCount <= (int) $body) { |
|
| 276 | 276 | $this->addBody(); |
| 277 | 277 | } |
| 278 | 278 | } else { |
| 279 | - return PEAR::raiseError('Invalid body reference[' . |
|
| 280 | - $body . '] in HTML_Table::' . $method); |
|
| 279 | + return PEAR::raiseError('Invalid body reference['. |
|
| 280 | + $body.'] in HTML_Table::'.$method); |
|
| 281 | 281 | } |
| 282 | 282 | } |
| 283 | 283 | |
@@ -939,26 +939,26 @@ discard block |
||
| 939 | 939 | $tBodyMaxColCount = max($tBodyColCounts); |
| 940 | 940 | } |
| 941 | 941 | if ($this->_comment) { |
| 942 | - $strHtml .= $tabs . "<!-- $this->_comment -->" . $lnEnd; |
|
| 942 | + $strHtml .= $tabs."<!-- $this->_comment -->".$lnEnd; |
|
| 943 | 943 | } |
| 944 | 944 | if ($this->getRowCount() > 0 && $tBodyMaxColCount > 0) { |
| 945 | 945 | $strHtml .= |
| 946 | - $tabs . '<table' . $this->_getAttrString($this->_attributes) . '>' . $lnEnd; |
|
| 946 | + $tabs.'<table'.$this->_getAttrString($this->_attributes).'>'.$lnEnd; |
|
| 947 | 947 | if (!empty($this->_caption)) { |
| 948 | 948 | $attr = $this->_caption['attr']; |
| 949 | 949 | $contents = $this->_caption['contents']; |
| 950 | - $strHtml .= $tabs . $tab . '<caption' . $this->_getAttrString($attr) . '>'; |
|
| 950 | + $strHtml .= $tabs.$tab.'<caption'.$this->_getAttrString($attr).'>'; |
|
| 951 | 951 | if (is_array($contents)) { |
| 952 | 952 | $contents = implode(', ', $contents); |
| 953 | 953 | } |
| 954 | 954 | $strHtml .= $contents; |
| 955 | - $strHtml .= '</caption>' . $lnEnd; |
|
| 955 | + $strHtml .= '</caption>'.$lnEnd; |
|
| 956 | 956 | } |
| 957 | 957 | if (!empty($this->_colgroup)) { |
| 958 | 958 | foreach ($this->_colgroup as $g => $col) { |
| 959 | 959 | $attr = $this->_colgroup[$g]['attr']; |
| 960 | 960 | $contents = $this->_colgroup[$g]['contents']; |
| 961 | - $strHtml .= $tabs . $tab . '<colgroup' . $this->_getAttrString($attr) . '>'; |
|
| 961 | + $strHtml .= $tabs.$tab.'<colgroup'.$this->_getAttrString($attr).'>'; |
|
| 962 | 962 | if (!empty($contents)) { |
| 963 | 963 | $strHtml .= $lnEnd; |
| 964 | 964 | if (!is_array($contents)) { |
@@ -966,11 +966,11 @@ discard block |
||
| 966 | 966 | } |
| 967 | 967 | foreach ($contents as $a => $colAttr) { |
| 968 | 968 | $attr = $this->_parseAttributes($colAttr); |
| 969 | - $strHtml .= $tabs . $tab . $tab . '<col' . $this->_getAttrString($attr) . ' />' . $lnEnd; |
|
| 969 | + $strHtml .= $tabs.$tab.$tab.'<col'.$this->_getAttrString($attr).' />'.$lnEnd; |
|
| 970 | 970 | } |
| 971 | - $strHtml .= $tabs . $tab; |
|
| 971 | + $strHtml .= $tabs.$tab; |
|
| 972 | 972 | } |
| 973 | - $strHtml .= '</colgroup>' . $lnEnd; |
|
| 973 | + $strHtml .= '</colgroup>'.$lnEnd; |
|
| 974 | 974 | } |
| 975 | 975 | } |
| 976 | 976 | if ($this->_useTGroups) { |
@@ -986,31 +986,31 @@ discard block |
||
| 986 | 986 | if ($this->_thead !== null) { |
| 987 | 987 | $this->_thead->setColCount($maxColCount); |
| 988 | 988 | if ($this->_thead->getRowCount() > 0) { |
| 989 | - $strHtml .= $tabs . $tab . '<thead' . |
|
| 990 | - $this->_getAttrString($this->_thead->_attributes) . |
|
| 991 | - '>' . $lnEnd; |
|
| 989 | + $strHtml .= $tabs.$tab.'<thead'. |
|
| 990 | + $this->_getAttrString($this->_thead->_attributes). |
|
| 991 | + '>'.$lnEnd; |
|
| 992 | 992 | $strHtml .= $this->_thead->toHtml($tabs, $tab); |
| 993 | - $strHtml .= $tabs . $tab . '</thead>' . $lnEnd; |
|
| 993 | + $strHtml .= $tabs.$tab.'</thead>'.$lnEnd; |
|
| 994 | 994 | } |
| 995 | 995 | } |
| 996 | 996 | if ($this->_tfoot !== null) { |
| 997 | 997 | $this->_tfoot->setColCount($maxColCount); |
| 998 | 998 | if ($this->_tfoot->getRowCount() > 0) { |
| 999 | - $strHtml .= $tabs . $tab . '<tfoot' . |
|
| 1000 | - $this->_getAttrString($this->_tfoot->_attributes) . |
|
| 1001 | - '>' . $lnEnd; |
|
| 999 | + $strHtml .= $tabs.$tab.'<tfoot'. |
|
| 1000 | + $this->_getAttrString($this->_tfoot->_attributes). |
|
| 1001 | + '>'.$lnEnd; |
|
| 1002 | 1002 | $strHtml .= $this->_tfoot->toHtml($tabs, $tab); |
| 1003 | - $strHtml .= $tabs . $tab . '</tfoot>' . $lnEnd; |
|
| 1003 | + $strHtml .= $tabs.$tab.'</tfoot>'.$lnEnd; |
|
| 1004 | 1004 | } |
| 1005 | 1005 | } |
| 1006 | 1006 | for ($i = 0; $i < $this->_tbodyCount; $i++) { |
| 1007 | 1007 | $this->_tbodies[$i]->setColCount($maxColCount); |
| 1008 | 1008 | if ($this->_tbodies[$i]->getRowCount() > 0) { |
| 1009 | - $strHtml .= $tabs . $tab . '<tbody' . |
|
| 1010 | - $this->_getAttrString($this->_tbodies[$i]->_attributes) . |
|
| 1011 | - '>' . $lnEnd; |
|
| 1009 | + $strHtml .= $tabs.$tab.'<tbody'. |
|
| 1010 | + $this->_getAttrString($this->_tbodies[$i]->_attributes). |
|
| 1011 | + '>'.$lnEnd; |
|
| 1012 | 1012 | $strHtml .= $this->_tbodies[$i]->toHtml($tabs, $tab); |
| 1013 | - $strHtml .= $tabs . $tab . '</tbody>' . $lnEnd; |
|
| 1013 | + $strHtml .= $tabs.$tab.'</tbody>'.$lnEnd; |
|
| 1014 | 1014 | } |
| 1015 | 1015 | } |
| 1016 | 1016 | } else { |
@@ -1019,7 +1019,7 @@ discard block |
||
| 1019 | 1019 | $strHtml .= $this->_tbodies[$i]->toHtml($tabs, $tab); |
| 1020 | 1020 | } |
| 1021 | 1021 | } |
| 1022 | - $strHtml .= $tabs . '</table>' . $lnEnd; |
|
| 1022 | + $strHtml .= $tabs.'</table>'.$lnEnd; |
|
| 1023 | 1023 | } |
| 1024 | 1024 | return $strHtml; |
| 1025 | 1025 | } |
@@ -48,7 +48,6 @@ discard block |
||
| 48 | 48 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 49 | 49 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 50 | 50 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 51 | - |
|
| 52 | 51 | * |
| 53 | 52 | * @category HTML |
| 54 | 53 | * @package HTML_Table |
@@ -256,7 +255,7 @@ discard block |
||
| 256 | 255 | |
| 257 | 256 | $body = $this->_tbodyCount++; |
| 258 | 257 | $this->_tbodies[$body] = new HTML_Table_Storage($this->_tabOffset, |
| 259 | - $this->_useTGroups); |
|
| 258 | + $this->_useTGroups); |
|
| 260 | 259 | $this->_tbodies[$body]->setAutoFill($this->_autoFill); |
| 261 | 260 | $this->_tbodies[$body]->setAttributes($attributes); |
| 262 | 261 | return $body; |
@@ -308,7 +307,7 @@ discard block |
||
| 308 | 307 | if (isset($colgroup)) { |
| 309 | 308 | $attributes = $this->_parseAttributes($attributes); |
| 310 | 309 | $this->_colgroup[] = array('attr' => $attributes, |
| 311 | - 'contents' => $colgroup); |
|
| 310 | + 'contents' => $colgroup); |
|
| 312 | 311 | } else { |
| 313 | 312 | $this->_colgroup = array(); |
| 314 | 313 | } |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | /** |
| 166 | 166 | * Returns the autoFill value |
| 167 | 167 | * @access public |
| 168 | - * @return mixed |
|
| 168 | + * @return string |
|
| 169 | 169 | */ |
| 170 | 170 | function getAutoFill() |
| 171 | 171 | { |
@@ -174,7 +174,6 @@ discard block |
||
| 174 | 174 | |
| 175 | 175 | /** |
| 176 | 176 | * Sets the autoGrow value |
| 177 | - * @param bool $fill |
|
| 178 | 177 | * @access public |
| 179 | 178 | */ |
| 180 | 179 | function setAutoGrow($grow) |
@@ -185,7 +184,7 @@ discard block |
||
| 185 | 184 | /** |
| 186 | 185 | * Returns the autoGrow value |
| 187 | 186 | * @access public |
| 188 | - * @return mixed |
|
| 187 | + * @return boolean |
|
| 189 | 188 | */ |
| 190 | 189 | function getAutoGrow() |
| 191 | 190 | { |
@@ -128,8 +128,8 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | function HTML_Table_Storage($tabOffset = 0, $useTGroups = false) |
| 130 | 130 | { |
| 131 | - parent::__construct(null, (int)$tabOffset); |
|
| 132 | - $this->_useTGroups = (boolean)$useTGroups; |
|
| 131 | + parent::__construct(null, (int) $tabOffset); |
|
| 132 | + $this->_useTGroups = (boolean) $useTGroups; |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | */ |
| 289 | 289 | function setCellAttributes($row, $col, $attributes) |
| 290 | 290 | { |
| 291 | - if ( isset($this->_structure[$row][$col]) |
|
| 291 | + if (isset($this->_structure[$row][$col]) |
|
| 292 | 292 | && $this->_structure[$row][$col] == '__SPANNED__' |
| 293 | 293 | ) { |
| 294 | 294 | return; |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | */ |
| 315 | 315 | function updateCellAttributes($row, $col, $attributes) |
| 316 | 316 | { |
| 317 | - if ( isset($this->_structure[$row][$col]) |
|
| 317 | + if (isset($this->_structure[$row][$col]) |
|
| 318 | 318 | && $this->_structure[$row][$col] == '__SPANNED__' |
| 319 | 319 | ) { |
| 320 | 320 | return; |
@@ -337,13 +337,13 @@ discard block |
||
| 337 | 337 | */ |
| 338 | 338 | function getCellAttributes($row, $col) |
| 339 | 339 | { |
| 340 | - if ( isset($this->_structure[$row][$col]) |
|
| 340 | + if (isset($this->_structure[$row][$col]) |
|
| 341 | 341 | && $this->_structure[$row][$col] != '__SPANNED__' |
| 342 | 342 | ) { |
| 343 | 343 | return $this->_structure[$row][$col]['attr']; |
| 344 | 344 | } elseif (!isset($this->_structure[$row][$col])) { |
| 345 | - return PEAR::raiseError('Invalid table cell reference[' . |
|
| 346 | - $row . '][' . $col . '] in HTML_Table::getCellAttributes'); |
|
| 345 | + return PEAR::raiseError('Invalid table cell reference['. |
|
| 346 | + $row.']['.$col.'] in HTML_Table::getCellAttributes'); |
|
| 347 | 347 | } |
| 348 | 348 | return; |
| 349 | 349 | } |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | */ |
| 406 | 406 | function _setSingleCellContents($row, $col, $contents, $type = 'TD') |
| 407 | 407 | { |
| 408 | - if ( isset($this->_structure[$row][$col]) |
|
| 408 | + if (isset($this->_structure[$row][$col]) |
|
| 409 | 409 | && $this->_structure[$row][$col] == '__SPANNED__' |
| 410 | 410 | ) { |
| 411 | 411 | return; |
@@ -427,14 +427,14 @@ discard block |
||
| 427 | 427 | */ |
| 428 | 428 | function getCellContents($row, $col) |
| 429 | 429 | { |
| 430 | - if ( isset($this->_structure[$row][$col]) |
|
| 430 | + if (isset($this->_structure[$row][$col]) |
|
| 431 | 431 | && $this->_structure[$row][$col] == '__SPANNED__' |
| 432 | 432 | ) { |
| 433 | 433 | return; |
| 434 | 434 | } |
| 435 | 435 | if (!isset($this->_structure[$row][$col])) { |
| 436 | - return PEAR::raiseError('Invalid table cell reference[' . |
|
| 437 | - $row . '][' . $col . '] in HTML_Table::getCellContents'); |
|
| 436 | + return PEAR::raiseError('Invalid table cell reference['. |
|
| 437 | + $row.']['.$col.'] in HTML_Table::getCellContents'); |
|
| 438 | 438 | } |
| 439 | 439 | return $this->_structure[$row][$col]['contents']; |
| 440 | 440 | } |
@@ -477,7 +477,7 @@ discard block |
||
| 477 | 477 | $inTR = false) |
| 478 | 478 | { |
| 479 | 479 | if (isset($contents) && !is_array($contents)) { |
| 480 | - return PEAR::raiseError('First parameter to HTML_Table::addRow ' . |
|
| 480 | + return PEAR::raiseError('First parameter to HTML_Table::addRow '. |
|
| 481 | 481 | 'must be an array'); |
| 482 | 482 | } |
| 483 | 483 | if (is_null($contents)) { |
@@ -620,7 +620,7 @@ discard block |
||
| 620 | 620 | function addCol($contents = null, $attributes = null, $type = 'td') |
| 621 | 621 | { |
| 622 | 622 | if (isset($contents) && !is_array($contents)) { |
| 623 | - return PEAR::raiseError('First parameter to HTML_Table::addCol ' . |
|
| 623 | + return PEAR::raiseError('First parameter to HTML_Table::addCol '. |
|
| 624 | 624 | 'must be an array'); |
| 625 | 625 | } |
| 626 | 626 | if (is_null($contents)) { |
@@ -727,13 +727,13 @@ discard block |
||
| 727 | 727 | $extraTab = ''; |
| 728 | 728 | } |
| 729 | 729 | if ($this->_cols > 0) { |
| 730 | - for ($i = 0 ; $i < $this->_rows ; $i++) { |
|
| 730 | + for ($i = 0; $i < $this->_rows; $i++) { |
|
| 731 | 731 | $attr = ''; |
| 732 | 732 | if (isset($this->_structure[$i]['attr'])) { |
| 733 | 733 | $attr = $this->_getAttrString($this->_structure[$i]['attr']); |
| 734 | 734 | } |
| 735 | - $strHtml .= $tabs .$tab . $extraTab . '<tr'.$attr.'>' . $lnEnd; |
|
| 736 | - for ($j = 0 ; $j < $this->_cols ; $j++) { |
|
| 735 | + $strHtml .= $tabs.$tab.$extraTab.'<tr'.$attr.'>'.$lnEnd; |
|
| 736 | + for ($j = 0; $j < $this->_cols; $j++) { |
|
| 737 | 737 | $attr = ''; |
| 738 | 738 | $contents = ''; |
| 739 | 739 | $type = 'td'; |
@@ -753,7 +753,7 @@ discard block |
||
| 753 | 753 | if (is_object($contents)) { |
| 754 | 754 | // changes indent and line end settings on nested tables |
| 755 | 755 | if (is_subclass_of($contents, 'html_common')) { |
| 756 | - $contents->setTab($tab . $extraTab); |
|
| 756 | + $contents->setTab($tab.$extraTab); |
|
| 757 | 757 | $contents->setTabOffset($this->_tabOffset + 3); |
| 758 | 758 | $contents->_nestLevel = $this->_nestLevel + 1; |
| 759 | 759 | $contents->setLineEnd($this->_getLineEnd()); |
@@ -768,7 +768,7 @@ discard block |
||
| 768 | 768 | $contents = implode(', ', $contents); |
| 769 | 769 | } |
| 770 | 770 | |
| 771 | - $typeContent = $tabs . $tab . $tab . $extraTab . "<$type" . $this->_getAttrString($attr) . '>'; |
|
| 771 | + $typeContent = $tabs.$tab.$tab.$extraTab."<$type".$this->_getAttrString($attr).'>'; |
|
| 772 | 772 | |
| 773 | 773 | if (empty($contents)) { |
| 774 | 774 | if (isset($this->_autoFill) && $this->_autoFill) { |
@@ -777,14 +777,14 @@ discard block |
||
| 777 | 777 | } else { |
| 778 | 778 | $typeContent .= $contents; |
| 779 | 779 | } |
| 780 | - $typeContent .= "</$type>" . $lnEnd; |
|
| 780 | + $typeContent .= "</$type>".$lnEnd; |
|
| 781 | 781 | |
| 782 | 782 | if (!empty($contents)) { |
| 783 | 783 | $strHtml .= $typeContent; |
| 784 | 784 | } |
| 785 | 785 | |
| 786 | 786 | } |
| 787 | - $strHtml .= $tabs . $tab . $extraTab . '</tr>' . $lnEnd; |
|
| 787 | + $strHtml .= $tabs.$tab.$extraTab.'</tr>'.$lnEnd; |
|
| 788 | 788 | } |
| 789 | 789 | } |
| 790 | 790 | return $strHtml; |