@@ -183,9 +183,9 @@ |
||
183 | 183 | return true; |
184 | 184 | } |
185 | 185 | |
186 | - /** |
|
187 | - * We don't need values from button-type elements (except submit) and files |
|
188 | - */ |
|
186 | + /** |
|
187 | + * We don't need values from button-type elements (except submit) and files |
|
188 | + */ |
|
189 | 189 | function exportValue(&$submitValues, $assoc = false) |
190 | 190 | { |
191 | 191 | $type = $this->getType(); |
@@ -184,9 +184,9 @@ |
||
184 | 184 | // }}} |
185 | 185 | // {{{ exportValue() |
186 | 186 | |
187 | - /** |
|
188 | - * We override this here because we don't want any values from static elements |
|
189 | - */ |
|
187 | + /** |
|
188 | + * We override this here because we don't want any values from static elements |
|
189 | + */ |
|
190 | 190 | function exportValue(&$submitValues, $assoc = false) |
191 | 191 | { |
192 | 192 | return 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; |
@@ -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 { |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | { |
176 | 176 | if ($this->getChecked()) { |
177 | 177 | return '<code>[x]</code>' . |
178 | - $this->_getPersistantData(); |
|
178 | + $this->_getPersistantData(); |
|
179 | 179 | } else { |
180 | 180 | return '<code>[ ]</code>'; |
181 | 181 | } |
@@ -288,9 +288,9 @@ discard block |
||
288 | 288 | // }}} |
289 | 289 | // {{{ exportValue() |
290 | 290 | |
291 | - /** |
|
292 | - * Return true if the checkbox is checked, null if it is not checked (getValue() returns false) |
|
293 | - */ |
|
291 | + /** |
|
292 | + * Return true if the checkbox is checked, null if it is not checked (getValue() returns false) |
|
293 | + */ |
|
294 | 294 | function exportValue(&$submitValues, $assoc = false) |
295 | 295 | { |
296 | 296 | $value = $this->_findValue($submitValues); |
@@ -1,20 +1,20 @@ |
||
1 | 1 | <?php |
2 | 2 | /* For licensing terms, see /license.txt */ |
3 | 3 | /** |
4 | - * QuickForm rule to check a date |
|
5 | - * @package chamilo.include |
|
6 | - */ |
|
4 | + * QuickForm rule to check a date |
|
5 | + * @package chamilo.include |
|
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 | } |
@@ -44,16 +44,16 @@ |
||
44 | 44 | */ |
45 | 45 | var $_data = array(); |
46 | 46 | |
47 | - /** |
|
48 | - * Whether to use BC mode for specific rules |
|
49 | - * |
|
50 | - * Previous versions of QF passed element's name as a first parameter |
|
51 | - * to validation functions, but not to validation methods. This behaviour |
|
52 | - * is emulated if you are using 'function' as rule type when registering. |
|
53 | - * |
|
54 | - * @var array |
|
55 | - * @access private |
|
56 | - */ |
|
47 | + /** |
|
48 | + * Whether to use BC mode for specific rules |
|
49 | + * |
|
50 | + * Previous versions of QF passed element's name as a first parameter |
|
51 | + * to validation functions, but not to validation methods. This behaviour |
|
52 | + * is emulated if you are using 'function' as rule type when registering. |
|
53 | + * |
|
54 | + * @var array |
|
55 | + * @access private |
|
56 | + */ |
|
57 | 57 | var $_BCMode = array(); |
58 | 58 | |
59 | 59 | /** |
@@ -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); |
@@ -38,10 +38,10 @@ discard block |
||
38 | 38 | { |
39 | 39 | // {{{ properties |
40 | 40 | |
41 | - /** |
|
42 | - * Uploaded file data, from $_FILES |
|
43 | - * @var array |
|
44 | - */ |
|
41 | + /** |
|
42 | + * Uploaded file data, from $_FILES |
|
43 | + * @var array |
|
44 | + */ |
|
45 | 45 | var $_value = null; |
46 | 46 | |
47 | 47 | // }}} |
@@ -237,15 +237,15 @@ discard block |
||
237 | 237 | // }}} |
238 | 238 | // {{{ _ruleCheckMaxFileSize() |
239 | 239 | |
240 | - /** |
|
241 | - * Tries to find the element value from the values array |
|
242 | - * |
|
243 | - * Needs to be redefined here as $_FILES is populated differently from |
|
244 | - * other arrays when element name is of the form foo[bar] |
|
245 | - * |
|
246 | - * @access private |
|
247 | - * @return mixed |
|
248 | - */ |
|
240 | + /** |
|
241 | + * Tries to find the element value from the values array |
|
242 | + * |
|
243 | + * Needs to be redefined here as $_FILES is populated differently from |
|
244 | + * other arrays when element name is of the form foo[bar] |
|
245 | + * |
|
246 | + * @access private |
|
247 | + * @return mixed |
|
248 | + */ |
|
249 | 249 | function _findValue(&$values = null) |
250 | 250 | { |
251 | 251 | if (empty($_FILES)) { |
@@ -262,12 +262,12 @@ discard block |
||
262 | 262 | $idx = "['" . str_replace( |
263 | 263 | array('\\', '\'', ']', '['), array('\\\\', '\\\'', '', "']['"), |
264 | 264 | substr($elementName, $pos + 1, -1) |
265 | - ) . "']"; |
|
265 | + ) . "']"; |
|
266 | 266 | $props = array('name', 'type', 'size', 'tmp_name', 'error'); |
267 | 267 | $code = "if (!isset(\$_FILES['{$base}']['name']{$idx})) {\n" . |
268 | - " return null;\n" . |
|
269 | - "} else {\n" . |
|
270 | - " \$value = array();\n"; |
|
268 | + " return null;\n" . |
|
269 | + "} else {\n" . |
|
270 | + " \$value = array();\n"; |
|
271 | 271 | foreach ($props as $prop) { |
272 | 272 | $code .= " \$value['{$prop}'] = \$_FILES['{$base}']['{$prop}']{$idx};\n"; |
273 | 273 | } |