@@ -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 |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | * |
146 | 146 | * @since 1.0 |
147 | 147 | * @access public |
148 | - * @return array of selected values |
|
148 | + * @return string of selected values |
|
149 | 149 | */ |
150 | 150 | function getSelected() |
151 | 151 | { |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | /** |
209 | 209 | * Sets the value of the form element |
210 | 210 | * |
211 | - * @param mixed $values Array or comma delimited string of selected values |
|
211 | + * @param mixed $value Array or comma delimited string of selected values |
|
212 | 212 | * @since 1.0 |
213 | 213 | * @access public |
214 | 214 | * @return void |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | * |
227 | 227 | * @since 1.0 |
228 | 228 | * @access public |
229 | - * @return array of selected values |
|
229 | + * @return string of selected values |
|
230 | 230 | */ |
231 | 231 | function getValue() |
232 | 232 | { |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * |
258 | 258 | * @since 1.0 |
259 | 259 | * @access public |
260 | - * @return int |
|
260 | + * @return string|null |
|
261 | 261 | */ |
262 | 262 | function getSize() |
263 | 263 | { |
@@ -357,12 +357,9 @@ discard block |
||
357 | 357 | /** |
358 | 358 | * Adds a new OPTION to the SELECT |
359 | 359 | * |
360 | - * @param string $text Display text for the OPTION |
|
361 | - * @param string $value Value for the OPTION |
|
362 | - * @param mixed $attributes Either a typical HTML attribute string |
|
363 | - * or an associative array |
|
364 | 360 | * @since 1.0 |
365 | 361 | * @access public |
362 | + * @param string $label |
|
366 | 363 | * @return void |
367 | 364 | */ |
368 | 365 | function addOptGroup($options, $label) |
@@ -355,16 +355,16 @@ discard block |
||
355 | 355 | |
356 | 356 | |
357 | 357 | /** |
358 | - * Adds a new OPTION to the SELECT |
|
359 | - * |
|
360 | - * @param string $text Display text for the OPTION |
|
361 | - * @param string $value Value for the OPTION |
|
362 | - * @param mixed $attributes Either a typical HTML attribute string |
|
363 | - * or an associative array |
|
364 | - * @since 1.0 |
|
365 | - * @access public |
|
366 | - * @return void |
|
367 | - */ |
|
358 | + * Adds a new OPTION to the SELECT |
|
359 | + * |
|
360 | + * @param string $text Display text for the OPTION |
|
361 | + * @param string $value Value for the OPTION |
|
362 | + * @param mixed $attributes Either a typical HTML attribute string |
|
363 | + * or an associative array |
|
364 | + * @since 1.0 |
|
365 | + * @access public |
|
366 | + * @return void |
|
367 | + */ |
|
368 | 368 | function addOptGroup($options, $label) |
369 | 369 | { |
370 | 370 | foreach ($options as $option) { |
@@ -614,10 +614,10 @@ discard block |
||
614 | 614 | } |
615 | 615 | foreach ($value as $key => $item) { |
616 | 616 | $html .= '<input' . $this->_getAttrString(array( |
617 | - 'type' => 'hidden', |
|
618 | - 'name' => $name, |
|
619 | - 'value' => $this->_values[$key] |
|
620 | - ) + $idAttr) . ' />'; |
|
617 | + 'type' => 'hidden', |
|
618 | + 'name' => $name, |
|
619 | + 'value' => $this->_values[$key] |
|
620 | + ) + $idAttr) . ' />'; |
|
621 | 621 | } |
622 | 622 | } |
623 | 623 | return $html; |
@@ -626,10 +626,10 @@ discard block |
||
626 | 626 | // }}} |
627 | 627 | // {{{ exportValue() |
628 | 628 | |
629 | - /** |
|
630 | - * We check the options and return only the values that _could_ have been |
|
631 | - * selected. We also return a scalar value if select is not "multiple" |
|
632 | - */ |
|
629 | + /** |
|
630 | + * We check the options and return only the values that _could_ have been |
|
631 | + * selected. We also return a scalar value if select is not "multiple" |
|
632 | + */ |
|
633 | 633 | function exportValue(&$submitValues, $assoc = false) |
634 | 634 | { |
635 | 635 | $value = $this->_findValue($submitValues); |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | if (!empty($attributes['class'])) { |
87 | 87 | $oldClass = $attributes['class']; |
88 | 88 | } |
89 | - $attributes['class'] = $oldClass . ' selectpicker show-tick form-control'; |
|
89 | + $attributes['class'] = $oldClass.' selectpicker show-tick form-control'; |
|
90 | 90 | $attributes['data-live-search'] = 'true'; |
91 | 91 | } |
92 | 92 | $columnsSize = isset($attributes['cols-size']) ? $attributes['cols-size'] : null; |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | function getPrivateName() |
197 | 197 | { |
198 | 198 | if ($this->getAttribute('multiple')) { |
199 | - return $this->getName() . '[]'; |
|
199 | + return $this->getName().'[]'; |
|
200 | 200 | } else { |
201 | 201 | return $this->getName(); |
202 | 202 | } |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | */ |
313 | 313 | function getMultiple() |
314 | 314 | { |
315 | - return (bool)$this->getAttribute('multiple'); |
|
315 | + return (bool) $this->getAttribute('multiple'); |
|
316 | 316 | } //end func getMultiple |
317 | 317 | |
318 | 318 | // }}} |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | function addOption($text, $value, $attributes = null, $return_array = false) |
333 | 333 | { |
334 | 334 | if (null === $attributes) { |
335 | - $attributes = array('value' => (string)$value); |
|
335 | + $attributes = array('value' => (string) $value); |
|
336 | 336 | } else { |
337 | 337 | $attributes = $this->_parseAttributes($attributes); |
338 | 338 | if (isset($attributes['selected'])) { |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | $this->_values[] = $value; |
345 | 345 | } |
346 | 346 | } |
347 | - $this->_updateAttrArray($attributes, array('value' => (string)$value)); |
|
347 | + $this->_updateAttrArray($attributes, array('value' => (string) $value)); |
|
348 | 348 | } |
349 | 349 | if ($return_array) { |
350 | 350 | return array('text' => $text, 'attr' => $attributes); |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | * @return PEAR_Error on error or true |
384 | 384 | * @throws PEAR_Error |
385 | 385 | */ |
386 | - function loadArray($arr, $values=null) |
|
386 | + function loadArray($arr, $values = null) |
|
387 | 387 | { |
388 | 388 | if (!is_array($arr)) { |
389 | 389 | return PEAR::raiseError('Argument 1 of HTML_Select::loadArray is not a valid array'); |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | * @return PEAR_Error on error or true |
421 | 421 | * @throws PEAR_Error |
422 | 422 | */ |
423 | - function loadDbResult(&$result, $textCol=null, $valueCol=null, $values=null) |
|
423 | + function loadDbResult(&$result, $textCol = null, $valueCol = null, $values = null) |
|
424 | 424 | { |
425 | 425 | if (!is_object($result) || !is_a($result, 'db_result')) { |
426 | 426 | return PEAR::raiseError('Argument 1 of HTML_Select::loadDbResult is not a valid DB_result'); |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | $this->setValue($values); |
430 | 430 | } |
431 | 431 | $fetchMode = ($textCol && $valueCol) ? DB_FETCHMODE_ASSOC : DB_FETCHMODE_ORDERED; |
432 | - while (is_array($row = $result->fetchRow($fetchMode)) ) { |
|
432 | + while (is_array($row = $result->fetchRow($fetchMode))) { |
|
433 | 433 | if ($fetchMode == DB_FETCHMODE_ASSOC) { |
434 | 434 | $this->addOption($row[$textCol], $row[$valueCol]); |
435 | 435 | } else { |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | * @return void |
456 | 456 | * @throws PEAR_Error |
457 | 457 | */ |
458 | - function loadQuery(&$conn, $sql, $textCol=null, $valueCol=null, $values=null) |
|
458 | + function loadQuery(&$conn, $sql, $textCol = null, $valueCol = null, $values = null) |
|
459 | 459 | { |
460 | 460 | if (is_string($conn)) { |
461 | 461 | require_once('DB.php'); |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | * @return PEAR_Error on error or true |
503 | 503 | * @throws PEAR_Error |
504 | 504 | */ |
505 | - function load(&$options, $param1=null, $param2=null, $param3=null, $param4=null) |
|
505 | + function load(&$options, $param1 = null, $param2 = null, $param3 = null, $param4 = null) |
|
506 | 506 | { |
507 | 507 | switch (true) { |
508 | 508 | case is_array($options): |
@@ -539,32 +539,32 @@ discard block |
||
539 | 539 | $strHtml = ''; |
540 | 540 | |
541 | 541 | if ($this->getComment() != '') { |
542 | - $strHtml .= $tabs . '<!-- ' . $this->getComment() . " //-->\n"; |
|
542 | + $strHtml .= $tabs.'<!-- '.$this->getComment()." //-->\n"; |
|
543 | 543 | } |
544 | 544 | |
545 | 545 | if (!$this->getMultiple()) { |
546 | 546 | $attrString = $this->_getAttrString($this->_attributes); |
547 | 547 | } else { |
548 | 548 | $myName = $this->getName(); |
549 | - $this->setName($myName . '[]'); |
|
549 | + $this->setName($myName.'[]'); |
|
550 | 550 | $attrString = $this->_getAttrString($this->_attributes); |
551 | 551 | $this->setName($myName); |
552 | 552 | } |
553 | 553 | |
554 | - $strHtml .= $tabs . '<select ' . $attrString . ">\n"; |
|
554 | + $strHtml .= $tabs.'<select '.$attrString.">\n"; |
|
555 | 555 | |
556 | - $strValues = is_array($this->_values)? array_map('strval', $this->_values): array(); |
|
556 | + $strValues = is_array($this->_values) ? array_map('strval', $this->_values) : array(); |
|
557 | 557 | |
558 | 558 | foreach ($this->_options as $option) { |
559 | 559 | |
560 | 560 | if (!empty($strValues) && in_array($option['attr']['value'], $strValues, true)) { |
561 | 561 | $option['attr']['selected'] = 'selected'; |
562 | 562 | } |
563 | - $strHtml .= $tabs . "<option" . $this->_getAttrString($option['attr']) . '>' . |
|
564 | - $option['text'] . "</option>"; |
|
563 | + $strHtml .= $tabs."<option".$this->_getAttrString($option['attr']).'>'. |
|
564 | + $option['text']."</option>"; |
|
565 | 565 | } |
566 | 566 | foreach ($this->_optgroups as $optgroup) { |
567 | - $strHtml .= $tabs . '<optgroup label="' . $optgroup['label'] . '">'; |
|
567 | + $strHtml .= $tabs.'<optgroup label="'.$optgroup['label'].'">'; |
|
568 | 568 | foreach ($optgroup['options'] as $option) { |
569 | 569 | $text = $option['text']; |
570 | 570 | unset($option['text']); |
@@ -573,11 +573,11 @@ discard block |
||
573 | 573 | $option['selected'] = 'selected'; |
574 | 574 | } |
575 | 575 | |
576 | - $strHtml .= $tabs . " <option" . $this->_getAttrString($option) . '>' .$text . "</option>"; |
|
576 | + $strHtml .= $tabs." <option".$this->_getAttrString($option).'>'.$text."</option>"; |
|
577 | 577 | } |
578 | 578 | $strHtml .= "</optgroup>"; |
579 | 579 | } |
580 | - return $strHtml . $tabs . '</select>'; |
|
580 | + return $strHtml.$tabs.'</select>'; |
|
581 | 581 | } |
582 | 582 | } |
583 | 583 | |
@@ -602,22 +602,22 @@ discard block |
||
602 | 602 | } |
603 | 603 | } |
604 | 604 | } |
605 | - $html = empty($value)? ' ': join('<br />', $value); |
|
605 | + $html = empty($value) ? ' ' : join('<br />', $value); |
|
606 | 606 | if ($this->_persistantFreeze) { |
607 | 607 | $name = $this->getPrivateName(); |
608 | 608 | // Only use id attribute if doing single hidden input |
609 | 609 | if (1 == count($value)) { |
610 | 610 | $id = $this->getAttribute('id'); |
611 | - $idAttr = isset($id)? array('id' => $id): array(); |
|
611 | + $idAttr = isset($id) ? array('id' => $id) : array(); |
|
612 | 612 | } else { |
613 | 613 | $idAttr = array(); |
614 | 614 | } |
615 | 615 | foreach ($value as $key => $item) { |
616 | - $html .= '<input' . $this->_getAttrString(array( |
|
616 | + $html .= '<input'.$this->_getAttrString(array( |
|
617 | 617 | 'type' => 'hidden', |
618 | 618 | 'name' => $name, |
619 | 619 | 'value' => $this->_values[$key] |
620 | - ) + $idAttr) . ' />'; |
|
620 | + ) + $idAttr).' />'; |
|
621 | 621 | } |
622 | 622 | } |
623 | 623 | return $html; |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | $value = $this->_findValue($submitValues); |
636 | 636 | if (is_null($value)) { |
637 | 637 | $value = $this->getValue(); |
638 | - } elseif(!is_array($value)) { |
|
638 | + } elseif (!is_array($value)) { |
|
639 | 639 | $value = array($value); |
640 | 640 | } |
641 | 641 | if (is_array($value) && !empty($this->_options)) { |
@@ -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 | } |