@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | * @param array $attributes Array of attribute |
200 | 200 | * @since 1.0 |
201 | 201 | * @access private |
202 | - * @return bool |
|
202 | + * @return boolean|null |
|
203 | 203 | */ |
204 | 204 | function _getAttrKey($attr, $attributes) |
205 | 205 | { |
@@ -265,6 +265,7 @@ discard block |
||
265 | 265 | * |
266 | 266 | * @param string Attribute name |
267 | 267 | * @param string Attribute value (will be set to $name if omitted) |
268 | + * @param string $name |
|
268 | 269 | * @access public |
269 | 270 | */ |
270 | 271 | function setAttribute($name, $value = null) |
@@ -141,7 +141,7 @@ |
||
141 | 141 | if (is_array($attributes)) { |
142 | 142 | $charset = HTML_Common::charset(); |
143 | 143 | foreach ($attributes as $key => $value) { |
144 | - // Modified by Ivan Tcholakov, 16-MAR-2010 |
|
144 | + // Modified by Ivan Tcholakov, 16-MAR-2010 |
|
145 | 145 | $value = @htmlspecialchars($value, ENT_COMPAT, $charset); |
146 | 146 | $strAttr .= ' ' . $key . '= "' . $value. '"'; |
147 | 147 | } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | foreach ($attributes as $key => $value) { |
144 | 144 | // Modified by Ivan Tcholakov, 16-MAR-2010 |
145 | 145 | $value = @htmlspecialchars($value, ENT_COMPAT, $charset); |
146 | - $strAttr .= ' ' . $key . '= "' . $value. '"'; |
|
146 | + $strAttr .= ' '.$key.'= "'.$value.'"'; |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | return $strAttr; |
@@ -170,10 +170,10 @@ discard block |
||
170 | 170 | return $ret; |
171 | 171 | |
172 | 172 | } elseif (is_string($attributes)) { |
173 | - $preg = "/(([A-Za-z_:]|[^\\x00-\\x7F])([A-Za-z0-9_:.-]|[^\\x00-\\x7F])*)" . |
|
173 | + $preg = "/(([A-Za-z_:]|[^\\x00-\\x7F])([A-Za-z0-9_:.-]|[^\\x00-\\x7F])*)". |
|
174 | 174 | "([ \\n\\t\\r]+)?(=([ \\n\\t\\r]+)?(\"[^\"]*\"|'[^']*'|[^ \\n\\t\\r]*))?/"; |
175 | 175 | if (preg_match_all($preg, $attributes, $regs)) { |
176 | - for ($counter=0; $counter<count($regs[1]); $counter++) { |
|
176 | + for ($counter = 0; $counter < count($regs[1]); $counter++) { |
|
177 | 177 | $name = $regs[1][$counter]; |
178 | 178 | $check = $regs[0][$counter]; |
179 | 179 | $value = $regs[7][$counter]; |
@@ -689,6 +689,8 @@ discard block |
||
689 | 689 | * @param HTML_QuickForm_element Element to insert |
690 | 690 | * @param string Name of the element before which the new |
691 | 691 | * one is inserted |
692 | + * @param HTML_QuickForm_element $element |
|
693 | + * @param string $nameAfter |
|
692 | 694 | * @return HTML_QuickForm_element reference to inserted element |
693 | 695 | * @throws HTML_QuickForm_Error |
694 | 696 | */ |
@@ -1290,7 +1292,7 @@ discard block |
||
1290 | 1292 | * Applies a data filter for the given field(s) |
1291 | 1293 | * |
1292 | 1294 | * @param mixed $element Form element name or array of such names |
1293 | - * @param mixed $filter Callback, either function name or array(&$object, 'method') |
|
1295 | + * @param string $filter Callback, either function name or array(&$object, 'method') |
|
1294 | 1296 | * @since 2.0 |
1295 | 1297 | * @access public |
1296 | 1298 | * @throws HTML_QuickForm_Error |
@@ -2042,6 +2044,7 @@ discard block |
||
2042 | 2044 | * |
2043 | 2045 | * @access public |
2044 | 2046 | * @param int error code |
2047 | + * @param integer $value |
|
2045 | 2048 | * @return string error message |
2046 | 2049 | * @static |
2047 | 2050 | */ |
@@ -42,16 +42,16 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @see HTML_QuickForm::errorMessage() |
44 | 44 | */ |
45 | -define('QUICKFORM_OK', 1); |
|
46 | -define('QUICKFORM_ERROR', -1); |
|
47 | -define('QUICKFORM_INVALID_RULE', -2); |
|
48 | -define('QUICKFORM_NONEXIST_ELEMENT', -3); |
|
49 | -define('QUICKFORM_INVALID_FILTER', -4); |
|
50 | -define('QUICKFORM_UNREGISTERED_ELEMENT', -5); |
|
51 | -define('QUICKFORM_INVALID_ELEMENT_NAME', -6); |
|
52 | -define('QUICKFORM_INVALID_PROCESS', -7); |
|
53 | -define('QUICKFORM_DEPRECATED', -8); |
|
54 | -define('QUICKFORM_INVALID_DATASOURCE', -9); |
|
45 | +define('QUICKFORM_OK', 1); |
|
46 | +define('QUICKFORM_ERROR', -1); |
|
47 | +define('QUICKFORM_INVALID_RULE', -2); |
|
48 | +define('QUICKFORM_NONEXIST_ELEMENT', -3); |
|
49 | +define('QUICKFORM_INVALID_FILTER', -4); |
|
50 | +define('QUICKFORM_UNREGISTERED_ELEMENT', -5); |
|
51 | +define('QUICKFORM_INVALID_ELEMENT_NAME', -6); |
|
52 | +define('QUICKFORM_INVALID_PROCESS', -7); |
|
53 | +define('QUICKFORM_DEPRECATED', -8); |
|
54 | +define('QUICKFORM_INVALID_DATASOURCE', -9); |
|
55 | 55 | /**#@-*/ |
56 | 56 | |
57 | 57 | // }}} |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * @param bool $trackSubmit (optional)Whether to track if the form was submitted by adding a special hidden field |
230 | 230 | * @access public |
231 | 231 | */ |
232 | - public function __construct($formName='', $method='post', $action='', $target='', $attributes=null, $trackSubmit = false) |
|
232 | + public function __construct($formName = '', $method = 'post', $action = '', $target = '', $attributes = null, $trackSubmit = false) |
|
233 | 233 | { |
234 | 234 | parent::__construct($attributes); |
235 | 235 | $method = (strtoupper($method) == 'GET') ? 'get' : 'post'; |
@@ -246,9 +246,9 @@ discard block |
||
246 | 246 | 'id' => $form_id |
247 | 247 | ) + $target; |
248 | 248 | $this->updateAttributes($attributes); |
249 | - if (!$trackSubmit || isset($_REQUEST['_qf__' . $formName])) { |
|
249 | + if (!$trackSubmit || isset($_REQUEST['_qf__'.$formName])) { |
|
250 | 250 | if (1 == get_magic_quotes_gpc()) { |
251 | - $this->_submitValues = $this->_recursiveFilter('stripslashes', 'get' == $method? $_GET: $_POST); |
|
251 | + $this->_submitValues = $this->_recursiveFilter('stripslashes', 'get' == $method ? $_GET : $_POST); |
|
252 | 252 | foreach ($_FILES as $keyFirst => $valFirst) { |
253 | 253 | foreach ($valFirst as $keySecond => $valSecond) { |
254 | 254 | if ('name' == $keySecond) { |
@@ -259,14 +259,14 @@ discard block |
||
259 | 259 | } |
260 | 260 | } |
261 | 261 | } else { |
262 | - $this->_submitValues = 'get' == $method? $_GET: $_POST; |
|
262 | + $this->_submitValues = 'get' == $method ? $_GET : $_POST; |
|
263 | 263 | $this->_submitFiles = $_FILES; |
264 | 264 | } |
265 | 265 | $this->_flagSubmitted = count($this->_submitValues) > 0 || count($this->_submitFiles) > 0; |
266 | 266 | } |
267 | 267 | if ($trackSubmit) { |
268 | - unset($this->_submitValues['_qf__' . $formName]); |
|
269 | - $this->addElement('hidden', '_qf__' . $formName, null); |
|
268 | + unset($this->_submitValues['_qf__'.$formName]); |
|
269 | + $this->addElement('hidden', '_qf__'.$formName, null); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | if (preg_match('/^([0-9]+)([a-zA-Z]*)$/', ini_get('upload_max_filesize'), $matches)) { |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | */ |
346 | 346 | public static function registerRule($ruleName, $type, $data1, $data2 = null) |
347 | 347 | { |
348 | - $registry =& HTML_QuickForm_RuleRegistry::singleton(); |
|
348 | + $registry = & HTML_QuickForm_RuleRegistry::singleton(); |
|
349 | 349 | $registry->registerRule($ruleName, $type, $data1, $data2); |
350 | 350 | } // end func registerRule |
351 | 351 | |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | * @access public |
361 | 361 | * @return boolean |
362 | 362 | */ |
363 | - function elementExists($element=null) |
|
363 | + function elementExists($element = null) |
|
364 | 364 | { |
365 | 365 | return isset($this->_elementIndex[$element]); |
366 | 366 | } // end func elementExists |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | function setDatasource(&$datasource, $defaultsFilter = null, $constantsFilter = null) |
386 | 386 | { |
387 | 387 | if (is_object($datasource)) { |
388 | - $this->_datasource =& $datasource; |
|
388 | + $this->_datasource = & $datasource; |
|
389 | 389 | if (is_callable(array($datasource, 'defaultValues'))) { |
390 | 390 | $this->setDefaults($datasource->defaultValues($this), $defaultsFilter); |
391 | 391 | } |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | if (!$this->elementExists('MAX_FILE_SIZE')) { |
497 | 497 | $this->addElement('hidden', 'MAX_FILE_SIZE', $this->_maxFileSize); |
498 | 498 | } else { |
499 | - $el =& $this->getElement('MAX_FILE_SIZE'); |
|
499 | + $el = & $this->getElement('MAX_FILE_SIZE'); |
|
500 | 500 | $el->updateAttributes(array('value' => $this->_maxFileSize)); |
501 | 501 | } |
502 | 502 | } // end func setMaxFileSize |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | $elementObject->onQuickFormEvent('updateValue', null, $this); |
635 | 635 | } else { |
636 | 636 | $args = func_get_args(); |
637 | - $elementObject =& $this->_loadElement('addElement', $element, array_slice($args, 1)); |
|
637 | + $elementObject = & $this->_loadElement('addElement', $element, array_slice($args, 1)); |
|
638 | 638 | if (PEAR::isError($elementObject)) { |
639 | 639 | return $elementObject; |
640 | 640 | } |
@@ -646,7 +646,7 @@ discard block |
||
646 | 646 | isset($this->_elementIndex[$elementName]) |
647 | 647 | ) { |
648 | 648 | if ($this->_elements[$this->_elementIndex[$elementName]]->getType() == $elementObject->getType()) { |
649 | - $this->_elements[] =& $elementObject; |
|
649 | + $this->_elements[] = & $elementObject; |
|
650 | 650 | $elKeys = array_keys($this->_elements); |
651 | 651 | $this->_duplicateIndex[$elementName][] = end($elKeys); |
652 | 652 | } else { |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | return $error; |
662 | 662 | } |
663 | 663 | } else { |
664 | - $this->_elements[] =& $elementObject; |
|
664 | + $this->_elements[] = & $elementObject; |
|
665 | 665 | $elKeys = array_keys($this->_elements); |
666 | 666 | $this->_elementIndex[$elementName] = end($elKeys); |
667 | 667 | } |
@@ -695,7 +695,7 @@ discard block |
||
695 | 695 | function &insertElementBefore(&$element, $nameAfter) |
696 | 696 | { |
697 | 697 | if (!empty($this->_duplicateIndex[$nameAfter])) { |
698 | - $error = PEAR::raiseError(null, QUICKFORM_INVALID_ELEMENT_NAME, null, E_USER_WARNING, 'Several elements named "' . $nameAfter . '" exist in HTML_QuickForm::insertElementBefore().', 'HTML_QuickForm_Error', true); |
|
698 | + $error = PEAR::raiseError(null, QUICKFORM_INVALID_ELEMENT_NAME, null, E_USER_WARNING, 'Several elements named "'.$nameAfter.'" exist in HTML_QuickForm::insertElementBefore().', 'HTML_QuickForm_Error', true); |
|
699 | 699 | return $error; |
700 | 700 | } elseif (!$this->elementExists($nameAfter)) { |
701 | 701 | $error = PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$nameAfter' does not exist in HTML_QuickForm::insertElementBefore()", 'HTML_QuickForm_Error', true); |
@@ -717,7 +717,7 @@ discard block |
||
717 | 717 | for ($i = end($elKeys); $i >= $targetIdx; $i--) { |
718 | 718 | if (isset($this->_elements[$i])) { |
719 | 719 | $currentName = $this->_elements[$i]->getName(); |
720 | - $this->_elements[$i + 1] =& $this->_elements[$i]; |
|
720 | + $this->_elements[$i + 1] = & $this->_elements[$i]; |
|
721 | 721 | if ($this->_elementIndex[$currentName] == $i) { |
722 | 722 | $this->_elementIndex[$currentName] = $i + 1; |
723 | 723 | } else { |
@@ -728,7 +728,7 @@ discard block |
||
728 | 728 | } |
729 | 729 | } |
730 | 730 | // Put the element in place finally |
731 | - $this->_elements[$targetIdx] =& $element; |
|
731 | + $this->_elements[$targetIdx] = & $element; |
|
732 | 732 | if (!$duplicate) { |
733 | 733 | $this->_elementIndex[$elementName] = $targetIdx; |
734 | 734 | } else { |
@@ -759,12 +759,12 @@ discard block |
||
759 | 759 | * @access public |
760 | 760 | * @throws HTML_QuickForm_Error |
761 | 761 | */ |
762 | - function &addGroup($elements, $name=null, $groupLabel='', $separator=null, $appendName = true) |
|
762 | + function &addGroup($elements, $name = null, $groupLabel = '', $separator = null, $appendName = true) |
|
763 | 763 | { |
764 | 764 | static $anonGroups = 1; |
765 | 765 | |
766 | 766 | if (0 == strlen($name)) { |
767 | - $name = 'qf_group_' . $anonGroups++; |
|
767 | + $name = 'qf_group_'.$anonGroups++; |
|
768 | 768 | $appendName = false; |
769 | 769 | } |
770 | 770 | $group = & $this->addElement('group', $name, $groupLabel, $elements, $separator, $appendName); |
@@ -821,7 +821,7 @@ discard block |
||
821 | 821 | if (is_array($value)) { |
822 | 822 | $value[] = $v; |
823 | 823 | } else { |
824 | - $value = (null === $value)? $v: array($value, $v); |
|
824 | + $value = (null === $value) ? $v : array($value, $v); |
|
825 | 825 | } |
826 | 826 | } |
827 | 827 | } |
@@ -844,7 +844,7 @@ discard block |
||
844 | 844 | { |
845 | 845 | $value = null; |
846 | 846 | if (isset($this->_submitValues[$elementName]) || isset($this->_submitFiles[$elementName])) { |
847 | - $value = isset($this->_submitValues[$elementName])? $this->_submitValues[$elementName]: array(); |
|
847 | + $value = isset($this->_submitValues[$elementName]) ? $this->_submitValues[$elementName] : array(); |
|
848 | 848 | if (is_array($value) && isset($this->_submitFiles[$elementName])) { |
849 | 849 | foreach ($this->_submitFiles[$elementName] as $k => $v) { |
850 | 850 | $value = HTML_QuickForm::arrayMerge($value, $this->_reindexFiles($this->_submitFiles[$elementName][$k], $k)); |
@@ -859,34 +859,34 @@ discard block |
||
859 | 859 | array('\\', '\''), array('\\\\', '\\\''), |
860 | 860 | substr($elementName, 0, $pos) |
861 | 861 | ); |
862 | - $idx = "['" . str_replace( |
|
862 | + $idx = "['".str_replace( |
|
863 | 863 | array('\\', '\'', ']', '['), array('\\\\', '\\\'', '', "']['"), |
864 | 864 | substr($elementName, $pos + 1, -1) |
865 | - ) . "']"; |
|
865 | + )."']"; |
|
866 | 866 | if (isset($this->_submitValues[$base])) { |
867 | 867 | $value = eval("return (isset(\$this->_submitValues['{$base}']{$idx})) ? \$this->_submitValues['{$base}']{$idx} : null;"); |
868 | 868 | } |
869 | 869 | |
870 | 870 | if ((is_array($value) || null === $value) && isset($this->_submitFiles[$base])) { |
871 | 871 | $props = array('name', 'type', 'size', 'tmp_name', 'error'); |
872 | - $code = "if (!isset(\$this->_submitFiles['{$base}']['name']{$idx})) {\n" . |
|
873 | - " return null;\n" . |
|
874 | - "} else {\n" . |
|
872 | + $code = "if (!isset(\$this->_submitFiles['{$base}']['name']{$idx})) {\n". |
|
873 | + " return null;\n". |
|
874 | + "} else {\n". |
|
875 | 875 | " \$v = array();\n"; |
876 | 876 | foreach ($props as $prop) { |
877 | 877 | $code .= " \$v = HTML_QuickForm::arrayMerge(\$v, \$this->_reindexFiles(\$this->_submitFiles['{$base}']['{$prop}']{$idx}, '{$prop}'));\n"; |
878 | 878 | } |
879 | - $fileValue = eval($code . " return \$v;\n}\n"); |
|
879 | + $fileValue = eval($code." return \$v;\n}\n"); |
|
880 | 880 | if (null !== $fileValue) { |
881 | - $value = null === $value? $fileValue: HTML_QuickForm::arrayMerge($value, $fileValue); |
|
881 | + $value = null === $value ? $fileValue : HTML_QuickForm::arrayMerge($value, $fileValue); |
|
882 | 882 | } |
883 | 883 | } |
884 | 884 | } |
885 | 885 | |
886 | 886 | // This is only supposed to work for groups with appendName = false |
887 | 887 | if (null === $value && 'group' == $this->getElementType($elementName)) { |
888 | - $group =& $this->getElement($elementName); |
|
889 | - $elements =& $group->getElements(); |
|
888 | + $group = & $this->getElement($elementName); |
|
889 | + $elements = & $group->getElements(); |
|
890 | 890 | foreach (array_keys($elements) as $key) { |
891 | 891 | $name = $group->getElementName($key); |
892 | 892 | // prevent endless recursion in case of radios and such |
@@ -1049,7 +1049,7 @@ discard block |
||
1049 | 1049 | $error = PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$elementName' does not exist in HTML_QuickForm::removeElement()", 'HTML_QuickForm_Error', true); |
1050 | 1050 | return $error; |
1051 | 1051 | } |
1052 | - $el =& $this->_elements[$this->_elementIndex[$elementName]]; |
|
1052 | + $el = & $this->_elements[$this->_elementIndex[$elementName]]; |
|
1053 | 1053 | unset($this->_elements[$this->_elementIndex[$elementName]]); |
1054 | 1054 | if (empty($this->_duplicateIndex[$elementName])) { |
1055 | 1055 | unset($this->_elementIndex[$elementName]); |
@@ -1148,7 +1148,7 @@ discard block |
||
1148 | 1148 | $this->_rules[$element] = array(); |
1149 | 1149 | } |
1150 | 1150 | if ($validation == 'client') { |
1151 | - $this->updateAttributes(array('onsubmit' => 'try { var myValidator = validate_' . $this->_attributes['id'] . '; } catch(e) { return true; } return myValidator(this);')); |
|
1151 | + $this->updateAttributes(array('onsubmit' => 'try { var myValidator = validate_'.$this->_attributes['id'].'; } catch(e) { return true; } return myValidator(this);')); |
|
1152 | 1152 | } |
1153 | 1153 | $this->_rules[$element][] = array( |
1154 | 1154 | 'type' => $type, |
@@ -1181,20 +1181,20 @@ discard block |
||
1181 | 1181 | * @access public |
1182 | 1182 | * @throws HTML_QuickForm_Error |
1183 | 1183 | */ |
1184 | - function addGroupRule($group, $arg1, $type='', $format=null, $howmany=0, $validation = 'server', $reset = false) |
|
1184 | + function addGroupRule($group, $arg1, $type = '', $format = null, $howmany = 0, $validation = 'server', $reset = false) |
|
1185 | 1185 | { |
1186 | 1186 | if (!$this->elementExists($group)) { |
1187 | 1187 | return PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Group '$group' does not exist in HTML_QuickForm::addGroupRule()", 'HTML_QuickForm_Error', true); |
1188 | 1188 | } |
1189 | 1189 | |
1190 | - $groupObj =& $this->getElement($group); |
|
1190 | + $groupObj = & $this->getElement($group); |
|
1191 | 1191 | if (is_array($arg1)) { |
1192 | 1192 | $required = 0; |
1193 | 1193 | foreach ($arg1 as $elementIndex => $rules) { |
1194 | 1194 | $elementName = $groupObj->getElementName($elementIndex); |
1195 | 1195 | foreach ($rules as $rule) { |
1196 | 1196 | $format = (isset($rule[2])) ? $rule[2] : null; |
1197 | - $validation = (isset($rule[3]) && 'client' == $rule[3])? 'client': 'server'; |
|
1197 | + $validation = (isset($rule[3]) && 'client' == $rule[3]) ? 'client' : 'server'; |
|
1198 | 1198 | $reset = isset($rule[4]) && $rule[4]; |
1199 | 1199 | $type = $rule[1]; |
1200 | 1200 | if (false === ($newName = $this->isRuleRegistered($type, true))) { |
@@ -1218,7 +1218,7 @@ discard block |
||
1218 | 1218 | $required++; |
1219 | 1219 | } |
1220 | 1220 | if ('client' == $validation) { |
1221 | - $this->updateAttributes(array('onsubmit' => 'try { var myValidator = validate_' . $this->_attributes['id'] . '; } catch(e) { return true; } return myValidator(this);')); |
|
1221 | + $this->updateAttributes(array('onsubmit' => 'try { var myValidator = validate_'.$this->_attributes['id'].'; } catch(e) { return true; } return myValidator(this);')); |
|
1222 | 1222 | } |
1223 | 1223 | } |
1224 | 1224 | } |
@@ -1255,7 +1255,7 @@ discard block |
||
1255 | 1255 | $this->_required[] = $group; |
1256 | 1256 | } |
1257 | 1257 | if ($validation == 'client') { |
1258 | - $this->updateAttributes(array('onsubmit' => 'try { var myValidator = validate_' . $this->_attributes['id'] . '; } catch(e) { return true; } return myValidator(this);')); |
|
1258 | + $this->updateAttributes(array('onsubmit' => 'try { var myValidator = validate_'.$this->_attributes['id'].'; } catch(e) { return true; } return myValidator(this);')); |
|
1259 | 1259 | } |
1260 | 1260 | } |
1261 | 1261 | } // end func addGroupRule |
@@ -1312,10 +1312,10 @@ discard block |
||
1312 | 1312 | if (false === strpos($elName, '[')) { |
1313 | 1313 | $this->_submitValues[$elName] = $this->_recursiveFilter($filter, $value); |
1314 | 1314 | } else { |
1315 | - $idx = "['" . str_replace( |
|
1315 | + $idx = "['".str_replace( |
|
1316 | 1316 | array('\\', '\'', ']', '['), array('\\\\', '\\\'', '', "']['"), |
1317 | 1317 | $elName |
1318 | - ) . "']"; |
|
1318 | + )."']"; |
|
1319 | 1319 | eval("\$this->_submitValues{$idx} = \$this->_recursiveFilter(\$filter, \$value);"); |
1320 | 1320 | } |
1321 | 1321 | } |
@@ -1435,7 +1435,7 @@ discard block |
||
1435 | 1435 | } |
1436 | 1436 | $ruleName = false; |
1437 | 1437 | if (is_object($name) && is_a($name, 'html_quickform_rule')) { |
1438 | - $ruleName = !empty($name->name)? $name->name: strtolower(get_class($name)); |
|
1438 | + $ruleName = !empty($name->name) ? $name->name : strtolower(get_class($name)); |
|
1439 | 1439 | } elseif (is_string($name) && class_exists($name)) { |
1440 | 1440 | $parent = strtolower($name); |
1441 | 1441 | do { |
@@ -1446,7 +1446,7 @@ discard block |
||
1446 | 1446 | } while ($parent = get_parent_class($parent)); |
1447 | 1447 | } |
1448 | 1448 | if ($ruleName) { |
1449 | - $registry =& HTML_QuickForm_RuleRegistry::singleton(); |
|
1449 | + $registry = & HTML_QuickForm_RuleRegistry::singleton(); |
|
1450 | 1450 | $registry->registerRule($ruleName, null, $name); |
1451 | 1451 | } |
1452 | 1452 | return $ruleName; |
@@ -1570,7 +1570,7 @@ discard block |
||
1570 | 1570 | return false; |
1571 | 1571 | } |
1572 | 1572 | |
1573 | - $registry =& HTML_QuickForm_RuleRegistry::singleton(); |
|
1573 | + $registry = & HTML_QuickForm_RuleRegistry::singleton(); |
|
1574 | 1574 | |
1575 | 1575 | foreach ($this->_rules as $target => $rules) { |
1576 | 1576 | $submitValue = $this->getSubmitValue($target); |
@@ -1601,10 +1601,10 @@ discard block |
||
1601 | 1601 | array('\\', '\''), array('\\\\', '\\\''), |
1602 | 1602 | substr($target, 0, $pos) |
1603 | 1603 | ); |
1604 | - $idx = "['" . str_replace( |
|
1604 | + $idx = "['".str_replace( |
|
1605 | 1605 | array('\\', '\'', ']', '['), array('\\\\', '\\\'', '', "']['"), |
1606 | 1606 | substr($target, $pos + 1, -1) |
1607 | - ) . "']"; |
|
1607 | + )."']"; |
|
1608 | 1608 | eval("\$isUpload = isset(\$this->_submitFiles['{$base}']['name']{$idx});"); |
1609 | 1609 | } |
1610 | 1610 | if ($isUpload && (!isset($submitValue['error']) || UPLOAD_ERR_NO_FILE == $submitValue['error'])) { |
@@ -1624,7 +1624,7 @@ discard block |
||
1624 | 1624 | $result = $registry->validate($rule['type'], $submitValue, $rule['format'], false); |
1625 | 1625 | } |
1626 | 1626 | |
1627 | - if (!$result || (!empty($rule['howmany']) && $rule['howmany'] > (int)$result)) { |
|
1627 | + if (!$result || (!empty($rule['howmany']) && $rule['howmany'] > (int) $result)) { |
|
1628 | 1628 | if (isset($rule['group'])) { |
1629 | 1629 | $this->_errors[$rule['group']] = $rule['message']; |
1630 | 1630 | } else { |
@@ -1659,7 +1659,7 @@ discard block |
||
1659 | 1659 | * @access public |
1660 | 1660 | * @throws HTML_QuickForm_Error |
1661 | 1661 | */ |
1662 | - function freeze($elementList=null) |
|
1662 | + function freeze($elementList = null) |
|
1663 | 1663 | { |
1664 | 1664 | if (!isset($elementList)) { |
1665 | 1665 | $this->_freezeAll = true; |
@@ -1680,7 +1680,7 @@ discard block |
||
1680 | 1680 | } |
1681 | 1681 | |
1682 | 1682 | if (!empty($elementList)) { |
1683 | - return PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Nonexistant element(s): '" . implode("', '", array_keys($elementList)) . "' in HTML_QuickForm::freeze()", 'HTML_QuickForm_Error', true); |
|
1683 | + return PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Nonexistant element(s): '".implode("', '", array_keys($elementList))."' in HTML_QuickForm::freeze()", 'HTML_QuickForm_Error', true); |
|
1684 | 1684 | } |
1685 | 1685 | return true; |
1686 | 1686 | } // end func freeze |
@@ -1736,7 +1736,7 @@ discard block |
||
1736 | 1736 | function accept(&$renderer) { |
1737 | 1737 | $renderer->startForm($this); |
1738 | 1738 | foreach (array_keys($this->_elements) as $key) { |
1739 | - $element =& $this->_elements[$key]; |
|
1739 | + $element = & $this->_elements[$key]; |
|
1740 | 1740 | $elementName = $element->getName(); |
1741 | 1741 | $required = ($this->isElementRequired($elementName) && !$element->isFrozen()); |
1742 | 1742 | $error = $this->getElementError($elementName); |
@@ -1782,7 +1782,7 @@ discard block |
||
1782 | 1782 | if (!is_null($in_data)) { |
1783 | 1783 | $this->addElement('html', $in_data); |
1784 | 1784 | } |
1785 | - $renderer =& $this->defaultRenderer(); |
|
1785 | + $renderer = & $this->defaultRenderer(); |
|
1786 | 1786 | $this->accept($renderer); |
1787 | 1787 | |
1788 | 1788 | return $renderer->toHtml(); |
@@ -1804,7 +1804,7 @@ discard block |
||
1804 | 1804 | return ''; |
1805 | 1805 | } |
1806 | 1806 | |
1807 | - $registry =& HTML_QuickForm_RuleRegistry::singleton(); |
|
1807 | + $registry = & HTML_QuickForm_RuleRegistry::singleton(); |
|
1808 | 1808 | $test = array(); |
1809 | 1809 | $js_escape = array( |
1810 | 1810 | "\r" => '\r', |
@@ -1820,30 +1820,30 @@ discard block |
||
1820 | 1820 | if ('client' == $rule['validation']) { |
1821 | 1821 | unset($element); |
1822 | 1822 | |
1823 | - $dependent = isset($rule['dependent']) && is_array($rule['dependent']); |
|
1823 | + $dependent = isset($rule['dependent']) && is_array($rule['dependent']); |
|
1824 | 1824 | $rule['message'] = strtr($rule['message'], $js_escape); |
1825 | 1825 | |
1826 | 1826 | if (isset($rule['group'])) { |
1827 | - $group =& $this->getElement($rule['group']); |
|
1827 | + $group = & $this->getElement($rule['group']); |
|
1828 | 1828 | // No JavaScript validation for frozen elements |
1829 | 1829 | if ($group->isFrozen()) { |
1830 | 1830 | continue 2; |
1831 | 1831 | } |
1832 | - $elements =& $group->getElements(); |
|
1832 | + $elements = & $group->getElements(); |
|
1833 | 1833 | foreach (array_keys($elements) as $key) { |
1834 | 1834 | if ($elementName == $group->getElementName($key)) { |
1835 | - $element =& $elements[$key]; |
|
1835 | + $element = & $elements[$key]; |
|
1836 | 1836 | break; |
1837 | 1837 | } |
1838 | 1838 | } |
1839 | 1839 | } elseif ($dependent) { |
1840 | - $element = array(); |
|
1841 | - $element[] =& $this->getElement($elementName); |
|
1840 | + $element = array(); |
|
1841 | + $element[] = & $this->getElement($elementName); |
|
1842 | 1842 | foreach ($rule['dependent'] as $elName) { |
1843 | - $element[] =& $this->getElement($elName); |
|
1843 | + $element[] = & $this->getElement($elName); |
|
1844 | 1844 | } |
1845 | 1845 | } else { |
1846 | - $element =& $this->getElement($elementName); |
|
1846 | + $element = & $this->getElement($elementName); |
|
1847 | 1847 | } |
1848 | 1848 | // No JavaScript validation for frozen elements |
1849 | 1849 | if (is_object($element) && $element->isFrozen()) { |
@@ -1862,23 +1862,23 @@ discard block |
||
1862 | 1862 | } |
1863 | 1863 | if (count($test) > 0) { |
1864 | 1864 | return |
1865 | - "\n<script type=\"text/javascript\">\n" . |
|
1866 | - "//<![CDATA[\n" . |
|
1867 | - "function validate_" . $this->_attributes['id'] . "(frm) {\n" . |
|
1868 | - " var value = '';\n" . |
|
1869 | - " var errFlag = new Array();\n" . |
|
1870 | - " var _qfGroups = {};\n" . |
|
1871 | - " _qfMsg = '';\n\n" . |
|
1872 | - join("\n", $test) . |
|
1873 | - "\n if (_qfMsg != '') {\n" . |
|
1874 | - " _qfMsg = '" . strtr($this->_jsPrefix, $js_escape) . "' + _qfMsg;\n" . |
|
1875 | - " _qfMsg = _qfMsg + '\\n" . strtr($this->_jsPostfix, $js_escape) . "';\n" . |
|
1876 | - " alert(_qfMsg);\n" . |
|
1877 | - " return false;\n" . |
|
1878 | - " }\n" . |
|
1879 | - " return true;\n" . |
|
1880 | - "}\n" . |
|
1881 | - "//]]>\n" . |
|
1865 | + "\n<script type=\"text/javascript\">\n". |
|
1866 | + "//<![CDATA[\n". |
|
1867 | + "function validate_".$this->_attributes['id']."(frm) {\n". |
|
1868 | + " var value = '';\n". |
|
1869 | + " var errFlag = new Array();\n". |
|
1870 | + " var _qfGroups = {};\n". |
|
1871 | + " _qfMsg = '';\n\n". |
|
1872 | + join("\n", $test). |
|
1873 | + "\n if (_qfMsg != '') {\n". |
|
1874 | + " _qfMsg = '".strtr($this->_jsPrefix, $js_escape)."' + _qfMsg;\n". |
|
1875 | + " _qfMsg = _qfMsg + '\\n".strtr($this->_jsPostfix, $js_escape)."';\n". |
|
1876 | + " alert(_qfMsg);\n". |
|
1877 | + " return false;\n". |
|
1878 | + " }\n". |
|
1879 | + " return true;\n". |
|
1880 | + "}\n". |
|
1881 | + "//]]>\n". |
|
1882 | 1882 | "</script>"; |
1883 | 1883 | } |
1884 | 1884 | return ''; |
@@ -1897,7 +1897,7 @@ discard block |
||
1897 | 1897 | */ |
1898 | 1898 | function getSubmitValues($mergeFiles = false) |
1899 | 1899 | { |
1900 | - return $mergeFiles? HTML_QuickForm::arrayMerge($this->_submitValues, $this->_submitFiles): $this->_submitValues; |
|
1900 | + return $mergeFiles ? HTML_QuickForm::arrayMerge($this->_submitValues, $this->_submitFiles) : $this->_submitValues; |
|
1901 | 1901 | } // end func getSubmitValues |
1902 | 1902 | |
1903 | 1903 | // }}} |
@@ -1951,7 +1951,7 @@ discard block |
||
1951 | 1951 | if (is_array($value)) { |
1952 | 1952 | $value[] = $v; |
1953 | 1953 | } else { |
1954 | - $value = (null === $value)? $v: array($value, $v); |
|
1954 | + $value = (null === $value) ? $v : array($value, $v); |
|
1955 | 1955 | } |
1956 | 1956 | } |
1957 | 1957 | } |
@@ -630,8 +630,8 @@ discard block |
||
630 | 630 | public function &addElement($element) |
631 | 631 | { |
632 | 632 | if (is_object($element) && is_subclass_of($element, 'html_quickform_element')) { |
633 | - $elementObject = &$element; |
|
634 | - $elementObject->onQuickFormEvent('updateValue', null, $this); |
|
633 | + $elementObject = &$element; |
|
634 | + $elementObject->onQuickFormEvent('updateValue', null, $this); |
|
635 | 635 | } else { |
636 | 636 | $args = func_get_args(); |
637 | 637 | $elementObject =& $this->_loadElement('addElement', $element, array_slice($args, 1)); |
@@ -676,22 +676,22 @@ discard block |
||
676 | 676 | // }}} |
677 | 677 | // {{{ insertElementBefore() |
678 | 678 | |
679 | - /** |
|
680 | - * Inserts a new element right before the other element |
|
681 | - * |
|
682 | - * Warning: it is not possible to check whether the $element is already |
|
683 | - * added to the form, therefore if you want to move the existing form |
|
684 | - * element to a new position, you'll have to use removeElement(): |
|
685 | - * $form->insertElementBefore($form->removeElement('foo', false), 'bar'); |
|
686 | - * |
|
687 | - * @access public |
|
688 | - * @since 3.2.4 |
|
689 | - * @param HTML_QuickForm_element Element to insert |
|
690 | - * @param string Name of the element before which the new |
|
691 | - * one is inserted |
|
692 | - * @return HTML_QuickForm_element reference to inserted element |
|
693 | - * @throws HTML_QuickForm_Error |
|
694 | - */ |
|
679 | + /** |
|
680 | + * Inserts a new element right before the other element |
|
681 | + * |
|
682 | + * Warning: it is not possible to check whether the $element is already |
|
683 | + * added to the form, therefore if you want to move the existing form |
|
684 | + * element to a new position, you'll have to use removeElement(): |
|
685 | + * $form->insertElementBefore($form->removeElement('foo', false), 'bar'); |
|
686 | + * |
|
687 | + * @access public |
|
688 | + * @since 3.2.4 |
|
689 | + * @param HTML_QuickForm_element Element to insert |
|
690 | + * @param string Name of the element before which the new |
|
691 | + * one is inserted |
|
692 | + * @return HTML_QuickForm_element reference to inserted element |
|
693 | + * @throws HTML_QuickForm_Error |
|
694 | + */ |
|
695 | 695 | function &insertElementBefore(&$element, $nameAfter) |
696 | 696 | { |
697 | 697 | if (!empty($this->_duplicateIndex[$nameAfter])) { |
@@ -870,9 +870,9 @@ discard block |
||
870 | 870 | if ((is_array($value) || null === $value) && isset($this->_submitFiles[$base])) { |
871 | 871 | $props = array('name', 'type', 'size', 'tmp_name', 'error'); |
872 | 872 | $code = "if (!isset(\$this->_submitFiles['{$base}']['name']{$idx})) {\n" . |
873 | - " return null;\n" . |
|
874 | - "} else {\n" . |
|
875 | - " \$v = array();\n"; |
|
873 | + " return null;\n" . |
|
874 | + "} else {\n" . |
|
875 | + " \$v = array();\n"; |
|
876 | 876 | foreach ($props as $prop) { |
877 | 877 | $code .= " \$v = HTML_QuickForm::arrayMerge(\$v, \$this->_reindexFiles(\$this->_submitFiles['{$base}']['{$prop}']{$idx}, '{$prop}'));\n"; |
878 | 878 | } |
@@ -917,13 +917,13 @@ discard block |
||
917 | 917 | return $value; |
918 | 918 | } |
919 | 919 | |
920 | - /** |
|
921 | - * A helper function to change the indexes in $_FILES array |
|
922 | - * |
|
923 | - * @param mixed Some value from the $_FILES array |
|
924 | - * @param string The key from the $_FILES array that should be appended |
|
925 | - * @return array |
|
926 | - */ |
|
920 | + /** |
|
921 | + * A helper function to change the indexes in $_FILES array |
|
922 | + * |
|
923 | + * @param mixed Some value from the $_FILES array |
|
924 | + * @param string The key from the $_FILES array that should be appended |
|
925 | + * @return array |
|
926 | + */ |
|
927 | 927 | function _reindexFiles($value, $key) |
928 | 928 | { |
929 | 929 | if (!is_array($value)) { |
@@ -976,27 +976,27 @@ discard block |
||
976 | 976 | } |
977 | 977 | } // end func setElementError |
978 | 978 | |
979 | - // }}} |
|
980 | - // {{{ getElementType() |
|
981 | - |
|
982 | - /** |
|
983 | - * Returns the type of the given element |
|
984 | - * |
|
985 | - * @param string $element Name of form element |
|
986 | - * @since 1.1 |
|
987 | - * @access public |
|
988 | - * @return string Type of the element, false if the element is not found |
|
989 | - */ |
|
990 | - function getElementType($element) |
|
991 | - { |
|
992 | - if (isset($this->_elementIndex[$element])) { |
|
993 | - return $this->_elements[$this->_elementIndex[$element]]->getType(); |
|
994 | - } |
|
995 | - return false; |
|
996 | - } // end func getElementType |
|
997 | - |
|
998 | - // }}} |
|
999 | - // {{{ updateElementAttr() |
|
979 | + // }}} |
|
980 | + // {{{ getElementType() |
|
981 | + |
|
982 | + /** |
|
983 | + * Returns the type of the given element |
|
984 | + * |
|
985 | + * @param string $element Name of form element |
|
986 | + * @since 1.1 |
|
987 | + * @access public |
|
988 | + * @return string Type of the element, false if the element is not found |
|
989 | + */ |
|
990 | + function getElementType($element) |
|
991 | + { |
|
992 | + if (isset($this->_elementIndex[$element])) { |
|
993 | + return $this->_elements[$this->_elementIndex[$element]]->getType(); |
|
994 | + } |
|
995 | + return false; |
|
996 | + } // end func getElementType |
|
997 | + |
|
998 | + // }}} |
|
999 | + // {{{ updateElementAttr() |
|
1000 | 1000 | |
1001 | 1001 | /** |
1002 | 1002 | * Updates Attributes for one or more elements |
@@ -1263,18 +1263,18 @@ discard block |
||
1263 | 1263 | // }}} |
1264 | 1264 | // {{{ addFormRule() |
1265 | 1265 | |
1266 | - /** |
|
1267 | - * Adds a global validation rule |
|
1268 | - * |
|
1269 | - * This should be used when for a rule involving several fields or if |
|
1270 | - * you want to use some completely custom validation for your form. |
|
1271 | - * The rule function/method should return true in case of successful |
|
1272 | - * validation and array('element name' => 'error') when there were errors. |
|
1273 | - * |
|
1274 | - * @access public |
|
1275 | - * @param mixed Callback, either function name or array(&$object, 'method') |
|
1276 | - * @throws HTML_QuickForm_Error |
|
1277 | - */ |
|
1266 | + /** |
|
1267 | + * Adds a global validation rule |
|
1268 | + * |
|
1269 | + * This should be used when for a rule involving several fields or if |
|
1270 | + * you want to use some completely custom validation for your form. |
|
1271 | + * The rule function/method should return true in case of successful |
|
1272 | + * validation and array('element name' => 'error') when there were errors. |
|
1273 | + * |
|
1274 | + * @access public |
|
1275 | + * @param mixed Callback, either function name or array(&$object, 'method') |
|
1276 | + * @throws HTML_QuickForm_Error |
|
1277 | + */ |
|
1278 | 1278 | function addFormRule($rule) |
1279 | 1279 | { |
1280 | 1280 | if (!is_callable($rule)) { |
@@ -1351,18 +1351,18 @@ discard block |
||
1351 | 1351 | // }}} |
1352 | 1352 | // {{{ arrayMerge() |
1353 | 1353 | |
1354 | - /** |
|
1355 | - * Merges two arrays |
|
1356 | - * |
|
1357 | - * Merges two array like the PHP function array_merge but recursively. |
|
1358 | - * The main difference is that existing keys will not be renumbered |
|
1359 | - * if they are integers. |
|
1360 | - * |
|
1361 | - * @access public |
|
1362 | - * @param array $a original array |
|
1363 | - * @param array $b array which will be merged into first one |
|
1364 | - * @return array merged array |
|
1365 | - */ |
|
1354 | + /** |
|
1355 | + * Merges two arrays |
|
1356 | + * |
|
1357 | + * Merges two array like the PHP function array_merge but recursively. |
|
1358 | + * The main difference is that existing keys will not be renumbered |
|
1359 | + * if they are integers. |
|
1360 | + * |
|
1361 | + * @access public |
|
1362 | + * @param array $a original array |
|
1363 | + * @param array $b array which will be merged into first one |
|
1364 | + * @return array merged array |
|
1365 | + */ |
|
1366 | 1366 | static function arrayMerge($a, $b) |
1367 | 1367 | { |
1368 | 1368 | foreach ($b as $k => $v) { |
@@ -1493,10 +1493,10 @@ discard block |
||
1493 | 1493 | */ |
1494 | 1494 | function isElementFrozen($element) |
1495 | 1495 | { |
1496 | - if (isset($this->_elementIndex[$element])) { |
|
1497 | - return $this->_elements[$this->_elementIndex[$element]]->isFrozen(); |
|
1498 | - } |
|
1499 | - return false; |
|
1496 | + if (isset($this->_elementIndex[$element])) { |
|
1497 | + return $this->_elements[$this->_elementIndex[$element]]->isFrozen(); |
|
1498 | + } |
|
1499 | + return false; |
|
1500 | 1500 | } // end func isElementFrozen |
1501 | 1501 | |
1502 | 1502 | // }}} |
@@ -1685,7 +1685,7 @@ discard block |
||
1685 | 1685 | */ |
1686 | 1686 | function isFrozen() |
1687 | 1687 | { |
1688 | - return $this->_freezeAll; |
|
1688 | + return $this->_freezeAll; |
|
1689 | 1689 | } |
1690 | 1690 | |
1691 | 1691 | /** |
@@ -1707,14 +1707,14 @@ discard block |
||
1707 | 1707 | return call_user_func($callback, $values); |
1708 | 1708 | } |
1709 | 1709 | |
1710 | - /** |
|
1711 | - * Accepts a renderer |
|
1712 | - * |
|
1713 | - * @param object An HTML_QuickForm_Renderer object |
|
1714 | - * @since 3.0 |
|
1715 | - * @access public |
|
1716 | - * @return void |
|
1717 | - */ |
|
1710 | + /** |
|
1711 | + * Accepts a renderer |
|
1712 | + * |
|
1713 | + * @param object An HTML_QuickForm_Renderer object |
|
1714 | + * @since 3.0 |
|
1715 | + * @access public |
|
1716 | + * @return void |
|
1717 | + */ |
|
1718 | 1718 | function accept(&$renderer) { |
1719 | 1719 | $renderer->startForm($this); |
1720 | 1720 | foreach (array_keys($this->_elements) as $key) { |
@@ -1727,13 +1727,13 @@ discard block |
||
1727 | 1727 | $renderer->finishForm($this); |
1728 | 1728 | } |
1729 | 1729 | |
1730 | - /** |
|
1731 | - * Returns a reference to default renderer object |
|
1732 | - * |
|
1733 | - * @access public |
|
1734 | - * @since 3.0 |
|
1735 | - * @return HTML_QuickForm_Renderer_Default |
|
1736 | - */ |
|
1730 | + /** |
|
1731 | + * Returns a reference to default renderer object |
|
1732 | + * |
|
1733 | + * @access public |
|
1734 | + * @since 3.0 |
|
1735 | + * @return HTML_QuickForm_Renderer_Default |
|
1736 | + */ |
|
1737 | 1737 | function &defaultRenderer() { |
1738 | 1738 | if (!isset($GLOBALS['_HTML_QuickForm_default_renderer'])) { |
1739 | 1739 | // Modified by Ivan Tcholakov, 16-MAR-2010. Suppressing a deprecation warning on PHP 5.3 |
@@ -1889,7 +1889,7 @@ discard block |
||
1889 | 1889 | // |
1890 | 1890 | $this->accept($renderer); |
1891 | 1891 | return $renderer->toArray(); |
1892 | - } |
|
1892 | + } |
|
1893 | 1893 | |
1894 | 1894 | /** |
1895 | 1895 | * Returns a 'safe' element's value |
@@ -1961,15 +1961,15 @@ discard block |
||
1961 | 1961 | return $values; |
1962 | 1962 | } |
1963 | 1963 | |
1964 | - /** |
|
1965 | - * Tells whether the form was already submitted |
|
1966 | - * |
|
1967 | - * This is useful since the _submitFiles and _submitValues arrays |
|
1968 | - * may be completely empty after the trackSubmit value is removed. |
|
1969 | - * |
|
1970 | - * @access public |
|
1971 | - * @return bool |
|
1972 | - */ |
|
1964 | + /** |
|
1965 | + * Tells whether the form was already submitted |
|
1966 | + * |
|
1967 | + * This is useful since the _submitFiles and _submitValues arrays |
|
1968 | + * may be completely empty after the trackSubmit value is removed. |
|
1969 | + * |
|
1970 | + * @access public |
|
1971 | + * @return bool |
|
1972 | + */ |
|
1973 | 1973 | function isSubmitted() |
1974 | 1974 | { |
1975 | 1975 | return $this->_flagSubmitted; |
@@ -2056,21 +2056,21 @@ discard block |
||
2056 | 2056 | { |
2057 | 2057 | |
2058 | 2058 | /** |
2059 | - * Prefix for all error messages |
|
2060 | - * @var string |
|
2061 | - */ |
|
2059 | + * Prefix for all error messages |
|
2060 | + * @var string |
|
2061 | + */ |
|
2062 | 2062 | var $error_message_prefix = 'QuickForm Error: '; |
2063 | 2063 | |
2064 | 2064 | /** |
2065 | - * Creates a quickform error object, extending the PEAR_Error class |
|
2066 | - * |
|
2067 | - * @param int $code the error code |
|
2068 | - * @param int $mode the reaction to the error, either return, die or trigger/callback |
|
2069 | - * @param int $level intensity of the error (PHP error code) |
|
2070 | - * @param mixed $debuginfo any information that can inform user as to nature of the error |
|
2071 | - */ |
|
2065 | + * Creates a quickform error object, extending the PEAR_Error class |
|
2066 | + * |
|
2067 | + * @param int $code the error code |
|
2068 | + * @param int $mode the reaction to the error, either return, die or trigger/callback |
|
2069 | + * @param int $level intensity of the error (PHP error code) |
|
2070 | + * @param mixed $debuginfo any information that can inform user as to nature of the error |
|
2071 | + */ |
|
2072 | 2072 | function HTML_QuickForm_Error($code = QUICKFORM_ERROR, $mode = PEAR_ERROR_RETURN, |
2073 | - $level = E_USER_NOTICE, $debuginfo = null) |
|
2073 | + $level = E_USER_NOTICE, $debuginfo = null) |
|
2074 | 2074 | { |
2075 | 2075 | if (is_int($code)) { |
2076 | 2076 | $this->PEAR_Error(HTML_QuickForm::errorMessage($code), $code, $mode, $level, $debuginfo); |
@@ -50,7 +50,8 @@ |
||
50 | 50 | /** |
51 | 51 | * Removes the '..' and '.' segments from the path component |
52 | 52 | * |
53 | - * @param string Path component of the URL, possibly with '.' and '..' segments |
|
53 | + * @param string Path component of the URL, possibly with '.' and '..' segments |
|
54 | + * @param string $path |
|
54 | 55 | * @return string Path component of the URL with '.' and '..' segments removed |
55 | 56 | * @access private |
56 | 57 | */ |
@@ -31,13 +31,13 @@ discard block |
||
31 | 31 | */ |
32 | 32 | class HTML_QuickForm_Action_Jump extends HTML_QuickForm_Action |
33 | 33 | { |
34 | - /** |
|
35 | - * Splits (part of) the URI into path and query components |
|
36 | - * |
|
37 | - * @param string String of the form 'foo?bar' |
|
38 | - * @return array Array of the form array('foo', '?bar) |
|
39 | - * @access private |
|
40 | - */ |
|
34 | + /** |
|
35 | + * Splits (part of) the URI into path and query components |
|
36 | + * |
|
37 | + * @param string String of the form 'foo?bar' |
|
38 | + * @return array Array of the form array('foo', '?bar) |
|
39 | + * @access private |
|
40 | + */ |
|
41 | 41 | function _splitUri($uri) |
42 | 42 | { |
43 | 43 | if (false === ($qm = strpos($uri, '?'))) { |
@@ -47,13 +47,13 @@ discard block |
||
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
50 | - /** |
|
51 | - * Removes the '..' and '.' segments from the path component |
|
52 | - * |
|
53 | - * @param string Path component of the URL, possibly with '.' and '..' segments |
|
54 | - * @return string Path component of the URL with '.' and '..' segments removed |
|
55 | - * @access private |
|
56 | - */ |
|
50 | + /** |
|
51 | + * Removes the '..' and '.' segments from the path component |
|
52 | + * |
|
53 | + * @param string Path component of the URL, possibly with '.' and '..' segments |
|
54 | + * @return string Path component of the URL with '.' and '..' segments removed |
|
55 | + * @access private |
|
56 | + */ |
|
57 | 57 | function _normalizePath($path) |
58 | 58 | { |
59 | 59 | $pathAry = explode('/', $path); |
@@ -84,17 +84,17 @@ discard block |
||
84 | 84 | return implode('/', $pathAry); |
85 | 85 | } |
86 | 86 | |
87 | - /** |
|
88 | - * Resolves relative URL using current page's URL as base |
|
89 | - * |
|
90 | - * The method follows procedure described in section 4 of RFC 1808 and |
|
91 | - * passes the examples provided in section 5 of said RFC. Values from |
|
92 | - * $_SERVER array are used for calculation of "current URL" |
|
93 | - * |
|
94 | - * @param string Relative URL, probably from form's action attribute |
|
95 | - * @return string Absolute URL |
|
96 | - * @access private |
|
97 | - */ |
|
87 | + /** |
|
88 | + * Resolves relative URL using current page's URL as base |
|
89 | + * |
|
90 | + * The method follows procedure described in section 4 of RFC 1808 and |
|
91 | + * passes the examples provided in section 5 of said RFC. Values from |
|
92 | + * $_SERVER array are used for calculation of "current URL" |
|
93 | + * |
|
94 | + * @param string Relative URL, probably from form's action attribute |
|
95 | + * @return string Absolute URL |
|
96 | + * @access private |
|
97 | + */ |
|
98 | 98 | function _resolveRelativeURL($url) |
99 | 99 | { |
100 | 100 | $https = !empty($_SERVER['HTTPS']) && ('off' != strtolower($_SERVER['HTTPS'])); |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | |
105 | 105 | } else { |
106 | 106 | $host = $scheme . '//' . $_SERVER['SERVER_NAME'] . |
107 | - (($https && 443 == $_SERVER['SERVER_PORT'] || |
|
107 | + (($https && 443 == $_SERVER['SERVER_PORT'] || |
|
108 | 108 | !$https && 80 == $_SERVER['SERVER_PORT'])? '': ':' . $_SERVER['SERVER_PORT']); |
109 | 109 | if ('' == $url) { |
110 | 110 | return $host . $_SERVER['REQUEST_URI']; |
@@ -148,8 +148,8 @@ discard block |
||
148 | 148 | $action = $this->_resolveRelativeURL($action); |
149 | 149 | } |
150 | 150 | $url = $action . (false === strpos($action, '?')? '?': '&') . |
151 | - $current->getButtonName('display') . '=true' . |
|
152 | - ((!defined('SID') || '' == SID || ini_get('session.use_only_cookies'))? '': '&' . SID); |
|
151 | + $current->getButtonName('display') . '=true' . |
|
152 | + ((!defined('SID') || '' == SID || ini_get('session.use_only_cookies'))? '': '&' . SID); |
|
153 | 153 | header('Location: ' . $url); |
154 | 154 | exit; |
155 | 155 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | } |
70 | 70 | |
71 | 71 | } elseif ('..' == $pathAry[$i] && $i > 1 && '..' != $pathAry[$i - 1]) { |
72 | - if ($i < count($pathAry) -1) { |
|
72 | + if ($i < count($pathAry) - 1) { |
|
73 | 73 | array_splice($pathAry, $i - 1, 2); |
74 | 74 | $i--; |
75 | 75 | } else { |
@@ -98,28 +98,28 @@ discard block |
||
98 | 98 | function _resolveRelativeURL($url) |
99 | 99 | { |
100 | 100 | $https = !empty($_SERVER['HTTPS']) && ('off' != strtolower($_SERVER['HTTPS'])); |
101 | - $scheme = ($https? 'https:': 'http:'); |
|
101 | + $scheme = ($https ? 'https:' : 'http:'); |
|
102 | 102 | if ('//' == substr($url, 0, 2)) { |
103 | - return $scheme . $url; |
|
103 | + return $scheme.$url; |
|
104 | 104 | |
105 | 105 | } else { |
106 | - $host = $scheme . '//' . $_SERVER['SERVER_NAME'] . |
|
106 | + $host = $scheme.'//'.$_SERVER['SERVER_NAME']. |
|
107 | 107 | (($https && 443 == $_SERVER['SERVER_PORT'] || |
108 | - !$https && 80 == $_SERVER['SERVER_PORT'])? '': ':' . $_SERVER['SERVER_PORT']); |
|
108 | + !$https && 80 == $_SERVER['SERVER_PORT']) ? '' : ':'.$_SERVER['SERVER_PORT']); |
|
109 | 109 | if ('' == $url) { |
110 | - return $host . $_SERVER['REQUEST_URI']; |
|
110 | + return $host.$_SERVER['REQUEST_URI']; |
|
111 | 111 | |
112 | 112 | } elseif ('/' == $url[0]) { |
113 | - return $host . $url; |
|
113 | + return $host.$url; |
|
114 | 114 | |
115 | 115 | } else { |
116 | 116 | list($basePath, $baseQuery) = $this->_splitUri($_SERVER['REQUEST_URI']); |
117 | 117 | list($actPath, $actQuery) = $this->_splitUri($url); |
118 | 118 | if ('' == $actPath) { |
119 | - return $host . $basePath . $actQuery; |
|
119 | + return $host.$basePath.$actQuery; |
|
120 | 120 | } else { |
121 | - $path = substr($basePath, 0, strrpos($basePath, '/') + 1) . $actPath; |
|
122 | - return $host . $this->_normalizePath($path) . $actQuery; |
|
121 | + $path = substr($basePath, 0, strrpos($basePath, '/') + 1).$actPath; |
|
122 | + return $host.$this->_normalizePath($path).$actQuery; |
|
123 | 123 | } |
124 | 124 | } |
125 | 125 | } |
@@ -136,10 +136,10 @@ discard block |
||
136 | 136 | if (!$page->controller->isValid($pageName)) { |
137 | 137 | $pageName = $page->controller->findInvalid(); |
138 | 138 | } |
139 | - $current =& $page->controller->getPage($pageName); |
|
139 | + $current = & $page->controller->getPage($pageName); |
|
140 | 140 | |
141 | 141 | } else { |
142 | - $current =& $page; |
|
142 | + $current = & $page; |
|
143 | 143 | } |
144 | 144 | // generate the URL for the page 'display' event and redirect to it |
145 | 145 | $action = $current->getAttribute('action'); |
@@ -147,10 +147,10 @@ discard block |
||
147 | 147 | if (!preg_match('!^https?://!i', $action)) { |
148 | 148 | $action = $this->_resolveRelativeURL($action); |
149 | 149 | } |
150 | - $url = $action . (false === strpos($action, '?')? '?': '&') . |
|
151 | - $current->getButtonName('display') . '=true' . |
|
152 | - ((!defined('SID') || '' == SID || ini_get('session.use_only_cookies'))? '': '&' . SID); |
|
153 | - header('Location: ' . $url); |
|
150 | + $url = $action.(false === strpos($action, '?') ? '?' : '&'). |
|
151 | + $current->getButtonName('display').'=true'. |
|
152 | + ((!defined('SID') || '' == SID || ini_get('session.use_only_cookies')) ? '' : '&'.SID); |
|
153 | + header('Location: '.$url); |
|
154 | 154 | exit; |
155 | 155 | } |
156 | 156 | } |
@@ -8,7 +8,6 @@ |
||
8 | 8 | /** |
9 | 9 | * Class constructor |
10 | 10 | * |
11 | - * @param string $text raw HTML to add |
|
12 | 11 | * @access public |
13 | 12 | * @return void |
14 | 13 | */ |
@@ -6,12 +6,12 @@ discard block |
||
6 | 6 | class HTML_QuickForm_advanced_settings extends HTML_QuickForm_static |
7 | 7 | { |
8 | 8 | /** |
9 | - * Class constructor |
|
10 | - * |
|
11 | - * @param string $text raw HTML to add |
|
12 | - * @access public |
|
13 | - * @return void |
|
14 | - */ |
|
9 | + * Class constructor |
|
10 | + * |
|
11 | + * @param string $text raw HTML to add |
|
12 | + * @access public |
|
13 | + * @return void |
|
14 | + */ |
|
15 | 15 | public function __construct($name = '', $label = '') |
16 | 16 | { |
17 | 17 | if (empty($label)) { |
@@ -26,13 +26,13 @@ discard block |
||
26 | 26 | $this->_type = 'html'; |
27 | 27 | } |
28 | 28 | |
29 | - /** |
|
30 | - * Accepts a renderer |
|
31 | - * |
|
32 | - * @param HTML_QuickForm_Renderer renderer object (only works with Default renderer!) |
|
33 | - * @access public |
|
34 | - * @return void |
|
35 | - */ |
|
29 | + /** |
|
30 | + * Accepts a renderer |
|
31 | + * |
|
32 | + * @param HTML_QuickForm_Renderer renderer object (only works with Default renderer!) |
|
33 | + * @access public |
|
34 | + * @return void |
|
35 | + */ |
|
36 | 36 | function accept(&$renderer, $required = false, $error = null) |
37 | 37 | { |
38 | 38 | $renderer->renderHtml($this); |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
120 | - * @param mixed $class |
|
120 | + * @param string|null $class |
|
121 | 121 | */ |
122 | 122 | public function setClass($class) |
123 | 123 | { |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
128 | - * @return mixed |
|
128 | + * @return string|null |
|
129 | 129 | */ |
130 | 130 | public function getIcon() |
131 | 131 | { |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
136 | - * @param mixed $icon |
|
136 | + * @param string $icon |
|
137 | 137 | */ |
138 | 138 | public function setIcon($icon) |
139 | 139 | { |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
144 | - * @return mixed |
|
144 | + * @return string|null |
|
145 | 145 | */ |
146 | 146 | public function getStyle() |
147 | 147 | { |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
152 | - * @param mixed $style |
|
152 | + * @param string $style |
|
153 | 153 | */ |
154 | 154 | public function setStyle($style) |
155 | 155 | { |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | $this->columnsSize = $columnsSize; |
181 | 181 | } |
182 | 182 | /** |
183 | - * @param mixed $size |
|
183 | + * @param string $size |
|
184 | 184 | */ |
185 | 185 | public function setSize($size) |
186 | 186 | { |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * Freeze the element so that only its value is returned |
208 | 208 | * |
209 | 209 | * @access public |
210 | - * @return void |
|
210 | + * @return boolean |
|
211 | 211 | */ |
212 | 212 | public function freeze() |
213 | 213 | { |
@@ -94,14 +94,14 @@ |
||
94 | 94 | $icon = $this->getIcon(); |
95 | 95 | |
96 | 96 | if (!empty($icon)) { |
97 | - $icon = '<em class="' . $this->getIcon() . '"></em> '; |
|
97 | + $icon = '<em class="'.$this->getIcon().'"></em> '; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | $class = $this->getClass().' '.$this->getStyle().' '.$this->getSize(); |
101 | 101 | |
102 | 102 | return |
103 | - $this->_getTabs() . ' |
|
104 | - <button class="'.$class.'" ' . $this->_getAttrString($this->_attributes) . '>'. |
|
103 | + $this->_getTabs().' |
|
104 | + <button class="'.$class.'" '.$this->_getAttrString($this->_attributes).'>'. |
|
105 | 105 | $icon. |
106 | 106 | $value. |
107 | 107 | '</button>'; |
@@ -191,6 +191,7 @@ |
||
191 | 191 | * @access public |
192 | 192 | * @param HTML_QuickForm_Page The page that failed to handle the action |
193 | 193 | * @param string Name of the action |
194 | + * @param HTML_QuickForm_Page $page |
|
194 | 195 | * @throws PEAR_Error |
195 | 196 | */ |
196 | 197 | function handle(&$page, $actionName) |
@@ -40,48 +40,48 @@ discard block |
||
40 | 40 | */ |
41 | 41 | class HTML_QuickForm_Controller |
42 | 42 | { |
43 | - /** |
|
44 | - * Contains the pages (HTML_QuickForm_Page objects) of the miultipage form |
|
45 | - * @var array |
|
46 | - */ |
|
43 | + /** |
|
44 | + * Contains the pages (HTML_QuickForm_Page objects) of the miultipage form |
|
45 | + * @var array |
|
46 | + */ |
|
47 | 47 | var $_pages = array(); |
48 | 48 | |
49 | - /** |
|
50 | - * Contains the mapping of actions to corresponding HTML_QuickForm_Action objects |
|
51 | - * @var array |
|
52 | - */ |
|
49 | + /** |
|
50 | + * Contains the mapping of actions to corresponding HTML_QuickForm_Action objects |
|
51 | + * @var array |
|
52 | + */ |
|
53 | 53 | var $_actions = array(); |
54 | 54 | |
55 | - /** |
|
56 | - * Name of the form, used to store the values in session |
|
57 | - * @var string |
|
58 | - */ |
|
55 | + /** |
|
56 | + * Name of the form, used to store the values in session |
|
57 | + * @var string |
|
58 | + */ |
|
59 | 59 | var $_name; |
60 | 60 | |
61 | - /** |
|
62 | - * Whether the form is modal |
|
63 | - * @var bool |
|
64 | - */ |
|
61 | + /** |
|
62 | + * Whether the form is modal |
|
63 | + * @var bool |
|
64 | + */ |
|
65 | 65 | var $_modal = true; |
66 | 66 | |
67 | - /** |
|
68 | - * The action extracted from HTTP request: array('page', 'action') |
|
69 | - * @var array |
|
70 | - */ |
|
67 | + /** |
|
68 | + * The action extracted from HTTP request: array('page', 'action') |
|
69 | + * @var array |
|
70 | + */ |
|
71 | 71 | var $_actionName = null; |
72 | 72 | |
73 | - /** |
|
74 | - * Class constructor. |
|
75 | - * |
|
76 | - * Sets the form name and modal/non-modal behaviuor. Different multipage |
|
77 | - * forms should have different names, as they are used to store form |
|
78 | - * values in session. Modal forms allow passing to the next page only when |
|
79 | - * all of the previous pages are valid. |
|
80 | - * |
|
81 | - * @access public |
|
82 | - * @param string form name |
|
83 | - * @param bool whether the form is modal |
|
84 | - */ |
|
73 | + /** |
|
74 | + * Class constructor. |
|
75 | + * |
|
76 | + * Sets the form name and modal/non-modal behaviuor. Different multipage |
|
77 | + * forms should have different names, as they are used to store form |
|
78 | + * values in session. Modal forms allow passing to the next page only when |
|
79 | + * all of the previous pages are valid. |
|
80 | + * |
|
81 | + * @access public |
|
82 | + * @param string form name |
|
83 | + * @param bool whether the form is modal |
|
84 | + */ |
|
85 | 85 | function HTML_QuickForm_Controller($name, $modal = true) |
86 | 86 | { |
87 | 87 | $this->_name = $name; |
@@ -89,17 +89,17 @@ discard block |
||
89 | 89 | } |
90 | 90 | |
91 | 91 | |
92 | - /** |
|
93 | - * Returns a reference to a session variable containing the form-page |
|
94 | - * values and pages' validation status. |
|
95 | - * |
|
96 | - * This is a "low-level" method, use exportValues() if you want just to |
|
97 | - * get the form's values. |
|
98 | - * |
|
99 | - * @access public |
|
100 | - * @param bool If true, then reset the container: clear all default, constant and submitted values |
|
101 | - * @return array |
|
102 | - */ |
|
92 | + /** |
|
93 | + * Returns a reference to a session variable containing the form-page |
|
94 | + * values and pages' validation status. |
|
95 | + * |
|
96 | + * This is a "low-level" method, use exportValues() if you want just to |
|
97 | + * get the form's values. |
|
98 | + * |
|
99 | + * @access public |
|
100 | + * @param bool If true, then reset the container: clear all default, constant and submitted values |
|
101 | + * @return array |
|
102 | + */ |
|
103 | 103 | function &container($reset = false) |
104 | 104 | { |
105 | 105 | $name = '_' . $this->_name . '_container'; |
@@ -121,15 +121,15 @@ discard block |
||
121 | 121 | } |
122 | 122 | |
123 | 123 | |
124 | - /** |
|
125 | - * Processes the request. |
|
126 | - * |
|
127 | - * This finds the current page, the current action and passes the action |
|
128 | - * to the page's handle() method. |
|
129 | - * |
|
130 | - * @access public |
|
131 | - * @throws PEAR_Error |
|
132 | - */ |
|
124 | + /** |
|
125 | + * Processes the request. |
|
126 | + * |
|
127 | + * This finds the current page, the current action and passes the action |
|
128 | + * to the page's handle() method. |
|
129 | + * |
|
130 | + * @access public |
|
131 | + * @throws PEAR_Error |
|
132 | + */ |
|
133 | 133 | function run() |
134 | 134 | { |
135 | 135 | // the names of the action and page should be saved |
@@ -138,25 +138,25 @@ discard block |
||
138 | 138 | } |
139 | 139 | |
140 | 140 | |
141 | - /** |
|
142 | - * Registers a handler for a specific action. |
|
143 | - * |
|
144 | - * @access public |
|
145 | - * @param string name of the action |
|
146 | - * @param HTML_QuickForm_Action the handler for the action |
|
147 | - */ |
|
141 | + /** |
|
142 | + * Registers a handler for a specific action. |
|
143 | + * |
|
144 | + * @access public |
|
145 | + * @param string name of the action |
|
146 | + * @param HTML_QuickForm_Action the handler for the action |
|
147 | + */ |
|
148 | 148 | function addAction($actionName, &$action) |
149 | 149 | { |
150 | 150 | $this->_actions[$actionName] =& $action; |
151 | 151 | } |
152 | 152 | |
153 | 153 | |
154 | - /** |
|
155 | - * Adds a new page to the form |
|
156 | - * |
|
157 | - * @access public |
|
158 | - * @param HTML_QuickForm_Page |
|
159 | - */ |
|
154 | + /** |
|
155 | + * Adds a new page to the form |
|
156 | + * |
|
157 | + * @access public |
|
158 | + * @param HTML_QuickForm_Page |
|
159 | + */ |
|
160 | 160 | function addPage(&$page) |
161 | 161 | { |
162 | 162 | $page->controller =& $this; |
@@ -164,14 +164,14 @@ discard block |
||
164 | 164 | } |
165 | 165 | |
166 | 166 | |
167 | - /** |
|
168 | - * Returns a page |
|
169 | - * |
|
170 | - * @access public |
|
171 | - * @param string Name of a page |
|
172 | - * @return HTML_QuickForm_Page A reference to the page |
|
173 | - * @throws PEAR_Error |
|
174 | - */ |
|
167 | + /** |
|
168 | + * Returns a page |
|
169 | + * |
|
170 | + * @access public |
|
171 | + * @param string Name of a page |
|
172 | + * @return HTML_QuickForm_Page A reference to the page |
|
173 | + * @throws PEAR_Error |
|
174 | + */ |
|
175 | 175 | function &getPage($pageName) |
176 | 176 | { |
177 | 177 | if (!isset($this->_pages[$pageName])) { |
@@ -181,18 +181,18 @@ discard block |
||
181 | 181 | } |
182 | 182 | |
183 | 183 | |
184 | - /** |
|
185 | - * Handles an action. |
|
186 | - * |
|
187 | - * This will be called if the page itself does not have a handler |
|
188 | - * to a specific action. The method also loads and uses default handlers |
|
189 | - * for common actions, if specific ones were not added. |
|
190 | - * |
|
191 | - * @access public |
|
192 | - * @param HTML_QuickForm_Page The page that failed to handle the action |
|
193 | - * @param string Name of the action |
|
194 | - * @throws PEAR_Error |
|
195 | - */ |
|
184 | + /** |
|
185 | + * Handles an action. |
|
186 | + * |
|
187 | + * This will be called if the page itself does not have a handler |
|
188 | + * to a specific action. The method also loads and uses default handlers |
|
189 | + * for common actions, if specific ones were not added. |
|
190 | + * |
|
191 | + * @access public |
|
192 | + * @param HTML_QuickForm_Page The page that failed to handle the action |
|
193 | + * @param string Name of the action |
|
194 | + * @throws PEAR_Error |
|
195 | + */ |
|
196 | 196 | function handle(&$page, $actionName) |
197 | 197 | { |
198 | 198 | if (isset($this->_actions[$actionName])) { |
@@ -215,26 +215,26 @@ discard block |
||
215 | 215 | } |
216 | 216 | |
217 | 217 | |
218 | - /** |
|
219 | - * Checks whether the form is modal. |
|
220 | - * |
|
221 | - * @access public |
|
222 | - * @return bool |
|
223 | - */ |
|
218 | + /** |
|
219 | + * Checks whether the form is modal. |
|
220 | + * |
|
221 | + * @access public |
|
222 | + * @return bool |
|
223 | + */ |
|
224 | 224 | function isModal() |
225 | 225 | { |
226 | 226 | return $this->_modal; |
227 | 227 | } |
228 | 228 | |
229 | 229 | |
230 | - /** |
|
231 | - * Checks whether the pages of the controller are valid |
|
232 | - * |
|
233 | - * @access public |
|
234 | - * @param string If set, check only the pages before (not including) that page |
|
235 | - * @return bool |
|
236 | - * @throws PEAR_Error |
|
237 | - */ |
|
230 | + /** |
|
231 | + * Checks whether the pages of the controller are valid |
|
232 | + * |
|
233 | + * @access public |
|
234 | + * @param string If set, check only the pages before (not including) that page |
|
235 | + * @return bool |
|
236 | + * @throws PEAR_Error |
|
237 | + */ |
|
238 | 238 | function isValid($pageName = null) |
239 | 239 | { |
240 | 240 | $data =& $this->container(); |
@@ -273,13 +273,13 @@ discard block |
||
273 | 273 | } |
274 | 274 | |
275 | 275 | |
276 | - /** |
|
277 | - * Returns the name of the page before the given. |
|
278 | - * |
|
279 | - * @access public |
|
280 | - * @param string |
|
281 | - * @return string |
|
282 | - */ |
|
276 | + /** |
|
277 | + * Returns the name of the page before the given. |
|
278 | + * |
|
279 | + * @access public |
|
280 | + * @param string |
|
281 | + * @return string |
|
282 | + */ |
|
283 | 283 | function getPrevName($pageName) |
284 | 284 | { |
285 | 285 | $prev = null; |
@@ -292,13 +292,13 @@ discard block |
||
292 | 292 | } |
293 | 293 | |
294 | 294 | |
295 | - /** |
|
296 | - * Returns the name of the page after the given. |
|
297 | - * |
|
298 | - * @access public |
|
299 | - * @param string |
|
300 | - * @return string |
|
301 | - */ |
|
295 | + /** |
|
296 | + * Returns the name of the page after the given. |
|
297 | + * |
|
298 | + * @access public |
|
299 | + * @param string |
|
300 | + * @return string |
|
301 | + */ |
|
302 | 302 | function getNextName($pageName) |
303 | 303 | { |
304 | 304 | $prev = null; |
@@ -312,12 +312,12 @@ discard block |
||
312 | 312 | } |
313 | 313 | |
314 | 314 | |
315 | - /** |
|
316 | - * Finds the (first) invalid page |
|
317 | - * |
|
318 | - * @access public |
|
319 | - * @return string Name of an invalid page |
|
320 | - */ |
|
315 | + /** |
|
316 | + * Finds the (first) invalid page |
|
317 | + * |
|
318 | + * @access public |
|
319 | + * @return string Name of an invalid page |
|
320 | + */ |
|
321 | 321 | function findInvalid() |
322 | 322 | { |
323 | 323 | $data =& $this->container(); |
@@ -330,13 +330,13 @@ discard block |
||
330 | 330 | } |
331 | 331 | |
332 | 332 | |
333 | - /** |
|
334 | - * Extracts the names of the current page and the current action from |
|
335 | - * HTTP request data. |
|
336 | - * |
|
337 | - * @access public |
|
338 | - * @return array first element is page name, second is action name |
|
339 | - */ |
|
333 | + /** |
|
334 | + * Extracts the names of the current page and the current action from |
|
335 | + * HTTP request data. |
|
336 | + * |
|
337 | + * @access public |
|
338 | + * @return array first element is page name, second is action name |
|
339 | + */ |
|
340 | 340 | function getActionName() |
341 | 341 | { |
342 | 342 | if (is_array($this->_actionName)) { |
@@ -360,14 +360,14 @@ discard block |
||
360 | 360 | } |
361 | 361 | |
362 | 362 | |
363 | - /** |
|
364 | - * Initializes default form values. |
|
365 | - * |
|
366 | - * @access public |
|
367 | - * @param array default values |
|
368 | - * @param mixed filter(s) to apply to default values |
|
369 | - * @throws PEAR_Error |
|
370 | - */ |
|
363 | + /** |
|
364 | + * Initializes default form values. |
|
365 | + * |
|
366 | + * @access public |
|
367 | + * @param array default values |
|
368 | + * @param mixed filter(s) to apply to default values |
|
369 | + * @throws PEAR_Error |
|
370 | + */ |
|
371 | 371 | function setDefaults($defaultValues = null, $filter = null) |
372 | 372 | { |
373 | 373 | if (is_array($defaultValues)) { |
@@ -377,15 +377,15 @@ discard block |
||
377 | 377 | } |
378 | 378 | |
379 | 379 | |
380 | - /** |
|
381 | - * Initializes constant form values. |
|
382 | - * These values won't get overridden by POST or GET vars |
|
383 | - * |
|
384 | - * @access public |
|
385 | - * @param array constant values |
|
386 | - * @param mixed filter(s) to apply to constant values |
|
387 | - * @throws PEAR_Error |
|
388 | - */ |
|
380 | + /** |
|
381 | + * Initializes constant form values. |
|
382 | + * These values won't get overridden by POST or GET vars |
|
383 | + * |
|
384 | + * @access public |
|
385 | + * @param array constant values |
|
386 | + * @param mixed filter(s) to apply to constant values |
|
387 | + * @throws PEAR_Error |
|
388 | + */ |
|
389 | 389 | function setConstants($constantValues = null, $filter = null) |
390 | 390 | { |
391 | 391 | if (is_array($constantValues)) { |
@@ -395,15 +395,15 @@ discard block |
||
395 | 395 | } |
396 | 396 | |
397 | 397 | |
398 | - /** |
|
399 | - * Adds new values to defaults or constants array |
|
400 | - * |
|
401 | - * @access private |
|
402 | - * @param array array to add values to (either defaults or constants) |
|
403 | - * @param array values to add |
|
404 | - * @param mixed filters to apply to new values |
|
405 | - * @throws PEAR_Error |
|
406 | - */ |
|
398 | + /** |
|
399 | + * Adds new values to defaults or constants array |
|
400 | + * |
|
401 | + * @access private |
|
402 | + * @param array array to add values to (either defaults or constants) |
|
403 | + * @param array values to add |
|
404 | + * @param mixed filters to apply to new values |
|
405 | + * @throws PEAR_Error |
|
406 | + */ |
|
407 | 407 | function _setDefaultsOrConstants(&$values, $newValues, $filter = null) |
408 | 408 | { |
409 | 409 | if (isset($filter)) { |
@@ -425,14 +425,14 @@ discard block |
||
425 | 425 | } |
426 | 426 | |
427 | 427 | |
428 | - /** |
|
429 | - * Recursively applies the callback function to the value |
|
430 | - * |
|
431 | - * @param mixed Callback function |
|
432 | - * @param mixed Value to process |
|
433 | - * @access private |
|
434 | - * @return mixed Processed values |
|
435 | - */ |
|
428 | + /** |
|
429 | + * Recursively applies the callback function to the value |
|
430 | + * |
|
431 | + * @param mixed Callback function |
|
432 | + * @param mixed Value to process |
|
433 | + * @access private |
|
434 | + * @return mixed Processed values |
|
435 | + */ |
|
436 | 436 | function _arrayMapRecursive($callback, $value) |
437 | 437 | { |
438 | 438 | if (!is_array($value)) { |
@@ -447,12 +447,12 @@ discard block |
||
447 | 447 | } |
448 | 448 | |
449 | 449 | |
450 | - /** |
|
451 | - * Sets the default values for the given page |
|
452 | - * |
|
453 | - * @access public |
|
454 | - * @param string Name of a page |
|
455 | - */ |
|
450 | + /** |
|
451 | + * Sets the default values for the given page |
|
452 | + * |
|
453 | + * @access public |
|
454 | + * @param string Name of a page |
|
455 | + */ |
|
456 | 456 | function applyDefaults($pageName) |
457 | 457 | { |
458 | 458 | $data =& $this->container(); |
@@ -465,13 +465,13 @@ discard block |
||
465 | 465 | } |
466 | 466 | |
467 | 467 | |
468 | - /** |
|
469 | - * Returns the form's values |
|
470 | - * |
|
471 | - * @access public |
|
472 | - * @param string name of the page, if not set then returns values for all pages |
|
473 | - * @return array |
|
474 | - */ |
|
468 | + /** |
|
469 | + * Returns the form's values |
|
470 | + * |
|
471 | + * @access public |
|
472 | + * @param string name of the page, if not set then returns values for all pages |
|
473 | + * @return array |
|
474 | + */ |
|
475 | 475 | function exportValues($pageName = null) |
476 | 476 | { |
477 | 477 | $data =& $this->container(); |
@@ -497,14 +497,14 @@ discard block |
||
497 | 497 | } |
498 | 498 | |
499 | 499 | |
500 | - /** |
|
501 | - * Returns the element's value |
|
502 | - * |
|
503 | - * @access public |
|
504 | - * @param string name of the page |
|
505 | - * @param string name of the element in the page |
|
506 | - * @return mixed value for the element |
|
507 | - */ |
|
500 | + /** |
|
501 | + * Returns the element's value |
|
502 | + * |
|
503 | + * @access public |
|
504 | + * @param string name of the page |
|
505 | + * @param string name of the element in the page |
|
506 | + * @return mixed value for the element |
|
507 | + */ |
|
508 | 508 | function exportValue($pageName, $elementName) |
509 | 509 | { |
510 | 510 | $data =& $this->container(); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | function &container($reset = false) |
104 | 104 | { |
105 | - $name = '_' . $this->_name . '_container'; |
|
105 | + $name = '_'.$this->_name.'_container'; |
|
106 | 106 | if (!isset($_SESSION[$name]) || $reset) { |
107 | 107 | $_SESSION[$name] = array( |
108 | 108 | 'defaults' => array(), |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | */ |
148 | 148 | function addAction($actionName, &$action) |
149 | 149 | { |
150 | - $this->_actions[$actionName] =& $action; |
|
150 | + $this->_actions[$actionName] = & $action; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | |
@@ -159,8 +159,8 @@ discard block |
||
159 | 159 | */ |
160 | 160 | function addPage(&$page) |
161 | 161 | { |
162 | - $page->controller =& $this; |
|
163 | - $this->_pages[$page->getAttribute('id')] =& $page; |
|
162 | + $page->controller = & $this; |
|
163 | + $this->_pages[$page->getAttribute('id')] = & $page; |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | function &getPage($pageName) |
176 | 176 | { |
177 | 177 | if (!isset($this->_pages[$pageName])) { |
178 | - return PEAR::raiseError('HTML_QuickForm_Controller: Unknown page "' . $pageName . '"'); |
|
178 | + return PEAR::raiseError('HTML_QuickForm_Controller: Unknown page "'.$pageName.'"'); |
|
179 | 179 | } |
180 | 180 | return $this->_pages[$pageName]; |
181 | 181 | } |
@@ -204,13 +204,13 @@ discard block |
||
204 | 204 | case 'submit': |
205 | 205 | case 'display': |
206 | 206 | case 'jump': |
207 | - include_once 'HTML/QuickForm/Action/' . ucfirst($actionName) . '.php'; |
|
208 | - $className = 'HTML_QuickForm_Action_' . $actionName; |
|
209 | - $this->_actions[$actionName] =& new $className(); |
|
207 | + include_once 'HTML/QuickForm/Action/'.ucfirst($actionName).'.php'; |
|
208 | + $className = 'HTML_QuickForm_Action_'.$actionName; |
|
209 | + $this->_actions[$actionName] = & new $className(); |
|
210 | 210 | return $this->_actions[$actionName]->perform($page, $actionName); |
211 | 211 | break; |
212 | 212 | default: |
213 | - return PEAR::raiseError('HTML_QuickForm_Controller: Unhandled action "' . $actionName . '" in page "' . $page->getAttribute('id') . '"'); |
|
213 | + return PEAR::raiseError('HTML_QuickForm_Controller: Unhandled action "'.$actionName.'" in page "'.$page->getAttribute('id').'"'); |
|
214 | 214 | } // switch |
215 | 215 | } |
216 | 216 | |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | */ |
238 | 238 | function isValid($pageName = null) |
239 | 239 | { |
240 | - $data =& $this->container(); |
|
240 | + $data = & $this->container(); |
|
241 | 241 | foreach (array_keys($this->_pages) as $key) { |
242 | 242 | if (isset($pageName) && $pageName == $key) { |
243 | 243 | return true; |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | // We should handle the possible situation when the user has never |
246 | 246 | // seen a page of a non-modal multipage form |
247 | 247 | if (!$this->isModal() && null === $data['valid'][$key]) { |
248 | - $page =& $this->_pages[$key]; |
|
248 | + $page = & $this->_pages[$key]; |
|
249 | 249 | // Fix for bug #8687: the unseen page was considered |
250 | 250 | // submitted, so defaults for checkboxes and multiselects |
251 | 251 | // were not used. Shouldn't break anything since this flag |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | */ |
321 | 321 | function findInvalid() |
322 | 322 | { |
323 | - $data =& $this->container(); |
|
323 | + $data = & $this->container(); |
|
324 | 324 | foreach (array_keys($this->_pages) as $key) { |
325 | 325 | if (!$data['valid'][$key]) { |
326 | 326 | return $key; |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | return $this->_actionName; |
344 | 344 | } |
345 | 345 | $names = array_map('preg_quote', array_keys($this->_pages)); |
346 | - $regex = '/^_qf_(' . implode('|', $names) . ')_(.+?)(_x)?$/'; |
|
346 | + $regex = '/^_qf_('.implode('|', $names).')_(.+?)(_x)?$/'; |
|
347 | 347 | foreach (array_keys($_REQUEST) as $key) { |
348 | 348 | if (preg_match($regex, $key, $matches)) { |
349 | 349 | return array($matches[1], $matches[2]); |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | function setDefaults($defaultValues = null, $filter = null) |
372 | 372 | { |
373 | 373 | if (is_array($defaultValues)) { |
374 | - $data =& $this->container(); |
|
374 | + $data = & $this->container(); |
|
375 | 375 | return $this->_setDefaultsOrConstants($data['defaults'], $defaultValues, $filter); |
376 | 376 | } |
377 | 377 | } |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | function setConstants($constantValues = null, $filter = null) |
390 | 390 | { |
391 | 391 | if (is_array($constantValues)) { |
392 | - $data =& $this->container(); |
|
392 | + $data = & $this->container(); |
|
393 | 393 | return $this->_setDefaultsOrConstants($data['constants'], $constantValues, $filter); |
394 | 394 | } |
395 | 395 | } |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | */ |
456 | 456 | function applyDefaults($pageName) |
457 | 457 | { |
458 | - $data =& $this->container(); |
|
458 | + $data = & $this->container(); |
|
459 | 459 | if (!empty($data['defaults'])) { |
460 | 460 | $this->_pages[$pageName]->setDefaults($data['defaults']); |
461 | 461 | } |
@@ -474,8 +474,8 @@ discard block |
||
474 | 474 | */ |
475 | 475 | function exportValues($pageName = null) |
476 | 476 | { |
477 | - $data =& $this->container(); |
|
478 | - $values = array(); |
|
477 | + $data = & $this->container(); |
|
478 | + $values = array(); |
|
479 | 479 | if (isset($pageName)) { |
480 | 480 | $pages = array($pageName); |
481 | 481 | } else { |
@@ -507,8 +507,8 @@ discard block |
||
507 | 507 | */ |
508 | 508 | function exportValue($pageName, $elementName) |
509 | 509 | { |
510 | - $data =& $this->container(); |
|
511 | - return isset($data['values'][$pageName][$elementName])? $data['values'][$pageName][$elementName]: null; |
|
510 | + $data = & $this->container(); |
|
511 | + return isset($data['values'][$pageName][$elementName]) ? $data['values'][$pageName][$elementName] : null; |
|
512 | 512 | } |
513 | 513 | } |
514 | 514 | ?> |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | * Sets display text for the element |
357 | 357 | * |
358 | 358 | * @param string $label Display text for the element |
359 | - * @param string $label_for Optionally add a "for" attribute |
|
359 | + * @param string $labelFor Optionally add a "for" attribute |
|
360 | 360 | * @since 1.3 |
361 | 361 | * @access public |
362 | 362 | * @return void |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | * @param object &$caller calling object |
436 | 436 | * @since 1.0 |
437 | 437 | * @access public |
438 | - * @return void |
|
438 | + * @return boolean |
|
439 | 439 | */ |
440 | 440 | public function onQuickFormEvent($event, $arg, &$caller) |
441 | 441 | { |
@@ -259,13 +259,13 @@ discard block |
||
259 | 259 | // }}} |
260 | 260 | // {{{ unfreeze() |
261 | 261 | |
262 | - /** |
|
263 | - * Unfreezes the element so that it becomes editable |
|
264 | - * |
|
265 | - * @access public |
|
266 | - * @return void |
|
267 | - * @since 3.2.4 |
|
268 | - */ |
|
262 | + /** |
|
263 | + * Unfreezes the element so that it becomes editable |
|
264 | + * |
|
265 | + * @access public |
|
266 | + * @return void |
|
267 | + * @since 3.2.4 |
|
268 | + */ |
|
269 | 269 | function unfreeze() |
270 | 270 | { |
271 | 271 | $this->_flagFrozen = false; |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | // $this->_getPersistantData(); |
290 | 290 | |
291 | 291 | $value = ('' != $value ? @htmlspecialchars($value, ENT_COMPAT, HTML_Common::charset()): ' ') . |
292 | - $this->_getPersistantData(); |
|
292 | + $this->_getPersistantData(); |
|
293 | 293 | return '<span class="freeze">'.$value.'</span>'; |
294 | 294 | // |
295 | 295 | } //end func getFrozenHtml |
@@ -297,12 +297,12 @@ discard block |
||
297 | 297 | // }}} |
298 | 298 | // {{{ _getPersistantData() |
299 | 299 | |
300 | - /** |
|
301 | - * Used by getFrozenHtml() to pass the element's value if _persistantFreeze is on |
|
302 | - * |
|
303 | - * @access private |
|
304 | - * @return string |
|
305 | - */ |
|
300 | + /** |
|
301 | + * Used by getFrozenHtml() to pass the element's value if _persistantFreeze is on |
|
302 | + * |
|
303 | + * @access private |
|
304 | + * @return string |
|
305 | + */ |
|
306 | 306 | function _getPersistantData() |
307 | 307 | { |
308 | 308 | if (!$this->_persistantFreeze) { |
@@ -310,10 +310,10 @@ discard block |
||
310 | 310 | } else { |
311 | 311 | $id = $this->getAttribute('id'); |
312 | 312 | return '<input' . $this->_getAttrString(array( |
313 | - 'type' => 'hidden', |
|
314 | - 'name' => $this->getName(), |
|
315 | - 'value' => $this->getValue() |
|
316 | - ) + (isset($id)? array('id' => $id): array())) . ' />'; |
|
313 | + 'type' => 'hidden', |
|
314 | + 'name' => $this->getName(), |
|
315 | + 'value' => $this->getValue() |
|
316 | + ) + (isset($id)? array('id' => $id): array())) . ' />'; |
|
317 | 317 | } |
318 | 318 | } |
319 | 319 | |
@@ -415,9 +415,9 @@ discard block |
||
415 | 415 | return $values[$elementName]; |
416 | 416 | } elseif (strpos($elementName, '[')) { |
417 | 417 | $myVar = "['" . str_replace( |
418 | - array('\\', '\'', ']', '['), array('\\\\', '\\\'', '', "']['"), |
|
419 | - $elementName |
|
420 | - ) . "']"; |
|
418 | + array('\\', '\'', ']', '['), array('\\\\', '\\\'', '', "']['"), |
|
419 | + $elementName |
|
420 | + ) . "']"; |
|
421 | 421 | return eval("return (isset(\$values$myVar)) ? \$values$myVar : null;"); |
422 | 422 | } else { |
423 | 423 | return null; |
@@ -471,29 +471,29 @@ discard block |
||
471 | 471 | return true; |
472 | 472 | } |
473 | 473 | |
474 | - /** |
|
475 | - * Accepts a renderer |
|
476 | - * |
|
477 | - * @param HTML_QuickForm_Renderer renderer object |
|
478 | - * @param bool Whether an element is required |
|
479 | - * @param string An error message associated with an element |
|
480 | - * @access public |
|
481 | - * @return void |
|
482 | - */ |
|
474 | + /** |
|
475 | + * Accepts a renderer |
|
476 | + * |
|
477 | + * @param HTML_QuickForm_Renderer renderer object |
|
478 | + * @param bool Whether an element is required |
|
479 | + * @param string An error message associated with an element |
|
480 | + * @access public |
|
481 | + * @return void |
|
482 | + */ |
|
483 | 483 | function accept(&$renderer, $required=false, $error=null) |
484 | 484 | { |
485 | 485 | $renderer->renderElement($this, $required, $error); |
486 | 486 | } |
487 | 487 | |
488 | - /** |
|
489 | - * Automatically generates and assigns an 'id' attribute for the element. |
|
490 | - * |
|
491 | - * Currently used to ensure that labels work on radio buttons and |
|
492 | - * checkboxes. Per idea of Alexander Radivanovich. |
|
493 | - * |
|
494 | - * @access private |
|
495 | - * @return void |
|
496 | - */ |
|
488 | + /** |
|
489 | + * Automatically generates and assigns an 'id' attribute for the element. |
|
490 | + * |
|
491 | + * Currently used to ensure that labels work on radio buttons and |
|
492 | + * checkboxes. Per idea of Alexander Radivanovich. |
|
493 | + * |
|
494 | + * @access private |
|
495 | + * @return void |
|
496 | + */ |
|
497 | 497 | function _generateId() |
498 | 498 | { |
499 | 499 | static $idx = 1; |
@@ -503,14 +503,14 @@ discard block |
||
503 | 503 | } |
504 | 504 | } |
505 | 505 | |
506 | - /** |
|
507 | - * Returns a 'safe' element's value |
|
508 | - * |
|
509 | - * @param array array of submitted values to search |
|
510 | - * @param bool whether to return the value as associative array |
|
511 | - * @access public |
|
512 | - * @return mixed |
|
513 | - */ |
|
506 | + /** |
|
507 | + * Returns a 'safe' element's value |
|
508 | + * |
|
509 | + * @param array array of submitted values to search |
|
510 | + * @param bool whether to return the value as associative array |
|
511 | + * @access public |
|
512 | + * @return mixed |
|
513 | + */ |
|
514 | 514 | function exportValue(&$submitValues, $assoc = false) |
515 | 515 | { |
516 | 516 | $value = $this->_findValue($submitValues); |
@@ -523,14 +523,14 @@ discard block |
||
523 | 523 | // }}} |
524 | 524 | // {{{ _prepareValue() |
525 | 525 | |
526 | - /** |
|
527 | - * Used by exportValue() to prepare the value for returning |
|
528 | - * |
|
529 | - * @param mixed the value found in exportValue() |
|
530 | - * @param bool whether to return the value as associative array |
|
531 | - * @access private |
|
532 | - * @return mixed |
|
533 | - */ |
|
526 | + /** |
|
527 | + * Used by exportValue() to prepare the value for returning |
|
528 | + * |
|
529 | + * @param mixed the value found in exportValue() |
|
530 | + * @param bool whether to return the value as associative array |
|
531 | + * @access private |
|
532 | + * @return mixed |
|
533 | + */ |
|
534 | 534 | function _prepareValue($value, $assoc) |
535 | 535 | { |
536 | 536 | if (null === $value) { |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | //return ('' != $value? htmlspecialchars($value): ' ') . |
289 | 289 | // $this->_getPersistantData(); |
290 | 290 | |
291 | - $value = ('' != $value ? @htmlspecialchars($value, ENT_COMPAT, HTML_Common::charset()): ' ') . |
|
291 | + $value = ('' != $value ? @htmlspecialchars($value, ENT_COMPAT, HTML_Common::charset()) : ' '). |
|
292 | 292 | $this->_getPersistantData(); |
293 | 293 | return '<span class="freeze">'.$value.'</span>'; |
294 | 294 | // |
@@ -309,11 +309,11 @@ discard block |
||
309 | 309 | return ''; |
310 | 310 | } else { |
311 | 311 | $id = $this->getAttribute('id'); |
312 | - return '<input' . $this->_getAttrString(array( |
|
312 | + return '<input'.$this->_getAttrString(array( |
|
313 | 313 | 'type' => 'hidden', |
314 | 314 | 'name' => $this->getName(), |
315 | 315 | 'value' => $this->getValue() |
316 | - ) + (isset($id)? array('id' => $id): array())) . ' />'; |
|
316 | + ) + (isset($id) ? array('id' => $id) : array())).' />'; |
|
317 | 317 | } |
318 | 318 | } |
319 | 319 | |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | * @access public |
345 | 345 | * @return void |
346 | 346 | */ |
347 | - function setPersistantFreeze($persistant=false) |
|
347 | + function setPersistantFreeze($persistant = false) |
|
348 | 348 | { |
349 | 349 | $this->_persistantFreeze = $persistant; |
350 | 350 | } //end func setPersistantFreeze |
@@ -414,10 +414,10 @@ discard block |
||
414 | 414 | if (isset($values[$elementName])) { |
415 | 415 | return $values[$elementName]; |
416 | 416 | } elseif (strpos($elementName, '[')) { |
417 | - $myVar = "['" . str_replace( |
|
417 | + $myVar = "['".str_replace( |
|
418 | 418 | array('\\', '\'', ']', '['), array('\\\\', '\\\'', '', "']['"), |
419 | 419 | $elementName |
420 | - ) . "']"; |
|
420 | + )."']"; |
|
421 | 421 | return eval("return (isset(\$values$myVar)) ? \$values$myVar : null;"); |
422 | 422 | } else { |
423 | 423 | return null; |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | * @access public |
481 | 481 | * @return void |
482 | 482 | */ |
483 | - function accept(&$renderer, $required=false, $error=null) |
|
483 | + function accept(&$renderer, $required = false, $error = null) |
|
484 | 484 | { |
485 | 485 | $renderer->renderElement($this, $required, $error); |
486 | 486 | } |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | static $idx = 1; |
500 | 500 | |
501 | 501 | if (!$this->getAttribute('id')) { |
502 | - $this->updateAttributes(array('id' => 'qf_' . substr(md5(microtime() . $idx++), 0, 6))); |
|
502 | + $this->updateAttributes(array('id' => 'qf_'.substr(md5(microtime().$idx++), 0, 6))); |
|
503 | 503 | } |
504 | 504 | } |
505 | 505 | |
@@ -543,10 +543,10 @@ discard block |
||
543 | 543 | return array($name => $value); |
544 | 544 | } else { |
545 | 545 | $valueAry = array(); |
546 | - $myIndex = "['" . str_replace( |
|
546 | + $myIndex = "['".str_replace( |
|
547 | 547 | array('\\', '\'', ']', '['), array('\\\\', '\\\'', '', "']['"), |
548 | 548 | $name |
549 | - ) . "']"; |
|
549 | + )."']"; |
|
550 | 550 | eval("\$valueAry$myIndex = \$value;"); |
551 | 551 | return $valueAry; |
552 | 552 | } |
@@ -86,7 +86,7 @@ |
||
86 | 86 | * |
87 | 87 | * @since 1.0 |
88 | 88 | * @access public |
89 | - * @return int |
|
89 | + * @return string|null |
|
90 | 90 | */ |
91 | 91 | function getSize() |
92 | 92 | { |
@@ -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 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @since 1.0 |
58 | 58 | * @access public |
59 | 59 | */ |
60 | - public function __construct($elementName=null, $elementLabel=null, $attributes=null) |
|
60 | + public function __construct($elementName = null, $elementLabel = null, $attributes = null) |
|
61 | 61 | { |
62 | 62 | parent::__construct($elementName, $elementLabel, $attributes); |
63 | 63 | $this->setType('file'); |
@@ -191,11 +191,11 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public function moveUploadedFile($dest, $fileName = '') |
193 | 193 | { |
194 | - if ($dest != '' && substr($dest, -1) != '/') { |
|
194 | + if ($dest != '' && substr($dest, -1) != '/') { |
|
195 | 195 | $dest .= '/'; |
196 | 196 | } |
197 | 197 | $fileName = ($fileName != '') ? $fileName : basename($this->_value['name']); |
198 | - return move_uploaded_file($this->_value['tmp_name'], $dest . $fileName); |
|
198 | + return move_uploaded_file($this->_value['tmp_name'], $dest.$fileName); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
@@ -245,23 +245,23 @@ discard block |
||
245 | 245 | if (isset($_FILES[$elementName])) { |
246 | 246 | return $_FILES[$elementName]; |
247 | 247 | } elseif (false !== ($pos = strpos($elementName, '['))) { |
248 | - $base = str_replace( |
|
248 | + $base = str_replace( |
|
249 | 249 | array('\\', '\''), array('\\\\', '\\\''), |
250 | 250 | substr($elementName, 0, $pos) |
251 | 251 | ); |
252 | - $idx = "['" . str_replace( |
|
252 | + $idx = "['".str_replace( |
|
253 | 253 | array('\\', '\'', ']', '['), array('\\\\', '\\\'', '', "']['"), |
254 | 254 | substr($elementName, $pos + 1, -1) |
255 | - ) . "']"; |
|
255 | + )."']"; |
|
256 | 256 | $props = array('name', 'type', 'size', 'tmp_name', 'error'); |
257 | - $code = "if (!isset(\$_FILES['{$base}']['name']{$idx})) {\n" . |
|
258 | - " return null;\n" . |
|
259 | - "} else {\n" . |
|
257 | + $code = "if (!isset(\$_FILES['{$base}']['name']{$idx})) {\n". |
|
258 | + " return null;\n". |
|
259 | + "} else {\n". |
|
260 | 260 | " \$value = array();\n"; |
261 | 261 | foreach ($props as $prop) { |
262 | 262 | $code .= " \$value['{$prop}'] = \$_FILES['{$base}']['{$prop}']{$idx};\n"; |
263 | 263 | } |
264 | - return eval($code . " return \$value;\n}\n"); |
|
264 | + return eval($code." return \$value;\n}\n"); |
|
265 | 265 | } else { |
266 | 266 | return null; |
267 | 267 | } |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | * @param object &$caller calling object |
346 | 346 | * @since 1.0 |
347 | 347 | * @access public |
348 | - * @return void |
|
348 | + * @return boolean |
|
349 | 349 | */ |
350 | 350 | public function onQuickFormEvent($event, $arg, &$caller) |
351 | 351 | { |
@@ -384,6 +384,7 @@ discard block |
||
384 | 384 | * @param HTML_QuickForm_Renderer renderer object |
385 | 385 | * @param bool Whether a group is required |
386 | 386 | * @param string An error message associated with a group |
387 | + * @param HTML_QuickForm_Renderer_Default $renderer |
|
387 | 388 | * @access public |
388 | 389 | * @return void |
389 | 390 | */ |
@@ -68,12 +68,12 @@ discard block |
||
68 | 68 | */ |
69 | 69 | private $_required = array(); |
70 | 70 | |
71 | - /** |
|
72 | - * Whether to change elements' names to $groupName[$elementName] or leave them as is |
|
73 | - * @var bool |
|
74 | - * @since 3.0 |
|
75 | - * @access private |
|
76 | - */ |
|
71 | + /** |
|
72 | + * Whether to change elements' names to $groupName[$elementName] or leave them as is |
|
73 | + * @var bool |
|
74 | + * @since 3.0 |
|
75 | + * @access private |
|
76 | + */ |
|
77 | 77 | private $_appendName = true; |
78 | 78 | |
79 | 79 | /** |
@@ -378,15 +378,15 @@ discard block |
||
378 | 378 | return true; |
379 | 379 | } |
380 | 380 | |
381 | - /** |
|
382 | - * Accepts a renderer |
|
383 | - * |
|
384 | - * @param HTML_QuickForm_Renderer renderer object |
|
385 | - * @param bool Whether a group is required |
|
386 | - * @param string An error message associated with a group |
|
387 | - * @access public |
|
388 | - * @return void |
|
389 | - */ |
|
381 | + /** |
|
382 | + * Accepts a renderer |
|
383 | + * |
|
384 | + * @param HTML_QuickForm_Renderer renderer object |
|
385 | + * @param bool Whether a group is required |
|
386 | + * @param string An error message associated with a group |
|
387 | + * @access public |
|
388 | + * @return void |
|
389 | + */ |
|
390 | 390 | function accept(&$renderer, $required = false, $error = null) |
391 | 391 | { |
392 | 392 | $this->_createElementsIfNotExist(); |
@@ -416,10 +416,10 @@ discard block |
||
416 | 416 | $renderer->finishGroup($this); |
417 | 417 | } |
418 | 418 | |
419 | - /** |
|
420 | - * As usual, to get the group's value we access its elements and call |
|
421 | - * their exportValue() methods |
|
422 | - */ |
|
419 | + /** |
|
420 | + * As usual, to get the group's value we access its elements and call |
|
421 | + * their exportValue() methods |
|
422 | + */ |
|
423 | 423 | function exportValue(&$submitValues, $assoc = false) |
424 | 424 | { |
425 | 425 | $value = null; |
@@ -462,31 +462,31 @@ discard block |
||
462 | 462 | return $value; |
463 | 463 | } |
464 | 464 | |
465 | - /** |
|
466 | - * Creates the group's elements. |
|
467 | - * |
|
468 | - * This should be overriden by child classes that need to create their |
|
469 | - * elements. The method will be called automatically when needed, calling |
|
470 | - * it from the constructor is discouraged as the constructor is usually |
|
471 | - * called _twice_ on element creation, first time with _no_ parameters. |
|
472 | - * |
|
473 | - * @access private |
|
474 | - * @abstract |
|
475 | - */ |
|
465 | + /** |
|
466 | + * Creates the group's elements. |
|
467 | + * |
|
468 | + * This should be overriden by child classes that need to create their |
|
469 | + * elements. The method will be called automatically when needed, calling |
|
470 | + * it from the constructor is discouraged as the constructor is usually |
|
471 | + * called _twice_ on element creation, first time with _no_ parameters. |
|
472 | + * |
|
473 | + * @access private |
|
474 | + * @abstract |
|
475 | + */ |
|
476 | 476 | function _createElements() |
477 | 477 | { |
478 | 478 | // abstract |
479 | 479 | } |
480 | 480 | |
481 | - /** |
|
482 | - * A wrapper around _createElements() |
|
483 | - * |
|
484 | - * This method calls _createElements() if the group's _elements array |
|
485 | - * is empty. It also performs some updates, e.g. freezes the created |
|
486 | - * elements if the group is already frozen. |
|
487 | - * |
|
488 | - * @access private |
|
489 | - */ |
|
481 | + /** |
|
482 | + * A wrapper around _createElements() |
|
483 | + * |
|
484 | + * This method calls _createElements() if the group's _elements array |
|
485 | + * is empty. It also performs some updates, e.g. freezes the created |
|
486 | + * elements if the group is already frozen. |
|
487 | + * |
|
488 | + * @access private |
|
489 | + */ |
|
490 | 490 | function _createElementsIfNotExist() |
491 | 491 | { |
492 | 492 | if (empty($this->_elements)) { |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @access public |
92 | 92 | * @return void |
93 | 93 | */ |
94 | - public function __construct($elementName=null, $elementLabel=null, $elements=null, $separator=null, $appendName = true) |
|
94 | + public function __construct($elementName = null, $elementLabel = null, $elements = null, $separator = null, $appendName = true) |
|
95 | 95 | { |
96 | 96 | parent::__construct($elementName, $elementLabel); |
97 | 97 | $this->_type = 'group'; |
@@ -174,13 +174,13 @@ discard block |
||
174 | 174 | { |
175 | 175 | $value = null; |
176 | 176 | foreach (array_keys($this->_elements) as $key) { |
177 | - $element =& $this->_elements[$key]; |
|
177 | + $element = & $this->_elements[$key]; |
|
178 | 178 | switch ($element->getType()) { |
179 | 179 | case 'radio': |
180 | - $v = $element->getChecked()? $element->getValue(): null; |
|
180 | + $v = $element->getChecked() ? $element->getValue() : null; |
|
181 | 181 | break; |
182 | 182 | case 'checkbox': |
183 | - $v = $element->getChecked()? true: null; |
|
183 | + $v = $element->getChecked() ? true : null; |
|
184 | 184 | break; |
185 | 185 | default: |
186 | 186 | $v = $element->getValue(); |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | $value = $v; |
192 | 192 | } else { |
193 | 193 | if (!is_array($value)) { |
194 | - $value = is_null($value)? array(): array($value); |
|
194 | + $value = is_null($value) ? array() : array($value); |
|
195 | 195 | } |
196 | 196 | if ('' === $elementName) { |
197 | 197 | $value[] = $v; |
@@ -360,9 +360,9 @@ discard block |
||
360 | 360 | if (is_null($elementName)) { |
361 | 361 | $this->_elements[$key]->setName($this->getName()); |
362 | 362 | } elseif ('' === $elementName) { |
363 | - $this->_elements[$key]->setName($this->getName() . '[' . $key . ']'); |
|
363 | + $this->_elements[$key]->setName($this->getName().'['.$key.']'); |
|
364 | 364 | } else { |
365 | - $this->_elements[$key]->setName($this->getName() . '[' . $elementName . ']'); |
|
365 | + $this->_elements[$key]->setName($this->getName().'['.$elementName.']'); |
|
366 | 366 | } |
367 | 367 | } |
368 | 368 | $this->_elements[$key]->onQuickFormEvent('updateValue', $arg, $caller); |
@@ -393,12 +393,12 @@ discard block |
||
393 | 393 | $renderer->startGroup($this, $required, $error); |
394 | 394 | $name = $this->getName(); |
395 | 395 | foreach (array_keys($this->_elements) as $key) { |
396 | - $element =& $this->_elements[$key]; |
|
396 | + $element = & $this->_elements[$key]; |
|
397 | 397 | |
398 | 398 | if ($this->_appendName) { |
399 | 399 | $elementName = $element->getName(); |
400 | 400 | if (isset($elementName)) { |
401 | - $element->setName($name . '['. (strlen($elementName)? $elementName: $key) .']'); |
|
401 | + $element->setName($name.'['.(strlen($elementName) ? $elementName : $key).']'); |
|
402 | 402 | } else { |
403 | 403 | $element->setName($name); |
404 | 404 | } |
@@ -429,9 +429,9 @@ discard block |
||
429 | 429 | if (is_null($elementName)) { |
430 | 430 | $this->_elements[$key]->setName($this->getName()); |
431 | 431 | } elseif ('' === $elementName) { |
432 | - $this->_elements[$key]->setName($this->getName() . '[' . $key . ']'); |
|
432 | + $this->_elements[$key]->setName($this->getName().'['.$key.']'); |
|
433 | 433 | } else { |
434 | - $this->_elements[$key]->setName($this->getName() . '[' . $elementName . ']'); |
|
434 | + $this->_elements[$key]->setName($this->getName().'['.$elementName.']'); |
|
435 | 435 | } |
436 | 436 | } |
437 | 437 | $v = $this->_elements[$key]->exportValue($submitValues, $assoc); |