@@ -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)) { |
@@ -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 |
@@ -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,8 +165,8 @@ discard block |
||
165 | 165 | */ |
166 | 166 | public function __construct($attributes = null, $tabOffset = 0, $useTGroups = false) |
167 | 167 | { |
168 | - parent::__construct($attributes, (int)$tabOffset); |
|
169 | - $this->_useTGroups = (boolean)$useTGroups; |
|
168 | + parent::__construct($attributes, (int) $tabOffset); |
|
169 | + $this->_useTGroups = (boolean) $useTGroups; |
|
170 | 170 | $this->addBody(); |
171 | 171 | if ($this->_useTGroups) { |
172 | 172 | $this->_thead = new HTML_Table_Storage($tabOffset, $this->_useTGroups); |
@@ -273,12 +273,12 @@ discard block |
||
273 | 273 | function _adjustTbodyCount($body, $method) |
274 | 274 | { |
275 | 275 | if ($this->_autoGrow) { |
276 | - while ($this->_tbodyCount <= (int)$body) { |
|
276 | + while ($this->_tbodyCount <= (int) $body) { |
|
277 | 277 | $this->addBody(); |
278 | 278 | } |
279 | 279 | } else { |
280 | - return PEAR::raiseError('Invalid body reference[' . |
|
281 | - $body . '] in HTML_Table::' . $method); |
|
280 | + return PEAR::raiseError('Invalid body reference['. |
|
281 | + $body.'] in HTML_Table::'.$method); |
|
282 | 282 | } |
283 | 283 | } |
284 | 284 | |
@@ -940,26 +940,26 @@ discard block |
||
940 | 940 | $tBodyMaxColCount = max($tBodyColCounts); |
941 | 941 | } |
942 | 942 | if ($this->_comment) { |
943 | - $strHtml .= $tabs . "<!-- $this->_comment -->" . $lnEnd; |
|
943 | + $strHtml .= $tabs."<!-- $this->_comment -->".$lnEnd; |
|
944 | 944 | } |
945 | 945 | if ($this->getRowCount() > 0 && $tBodyMaxColCount > 0) { |
946 | 946 | $strHtml .= |
947 | - $tabs . '<table' . $this->_getAttrString($this->_attributes) . '>' . $lnEnd; |
|
947 | + $tabs.'<table'.$this->_getAttrString($this->_attributes).'>'.$lnEnd; |
|
948 | 948 | if (!empty($this->_caption)) { |
949 | 949 | $attr = $this->_caption['attr']; |
950 | 950 | $contents = $this->_caption['contents']; |
951 | - $strHtml .= $tabs . $tab . '<caption' . $this->_getAttrString($attr) . '>'; |
|
951 | + $strHtml .= $tabs.$tab.'<caption'.$this->_getAttrString($attr).'>'; |
|
952 | 952 | if (is_array($contents)) { |
953 | 953 | $contents = implode(', ', $contents); |
954 | 954 | } |
955 | 955 | $strHtml .= $contents; |
956 | - $strHtml .= '</caption>' . $lnEnd; |
|
956 | + $strHtml .= '</caption>'.$lnEnd; |
|
957 | 957 | } |
958 | 958 | if (!empty($this->_colgroup)) { |
959 | 959 | foreach ($this->_colgroup as $g => $col) { |
960 | 960 | $attr = $this->_colgroup[$g]['attr']; |
961 | 961 | $contents = $this->_colgroup[$g]['contents']; |
962 | - $strHtml .= $tabs . $tab . '<colgroup' . $this->_getAttrString($attr) . '>'; |
|
962 | + $strHtml .= $tabs.$tab.'<colgroup'.$this->_getAttrString($attr).'>'; |
|
963 | 963 | if (!empty($contents)) { |
964 | 964 | $strHtml .= $lnEnd; |
965 | 965 | if (!is_array($contents)) { |
@@ -967,11 +967,11 @@ discard block |
||
967 | 967 | } |
968 | 968 | foreach ($contents as $a => $colAttr) { |
969 | 969 | $attr = $this->_parseAttributes($colAttr); |
970 | - $strHtml .= $tabs . $tab . $tab . '<col' . $this->_getAttrString($attr) . ' />' . $lnEnd; |
|
970 | + $strHtml .= $tabs.$tab.$tab.'<col'.$this->_getAttrString($attr).' />'.$lnEnd; |
|
971 | 971 | } |
972 | - $strHtml .= $tabs . $tab; |
|
972 | + $strHtml .= $tabs.$tab; |
|
973 | 973 | } |
974 | - $strHtml .= '</colgroup>' . $lnEnd; |
|
974 | + $strHtml .= '</colgroup>'.$lnEnd; |
|
975 | 975 | } |
976 | 976 | } |
977 | 977 | if ($this->_useTGroups) { |
@@ -987,31 +987,31 @@ discard block |
||
987 | 987 | if ($this->_thead !== null) { |
988 | 988 | $this->_thead->setColCount($maxColCount); |
989 | 989 | if ($this->_thead->getRowCount() > 0) { |
990 | - $strHtml .= $tabs . $tab . '<thead' . |
|
991 | - $this->_getAttrString($this->_thead->_attributes) . |
|
992 | - '>' . $lnEnd; |
|
990 | + $strHtml .= $tabs.$tab.'<thead'. |
|
991 | + $this->_getAttrString($this->_thead->_attributes). |
|
992 | + '>'.$lnEnd; |
|
993 | 993 | $strHtml .= $this->_thead->toHtml($tabs, $tab); |
994 | - $strHtml .= $tabs . $tab . '</thead>' . $lnEnd; |
|
994 | + $strHtml .= $tabs.$tab.'</thead>'.$lnEnd; |
|
995 | 995 | } |
996 | 996 | } |
997 | 997 | if ($this->_tfoot !== null) { |
998 | 998 | $this->_tfoot->setColCount($maxColCount); |
999 | 999 | if ($this->_tfoot->getRowCount() > 0) { |
1000 | - $strHtml .= $tabs . $tab . '<tfoot' . |
|
1001 | - $this->_getAttrString($this->_tfoot->_attributes) . |
|
1002 | - '>' . $lnEnd; |
|
1000 | + $strHtml .= $tabs.$tab.'<tfoot'. |
|
1001 | + $this->_getAttrString($this->_tfoot->_attributes). |
|
1002 | + '>'.$lnEnd; |
|
1003 | 1003 | $strHtml .= $this->_tfoot->toHtml($tabs, $tab); |
1004 | - $strHtml .= $tabs . $tab . '</tfoot>' . $lnEnd; |
|
1004 | + $strHtml .= $tabs.$tab.'</tfoot>'.$lnEnd; |
|
1005 | 1005 | } |
1006 | 1006 | } |
1007 | 1007 | for ($i = 0; $i < $this->_tbodyCount; $i++) { |
1008 | 1008 | $this->_tbodies[$i]->setColCount($maxColCount); |
1009 | 1009 | if ($this->_tbodies[$i]->getRowCount() > 0) { |
1010 | - $strHtml .= $tabs . $tab . '<tbody' . |
|
1011 | - $this->_getAttrString($this->_tbodies[$i]->_attributes) . |
|
1012 | - '>' . $lnEnd; |
|
1010 | + $strHtml .= $tabs.$tab.'<tbody'. |
|
1011 | + $this->_getAttrString($this->_tbodies[$i]->_attributes). |
|
1012 | + '>'.$lnEnd; |
|
1013 | 1013 | $strHtml .= $this->_tbodies[$i]->toHtml($tabs, $tab); |
1014 | - $strHtml .= $tabs . $tab . '</tbody>' . $lnEnd; |
|
1014 | + $strHtml .= $tabs.$tab.'</tbody>'.$lnEnd; |
|
1015 | 1015 | } |
1016 | 1016 | } |
1017 | 1017 | } else { |
@@ -1020,7 +1020,7 @@ discard block |
||
1020 | 1020 | $strHtml .= $this->_tbodies[$i]->toHtml($tabs, $tab); |
1021 | 1021 | } |
1022 | 1022 | } |
1023 | - $strHtml .= $tabs . '</table>' . $lnEnd; |
|
1023 | + $strHtml .= $tabs.'</table>'.$lnEnd; |
|
1024 | 1024 | } |
1025 | 1025 | return $strHtml; |
1026 | 1026 | } |
@@ -328,8 +328,8 @@ discard block |
||
328 | 328 | * the Image_Text object after changing options. For possible options, please |
329 | 329 | * take a look at the class options array! |
330 | 330 | * |
331 | - * @param array|string $option A single option name or the options array. |
|
332 | - * @param mixed $value Option value if $option is string. |
|
331 | + * @param string $option A single option name or the options array. |
|
332 | + * @param string $value Option value if $option is string. |
|
333 | 333 | * |
334 | 334 | * @return void |
335 | 335 | * @see Image_Text::Image_Text() |
@@ -982,7 +982,7 @@ discard block |
||
982 | 982 | * @param bool $save Save or not the image on printout. |
983 | 983 | * @param bool $free Free the image on exit. |
984 | 984 | * |
985 | - * @return bool True on success |
|
985 | + * @return boolean|null True on success |
|
986 | 986 | * @see Image_Text::save() |
987 | 987 | * @throws Image_Text_Exception |
988 | 988 | */ |
@@ -1133,7 +1133,7 @@ discard block |
||
1133 | 1133 | * @param string $scolor string of colorcode. |
1134 | 1134 | * |
1135 | 1135 | * @see Image_Text::IMAGE_TEXT_REGEX_HTMLCOLOR |
1136 | - * @return bool|array false if string can't be converted to array |
|
1136 | + * @return resource false if string can't be converted to array |
|
1137 | 1137 | */ |
1138 | 1138 | public static function convertString2RGB($scolor) |
1139 | 1139 | { |
@@ -346,19 +346,19 @@ discard block |
||
346 | 346 | } |
347 | 347 | foreach ($option as $opt => $val) { |
348 | 348 | switch ($opt) { |
349 | - case 'color': |
|
350 | - $this->setColors($val); |
|
351 | - break; |
|
352 | - case 'text': |
|
353 | - if (is_array($val)) { |
|
354 | - $this->_text = implode('\n', $val); |
|
355 | - } else { |
|
356 | - $this->_text = $val; |
|
357 | - } |
|
358 | - break; |
|
359 | - default: |
|
360 | - $this->_options[$opt] = $val; |
|
361 | - break; |
|
349 | + case 'color': |
|
350 | + $this->setColors($val); |
|
351 | + break; |
|
352 | + case 'text': |
|
353 | + if (is_array($val)) { |
|
354 | + $this->_text = implode('\n', $val); |
|
355 | + } else { |
|
356 | + $this->_text = $val; |
|
357 | + } |
|
358 | + break; |
|
359 | + default: |
|
360 | + $this->_options[$opt] = $val; |
|
361 | + break; |
|
362 | 362 | } |
363 | 363 | if (isset($reInits[$opt])) { |
364 | 364 | $this->_init = false; |
@@ -511,45 +511,45 @@ discard block |
||
511 | 511 | $image_canvas = false; |
512 | 512 | switch (true) { |
513 | 513 | |
514 | - case (empty($this->_options['canvas'])): |
|
515 | - // Create new image from width && height of the clipping |
|
516 | - $this->_img = imagecreatetruecolor( |
|
517 | - $this->_options['width'], $this->_options['height'] |
|
518 | - ); |
|
519 | - if (!$this->_img) { |
|
520 | - throw new Image_Text_Exception('Could not create image canvas.'); |
|
521 | - } |
|
522 | - break; |
|
514 | + case (empty($this->_options['canvas'])): |
|
515 | + // Create new image from width && height of the clipping |
|
516 | + $this->_img = imagecreatetruecolor( |
|
517 | + $this->_options['width'], $this->_options['height'] |
|
518 | + ); |
|
519 | + if (!$this->_img) { |
|
520 | + throw new Image_Text_Exception('Could not create image canvas.'); |
|
521 | + } |
|
522 | + break; |
|
523 | 523 | |
524 | - case (is_resource($this->_options['canvas']) && |
|
525 | - get_resource_type($this->_options['canvas']) == 'gd'): |
|
526 | - // The canvas is an image resource |
|
527 | - $image_canvas = true; |
|
528 | - $this->_img = $this->_options['canvas']; |
|
529 | - break; |
|
524 | + case (is_resource($this->_options['canvas']) && |
|
525 | + get_resource_type($this->_options['canvas']) == 'gd'): |
|
526 | + // The canvas is an image resource |
|
527 | + $image_canvas = true; |
|
528 | + $this->_img = $this->_options['canvas']; |
|
529 | + break; |
|
530 | 530 | |
531 | - case (is_array($this->_options['canvas']) && |
|
532 | - isset($this->_options['canvas']['width']) && |
|
533 | - isset($this->_options['canvas']['height'])): |
|
531 | + case (is_array($this->_options['canvas']) && |
|
532 | + isset($this->_options['canvas']['width']) && |
|
533 | + isset($this->_options['canvas']['height'])): |
|
534 | 534 | |
535 | - // Canvas must be a width and height measure |
|
536 | - $this->_img = imagecreatetruecolor( |
|
537 | - $this->_options['canvas']['width'], |
|
538 | - $this->_options['canvas']['height'] |
|
539 | - ); |
|
540 | - break; |
|
535 | + // Canvas must be a width and height measure |
|
536 | + $this->_img = imagecreatetruecolor( |
|
537 | + $this->_options['canvas']['width'], |
|
538 | + $this->_options['canvas']['height'] |
|
539 | + ); |
|
540 | + break; |
|
541 | 541 | |
542 | - case (is_array($this->_options['canvas']) && |
|
543 | - isset($this->_options['canvas']['size']) && |
|
544 | - ($this->_options['canvas']['size'] = 'auto')): |
|
542 | + case (is_array($this->_options['canvas']) && |
|
543 | + isset($this->_options['canvas']['size']) && |
|
544 | + ($this->_options['canvas']['size'] = 'auto')): |
|
545 | 545 | |
546 | - case (is_string($this->_options['canvas']) && |
|
547 | - ($this->_options['canvas'] = 'auto')): |
|
548 | - $this->_mode = 'auto'; |
|
549 | - break; |
|
546 | + case (is_string($this->_options['canvas']) && |
|
547 | + ($this->_options['canvas'] = 'auto')): |
|
548 | + $this->_mode = 'auto'; |
|
549 | + break; |
|
550 | 550 | |
551 | - default: |
|
552 | - throw new Image_Text_Exception('Could not create image canvas.'); |
|
551 | + default: |
|
552 | + throw new Image_Text_Exception('Could not create image canvas.'); |
|
553 | 553 | } |
554 | 554 | |
555 | 555 | if ($this->_img) { |
@@ -889,19 +889,19 @@ discard block |
||
889 | 889 | $cosR = cos($radians); |
890 | 890 | |
891 | 891 | switch ($this->_options['valign']) { |
892 | - case self::IMAGE_TEXT_ALIGN_TOP: |
|
893 | - $valign_space = 0; |
|
894 | - break; |
|
895 | - case self::IMAGE_TEXT_ALIGN_MIDDLE: |
|
896 | - $valign_space = ($this->_options['height'] |
|
897 | - - $this->_realTextSize['height']) / 2; |
|
898 | - break; |
|
899 | - case self::IMAGE_TEXT_ALIGN_BOTTOM: |
|
900 | - $valign_space = $this->_options['height'] |
|
901 | - - $this->_realTextSize['height']; |
|
902 | - break; |
|
903 | - default: |
|
904 | - $valign_space = 0; |
|
892 | + case self::IMAGE_TEXT_ALIGN_TOP: |
|
893 | + $valign_space = 0; |
|
894 | + break; |
|
895 | + case self::IMAGE_TEXT_ALIGN_MIDDLE: |
|
896 | + $valign_space = ($this->_options['height'] |
|
897 | + - $this->_realTextSize['height']) / 2; |
|
898 | + break; |
|
899 | + case self::IMAGE_TEXT_ALIGN_BOTTOM: |
|
900 | + $valign_space = $this->_options['height'] |
|
901 | + - $this->_realTextSize['height']; |
|
902 | + break; |
|
903 | + default: |
|
904 | + $valign_space = 0; |
|
905 | 905 | } |
906 | 906 | |
907 | 907 | $space = (1 + $line_spacing) * $size; |
@@ -932,18 +932,18 @@ discard block |
||
932 | 932 | // Calc the position using the block width, the current line width and |
933 | 933 | // obviously the angle. That gives us the offset to slide the line. |
934 | 934 | switch ($align) { |
935 | - case self::IMAGE_TEXT_ALIGN_LEFT: |
|
936 | - $hyp = 0; |
|
937 | - break; |
|
938 | - case self::IMAGE_TEXT_ALIGN_RIGHT: |
|
939 | - $hyp = $block_width - $line_width - $left_margin; |
|
940 | - break; |
|
941 | - case self::IMAGE_TEXT_ALIGN_CENTER: |
|
942 | - $hyp = ($block_width - $line_width) / 2 - $left_margin; |
|
943 | - break; |
|
944 | - default: |
|
945 | - $hyp = 0; |
|
946 | - break; |
|
935 | + case self::IMAGE_TEXT_ALIGN_LEFT: |
|
936 | + $hyp = 0; |
|
937 | + break; |
|
938 | + case self::IMAGE_TEXT_ALIGN_RIGHT: |
|
939 | + $hyp = $block_width - $line_width - $left_margin; |
|
940 | + break; |
|
941 | + case self::IMAGE_TEXT_ALIGN_CENTER: |
|
942 | + $hyp = ($block_width - $line_width) / 2 - $left_margin; |
|
943 | + break; |
|
944 | + default: |
|
945 | + $hyp = 0; |
|
946 | + break; |
|
947 | 947 | } |
948 | 948 | |
949 | 949 | $posx = $new_posx + $cosR * $hyp; |
@@ -997,17 +997,17 @@ discard block |
||
997 | 997 | throw new Image_Text_Exception('Header already sent.'); |
998 | 998 | } |
999 | 999 | switch ($this->_options['image_type']) { |
1000 | - case IMAGETYPE_PNG: |
|
1001 | - $imgout = 'imagepng'; |
|
1002 | - break; |
|
1003 | - case IMAGETYPE_JPEG: |
|
1004 | - $imgout = 'imagejpeg'; |
|
1005 | - break; |
|
1006 | - case IMAGETYPE_BMP: |
|
1007 | - $imgout = 'imagebmp'; |
|
1008 | - break; |
|
1009 | - default: |
|
1010 | - throw new Image_Text_Exception('Unsupported image type.'); |
|
1000 | + case IMAGETYPE_PNG: |
|
1001 | + $imgout = 'imagepng'; |
|
1002 | + break; |
|
1003 | + case IMAGETYPE_JPEG: |
|
1004 | + $imgout = 'imagejpeg'; |
|
1005 | + break; |
|
1006 | + case IMAGETYPE_BMP: |
|
1007 | + $imgout = 'imagebmp'; |
|
1008 | + break; |
|
1009 | + default: |
|
1010 | + throw new Image_Text_Exception('Unsupported image type.'); |
|
1011 | 1011 | } |
1012 | 1012 | if ($save) { |
1013 | 1013 | $imgout($this->_img); |
@@ -1048,18 +1048,18 @@ discard block |
||
1048 | 1048 | } |
1049 | 1049 | |
1050 | 1050 | switch ($this->_options['image_type']) { |
1051 | - case IMAGETYPE_PNG: |
|
1052 | - $imgout = 'imagepng'; |
|
1053 | - break; |
|
1054 | - case IMAGETYPE_JPEG: |
|
1055 | - $imgout = 'imagejpeg'; |
|
1056 | - break; |
|
1057 | - case IMAGETYPE_BMP: |
|
1058 | - $imgout = 'imagebmp'; |
|
1059 | - break; |
|
1060 | - default: |
|
1061 | - throw new Image_Text_Exception('Unsupported image type.'); |
|
1062 | - break; |
|
1051 | + case IMAGETYPE_PNG: |
|
1052 | + $imgout = 'imagepng'; |
|
1053 | + break; |
|
1054 | + case IMAGETYPE_JPEG: |
|
1055 | + $imgout = 'imagejpeg'; |
|
1056 | + break; |
|
1057 | + case IMAGETYPE_BMP: |
|
1058 | + $imgout = 'imagebmp'; |
|
1059 | + break; |
|
1060 | + default: |
|
1061 | + throw new Image_Text_Exception('Unsupported image type.'); |
|
1062 | + break; |
|
1063 | 1063 | } |
1064 | 1064 | |
1065 | 1065 | $res = $imgout($this->_img, $destFile); |
@@ -683,7 +683,7 @@ discard block |
||
683 | 683 | $space = (1 + $this->_options['line_spacing']) |
684 | 684 | * $this->_options['font_size']; |
685 | 685 | |
686 | - $max_lines = (int)$this->_options['max_lines']; |
|
686 | + $max_lines = (int) $this->_options['max_lines']; |
|
687 | 687 | |
688 | 688 | if (($max_lines < 1) && !$force) { |
689 | 689 | return false; |
@@ -732,7 +732,7 @@ discard block |
||
732 | 732 | 'color' => $c |
733 | 733 | ); |
734 | 734 | $text_width = max($text_width, ($bounds[2] - $bounds[0])); |
735 | - $text_height += (int)$space; |
|
735 | + $text_height += (int) $space; |
|
736 | 736 | if (($text_height > $block_height) && !$force) { |
737 | 737 | return false; |
738 | 738 | } |
@@ -749,7 +749,7 @@ discard block |
||
749 | 749 | $text_line_next = $token; |
750 | 750 | $beginning_of_line = false; |
751 | 751 | } else { |
752 | - $text_line_next = $text_line . ' ' . $token; |
|
752 | + $text_line_next = $text_line.' '.$token; |
|
753 | 753 | } |
754 | 754 | $bounds = imagettfbbox($size, 0, $font, $text_line_next); |
755 | 755 | $prev_width = isset($prev_width) ? $width : 0; |
@@ -776,7 +776,7 @@ discard block |
||
776 | 776 | 'color' => $c |
777 | 777 | ); |
778 | 778 | $text_width = max($text_width, ($bounds[2] - $bounds[0])); |
779 | - $text_height += (int)$space; |
|
779 | + $text_height += (int) $space; |
|
780 | 780 | if (($text_height > $block_height) && !$force) { |
781 | 781 | return false; |
782 | 782 | } |
@@ -990,7 +990,7 @@ discard block |
||
990 | 990 | { |
991 | 991 | if (!headers_sent()) { |
992 | 992 | header( |
993 | - "Content-type: " . |
|
993 | + "Content-type: ". |
|
994 | 994 | image_type_to_mime_type($this->_options['image_type']) |
995 | 995 | ); |
996 | 996 | } else { |
@@ -1121,7 +1121,7 @@ discard block |
||
1121 | 1121 | $y += $vC[1]; |
1122 | 1122 | } |
1123 | 1123 | } |
1124 | - return array('x' => (int)round($x, 0), 'y' => (int)round($y, 0)); |
|
1124 | + return array('x' => (int) round($x, 0), 'y' => (int) round($y, 0)); |
|
1125 | 1125 | } |
1126 | 1126 | |
1127 | 1127 | /** |
@@ -286,7 +286,7 @@ |
||
286 | 286 | * |
287 | 287 | * @access private |
288 | 288 | * @param integer $blockId the block id of the first block |
289 | - * @return mixed true on success, PEAR_Error on failure |
|
289 | + * @return boolean true on success, PEAR_Error on failure |
|
290 | 290 | */ |
291 | 291 | function _readPpsWks($blockId) |
292 | 292 | { |
@@ -49,74 +49,74 @@ discard block |
||
49 | 49 | { |
50 | 50 | |
51 | 51 | /** |
52 | - * The file handle for reading an OLE container |
|
53 | - * @var resource |
|
54 | - */ |
|
52 | + * The file handle for reading an OLE container |
|
53 | + * @var resource |
|
54 | + */ |
|
55 | 55 | var $_file_handle; |
56 | 56 | |
57 | 57 | /** |
58 | - * Array of PPS's found on the OLE container |
|
59 | - * @var array |
|
60 | - */ |
|
58 | + * Array of PPS's found on the OLE container |
|
59 | + * @var array |
|
60 | + */ |
|
61 | 61 | var $_list; |
62 | 62 | |
63 | 63 | /** |
64 | - * Root directory of OLE container |
|
65 | - * @var OLE_PPS_Root |
|
66 | - */ |
|
64 | + * Root directory of OLE container |
|
65 | + * @var OLE_PPS_Root |
|
66 | + */ |
|
67 | 67 | var $root; |
68 | 68 | |
69 | 69 | /** |
70 | - * Big Block Allocation Table |
|
71 | - * @var array (blockId => nextBlockId) |
|
72 | - */ |
|
70 | + * Big Block Allocation Table |
|
71 | + * @var array (blockId => nextBlockId) |
|
72 | + */ |
|
73 | 73 | var $bbat; |
74 | 74 | |
75 | 75 | /** |
76 | - * Short Block Allocation Table |
|
77 | - * @var array (blockId => nextBlockId) |
|
78 | - */ |
|
76 | + * Short Block Allocation Table |
|
77 | + * @var array (blockId => nextBlockId) |
|
78 | + */ |
|
79 | 79 | var $sbat; |
80 | 80 | |
81 | 81 | /** |
82 | - * Size of big blocks. This is usually 512. |
|
83 | - * @var int number of octets per block. |
|
84 | - */ |
|
82 | + * Size of big blocks. This is usually 512. |
|
83 | + * @var int number of octets per block. |
|
84 | + */ |
|
85 | 85 | var $bigBlockSize; |
86 | 86 | |
87 | 87 | /** |
88 | - * Size of small blocks. This is usually 64. |
|
89 | - * @var int number of octets per block |
|
90 | - */ |
|
88 | + * Size of small blocks. This is usually 64. |
|
89 | + * @var int number of octets per block |
|
90 | + */ |
|
91 | 91 | var $smallBlockSize; |
92 | 92 | |
93 | 93 | /** |
94 | - * Creates a new OLE object |
|
95 | - * @access public |
|
96 | - */ |
|
94 | + * Creates a new OLE object |
|
95 | + * @access public |
|
96 | + */ |
|
97 | 97 | function OLE() |
98 | 98 | { |
99 | 99 | $this->_list = array(); |
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
103 | - * Destructor (using PEAR) |
|
104 | - * Just closes the file handle on the OLE file. |
|
105 | - * |
|
106 | - * @access private |
|
107 | - */ |
|
103 | + * Destructor (using PEAR) |
|
104 | + * Just closes the file handle on the OLE file. |
|
105 | + * |
|
106 | + * @access private |
|
107 | + */ |
|
108 | 108 | function _OLE() |
109 | 109 | { |
110 | 110 | fclose($this->_file_handle); |
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
114 | - * Reads an OLE container from the contents of the file given. |
|
115 | - * |
|
116 | - * @access public |
|
117 | - * @param string $file |
|
118 | - * @return mixed true on success, PEAR_Error on failure |
|
119 | - */ |
|
114 | + * Reads an OLE container from the contents of the file given. |
|
115 | + * |
|
116 | + * @access public |
|
117 | + * @param string $file |
|
118 | + * @return mixed true on success, PEAR_Error on failure |
|
119 | + */ |
|
120 | 120 | function read($file) |
121 | 121 | { |
122 | 122 | $fh = @fopen($file, "r"); |
@@ -281,13 +281,13 @@ discard block |
||
281 | 281 | } |
282 | 282 | |
283 | 283 | /** |
284 | - * Gets information about all PPS's on the OLE container from the PPS WK's |
|
285 | - * creates an OLE_PPS object for each one. |
|
286 | - * |
|
287 | - * @access private |
|
288 | - * @param integer $blockId the block id of the first block |
|
289 | - * @return mixed true on success, PEAR_Error on failure |
|
290 | - */ |
|
284 | + * Gets information about all PPS's on the OLE container from the PPS WK's |
|
285 | + * creates an OLE_PPS object for each one. |
|
286 | + * |
|
287 | + * @access private |
|
288 | + * @param integer $blockId the block id of the first block |
|
289 | + * @return mixed true on success, PEAR_Error on failure |
|
290 | + */ |
|
291 | 291 | function _readPpsWks($blockId) |
292 | 292 | { |
293 | 293 | $fh = $this->getStream($blockId); |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | break; |
308 | 308 | case OLE_PPS_TYPE_DIR: |
309 | 309 | $pps = new OLE_PPS(null, null, null, null, null, |
310 | - null, null, null, null, array()); |
|
310 | + null, null, null, null, array()); |
|
311 | 311 | break; |
312 | 312 | case OLE_PPS_TYPE_FILE: |
313 | 313 | require_once 'OLE/PPS/File.php'; |
@@ -360,13 +360,13 @@ discard block |
||
360 | 360 | } |
361 | 361 | |
362 | 362 | /** |
363 | - * It checks whether the PPS tree is complete (all PPS's read) |
|
364 | - * starting with the given PPS (not necessarily root) |
|
365 | - * |
|
366 | - * @access private |
|
367 | - * @param integer $index The index of the PPS from which we are checking |
|
368 | - * @return boolean Whether the PPS tree for the given PPS is complete |
|
369 | - */ |
|
363 | + * It checks whether the PPS tree is complete (all PPS's read) |
|
364 | + * starting with the given PPS (not necessarily root) |
|
365 | + * |
|
366 | + * @access private |
|
367 | + * @param integer $index The index of the PPS from which we are checking |
|
368 | + * @return boolean Whether the PPS tree for the given PPS is complete |
|
369 | + */ |
|
370 | 370 | function _ppsTreeComplete($index) |
371 | 371 | { |
372 | 372 | return isset($this->_list[$index]) && |
@@ -380,12 +380,12 @@ discard block |
||
380 | 380 | } |
381 | 381 | |
382 | 382 | /** |
383 | - * Checks whether a PPS is a File PPS or not. |
|
384 | - * If there is no PPS for the index given, it will return false. |
|
385 | - * @param integer $index The index for the PPS |
|
386 | - * @return bool true if it's a File PPS, false otherwise |
|
387 | - * @access public |
|
388 | - */ |
|
383 | + * Checks whether a PPS is a File PPS or not. |
|
384 | + * If there is no PPS for the index given, it will return false. |
|
385 | + * @param integer $index The index for the PPS |
|
386 | + * @return bool true if it's a File PPS, false otherwise |
|
387 | + * @access public |
|
388 | + */ |
|
389 | 389 | function isFile($index) |
390 | 390 | { |
391 | 391 | if (isset($this->_list[$index])) { |
@@ -395,12 +395,12 @@ discard block |
||
395 | 395 | } |
396 | 396 | |
397 | 397 | /** |
398 | - * Checks whether a PPS is a Root PPS or not. |
|
399 | - * If there is no PPS for the index given, it will return false. |
|
400 | - * @param integer $index The index for the PPS. |
|
401 | - * @return bool true if it's a Root PPS, false otherwise |
|
402 | - * @access public |
|
403 | - */ |
|
398 | + * Checks whether a PPS is a Root PPS or not. |
|
399 | + * If there is no PPS for the index given, it will return false. |
|
400 | + * @param integer $index The index for the PPS. |
|
401 | + * @return bool true if it's a Root PPS, false otherwise |
|
402 | + * @access public |
|
403 | + */ |
|
404 | 404 | function isRoot($index) |
405 | 405 | { |
406 | 406 | if (isset($this->_list[$index])) { |
@@ -410,26 +410,26 @@ discard block |
||
410 | 410 | } |
411 | 411 | |
412 | 412 | /** |
413 | - * Gives the total number of PPS's found in the OLE container. |
|
414 | - * @return integer The total number of PPS's found in the OLE container |
|
415 | - * @access public |
|
416 | - */ |
|
413 | + * Gives the total number of PPS's found in the OLE container. |
|
414 | + * @return integer The total number of PPS's found in the OLE container |
|
415 | + * @access public |
|
416 | + */ |
|
417 | 417 | function ppsTotal() |
418 | 418 | { |
419 | 419 | return count($this->_list); |
420 | 420 | } |
421 | 421 | |
422 | 422 | /** |
423 | - * Gets data from a PPS |
|
424 | - * If there is no PPS for the index given, it will return an empty string. |
|
425 | - * @param integer $index The index for the PPS |
|
426 | - * @param integer $position The position from which to start reading |
|
427 | - * (relative to the PPS) |
|
428 | - * @param integer $length The amount of bytes to read (at most) |
|
429 | - * @return string The binary string containing the data requested |
|
430 | - * @access public |
|
431 | - * @see OLE_PPS_File::getStream() |
|
432 | - */ |
|
423 | + * Gets data from a PPS |
|
424 | + * If there is no PPS for the index given, it will return an empty string. |
|
425 | + * @param integer $index The index for the PPS |
|
426 | + * @param integer $position The position from which to start reading |
|
427 | + * (relative to the PPS) |
|
428 | + * @param integer $length The amount of bytes to read (at most) |
|
429 | + * @return string The binary string containing the data requested |
|
430 | + * @access public |
|
431 | + * @see OLE_PPS_File::getStream() |
|
432 | + */ |
|
433 | 433 | function getData($index, $position, $length) |
434 | 434 | { |
435 | 435 | // if position is not valid return empty string |
@@ -446,12 +446,12 @@ discard block |
||
446 | 446 | } |
447 | 447 | |
448 | 448 | /** |
449 | - * Gets the data length from a PPS |
|
450 | - * If there is no PPS for the index given, it will return 0. |
|
451 | - * @param integer $index The index for the PPS |
|
452 | - * @return integer The amount of bytes in data the PPS has |
|
453 | - * @access public |
|
454 | - */ |
|
449 | + * Gets the data length from a PPS |
|
450 | + * If there is no PPS for the index given, it will return 0. |
|
451 | + * @param integer $index The index for the PPS |
|
452 | + * @return integer The amount of bytes in data the PPS has |
|
453 | + * @access public |
|
454 | + */ |
|
455 | 455 | function getDataLength($index) |
456 | 456 | { |
457 | 457 | if (isset($this->_list[$index])) { |
@@ -461,13 +461,13 @@ discard block |
||
461 | 461 | } |
462 | 462 | |
463 | 463 | /** |
464 | - * Utility function to transform ASCII text to Unicode |
|
465 | - * |
|
466 | - * @access public |
|
467 | - * @static |
|
468 | - * @param string $ascii The ASCII string to transform |
|
469 | - * @return string The string in Unicode |
|
470 | - */ |
|
464 | + * Utility function to transform ASCII text to Unicode |
|
465 | + * |
|
466 | + * @access public |
|
467 | + * @static |
|
468 | + * @param string $ascii The ASCII string to transform |
|
469 | + * @return string The string in Unicode |
|
470 | + */ |
|
471 | 471 | function Asc2Ucs($ascii) |
472 | 472 | { |
473 | 473 | $rawname = ''; |
@@ -478,14 +478,14 @@ discard block |
||
478 | 478 | } |
479 | 479 | |
480 | 480 | /** |
481 | - * Utility function |
|
482 | - * Returns a string for the OLE container with the date given |
|
483 | - * |
|
484 | - * @access public |
|
485 | - * @static |
|
486 | - * @param integer $date A timestamp |
|
487 | - * @return string The string for the OLE container |
|
488 | - */ |
|
481 | + * Utility function |
|
482 | + * Returns a string for the OLE container with the date given |
|
483 | + * |
|
484 | + * @access public |
|
485 | + * @static |
|
486 | + * @param integer $date A timestamp |
|
487 | + * @return string The string for the OLE container |
|
488 | + */ |
|
489 | 489 | function LocalDate2OLE($date = null) |
490 | 490 | { |
491 | 491 | if (!isset($date)) { |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | // calculate seconds |
501 | 501 | $big_date = $days * 24 * 3600 + |
502 | 502 | gmmktime(date("H",$date),date("i",$date),date("s",$date), |
503 | - date("m",$date),date("d",$date),date("Y",$date)); |
|
503 | + date("m",$date),date("d",$date),date("Y",$date)); |
|
504 | 504 | // multiply just to make MS happy |
505 | 505 | $big_date *= 10000000; |
506 | 506 | |
@@ -525,12 +525,12 @@ discard block |
||
525 | 525 | } |
526 | 526 | |
527 | 527 | /** |
528 | - * Returns a timestamp from an OLE container's date |
|
529 | - * @param integer $string A binary string with the encoded date |
|
530 | - * @return string The timestamp corresponding to the string |
|
531 | - * @access public |
|
532 | - * @static |
|
533 | - */ |
|
528 | + * Returns a timestamp from an OLE container's date |
|
529 | + * @param integer $string A binary string with the encoded date |
|
530 | + * @return string The timestamp corresponding to the string |
|
531 | + * @access public |
|
532 | + * @static |
|
533 | + */ |
|
534 | 534 | function OLE2LocalDate($string) |
535 | 535 | { |
536 | 536 | if (strlen($string) != 8) { |
@@ -300,21 +300,21 @@ |
||
300 | 300 | $name = str_replace("\x00", "", $nameUtf16); |
301 | 301 | $type = $this->_readInt1($fh); |
302 | 302 | switch ($type) { |
303 | - case OLE_PPS_TYPE_ROOT: |
|
304 | - require_once 'OLE/PPS/Root.php'; |
|
305 | - $pps = new OLE_PPS_Root(null, null, array()); |
|
306 | - $this->root = $pps; |
|
307 | - break; |
|
308 | - case OLE_PPS_TYPE_DIR: |
|
309 | - $pps = new OLE_PPS(null, null, null, null, null, |
|
310 | - null, null, null, null, array()); |
|
311 | - break; |
|
312 | - case OLE_PPS_TYPE_FILE: |
|
313 | - require_once 'OLE/PPS/File.php'; |
|
314 | - $pps = new OLE_PPS_File($name); |
|
315 | - break; |
|
316 | - default: |
|
317 | - continue; |
|
303 | + case OLE_PPS_TYPE_ROOT: |
|
304 | + require_once 'OLE/PPS/Root.php'; |
|
305 | + $pps = new OLE_PPS_Root(null, null, array()); |
|
306 | + $this->root = $pps; |
|
307 | + break; |
|
308 | + case OLE_PPS_TYPE_DIR: |
|
309 | + $pps = new OLE_PPS(null, null, null, null, null, |
|
310 | + null, null, null, null, array()); |
|
311 | + break; |
|
312 | + case OLE_PPS_TYPE_FILE: |
|
313 | + require_once 'OLE/PPS/File.php'; |
|
314 | + $pps = new OLE_PPS_File($name); |
|
315 | + break; |
|
316 | + default: |
|
317 | + continue; |
|
318 | 318 | } |
319 | 319 | fseek($fh, 1, SEEK_CUR); |
320 | 320 | $pps->Type = $type; |
@@ -23,12 +23,12 @@ discard block |
||
23 | 23 | /** |
24 | 24 | * Constants for OLE package |
25 | 25 | */ |
26 | -define('OLE_PPS_TYPE_ROOT', 5); |
|
27 | -define('OLE_PPS_TYPE_DIR', 1); |
|
28 | -define('OLE_PPS_TYPE_FILE', 2); |
|
26 | +define('OLE_PPS_TYPE_ROOT', 5); |
|
27 | +define('OLE_PPS_TYPE_DIR', 1); |
|
28 | +define('OLE_PPS_TYPE_FILE', 2); |
|
29 | 29 | define('OLE_DATA_SIZE_SMALL', 0x1000); |
30 | -define('OLE_LONG_INT_SIZE', 4); |
|
31 | -define('OLE_PPS_SIZE', 0x80); |
|
30 | +define('OLE_LONG_INT_SIZE', 4); |
|
31 | +define('OLE_PPS_SIZE', 0x80); |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Array for storing OLE instances that are accessed from |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | for ($i = 0; $i < $bbatBlockCount; $i++) { |
184 | 184 | $pos = $this->_getBlockOffset($mbatBlocks[$i]); |
185 | 185 | fseek($fh, $pos); |
186 | - for ($j = 0 ; $j < $this->bigBlockSize / 4; $j++) { |
|
186 | + for ($j = 0; $j < $this->bigBlockSize / 4; $j++) { |
|
187 | 187 | $this->bbat[] = $this->_readInt4($fh); |
188 | 188 | } |
189 | 189 | } |
@@ -234,12 +234,12 @@ discard block |
||
234 | 234 | $GLOBALS['_OLE_INSTANCES'][] = $this; |
235 | 235 | $instanceId = end(array_keys($GLOBALS['_OLE_INSTANCES'])); |
236 | 236 | |
237 | - $path = 'ole-chainedblockstream://oleInstanceId=' . $instanceId; |
|
237 | + $path = 'ole-chainedblockstream://oleInstanceId='.$instanceId; |
|
238 | 238 | if (is_a($blockIdOrPps, 'OLE_PPS')) { |
239 | - $path .= '&blockId=' . $blockIdOrPps->_StartBlock; |
|
240 | - $path .= '&size=' . $blockIdOrPps->Size; |
|
239 | + $path .= '&blockId='.$blockIdOrPps->_StartBlock; |
|
240 | + $path .= '&size='.$blockIdOrPps->Size; |
|
241 | 241 | } else { |
242 | - $path .= '&blockId=' . $blockIdOrPps; |
|
242 | + $path .= '&blockId='.$blockIdOrPps; |
|
243 | 243 | } |
244 | 244 | return fopen($path, 'r'); |
245 | 245 | } |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | { |
473 | 473 | $rawname = ''; |
474 | 474 | for ($i = 0; $i < strlen($ascii); $i++) { |
475 | - $rawname .= $ascii{$i} . "\x00"; |
|
475 | + $rawname .= $ascii{$i}."\x00"; |
|
476 | 476 | } |
477 | 477 | return $rawname; |
478 | 478 | } |
@@ -499,8 +499,8 @@ discard block |
||
499 | 499 | $days = 134774; |
500 | 500 | // calculate seconds |
501 | 501 | $big_date = $days * 24 * 3600 + |
502 | - gmmktime(date("H",$date),date("i",$date),date("s",$date), |
|
503 | - date("m",$date),date("d",$date),date("Y",$date)); |
|
502 | + gmmktime(date("H", $date), date("i", $date), date("s", $date), |
|
503 | + date("m", $date), date("d", $date), date("Y", $date)); |
|
504 | 504 | // multiply just to make MS happy |
505 | 505 | $big_date *= 10000000; |
506 | 506 | |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | } |
539 | 539 | |
540 | 540 | // factor used for separating numbers into 4 bytes parts |
541 | - $factor = pow(2,32); |
|
541 | + $factor = pow(2, 32); |
|
542 | 542 | $high_part = 0; |
543 | 543 | for ($i = 0; $i < 4; $i++) { |
544 | 544 | list(, $high_part) = unpack('C', $string{(7 - $i)}); |