@@ -331,6 +331,7 @@ |
||
| 331 | 331 | * So we use the smarty eval plugin function to do this. |
| 332 | 332 | * |
| 333 | 333 | * @param string The template source |
| 334 | + * @param string $tplSource |
|
| 334 | 335 | * @access private |
| 335 | 336 | * @return void |
| 336 | 337 | */ |
@@ -87,63 +87,63 @@ discard block |
||
| 87 | 87 | */ |
| 88 | 88 | class HTML_QuickForm_Renderer_ArraySmarty extends HTML_QuickForm_Renderer_Array |
| 89 | 89 | { |
| 90 | - /**#@+ |
|
| 90 | + /**#@+ |
|
| 91 | 91 | * @access private |
| 92 | 92 | */ |
| 93 | - /** |
|
| 94 | - * The Smarty template engine instance |
|
| 95 | - * @var object |
|
| 96 | - */ |
|
| 93 | + /** |
|
| 94 | + * The Smarty template engine instance |
|
| 95 | + * @var object |
|
| 96 | + */ |
|
| 97 | 97 | var $_tpl = null; |
| 98 | 98 | |
| 99 | - /** |
|
| 100 | - * Current element index |
|
| 101 | - * @var integer |
|
| 102 | - */ |
|
| 99 | + /** |
|
| 100 | + * Current element index |
|
| 101 | + * @var integer |
|
| 102 | + */ |
|
| 103 | 103 | var $_elementIdx = 0; |
| 104 | 104 | |
| 105 | 105 | /** |
| 106 | - * The current element index inside a group |
|
| 107 | - * @var integer |
|
| 108 | - */ |
|
| 106 | + * The current element index inside a group |
|
| 107 | + * @var integer |
|
| 108 | + */ |
|
| 109 | 109 | var $_groupElementIdx = 0; |
| 110 | 110 | |
| 111 | - /** |
|
| 112 | - * How to handle the required tag for required fields |
|
| 113 | - * @var string |
|
| 114 | - * @see setRequiredTemplate() |
|
| 115 | - */ |
|
| 111 | + /** |
|
| 112 | + * How to handle the required tag for required fields |
|
| 113 | + * @var string |
|
| 114 | + * @see setRequiredTemplate() |
|
| 115 | + */ |
|
| 116 | 116 | var $_required = ''; |
| 117 | 117 | |
| 118 | - /** |
|
| 119 | - * How to handle error messages in form validation |
|
| 120 | - * @var string |
|
| 121 | - * @see setErrorTemplate() |
|
| 122 | - */ |
|
| 118 | + /** |
|
| 119 | + * How to handle error messages in form validation |
|
| 120 | + * @var string |
|
| 121 | + * @see setErrorTemplate() |
|
| 122 | + */ |
|
| 123 | 123 | var $_error = ''; |
| 124 | - /**#@-*/ |
|
| 124 | + /**#@-*/ |
|
| 125 | 125 | |
| 126 | - /** |
|
| 127 | - * Constructor |
|
| 128 | - * |
|
| 129 | - * @param Smarty reference to the Smarty template engine instance |
|
| 130 | - * @param bool true: render an array of labels to many labels, $key 0 to 'label' and the oterh to "label_$key" |
|
| 131 | - * @param bool true: collect all hidden elements into string; false: process them as usual form elements |
|
| 132 | - * @access public |
|
| 133 | - */ |
|
| 126 | + /** |
|
| 127 | + * Constructor |
|
| 128 | + * |
|
| 129 | + * @param Smarty reference to the Smarty template engine instance |
|
| 130 | + * @param bool true: render an array of labels to many labels, $key 0 to 'label' and the oterh to "label_$key" |
|
| 131 | + * @param bool true: collect all hidden elements into string; false: process them as usual form elements |
|
| 132 | + * @access public |
|
| 133 | + */ |
|
| 134 | 134 | function HTML_QuickForm_Renderer_ArraySmarty(&$tpl, $staticLabels = false, $collectHidden = true) |
| 135 | 135 | { |
| 136 | 136 | $this->HTML_QuickForm_Renderer_Array($collectHidden, $staticLabels); |
| 137 | 137 | $this->_tpl =& $tpl; |
| 138 | 138 | } // end constructor |
| 139 | 139 | |
| 140 | - /** |
|
| 141 | - * Called when visiting a header element |
|
| 142 | - * |
|
| 143 | - * @param HTML_QuickForm_header header element being visited |
|
| 144 | - * @access public |
|
| 145 | - * @return void |
|
| 146 | - */ |
|
| 140 | + /** |
|
| 141 | + * Called when visiting a header element |
|
| 142 | + * |
|
| 143 | + * @param HTML_QuickForm_header header element being visited |
|
| 144 | + * @access public |
|
| 145 | + * @return void |
|
| 146 | + */ |
|
| 147 | 147 | function renderHeader(&$header) |
| 148 | 148 | { |
| 149 | 149 | if ($name = $header->getName()) { |
@@ -154,31 +154,31 @@ discard block |
||
| 154 | 154 | $this->_currentSection = $this->_sectionCount++; |
| 155 | 155 | } // end func renderHeader |
| 156 | 156 | |
| 157 | - /** |
|
| 158 | - * Called when visiting a group, before processing any group elements |
|
| 159 | - * |
|
| 160 | - * @param HTML_QuickForm_group group being visited |
|
| 161 | - * @param bool Whether a group is required |
|
| 162 | - * @param string An error message associated with a group |
|
| 163 | - * @access public |
|
| 164 | - * @return void |
|
| 165 | - */ |
|
| 157 | + /** |
|
| 158 | + * Called when visiting a group, before processing any group elements |
|
| 159 | + * |
|
| 160 | + * @param HTML_QuickForm_group group being visited |
|
| 161 | + * @param bool Whether a group is required |
|
| 162 | + * @param string An error message associated with a group |
|
| 163 | + * @access public |
|
| 164 | + * @return void |
|
| 165 | + */ |
|
| 166 | 166 | function startGroup(&$group, $required, $error) |
| 167 | 167 | { |
| 168 | 168 | parent::startGroup($group, $required, $error); |
| 169 | 169 | $this->_groupElementIdx = 1; |
| 170 | 170 | } // end func startGroup |
| 171 | 171 | |
| 172 | - /** |
|
| 173 | - * Creates an array representing an element containing |
|
| 174 | - * the key for storing this |
|
| 175 | - * |
|
| 176 | - * @access private |
|
| 177 | - * @param HTML_QuickForm_element form element being visited |
|
| 178 | - * @param bool Whether an element is required |
|
| 179 | - * @param string Error associated with the element |
|
| 180 | - * @return array |
|
| 181 | - */ |
|
| 172 | + /** |
|
| 173 | + * Creates an array representing an element containing |
|
| 174 | + * the key for storing this |
|
| 175 | + * |
|
| 176 | + * @access private |
|
| 177 | + * @param HTML_QuickForm_element form element being visited |
|
| 178 | + * @param bool Whether an element is required |
|
| 179 | + * @param string Error associated with the element |
|
| 180 | + * @return array |
|
| 181 | + */ |
|
| 182 | 182 | function _elementToArray(&$element, $required, $error) |
| 183 | 183 | { |
| 184 | 184 | $ret = parent::_elementToArray($element, $required, $error); |
@@ -242,13 +242,13 @@ discard block |
||
| 242 | 242 | return $ret; |
| 243 | 243 | } // end func _elementToArray |
| 244 | 244 | |
| 245 | - /** |
|
| 246 | - * Stores an array representation of an element in the form array |
|
| 247 | - * |
|
| 248 | - * @access private |
|
| 249 | - * @param array Array representation of an element |
|
| 250 | - * @return void |
|
| 251 | - */ |
|
| 245 | + /** |
|
| 246 | + * Stores an array representation of an element in the form array |
|
| 247 | + * |
|
| 248 | + * @access private |
|
| 249 | + * @param array Array representation of an element |
|
| 250 | + * @return void |
|
| 251 | + */ |
|
| 252 | 252 | function _storeArray($elAry) |
| 253 | 253 | { |
| 254 | 254 | if ($elAry) { |
@@ -265,20 +265,20 @@ discard block |
||
| 265 | 265 | return; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - /** |
|
| 269 | - * Called when an element is required |
|
| 270 | - * |
|
| 271 | - * This method will add the required tag to the element label and/or the element html |
|
| 272 | - * such as defined with the method setRequiredTemplate. |
|
| 273 | - * |
|
| 274 | - * @param string The element label |
|
| 275 | - * @param string The element html rendering |
|
| 276 | - * @param boolean The element required |
|
| 277 | - * @param string The element error |
|
| 278 | - * @see setRequiredTemplate() |
|
| 279 | - * @access private |
|
| 280 | - * @return void |
|
| 281 | - */ |
|
| 268 | + /** |
|
| 269 | + * Called when an element is required |
|
| 270 | + * |
|
| 271 | + * This method will add the required tag to the element label and/or the element html |
|
| 272 | + * such as defined with the method setRequiredTemplate. |
|
| 273 | + * |
|
| 274 | + * @param string The element label |
|
| 275 | + * @param string The element html rendering |
|
| 276 | + * @param boolean The element required |
|
| 277 | + * @param string The element error |
|
| 278 | + * @see setRequiredTemplate() |
|
| 279 | + * @access private |
|
| 280 | + * @return void |
|
| 281 | + */ |
|
| 282 | 282 | function _renderRequired(&$label, &$html, &$required, &$error) |
| 283 | 283 | { |
| 284 | 284 | $this->_tpl->assign(array( |
@@ -296,20 +296,20 @@ discard block |
||
| 296 | 296 | $this->_tpl->clear_assign(array('label', 'html', 'required')); |
| 297 | 297 | } // end func _renderRequired |
| 298 | 298 | |
| 299 | - /** |
|
| 300 | - * Called when an element has a validation error |
|
| 301 | - * |
|
| 302 | - * This method will add the error message to the element label or the element html |
|
| 303 | - * such as defined with the method setErrorTemplate. If the error placeholder is not found |
|
| 304 | - * in the template, the error will be displayed in the form error block. |
|
| 305 | - * |
|
| 306 | - * @param string The element label |
|
| 307 | - * @param string The element html rendering |
|
| 308 | - * @param string The element error |
|
| 309 | - * @see setErrorTemplate() |
|
| 310 | - * @access private |
|
| 311 | - * @return void |
|
| 312 | - */ |
|
| 299 | + /** |
|
| 300 | + * Called when an element has a validation error |
|
| 301 | + * |
|
| 302 | + * This method will add the error message to the element label or the element html |
|
| 303 | + * such as defined with the method setErrorTemplate. If the error placeholder is not found |
|
| 304 | + * in the template, the error will be displayed in the form error block. |
|
| 305 | + * |
|
| 306 | + * @param string The element label |
|
| 307 | + * @param string The element html rendering |
|
| 308 | + * @param string The element error |
|
| 309 | + * @see setErrorTemplate() |
|
| 310 | + * @access private |
|
| 311 | + * @return void |
|
| 312 | + */ |
|
| 313 | 313 | function _renderError(&$label, &$html, &$error) |
| 314 | 314 | { |
| 315 | 315 | $this->_tpl->assign(array('label' => '', 'html' => '', 'error' => $error)); |
@@ -324,16 +324,16 @@ discard block |
||
| 324 | 324 | $this->_tpl->clear_assign(array('label', 'html', 'error')); |
| 325 | 325 | } // end func _renderError |
| 326 | 326 | |
| 327 | - /** |
|
| 328 | - * Process an template sourced in a string with Smarty |
|
| 329 | - * |
|
| 330 | - * Smarty has no core function to render a template given as a string. |
|
| 331 | - * So we use the smarty eval plugin function to do this. |
|
| 332 | - * |
|
| 333 | - * @param string The template source |
|
| 334 | - * @access private |
|
| 335 | - * @return void |
|
| 336 | - */ |
|
| 327 | + /** |
|
| 328 | + * Process an template sourced in a string with Smarty |
|
| 329 | + * |
|
| 330 | + * Smarty has no core function to render a template given as a string. |
|
| 331 | + * So we use the smarty eval plugin function to do this. |
|
| 332 | + * |
|
| 333 | + * @param string The template source |
|
| 334 | + * @access private |
|
| 335 | + * @return void |
|
| 336 | + */ |
|
| 337 | 337 | function _tplFetch($tplSource) |
| 338 | 338 | { |
| 339 | 339 | if (!function_exists('smarty_function_eval')) { |
@@ -342,54 +342,54 @@ discard block |
||
| 342 | 342 | return smarty_function_eval(array('var' => $tplSource), $this->_tpl); |
| 343 | 343 | }// end func _tplFetch |
| 344 | 344 | |
| 345 | - /** |
|
| 346 | - * Sets the way required elements are rendered |
|
| 347 | - * |
|
| 348 | - * You can use {$label} or {$html} placeholders to let the renderer know where |
|
| 349 | - * where the element label or the element html are positionned according to the |
|
| 350 | - * required tag. They will be replaced accordingly with the right value. You |
|
| 351 | - * can use the full smarty syntax here, especially a custom modifier for I18N. |
|
| 352 | - * For example: |
|
| 353 | - * {if $required}<span style="color: red;">*</span>{/if}{$label|translate} |
|
| 354 | - * will put a red star in front of the label if the element is required and |
|
| 355 | - * translate the label. |
|
| 356 | - * |
|
| 357 | - * |
|
| 358 | - * @param string The required element template |
|
| 359 | - * @access public |
|
| 360 | - * @return void |
|
| 361 | - */ |
|
| 345 | + /** |
|
| 346 | + * Sets the way required elements are rendered |
|
| 347 | + * |
|
| 348 | + * You can use {$label} or {$html} placeholders to let the renderer know where |
|
| 349 | + * where the element label or the element html are positionned according to the |
|
| 350 | + * required tag. They will be replaced accordingly with the right value. You |
|
| 351 | + * can use the full smarty syntax here, especially a custom modifier for I18N. |
|
| 352 | + * For example: |
|
| 353 | + * {if $required}<span style="color: red;">*</span>{/if}{$label|translate} |
|
| 354 | + * will put a red star in front of the label if the element is required and |
|
| 355 | + * translate the label. |
|
| 356 | + * |
|
| 357 | + * |
|
| 358 | + * @param string The required element template |
|
| 359 | + * @access public |
|
| 360 | + * @return void |
|
| 361 | + */ |
|
| 362 | 362 | function setRequiredTemplate($template) |
| 363 | 363 | { |
| 364 | 364 | $this->_required = $template; |
| 365 | 365 | } // end func setRequiredTemplate |
| 366 | 366 | |
| 367 | - /** |
|
| 368 | - * Sets the way elements with validation errors are rendered |
|
| 369 | - * |
|
| 370 | - * You can use {$label} or {$html} placeholders to let the renderer know where |
|
| 371 | - * where the element label or the element html are positionned according to the |
|
| 372 | - * error message. They will be replaced accordingly with the right value. |
|
| 373 | - * The error message will replace the {$error} placeholder. |
|
| 374 | - * For example: |
|
| 375 | - * {if $error}<span style="color: red;">{$error}</span>{/if}<br />{$html} |
|
| 376 | - * will put the error message in red on top of the element html. |
|
| 377 | - * |
|
| 378 | - * If you want all error messages to be output in the main error block, use |
|
| 379 | - * the {$form.errors} part of the rendered array that collects all raw error |
|
| 380 | - * messages. |
|
| 381 | - * |
|
| 382 | - * If you want to place all error messages manually, do not specify {$html} |
|
| 383 | - * nor {$label}. |
|
| 384 | - * |
|
| 385 | - * Groups can have special layouts. With this kind of groups, you have to |
|
| 386 | - * place the formated error message manually. In this case, use {$form.group.error} |
|
| 387 | - * where you want the formated error message to appear in the form. |
|
| 388 | - * |
|
| 389 | - * @param string The element error template |
|
| 390 | - * @access public |
|
| 391 | - * @return void |
|
| 392 | - */ |
|
| 367 | + /** |
|
| 368 | + * Sets the way elements with validation errors are rendered |
|
| 369 | + * |
|
| 370 | + * You can use {$label} or {$html} placeholders to let the renderer know where |
|
| 371 | + * where the element label or the element html are positionned according to the |
|
| 372 | + * error message. They will be replaced accordingly with the right value. |
|
| 373 | + * The error message will replace the {$error} placeholder. |
|
| 374 | + * For example: |
|
| 375 | + * {if $error}<span style="color: red;">{$error}</span>{/if}<br />{$html} |
|
| 376 | + * will put the error message in red on top of the element html. |
|
| 377 | + * |
|
| 378 | + * If you want all error messages to be output in the main error block, use |
|
| 379 | + * the {$form.errors} part of the rendered array that collects all raw error |
|
| 380 | + * messages. |
|
| 381 | + * |
|
| 382 | + * If you want to place all error messages manually, do not specify {$html} |
|
| 383 | + * nor {$label}. |
|
| 384 | + * |
|
| 385 | + * Groups can have special layouts. With this kind of groups, you have to |
|
| 386 | + * place the formated error message manually. In this case, use {$form.group.error} |
|
| 387 | + * where you want the formated error message to appear in the form. |
|
| 388 | + * |
|
| 389 | + * @param string The element error template |
|
| 390 | + * @access public |
|
| 391 | + * @return void |
|
| 392 | + */ |
|
| 393 | 393 | function setErrorTemplate($template) |
| 394 | 394 | { |
| 395 | 395 | $this->_error = $template; |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | function HTML_QuickForm_Renderer_ArraySmarty(&$tpl, $staticLabels = false, $collectHidden = true) |
| 135 | 135 | { |
| 136 | 136 | $this->HTML_QuickForm_Renderer_Array($collectHidden, $staticLabels); |
| 137 | - $this->_tpl =& $tpl; |
|
| 137 | + $this->_tpl = & $tpl; |
|
| 138 | 138 | } // end constructor |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | // we don't need the elements, see the array structure |
| 189 | 189 | unset($ret['elements']); |
| 190 | 190 | } |
| 191 | - if (($required || $error) && !empty($this->_required)){ |
|
| 191 | + if (($required || $error) && !empty($this->_required)) { |
|
| 192 | 192 | $this->_renderRequired($ret['label'], $ret['html'], $required, $error); |
| 193 | 193 | } |
| 194 | 194 | if ($error && !empty($this->_error)) { |
@@ -206,13 +206,13 @@ discard block |
||
| 206 | 206 | if (isset($matches[1])) { |
| 207 | 207 | $sKeysSub = substr_replace($ret['name'], '', 0, strlen($matches[1])); |
| 208 | 208 | $sKeysSub = str_replace( |
| 209 | - array('\\', '\'', '[' , ']', '[\'\']'), |
|
| 210 | - array('\\\\', '\\\'', '[\'', '\']', '[]' ), |
|
| 209 | + array('\\', '\'', '[', ']', '[\'\']'), |
|
| 210 | + array('\\\\', '\\\'', '[\'', '\']', '[]'), |
|
| 211 | 211 | $sKeysSub |
| 212 | 212 | ); |
| 213 | - $sKeys = '[\'' . str_replace(array('\\', '\''), array('\\\\', '\\\''), $matches[1]) . '\']' . $sKeysSub; |
|
| 213 | + $sKeys = '[\''.str_replace(array('\\', '\''), array('\\\\', '\\\''), $matches[1]).'\']'.$sKeysSub; |
|
| 214 | 214 | } else { |
| 215 | - $sKeys = '[\'' . str_replace(array('\\', '\''), array('\\\\', '\\\''), $ret['name']) . '\']'; |
|
| 215 | + $sKeys = '[\''.str_replace(array('\\', '\''), array('\\\\', '\\\''), $ret['name']).'\']'; |
|
| 216 | 216 | } |
| 217 | 217 | // special handling for elements in native groups |
| 218 | 218 | if ($this->_currentGroup) { |
@@ -228,14 +228,14 @@ discard block |
||
| 228 | 228 | } |
| 229 | 229 | // element without a name |
| 230 | 230 | } elseif ($ret['name'] == '') { |
| 231 | - $sKeys = '[\'element_' . $this->_elementIdx . '\']'; |
|
| 231 | + $sKeys = '[\'element_'.$this->_elementIdx.'\']'; |
|
| 232 | 232 | // other elements |
| 233 | 233 | } else { |
| 234 | - $sKeys = '[\'' . str_replace(array('\\', '\''), array('\\\\', '\\\''), $ret['name']) . '\']'; |
|
| 234 | + $sKeys = '[\''.str_replace(array('\\', '\''), array('\\\\', '\\\''), $ret['name']).'\']'; |
|
| 235 | 235 | } |
| 236 | 236 | // for radios: add extra key from value |
| 237 | 237 | if ('radio' == $ret['type'] and substr($sKeys, -2) != '[]') { |
| 238 | - $sKeys .= '[\'' . str_replace(array('\\', '\''), array('\\\\', '\\\''), $ret['value']) . '\']'; |
|
| 238 | + $sKeys .= '[\''.str_replace(array('\\', '\''), array('\\\\', '\\\''), $ret['value']).'\']'; |
|
| 239 | 239 | } |
| 240 | 240 | $this->_elementIdx++; |
| 241 | 241 | $ret['keys'] = $sKeys; |
@@ -256,9 +256,9 @@ discard block |
||
| 256 | 256 | unset($elAry['keys']); |
| 257 | 257 | // where should we put this element... |
| 258 | 258 | if (is_array($this->_currentGroup) && ('group' != $elAry['type'])) { |
| 259 | - $toEval = '$this->_currentGroup' . $sKeys . ' = $elAry;'; |
|
| 259 | + $toEval = '$this->_currentGroup'.$sKeys.' = $elAry;'; |
|
| 260 | 260 | } else { |
| 261 | - $toEval = '$this->_ary' . $sKeys . ' = $elAry;'; |
|
| 261 | + $toEval = '$this->_ary'.$sKeys.' = $elAry;'; |
|
| 262 | 262 | } |
| 263 | 263 | eval($toEval); |
| 264 | 264 | } |
@@ -287,10 +287,10 @@ discard block |
||
| 287 | 287 | 'required' => $required, |
| 288 | 288 | 'error' => $error |
| 289 | 289 | )); |
| 290 | - if (!empty($label) && strpos($this->_required, $this->_tpl->left_delimiter . '$label') !== false) { |
|
| 290 | + if (!empty($label) && strpos($this->_required, $this->_tpl->left_delimiter.'$label') !== false) { |
|
| 291 | 291 | $label = $this->_tplFetch($this->_required); |
| 292 | 292 | } |
| 293 | - if (!empty($html) && strpos($this->_required, $this->_tpl->left_delimiter . '$html') !== false) { |
|
| 293 | + if (!empty($html) && strpos($this->_required, $this->_tpl->left_delimiter.'$html') !== false) { |
|
| 294 | 294 | $html = $this->_tplFetch($this->_required); |
| 295 | 295 | } |
| 296 | 296 | $this->_tpl->clear_assign(array('label', 'html', 'required')); |
@@ -316,9 +316,9 @@ discard block |
||
| 316 | 316 | $error = $this->_tplFetch($this->_error); |
| 317 | 317 | $this->_tpl->assign(array('label' => $label, 'html' => $html)); |
| 318 | 318 | |
| 319 | - if (!empty($label) && strpos($this->_error, $this->_tpl->left_delimiter . '$label') !== false) { |
|
| 319 | + if (!empty($label) && strpos($this->_error, $this->_tpl->left_delimiter.'$label') !== false) { |
|
| 320 | 320 | $label = $this->_tplFetch($this->_error); |
| 321 | - } elseif (!empty($html) && strpos($this->_error, $this->_tpl->left_delimiter . '$html') !== false) { |
|
| 321 | + } elseif (!empty($html) && strpos($this->_error, $this->_tpl->left_delimiter.'$html') !== false) { |
|
| 322 | 322 | $html = $this->_tplFetch($this->_error); |
| 323 | 323 | } |
| 324 | 324 | $this->_tpl->clear_assign(array('label', 'html', 'error')); |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | function _tplFetch($tplSource) |
| 338 | 338 | { |
| 339 | 339 | if (!function_exists('smarty_function_eval')) { |
| 340 | - require SMARTY_DIR . '/plugins/function.eval.php'; |
|
| 340 | + require SMARTY_DIR.'/plugins/function.eval.php'; |
|
| 341 | 341 | } |
| 342 | 342 | return smarty_function_eval(array('var' => $tplSource), $this->_tpl); |
| 343 | 343 | }// end func _tplFetch |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | private $customElementTemplate; |
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | - * @return mixed |
|
| 43 | + * @return string |
|
| 44 | 44 | */ |
| 45 | 45 | public function getCustomElementTemplate() |
| 46 | 46 | { |
@@ -457,6 +457,7 @@ discard block |
||
| 457 | 457 | * |
| 458 | 458 | * @param string The HTML surrounding an element |
| 459 | 459 | * @param string (optional) Name of the element to apply template for |
| 460 | + * @param string $html |
|
| 460 | 461 | * @access public |
| 461 | 462 | * @return void |
| 462 | 463 | */ |
@@ -504,6 +505,7 @@ discard block |
||
| 504 | 505 | * Sets header template |
| 505 | 506 | * |
| 506 | 507 | * @param string The HTML surrounding the header |
| 508 | + * @param string $html |
|
| 507 | 509 | * @access public |
| 508 | 510 | * @return void |
| 509 | 511 | */ |
@@ -516,6 +518,7 @@ discard block |
||
| 516 | 518 | * Sets form template |
| 517 | 519 | * |
| 518 | 520 | * @param string The HTML surrounding the form tags |
| 521 | + * @param string $html |
|
| 519 | 522 | * @access public |
| 520 | 523 | * @return void |
| 521 | 524 | */ |
@@ -527,6 +530,7 @@ discard block |
||
| 527 | 530 | * Sets the note indicating required fields template |
| 528 | 531 | * |
| 529 | 532 | * @param string The HTML surrounding the required note |
| 533 | + * @param string $html |
|
| 530 | 534 | * @access public |
| 531 | 535 | * @return void |
| 532 | 536 | */ |
@@ -56,128 +56,128 @@ discard block |
||
| 56 | 56 | $this->customElementTemplate = $customElementTemplate; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * The HTML of the form |
|
| 61 | - * @var string |
|
| 62 | - * @access private |
|
| 63 | - */ |
|
| 59 | + /** |
|
| 60 | + * The HTML of the form |
|
| 61 | + * @var string |
|
| 62 | + * @access private |
|
| 63 | + */ |
|
| 64 | 64 | var $_html; |
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * Header Template string |
|
| 68 | - * @var string |
|
| 69 | - * @access private |
|
| 70 | - */ |
|
| 66 | + /** |
|
| 67 | + * Header Template string |
|
| 68 | + * @var string |
|
| 69 | + * @access private |
|
| 70 | + */ |
|
| 71 | 71 | var $_headerTemplate = |
| 72 | 72 | "\n\t<tr>\n\t\t<td style=\"white-space: nowrap; background-color: #CCCCCC;\" align=\"left\" valign=\"top\" colspan=\"2\"><b>{header}</b></td>\n\t</tr>"; |
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * Element template string |
|
| 76 | - * @var string |
|
| 77 | - * @access private |
|
| 78 | - */ |
|
| 74 | + /** |
|
| 75 | + * Element template string |
|
| 76 | + * @var string |
|
| 77 | + * @access private |
|
| 78 | + */ |
|
| 79 | 79 | var $_elementTemplate = |
| 80 | 80 | "\n\t<tr>\n\t\t<td align=\"right\" valign=\"top\"><!-- BEGIN required --><span style=\"color: #ff0000\">*</span><!-- END required --><b>{label}</b></td>\n\t\t<td valign=\"top\" align=\"left\"><!-- BEGIN error --><span style=\"color: #ff0000\">{error}</span><br /><!-- END error -->\t{element}</td>\n\t</tr>"; |
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * Form template string |
|
| 84 | - * @var string |
|
| 85 | - * @access private |
|
| 86 | - */ |
|
| 82 | + /** |
|
| 83 | + * Form template string |
|
| 84 | + * @var string |
|
| 85 | + * @access private |
|
| 86 | + */ |
|
| 87 | 87 | var $_formTemplate = |
| 88 | 88 | "\n<form{attributes}>\n<div>\n{hidden}<table border=\"0\">\n{content}\n</table>\n</div>\n</form>"; |
| 89 | 89 | |
| 90 | - /** |
|
| 91 | - * Required Note template string |
|
| 92 | - * @var string |
|
| 93 | - * @access private |
|
| 94 | - */ |
|
| 90 | + /** |
|
| 91 | + * Required Note template string |
|
| 92 | + * @var string |
|
| 93 | + * @access private |
|
| 94 | + */ |
|
| 95 | 95 | var $_requiredNoteTemplate = |
| 96 | 96 | "\n\t<tr>\n\t\t<td></td>\n\t<td align=\"left\" valign=\"top\">{requiredNote}</td>\n\t</tr>"; |
| 97 | 97 | |
| 98 | - /** |
|
| 99 | - * Array containing the templates for customised elements |
|
| 100 | - * @var array |
|
| 101 | - * @access private |
|
| 102 | - */ |
|
| 98 | + /** |
|
| 99 | + * Array containing the templates for customised elements |
|
| 100 | + * @var array |
|
| 101 | + * @access private |
|
| 102 | + */ |
|
| 103 | 103 | var $_templates = array(); |
| 104 | 104 | |
| 105 | - /** |
|
| 106 | - * Array containing the templates for group wraps. |
|
| 107 | - * |
|
| 108 | - * These templates are wrapped around group elements and groups' own |
|
| 109 | - * templates wrap around them. This is set by setGroupTemplate(). |
|
| 110 | - * |
|
| 111 | - * @var array |
|
| 112 | - * @access private |
|
| 113 | - */ |
|
| 105 | + /** |
|
| 106 | + * Array containing the templates for group wraps. |
|
| 107 | + * |
|
| 108 | + * These templates are wrapped around group elements and groups' own |
|
| 109 | + * templates wrap around them. This is set by setGroupTemplate(). |
|
| 110 | + * |
|
| 111 | + * @var array |
|
| 112 | + * @access private |
|
| 113 | + */ |
|
| 114 | 114 | var $_groupWraps = array(); |
| 115 | 115 | |
| 116 | - /** |
|
| 117 | - * Array containing the templates for elements within groups |
|
| 118 | - * @var array |
|
| 119 | - * @access private |
|
| 120 | - */ |
|
| 116 | + /** |
|
| 117 | + * Array containing the templates for elements within groups |
|
| 118 | + * @var array |
|
| 119 | + * @access private |
|
| 120 | + */ |
|
| 121 | 121 | var $_groupTemplates = array(); |
| 122 | 122 | |
| 123 | - /** |
|
| 124 | - * True if we are inside a group |
|
| 125 | - * @var bool |
|
| 126 | - * @access private |
|
| 127 | - */ |
|
| 123 | + /** |
|
| 124 | + * True if we are inside a group |
|
| 125 | + * @var bool |
|
| 126 | + * @access private |
|
| 127 | + */ |
|
| 128 | 128 | var $_inGroup = false; |
| 129 | 129 | |
| 130 | - /** |
|
| 131 | - * Array with HTML generated for group elements |
|
| 132 | - * @var array |
|
| 133 | - * @access private |
|
| 134 | - */ |
|
| 130 | + /** |
|
| 131 | + * Array with HTML generated for group elements |
|
| 132 | + * @var array |
|
| 133 | + * @access private |
|
| 134 | + */ |
|
| 135 | 135 | var $_groupElements = array(); |
| 136 | 136 | |
| 137 | - /** |
|
| 138 | - * Template for an element inside a group |
|
| 139 | - * @var string |
|
| 140 | - * @access private |
|
| 141 | - */ |
|
| 137 | + /** |
|
| 138 | + * Template for an element inside a group |
|
| 139 | + * @var string |
|
| 140 | + * @access private |
|
| 141 | + */ |
|
| 142 | 142 | var $_groupElementTemplate = ''; |
| 143 | 143 | |
| 144 | - /** |
|
| 145 | - * HTML that wraps around the group elements |
|
| 146 | - * @var string |
|
| 147 | - * @access private |
|
| 148 | - */ |
|
| 144 | + /** |
|
| 145 | + * HTML that wraps around the group elements |
|
| 146 | + * @var string |
|
| 147 | + * @access private |
|
| 148 | + */ |
|
| 149 | 149 | var $_groupWrap = ''; |
| 150 | 150 | |
| 151 | - /** |
|
| 152 | - * HTML for the current group |
|
| 153 | - * @var string |
|
| 154 | - * @access private |
|
| 155 | - */ |
|
| 151 | + /** |
|
| 152 | + * HTML for the current group |
|
| 153 | + * @var string |
|
| 154 | + * @access private |
|
| 155 | + */ |
|
| 156 | 156 | var $_groupTemplate = ''; |
| 157 | 157 | |
| 158 | - /** |
|
| 159 | - * Collected HTML of the hidden fields |
|
| 160 | - * @var string |
|
| 161 | - * @access private |
|
| 162 | - */ |
|
| 158 | + /** |
|
| 159 | + * Collected HTML of the hidden fields |
|
| 160 | + * @var string |
|
| 161 | + * @access private |
|
| 162 | + */ |
|
| 163 | 163 | var $_hiddenHtml = ''; |
| 164 | 164 | |
| 165 | - /** |
|
| 166 | - * Constructor |
|
| 167 | - * |
|
| 168 | - * @access public |
|
| 169 | - */ |
|
| 165 | + /** |
|
| 166 | + * Constructor |
|
| 167 | + * |
|
| 168 | + * @access public |
|
| 169 | + */ |
|
| 170 | 170 | public function HTML_QuickForm_Renderer_Default() |
| 171 | 171 | { |
| 172 | 172 | parent::__construct(); |
| 173 | 173 | } // end constructor |
| 174 | 174 | |
| 175 | - /** |
|
| 176 | - * returns the HTML generated for the form |
|
| 177 | - * |
|
| 178 | - * @access public |
|
| 179 | - * @return string |
|
| 180 | - */ |
|
| 175 | + /** |
|
| 176 | + * returns the HTML generated for the form |
|
| 177 | + * |
|
| 178 | + * @access public |
|
| 179 | + * @return string |
|
| 180 | + */ |
|
| 181 | 181 | public function toHtml() |
| 182 | 182 | { |
| 183 | 183 | // _hiddenHtml is cleared in finishForm(), so this only matters when |
@@ -185,13 +185,13 @@ discard block |
||
| 185 | 185 | return $this->_hiddenHtml . $this->_html; |
| 186 | 186 | } // end func toHtml |
| 187 | 187 | |
| 188 | - /** |
|
| 189 | - * Called when visiting a form, before processing any form elements |
|
| 190 | - * |
|
| 191 | - * @param HTML_QuickForm form object being visited |
|
| 192 | - * @access public |
|
| 193 | - * @return void |
|
| 194 | - */ |
|
| 188 | + /** |
|
| 189 | + * Called when visiting a form, before processing any form elements |
|
| 190 | + * |
|
| 191 | + * @param HTML_QuickForm form object being visited |
|
| 192 | + * @access public |
|
| 193 | + * @return void |
|
| 194 | + */ |
|
| 195 | 195 | function startForm(&$form) |
| 196 | 196 | { |
| 197 | 197 | $this->setForm($form); |
@@ -218,14 +218,14 @@ discard block |
||
| 218 | 218 | |
| 219 | 219 | |
| 220 | 220 | |
| 221 | - /** |
|
| 222 | - * Called when visiting a form, after processing all form elements |
|
| 223 | - * Adds required note, form attributes, validation javascript and form content. |
|
| 224 | - * |
|
| 225 | - * @param HTML_QuickForm form object being visited |
|
| 226 | - * @access public |
|
| 227 | - * @return void |
|
| 228 | - */ |
|
| 221 | + /** |
|
| 222 | + * Called when visiting a form, after processing all form elements |
|
| 223 | + * Adds required note, form attributes, validation javascript and form content. |
|
| 224 | + * |
|
| 225 | + * @param HTML_QuickForm form object being visited |
|
| 226 | + * @access public |
|
| 227 | + * @return void |
|
| 228 | + */ |
|
| 229 | 229 | public function finishForm(&$form) |
| 230 | 230 | { |
| 231 | 231 | // add a required note, if one is needed |
@@ -248,13 +248,13 @@ discard block |
||
| 248 | 248 | } |
| 249 | 249 | } // end func finishForm |
| 250 | 250 | |
| 251 | - /** |
|
| 252 | - * Called when visiting a header element |
|
| 253 | - * |
|
| 254 | - * @param HTML_QuickForm_header header element being visited |
|
| 255 | - * @access public |
|
| 256 | - * @return void |
|
| 257 | - */ |
|
| 251 | + /** |
|
| 252 | + * Called when visiting a header element |
|
| 253 | + * |
|
| 254 | + * @param HTML_QuickForm_header header element being visited |
|
| 255 | + * @access public |
|
| 256 | + * @return void |
|
| 257 | + */ |
|
| 258 | 258 | function renderHeader(&$header) |
| 259 | 259 | { |
| 260 | 260 | $name = $header->getName(); |
@@ -265,17 +265,17 @@ discard block |
||
| 265 | 265 | } |
| 266 | 266 | } // end func renderHeader |
| 267 | 267 | |
| 268 | - /** |
|
| 269 | - * Helper method for renderElement |
|
| 270 | - * |
|
| 271 | - * @param HTML_QuickForm_element $element |
|
| 272 | - * @param bool Whether an element is required |
|
| 273 | - * @param string $required Error message associated with the element |
|
| 274 | - * @param string $error Label for ID |
|
| 275 | - * @access private |
|
| 276 | - * @see renderElement() |
|
| 277 | - * @return string Html for element |
|
| 278 | - */ |
|
| 268 | + /** |
|
| 269 | + * Helper method for renderElement |
|
| 270 | + * |
|
| 271 | + * @param HTML_QuickForm_element $element |
|
| 272 | + * @param bool Whether an element is required |
|
| 273 | + * @param string $required Error message associated with the element |
|
| 274 | + * @param string $error Label for ID |
|
| 275 | + * @access private |
|
| 276 | + * @see renderElement() |
|
| 277 | + * @return string Html for element |
|
| 278 | + */ |
|
| 279 | 279 | private function _prepareTemplate(HTML_QuickForm_element $element, $required, $error) |
| 280 | 280 | { |
| 281 | 281 | $name = $element->getName(); |
@@ -343,16 +343,16 @@ discard block |
||
| 343 | 343 | return $html; |
| 344 | 344 | } // end func _prepareTemplate |
| 345 | 345 | |
| 346 | - /** |
|
| 347 | - * Renders an element Html |
|
| 348 | - * Called when visiting an element |
|
| 349 | - * |
|
| 350 | - * @param HTML_QuickForm_element form element being visited |
|
| 351 | - * @param bool Whether an element is required |
|
| 352 | - * @param string An error message associated with an element |
|
| 353 | - * @access public |
|
| 354 | - * @return void |
|
| 355 | - */ |
|
| 346 | + /** |
|
| 347 | + * Renders an element Html |
|
| 348 | + * Called when visiting an element |
|
| 349 | + * |
|
| 350 | + * @param HTML_QuickForm_element form element being visited |
|
| 351 | + * @param bool Whether an element is required |
|
| 352 | + * @param string An error message associated with an element |
|
| 353 | + * @access public |
|
| 354 | + * @return void |
|
| 355 | + */ |
|
| 356 | 356 | public function renderElement(&$element, $required, $error) |
| 357 | 357 | { |
| 358 | 358 | if (!$this->_inGroup) { |
@@ -379,40 +379,40 @@ discard block |
||
| 379 | 379 | } |
| 380 | 380 | } // end func renderElement |
| 381 | 381 | |
| 382 | - /** |
|
| 383 | - * Renders an hidden element |
|
| 384 | - * Called when visiting a hidden element |
|
| 385 | - * |
|
| 386 | - * @param HTML_QuickForm_element form element being visited |
|
| 387 | - * @access public |
|
| 388 | - * @return void |
|
| 389 | - */ |
|
| 382 | + /** |
|
| 383 | + * Renders an hidden element |
|
| 384 | + * Called when visiting a hidden element |
|
| 385 | + * |
|
| 386 | + * @param HTML_QuickForm_element form element being visited |
|
| 387 | + * @access public |
|
| 388 | + * @return void |
|
| 389 | + */ |
|
| 390 | 390 | function renderHidden(&$element) |
| 391 | 391 | { |
| 392 | 392 | $this->_hiddenHtml .= $element->toHtml() . "\n"; |
| 393 | 393 | } // end func renderHidden |
| 394 | 394 | |
| 395 | - /** |
|
| 396 | - * Called when visiting a raw HTML/text pseudo-element |
|
| 397 | - * |
|
| 398 | - * @param HTML_QuickForm_html element being visited |
|
| 399 | - * @access public |
|
| 400 | - * @return void |
|
| 401 | - */ |
|
| 395 | + /** |
|
| 396 | + * Called when visiting a raw HTML/text pseudo-element |
|
| 397 | + * |
|
| 398 | + * @param HTML_QuickForm_html element being visited |
|
| 399 | + * @access public |
|
| 400 | + * @return void |
|
| 401 | + */ |
|
| 402 | 402 | function renderHtml(&$data) |
| 403 | 403 | { |
| 404 | 404 | $this->_html .= $data->toHtml(); |
| 405 | 405 | } // end func renderHtml |
| 406 | 406 | |
| 407 | - /** |
|
| 408 | - * Called when visiting a group, before processing any group elements |
|
| 409 | - * |
|
| 410 | - * @param HTML_QuickForm_group group being visited |
|
| 411 | - * @param bool Whether a group is required |
|
| 412 | - * @param string An error message associated with a group |
|
| 413 | - * @access public |
|
| 414 | - * @return void |
|
| 415 | - */ |
|
| 407 | + /** |
|
| 408 | + * Called when visiting a group, before processing any group elements |
|
| 409 | + * |
|
| 410 | + * @param HTML_QuickForm_group group being visited |
|
| 411 | + * @param bool Whether a group is required |
|
| 412 | + * @param string An error message associated with a group |
|
| 413 | + * @access public |
|
| 414 | + * @return void |
|
| 415 | + */ |
|
| 416 | 416 | function startGroup(&$group, $required, $error) |
| 417 | 417 | { |
| 418 | 418 | $name = $group->getName(); |
@@ -423,13 +423,13 @@ discard block |
||
| 423 | 423 | $this->_inGroup = true; |
| 424 | 424 | } // end func startGroup |
| 425 | 425 | |
| 426 | - /** |
|
| 427 | - * Called when visiting a group, after processing all group elements |
|
| 428 | - * |
|
| 429 | - * @param HTML_QuickForm_group group being visited |
|
| 430 | - * @access public |
|
| 431 | - * @return void |
|
| 432 | - */ |
|
| 426 | + /** |
|
| 427 | + * Called when visiting a group, after processing all group elements |
|
| 428 | + * |
|
| 429 | + * @param HTML_QuickForm_group group being visited |
|
| 430 | + * @access public |
|
| 431 | + * @return void |
|
| 432 | + */ |
|
| 433 | 433 | function finishGroup(&$group) |
| 434 | 434 | { |
| 435 | 435 | $separator = $group->_separator; |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | { |
| 183 | 183 | // _hiddenHtml is cleared in finishForm(), so this only matters when |
| 184 | 184 | // finishForm() was not called (e.g. group::toHtml(), bug #3511) |
| 185 | - return $this->_hiddenHtml . $this->_html; |
|
| 185 | + return $this->_hiddenHtml.$this->_html; |
|
| 186 | 186 | } // end func toHtml |
| 187 | 187 | |
| 188 | 188 | /** |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | $this->_html = str_replace('{content}', $this->_html, $html); |
| 245 | 245 | // add a validation script |
| 246 | 246 | if ('' != ($script = $form->getValidationScript())) { |
| 247 | - $this->_html = $script . "\n" . $this->_html; |
|
| 247 | + $this->_html = $script."\n".$this->_html; |
|
| 248 | 248 | } |
| 249 | 249 | } // end func finishForm |
| 250 | 250 | |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | $nameLabel = $label; |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - $labelFor = !empty($labelForId) ? 'for="' . $labelForId . '"' : 'for="' . $element->getName() . '"'; |
|
| 292 | + $labelFor = !empty($labelForId) ? 'for="'.$labelForId.'"' : 'for="'.$element->getName().'"'; |
|
| 293 | 293 | |
| 294 | 294 | if (isset($this->_templates[$name])) { |
| 295 | 295 | // Custom template |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | } |
| 331 | 331 | if (is_array($label)) { |
| 332 | 332 | foreach ($label as $key => $text) { |
| 333 | - $key = is_int($key)? $key + 2: $key; |
|
| 333 | + $key = is_int($key) ? $key + 2 : $key; |
|
| 334 | 334 | $html = str_replace("{label_{$key}}", $text, $html); |
| 335 | 335 | $html = str_replace("<!-- BEGIN label_{$key} -->", '', $html); |
| 336 | 336 | $html = str_replace("<!-- END label_{$key} -->", '', $html); |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | */ |
| 390 | 390 | function renderHidden(&$element) |
| 391 | 391 | { |
| 392 | - $this->_hiddenHtml .= $element->toHtml() . "\n"; |
|
| 392 | + $this->_hiddenHtml .= $element->toHtml()."\n"; |
|
| 393 | 393 | } // end func renderHidden |
| 394 | 394 | |
| 395 | 395 | /** |
@@ -417,8 +417,8 @@ discard block |
||
| 417 | 417 | { |
| 418 | 418 | $name = $group->getName(); |
| 419 | 419 | $this->_groupTemplate = $this->_prepareTemplate($group, $required, $error); |
| 420 | - $this->_groupElementTemplate = empty($this->_groupTemplates[$name])? '': $this->_groupTemplates[$name]; |
|
| 421 | - $this->_groupWrap = empty($this->_groupWraps[$name])? '': $this->_groupWraps[$name]; |
|
| 420 | + $this->_groupElementTemplate = empty($this->_groupTemplates[$name]) ? '' : $this->_groupTemplates[$name]; |
|
| 421 | + $this->_groupWrap = empty($this->_groupWraps[$name]) ? '' : $this->_groupWraps[$name]; |
|
| 422 | 422 | $this->_groupElements = array(); |
| 423 | 423 | $this->_inGroup = true; |
| 424 | 424 | } // end func startGroup |
@@ -437,13 +437,13 @@ discard block |
||
| 437 | 437 | $count = count($separator); |
| 438 | 438 | $html = ''; |
| 439 | 439 | for ($i = 0; $i < count($this->_groupElements); $i++) { |
| 440 | - $html .= (0 == $i? '': $separator[($i - 1) % $count]) . $this->_groupElements[$i]; |
|
| 440 | + $html .= (0 == $i ? '' : $separator[($i - 1) % $count]).$this->_groupElements[$i]; |
|
| 441 | 441 | } |
| 442 | 442 | } else { |
| 443 | 443 | if (is_null($separator)) { |
| 444 | 444 | $separator = ' '; |
| 445 | 445 | } |
| 446 | - $html = implode((string)$separator, $this->_groupElements); |
|
| 446 | + $html = implode((string) $separator, $this->_groupElements); |
|
| 447 | 447 | } |
| 448 | 448 | if (!empty($this->_groupWrap)) { |
| 449 | 449 | $html = str_replace('{content}', $html, $this->_groupWrap); |
@@ -480,6 +480,7 @@ |
||
| 480 | 480 | * the block contents on get() a bit differently |
| 481 | 481 | * |
| 482 | 482 | * @param string Block name |
| 483 | + * @param string $block |
|
| 483 | 484 | * @return string Block contents |
| 484 | 485 | */ |
| 485 | 486 | function _getTplBlock($block) |
@@ -38,88 +38,88 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | class HTML_QuickForm_Renderer_ITStatic extends HTML_QuickForm_Renderer |
| 40 | 40 | { |
| 41 | - /**#@+ |
|
| 41 | + /**#@+ |
|
| 42 | 42 | * @access private |
| 43 | 43 | */ |
| 44 | - /** |
|
| 45 | - * An HTML_Template_IT or some other API compatible Template instance |
|
| 46 | - * @var object |
|
| 47 | - */ |
|
| 44 | + /** |
|
| 45 | + * An HTML_Template_IT or some other API compatible Template instance |
|
| 46 | + * @var object |
|
| 47 | + */ |
|
| 48 | 48 | var $_tpl = null; |
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * Rendered form name |
|
| 52 | - * @var string |
|
| 53 | - */ |
|
| 50 | + /** |
|
| 51 | + * Rendered form name |
|
| 52 | + * @var string |
|
| 53 | + */ |
|
| 54 | 54 | var $_formName = 'form'; |
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * The errors that were not shown near concrete fields go here |
|
| 58 | - * @var array |
|
| 59 | - */ |
|
| 56 | + /** |
|
| 57 | + * The errors that were not shown near concrete fields go here |
|
| 58 | + * @var array |
|
| 59 | + */ |
|
| 60 | 60 | var $_errors = array(); |
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * Show the block with required note? |
|
| 64 | - * @var bool |
|
| 65 | - */ |
|
| 62 | + /** |
|
| 63 | + * Show the block with required note? |
|
| 64 | + * @var bool |
|
| 65 | + */ |
|
| 66 | 66 | var $_showRequired = false; |
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * Which group are we currently parsing ? |
|
| 70 | - * @var string |
|
| 71 | - */ |
|
| 68 | + /** |
|
| 69 | + * Which group are we currently parsing ? |
|
| 70 | + * @var string |
|
| 71 | + */ |
|
| 72 | 72 | var $_inGroup; |
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * Index of the element in its group |
|
| 76 | - * @var int |
|
| 77 | - */ |
|
| 74 | + /** |
|
| 75 | + * Index of the element in its group |
|
| 76 | + * @var int |
|
| 77 | + */ |
|
| 78 | 78 | var $_elementIndex = 0; |
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * If elements have been added with the same name |
|
| 82 | - * @var array |
|
| 83 | - */ |
|
| 80 | + /** |
|
| 81 | + * If elements have been added with the same name |
|
| 82 | + * @var array |
|
| 83 | + */ |
|
| 84 | 84 | var $_duplicateElements = array(); |
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * How to handle the required tag for required fields |
|
| 88 | - * @var string |
|
| 89 | - */ |
|
| 86 | + /** |
|
| 87 | + * How to handle the required tag for required fields |
|
| 88 | + * @var string |
|
| 89 | + */ |
|
| 90 | 90 | var $_required = '{label}<font size="1" color="red">*</font>'; |
| 91 | 91 | |
| 92 | - /** |
|
| 93 | - * How to handle error messages in form validation |
|
| 94 | - * @var string |
|
| 95 | - */ |
|
| 92 | + /** |
|
| 93 | + * How to handle error messages in form validation |
|
| 94 | + * @var string |
|
| 95 | + */ |
|
| 96 | 96 | var $_error = '<font color="red">{error}</font><br />{html}'; |
| 97 | 97 | |
| 98 | - /** |
|
| 99 | - * Collected HTML for hidden elements, if needed |
|
| 100 | - * @var string |
|
| 101 | - */ |
|
| 98 | + /** |
|
| 99 | + * Collected HTML for hidden elements, if needed |
|
| 100 | + * @var string |
|
| 101 | + */ |
|
| 102 | 102 | var $_hidden = ''; |
| 103 | - /**#@-*/ |
|
| 103 | + /**#@-*/ |
|
| 104 | 104 | |
| 105 | - /** |
|
| 106 | - * Constructor |
|
| 107 | - * |
|
| 108 | - * @param HTML_Template_IT|HTML_Template_Sigma Template object to use |
|
| 109 | - */ |
|
| 105 | + /** |
|
| 106 | + * Constructor |
|
| 107 | + * |
|
| 108 | + * @param HTML_Template_IT|HTML_Template_Sigma Template object to use |
|
| 109 | + */ |
|
| 110 | 110 | function HTML_QuickForm_Renderer_ITStatic(&$tpl) |
| 111 | 111 | { |
| 112 | 112 | $this->HTML_QuickForm_Renderer(); |
| 113 | 113 | $this->_tpl =& $tpl; |
| 114 | 114 | } // end constructor |
| 115 | 115 | |
| 116 | - /** |
|
| 117 | - * Called when visiting a form, before processing any form elements |
|
| 118 | - * |
|
| 119 | - * @param HTML_QuickForm form object being visited |
|
| 120 | - * @access public |
|
| 121 | - * @return void |
|
| 122 | - */ |
|
| 116 | + /** |
|
| 117 | + * Called when visiting a form, before processing any form elements |
|
| 118 | + * |
|
| 119 | + * @param HTML_QuickForm form object being visited |
|
| 120 | + * @access public |
|
| 121 | + * @return void |
|
| 122 | + */ |
|
| 123 | 123 | function startForm(&$form) |
| 124 | 124 | { |
| 125 | 125 | $this->_formName = $form->getAttribute('id'); |
@@ -132,13 +132,13 @@ discard block |
||
| 132 | 132 | } |
| 133 | 133 | } // end func startForm |
| 134 | 134 | |
| 135 | - /** |
|
| 136 | - * Called when visiting a form, after processing all form elements |
|
| 137 | - * |
|
| 138 | - * @param HTML_QuickForm form object being visited |
|
| 139 | - * @access public |
|
| 140 | - * @return void |
|
| 141 | - */ |
|
| 135 | + /** |
|
| 136 | + * Called when visiting a form, after processing all form elements |
|
| 137 | + * |
|
| 138 | + * @param HTML_QuickForm form object being visited |
|
| 139 | + * @access public |
|
| 140 | + * @return void |
|
| 141 | + */ |
|
| 142 | 142 | function finishForm(&$form) |
| 143 | 143 | { |
| 144 | 144 | // display errors above form |
@@ -162,13 +162,13 @@ discard block |
||
| 162 | 162 | $this->_tpl->setVariable($this->_formName.'_javascript', $form->getValidationScript()); |
| 163 | 163 | } // end func finishForm |
| 164 | 164 | |
| 165 | - /** |
|
| 166 | - * Called when visiting a header element |
|
| 167 | - * |
|
| 168 | - * @param HTML_QuickForm_header header element being visited |
|
| 169 | - * @access public |
|
| 170 | - * @return void |
|
| 171 | - */ |
|
| 165 | + /** |
|
| 166 | + * Called when visiting a header element |
|
| 167 | + * |
|
| 168 | + * @param HTML_QuickForm_header header element being visited |
|
| 169 | + * @access public |
|
| 170 | + * @return void |
|
| 171 | + */ |
|
| 172 | 172 | function renderHeader(&$header) |
| 173 | 173 | { |
| 174 | 174 | $name = $header->getName(); |
@@ -181,15 +181,15 @@ discard block |
||
| 181 | 181 | $this->_tpl->setVariable($varName, $header->toHtml()); |
| 182 | 182 | } // end func renderHeader |
| 183 | 183 | |
| 184 | - /** |
|
| 185 | - * Called when visiting an element |
|
| 186 | - * |
|
| 187 | - * @param HTML_QuickForm_element form element being visited |
|
| 188 | - * @param bool Whether an element is required |
|
| 189 | - * @param string An error message associated with an element |
|
| 190 | - * @access public |
|
| 191 | - * @return void |
|
| 192 | - */ |
|
| 184 | + /** |
|
| 185 | + * Called when visiting an element |
|
| 186 | + * |
|
| 187 | + * @param HTML_QuickForm_element form element being visited |
|
| 188 | + * @param bool Whether an element is required |
|
| 189 | + * @param string An error message associated with an element |
|
| 190 | + * @access public |
|
| 191 | + * @return void |
|
| 192 | + */ |
|
| 193 | 193 | function renderElement(&$element, $required, $error) |
| 194 | 194 | { |
| 195 | 195 | $name = $element->getName(); |
@@ -257,13 +257,13 @@ discard block |
||
| 257 | 257 | } |
| 258 | 258 | } // end func renderElement |
| 259 | 259 | |
| 260 | - /** |
|
| 261 | - * Called when visiting a hidden element |
|
| 262 | - * |
|
| 263 | - * @param HTML_QuickForm_element hidden element being visited |
|
| 264 | - * @access public |
|
| 265 | - * @return void |
|
| 266 | - */ |
|
| 260 | + /** |
|
| 261 | + * Called when visiting a hidden element |
|
| 262 | + * |
|
| 263 | + * @param HTML_QuickForm_element hidden element being visited |
|
| 264 | + * @access public |
|
| 265 | + * @return void |
|
| 266 | + */ |
|
| 267 | 267 | function renderHidden(&$element) |
| 268 | 268 | { |
| 269 | 269 | if ($this->_tpl->placeholderExists($this->_formName . '_hidden')) { |
@@ -275,15 +275,15 @@ discard block |
||
| 275 | 275 | } |
| 276 | 276 | } // end func renderHidden |
| 277 | 277 | |
| 278 | - /** |
|
| 279 | - * Called when visiting a group, before processing any group elements |
|
| 280 | - * |
|
| 281 | - * @param HTML_QuickForm_group group being visited |
|
| 282 | - * @param bool Whether a group is required |
|
| 283 | - * @param string An error message associated with a group |
|
| 284 | - * @access public |
|
| 285 | - * @return void |
|
| 286 | - */ |
|
| 278 | + /** |
|
| 279 | + * Called when visiting a group, before processing any group elements |
|
| 280 | + * |
|
| 281 | + * @param HTML_QuickForm_group group being visited |
|
| 282 | + * @param bool Whether a group is required |
|
| 283 | + * @param string An error message associated with a group |
|
| 284 | + * @access public |
|
| 285 | + * @return void |
|
| 286 | + */ |
|
| 287 | 287 | function startGroup(&$group, $required, $error) |
| 288 | 288 | { |
| 289 | 289 | $name = $group->getName(); |
@@ -328,77 +328,77 @@ discard block |
||
| 328 | 328 | $this->_inGroup = $varName; |
| 329 | 329 | } // end func startGroup |
| 330 | 330 | |
| 331 | - /** |
|
| 332 | - * Called when visiting a group, after processing all group elements |
|
| 333 | - * |
|
| 334 | - * @param HTML_QuickForm_group group being visited |
|
| 335 | - * @access public |
|
| 336 | - * @return void |
|
| 337 | - */ |
|
| 331 | + /** |
|
| 332 | + * Called when visiting a group, after processing all group elements |
|
| 333 | + * |
|
| 334 | + * @param HTML_QuickForm_group group being visited |
|
| 335 | + * @access public |
|
| 336 | + * @return void |
|
| 337 | + */ |
|
| 338 | 338 | function finishGroup(&$group) |
| 339 | 339 | { |
| 340 | 340 | $this->_inGroup = ''; |
| 341 | 341 | } // end func finishGroup |
| 342 | 342 | |
| 343 | - /** |
|
| 344 | - * Sets the way required elements are rendered |
|
| 345 | - * |
|
| 346 | - * You can use {label} or {html} placeholders to let the renderer know where |
|
| 347 | - * where the element label or the element html are positionned according to the |
|
| 348 | - * required tag. They will be replaced accordingly with the right value. |
|
| 349 | - * For example: |
|
| 350 | - * <font color="red">*</font>{label} |
|
| 351 | - * will put a red star in front of the label if the element is required. |
|
| 352 | - * |
|
| 353 | - * @param string The required element template |
|
| 354 | - * @access public |
|
| 355 | - * @return void |
|
| 356 | - */ |
|
| 343 | + /** |
|
| 344 | + * Sets the way required elements are rendered |
|
| 345 | + * |
|
| 346 | + * You can use {label} or {html} placeholders to let the renderer know where |
|
| 347 | + * where the element label or the element html are positionned according to the |
|
| 348 | + * required tag. They will be replaced accordingly with the right value. |
|
| 349 | + * For example: |
|
| 350 | + * <font color="red">*</font>{label} |
|
| 351 | + * will put a red star in front of the label if the element is required. |
|
| 352 | + * |
|
| 353 | + * @param string The required element template |
|
| 354 | + * @access public |
|
| 355 | + * @return void |
|
| 356 | + */ |
|
| 357 | 357 | function setRequiredTemplate($template) |
| 358 | 358 | { |
| 359 | 359 | $this->_required = $template; |
| 360 | 360 | } // end func setRequiredTemplate |
| 361 | 361 | |
| 362 | - /** |
|
| 363 | - * Sets the way elements with validation errors are rendered |
|
| 364 | - * |
|
| 365 | - * You can use {label} or {html} placeholders to let the renderer know where |
|
| 366 | - * where the element label or the element html are positionned according to the |
|
| 367 | - * error message. They will be replaced accordingly with the right value. |
|
| 368 | - * The error message will replace the {error} place holder. |
|
| 369 | - * For example: |
|
| 370 | - * <font color="red">{error}</font><br />{html} |
|
| 371 | - * will put the error message in red on top of the element html. |
|
| 372 | - * |
|
| 373 | - * If you want all error messages to be output in the main error block, do not specify |
|
| 374 | - * {html} nor {label}. |
|
| 375 | - * |
|
| 376 | - * Groups can have special layouts. With this kind of groups, the renderer will need |
|
| 377 | - * to know where to place the error message. In this case, use error blocks like: |
|
| 378 | - * <!-- BEGIN form_group_error -->{form_group_error}<!-- END form_group_error --> |
|
| 379 | - * where you want the error message to appear in the form. |
|
| 380 | - * |
|
| 381 | - * @param string The element error template |
|
| 382 | - * @access public |
|
| 383 | - * @return void |
|
| 384 | - */ |
|
| 362 | + /** |
|
| 363 | + * Sets the way elements with validation errors are rendered |
|
| 364 | + * |
|
| 365 | + * You can use {label} or {html} placeholders to let the renderer know where |
|
| 366 | + * where the element label or the element html are positionned according to the |
|
| 367 | + * error message. They will be replaced accordingly with the right value. |
|
| 368 | + * The error message will replace the {error} place holder. |
|
| 369 | + * For example: |
|
| 370 | + * <font color="red">{error}</font><br />{html} |
|
| 371 | + * will put the error message in red on top of the element html. |
|
| 372 | + * |
|
| 373 | + * If you want all error messages to be output in the main error block, do not specify |
|
| 374 | + * {html} nor {label}. |
|
| 375 | + * |
|
| 376 | + * Groups can have special layouts. With this kind of groups, the renderer will need |
|
| 377 | + * to know where to place the error message. In this case, use error blocks like: |
|
| 378 | + * <!-- BEGIN form_group_error -->{form_group_error}<!-- END form_group_error --> |
|
| 379 | + * where you want the error message to appear in the form. |
|
| 380 | + * |
|
| 381 | + * @param string The element error template |
|
| 382 | + * @access public |
|
| 383 | + * @return void |
|
| 384 | + */ |
|
| 385 | 385 | function setErrorTemplate($template) |
| 386 | 386 | { |
| 387 | 387 | $this->_error = $template; |
| 388 | 388 | } // end func setErrorTemplate |
| 389 | 389 | |
| 390 | - /** |
|
| 391 | - * Called when an element is required |
|
| 392 | - * |
|
| 393 | - * This method will add the required tag to the element label and/or the element html |
|
| 394 | - * such as defined with the method setRequiredTemplate |
|
| 395 | - * |
|
| 396 | - * @param string The element label |
|
| 397 | - * @param string The element html rendering |
|
| 398 | - * @see setRequiredTemplate() |
|
| 399 | - * @access private |
|
| 400 | - * @return void |
|
| 401 | - */ |
|
| 390 | + /** |
|
| 391 | + * Called when an element is required |
|
| 392 | + * |
|
| 393 | + * This method will add the required tag to the element label and/or the element html |
|
| 394 | + * such as defined with the method setRequiredTemplate |
|
| 395 | + * |
|
| 396 | + * @param string The element label |
|
| 397 | + * @param string The element html rendering |
|
| 398 | + * @see setRequiredTemplate() |
|
| 399 | + * @access private |
|
| 400 | + * @return void |
|
| 401 | + */ |
|
| 402 | 402 | function _renderRequired(&$label, &$html) |
| 403 | 403 | { |
| 404 | 404 | if ($this->_tpl->blockExists($tplBlock = $this->_formName . '_required_block')) { |
@@ -428,20 +428,20 @@ discard block |
||
| 428 | 428 | } |
| 429 | 429 | } // end func _renderRequired |
| 430 | 430 | |
| 431 | - /** |
|
| 432 | - * Called when an element has a validation error |
|
| 433 | - * |
|
| 434 | - * This method will add the error message to the element label or the element html |
|
| 435 | - * such as defined with the method setErrorTemplate. If the error placeholder is not found |
|
| 436 | - * in the template, the error will be displayed in the form error block. |
|
| 437 | - * |
|
| 438 | - * @param string The element label |
|
| 439 | - * @param string The element html rendering |
|
| 440 | - * @param string The element error |
|
| 441 | - * @see setErrorTemplate() |
|
| 442 | - * @access private |
|
| 443 | - * @return void |
|
| 444 | - */ |
|
| 431 | + /** |
|
| 432 | + * Called when an element has a validation error |
|
| 433 | + * |
|
| 434 | + * This method will add the error message to the element label or the element html |
|
| 435 | + * such as defined with the method setErrorTemplate. If the error placeholder is not found |
|
| 436 | + * in the template, the error will be displayed in the form error block. |
|
| 437 | + * |
|
| 438 | + * @param string The element label |
|
| 439 | + * @param string The element html rendering |
|
| 440 | + * @param string The element error |
|
| 441 | + * @see setErrorTemplate() |
|
| 442 | + * @access private |
|
| 443 | + * @return void |
|
| 444 | + */ |
|
| 445 | 445 | function _renderError(&$label, &$html, $error) |
| 446 | 446 | { |
| 447 | 447 | if ($this->_tpl->blockExists($tplBlock = $this->_formName . '_error_block')) { |
@@ -473,15 +473,15 @@ discard block |
||
| 473 | 473 | }// end func _renderError |
| 474 | 474 | |
| 475 | 475 | |
| 476 | - /** |
|
| 477 | - * Returns the block's contents |
|
| 478 | - * |
|
| 479 | - * The method is needed because ITX and Sigma implement clearing |
|
| 480 | - * the block contents on get() a bit differently |
|
| 481 | - * |
|
| 482 | - * @param string Block name |
|
| 483 | - * @return string Block contents |
|
| 484 | - */ |
|
| 476 | + /** |
|
| 477 | + * Returns the block's contents |
|
| 478 | + * |
|
| 479 | + * The method is needed because ITX and Sigma implement clearing |
|
| 480 | + * the block contents on get() a bit differently |
|
| 481 | + * |
|
| 482 | + * @param string Block name |
|
| 483 | + * @return string Block contents |
|
| 484 | + */ |
|
| 485 | 485 | function _getTplBlock($block) |
| 486 | 486 | { |
| 487 | 487 | $this->_tpl->parse($block); |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | function HTML_QuickForm_Renderer_ITStatic(&$tpl) |
| 111 | 111 | { |
| 112 | 112 | $this->HTML_QuickForm_Renderer(); |
| 113 | - $this->_tpl =& $tpl; |
|
| 113 | + $this->_tpl = & $tpl; |
|
| 114 | 114 | } // end constructor |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | } |
| 155 | 155 | // add hidden elements, if collected |
| 156 | 156 | if (!empty($this->_hidden)) { |
| 157 | - $this->_tpl->setVariable($this->_formName . '_hidden', $this->_hidden); |
|
| 157 | + $this->_tpl->setVariable($this->_formName.'_hidden', $this->_hidden); |
|
| 158 | 158 | } |
| 159 | 159 | // assign form attributes |
| 160 | 160 | $this->_tpl->setVariable($this->_formName.'_attributes', $form->getAttributes(true)); |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | $this->_elementIndex++; |
| 204 | 204 | } |
| 205 | 205 | if ($varName != $this->_inGroup) { |
| 206 | - $varName .= '_' == substr($varName, -1)? '': '_'; |
|
| 206 | + $varName .= '_' == substr($varName, -1) ? '' : '_'; |
|
| 207 | 207 | // element name is of type : group[name] |
| 208 | 208 | $label = $element->getLabel(); |
| 209 | 209 | $html = $element->toHtml(); |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | */ |
| 267 | 267 | function renderHidden(&$element) |
| 268 | 268 | { |
| 269 | - if ($this->_tpl->placeholderExists($this->_formName . '_hidden')) { |
|
| 269 | + if ($this->_tpl->placeholderExists($this->_formName.'_hidden')) { |
|
| 270 | 270 | $this->_hidden .= $element->toHtml(); |
| 271 | 271 | } else { |
| 272 | 272 | $name = $element->getName(); |
@@ -307,14 +307,14 @@ discard block |
||
| 307 | 307 | // <!-- BEGIN form_group_error -->{form_group_error}<!-- END form_group_error --> |
| 308 | 308 | if (!empty($error)) { |
| 309 | 309 | if ($this->_tpl->placeholderExists($varName.'_error')) { |
| 310 | - if ($this->_tpl->blockExists($this->_formName . '_error_block')) { |
|
| 311 | - $this->_tpl->setVariable($this->_formName . '_error', $error); |
|
| 312 | - $error = $this->_getTplBlock($this->_formName . '_error_block'); |
|
| 310 | + if ($this->_tpl->blockExists($this->_formName.'_error_block')) { |
|
| 311 | + $this->_tpl->setVariable($this->_formName.'_error', $error); |
|
| 312 | + $error = $this->_getTplBlock($this->_formName.'_error_block'); |
|
| 313 | 313 | } elseif (strpos($this->_error, '{html}') !== false || strpos($this->_error, '{label}') !== false) { |
| 314 | 314 | $error = str_replace('{error}', $error, $this->_error); |
| 315 | 315 | } |
| 316 | 316 | } |
| 317 | - $this->_tpl->setVariable($varName . '_error', $error); |
|
| 317 | + $this->_tpl->setVariable($varName.'_error', $error); |
|
| 318 | 318 | array_pop($this->_errors); |
| 319 | 319 | } |
| 320 | 320 | } |
@@ -401,17 +401,17 @@ discard block |
||
| 401 | 401 | */ |
| 402 | 402 | function _renderRequired(&$label, &$html) |
| 403 | 403 | { |
| 404 | - if ($this->_tpl->blockExists($tplBlock = $this->_formName . '_required_block')) { |
|
| 405 | - if (!empty($label) && $this->_tpl->placeholderExists($this->_formName . '_label', $tplBlock)) { |
|
| 406 | - $this->_tpl->setVariable($this->_formName . '_label', is_array($label)? $label[0]: $label); |
|
| 404 | + if ($this->_tpl->blockExists($tplBlock = $this->_formName.'_required_block')) { |
|
| 405 | + if (!empty($label) && $this->_tpl->placeholderExists($this->_formName.'_label', $tplBlock)) { |
|
| 406 | + $this->_tpl->setVariable($this->_formName.'_label', is_array($label) ? $label[0] : $label); |
|
| 407 | 407 | if (is_array($label)) { |
| 408 | 408 | $label[0] = $this->_getTplBlock($tplBlock); |
| 409 | 409 | } else { |
| 410 | 410 | $label = $this->_getTplBlock($tplBlock); |
| 411 | 411 | } |
| 412 | 412 | } |
| 413 | - if (!empty($html) && $this->_tpl->placeholderExists($this->_formName . '_html', $tplBlock)) { |
|
| 414 | - $this->_tpl->setVariable($this->_formName . '_html', $html); |
|
| 413 | + if (!empty($html) && $this->_tpl->placeholderExists($this->_formName.'_html', $tplBlock)) { |
|
| 414 | + $this->_tpl->setVariable($this->_formName.'_html', $html); |
|
| 415 | 415 | $html = $this->_getTplBlock($tplBlock); |
| 416 | 416 | } |
| 417 | 417 | } else { |
@@ -444,21 +444,21 @@ discard block |
||
| 444 | 444 | */ |
| 445 | 445 | function _renderError(&$label, &$html, $error) |
| 446 | 446 | { |
| 447 | - if ($this->_tpl->blockExists($tplBlock = $this->_formName . '_error_block')) { |
|
| 448 | - $this->_tpl->setVariable($this->_formName . '_error', $error); |
|
| 449 | - if (!empty($label) && $this->_tpl->placeholderExists($this->_formName . '_label', $tplBlock)) { |
|
| 450 | - $this->_tpl->setVariable($this->_formName . '_label', is_array($label)? $label[0]: $label); |
|
| 447 | + if ($this->_tpl->blockExists($tplBlock = $this->_formName.'_error_block')) { |
|
| 448 | + $this->_tpl->setVariable($this->_formName.'_error', $error); |
|
| 449 | + if (!empty($label) && $this->_tpl->placeholderExists($this->_formName.'_label', $tplBlock)) { |
|
| 450 | + $this->_tpl->setVariable($this->_formName.'_label', is_array($label) ? $label[0] : $label); |
|
| 451 | 451 | if (is_array($label)) { |
| 452 | 452 | $label[0] = $this->_getTplBlock($tplBlock); |
| 453 | 453 | } else { |
| 454 | 454 | $label = $this->_getTplBlock($tplBlock); |
| 455 | 455 | } |
| 456 | - } elseif (!empty($html) && $this->_tpl->placeholderExists($this->_formName . '_html', $tplBlock)) { |
|
| 457 | - $this->_tpl->setVariable($this->_formName . '_html', $html); |
|
| 456 | + } elseif (!empty($html) && $this->_tpl->placeholderExists($this->_formName.'_html', $tplBlock)) { |
|
| 457 | + $this->_tpl->setVariable($this->_formName.'_html', $html); |
|
| 458 | 458 | $html = $this->_getTplBlock($tplBlock); |
| 459 | 459 | } |
| 460 | 460 | // clean up after ourselves |
| 461 | - $this->_tpl->setVariable($this->_formName . '_error', null); |
|
| 461 | + $this->_tpl->setVariable($this->_formName.'_error', null); |
|
| 462 | 462 | } elseif (!empty($label) && strpos($this->_error, '{label}') !== false) { |
| 463 | 463 | if (is_array($label)) { |
| 464 | 464 | $label[0] = str_replace(array('{label}', '{error}'), array($label[0], $error), $this->_error); |
@@ -137,6 +137,9 @@ |
||
| 137 | 137 | $this->_currentSection = $this->_sectionCount++; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | + /** |
|
| 141 | + * @param boolean $required |
|
| 142 | + */ |
|
| 140 | 143 | function renderElement(&$element, $required, $error) |
| 141 | 144 | { |
| 142 | 145 | $elObj = $this->_elementToObject($element, $required, $error); |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | class HTML_QuickForm_Renderer_Object extends HTML_QuickForm_Renderer |
| 36 | 36 | { |
| 37 | - /**#@+ |
|
| 37 | + /**#@+ |
|
| 38 | 38 | * @access private |
| 39 | 39 | */ |
| 40 | 40 | /** |
@@ -50,15 +50,15 @@ discard block |
||
| 50 | 50 | var $_sectionCount; |
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | - * Current section number |
|
| 54 | - * @var integer $_currentSection |
|
| 55 | - */ |
|
| 53 | + * Current section number |
|
| 54 | + * @var integer $_currentSection |
|
| 55 | + */ |
|
| 56 | 56 | var $_currentSection; |
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | - * Object representing current group |
|
| 60 | - * @var object $_currentGroup |
|
| 61 | - */ |
|
| 59 | + * Object representing current group |
|
| 60 | + * @var object $_currentGroup |
|
| 61 | + */ |
|
| 62 | 62 | var $_currentGroup = null; |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -68,17 +68,17 @@ discard block |
||
| 68 | 68 | var $_elementType = 'QuickFormElement'; |
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | - * Additional style information for different elements |
|
| 72 | - * @var array $_elementStyles |
|
| 73 | - */ |
|
| 71 | + * Additional style information for different elements |
|
| 72 | + * @var array $_elementStyles |
|
| 73 | + */ |
|
| 74 | 74 | var $_elementStyles = array(); |
| 75 | 75 | |
| 76 | 76 | /** |
| 77 | - * true: collect all hidden elements into string; false: process them as usual form elements |
|
| 78 | - * @var bool $_collectHidden |
|
| 79 | - */ |
|
| 77 | + * true: collect all hidden elements into string; false: process them as usual form elements |
|
| 78 | + * @var bool $_collectHidden |
|
| 79 | + */ |
|
| 80 | 80 | var $_collectHidden = false; |
| 81 | - /**#@-*/ |
|
| 81 | + /**#@-*/ |
|
| 82 | 82 | |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -270,73 +270,73 @@ discard block |
||
| 270 | 270 | */ |
| 271 | 271 | class QuickformForm |
| 272 | 272 | { |
| 273 | - /** |
|
| 274 | - * Whether the form has been frozen |
|
| 275 | - * @var boolean $frozen |
|
| 276 | - */ |
|
| 273 | + /** |
|
| 274 | + * Whether the form has been frozen |
|
| 275 | + * @var boolean $frozen |
|
| 276 | + */ |
|
| 277 | 277 | var $frozen; |
| 278 | 278 | |
| 279 | - /** |
|
| 280 | - * Javascript for client-side validation |
|
| 281 | - * @var string $javascript |
|
| 282 | - */ |
|
| 279 | + /** |
|
| 280 | + * Javascript for client-side validation |
|
| 281 | + * @var string $javascript |
|
| 282 | + */ |
|
| 283 | 283 | var $javascript; |
| 284 | 284 | |
| 285 | - /** |
|
| 286 | - * Attributes for form tag |
|
| 287 | - * @var string $attributes |
|
| 288 | - */ |
|
| 285 | + /** |
|
| 286 | + * Attributes for form tag |
|
| 287 | + * @var string $attributes |
|
| 288 | + */ |
|
| 289 | 289 | var $attributes; |
| 290 | 290 | |
| 291 | - /** |
|
| 292 | - * Note about required elements |
|
| 293 | - * @var string $requirednote |
|
| 294 | - */ |
|
| 291 | + /** |
|
| 292 | + * Note about required elements |
|
| 293 | + * @var string $requirednote |
|
| 294 | + */ |
|
| 295 | 295 | var $requirednote; |
| 296 | 296 | |
| 297 | - /** |
|
| 298 | - * Collected html of all hidden variables |
|
| 299 | - * @var string $hidden |
|
| 300 | - */ |
|
| 297 | + /** |
|
| 298 | + * Collected html of all hidden variables |
|
| 299 | + * @var string $hidden |
|
| 300 | + */ |
|
| 301 | 301 | var $hidden; |
| 302 | 302 | |
| 303 | - /** |
|
| 304 | - * Set if there were validation errors. |
|
| 305 | - * StdClass object with element names for keys and their |
|
| 306 | - * error messages as values |
|
| 307 | - * @var object $errors |
|
| 308 | - */ |
|
| 303 | + /** |
|
| 304 | + * Set if there were validation errors. |
|
| 305 | + * StdClass object with element names for keys and their |
|
| 306 | + * error messages as values |
|
| 307 | + * @var object $errors |
|
| 308 | + */ |
|
| 309 | 309 | var $errors; |
| 310 | 310 | |
| 311 | - /** |
|
| 312 | - * Array of QuickformElementObject elements. If there are headers in the form |
|
| 313 | - * this will be empty and the elements will be in the |
|
| 314 | - * separate sections |
|
| 315 | - * @var array $elements |
|
| 316 | - */ |
|
| 311 | + /** |
|
| 312 | + * Array of QuickformElementObject elements. If there are headers in the form |
|
| 313 | + * this will be empty and the elements will be in the |
|
| 314 | + * separate sections |
|
| 315 | + * @var array $elements |
|
| 316 | + */ |
|
| 317 | 317 | var $elements; |
| 318 | 318 | |
| 319 | - /** |
|
| 320 | - * Array of sections contained in the document |
|
| 321 | - * @var array $sections |
|
| 322 | - */ |
|
| 319 | + /** |
|
| 320 | + * Array of sections contained in the document |
|
| 321 | + * @var array $sections |
|
| 322 | + */ |
|
| 323 | 323 | var $sections; |
| 324 | 324 | |
| 325 | - /** |
|
| 326 | - * Output <form> header |
|
| 327 | - * {form.outputHeader():h} |
|
| 328 | - * @return string <form attributes> |
|
| 329 | - */ |
|
| 325 | + /** |
|
| 326 | + * Output <form> header |
|
| 327 | + * {form.outputHeader():h} |
|
| 328 | + * @return string <form attributes> |
|
| 329 | + */ |
|
| 330 | 330 | function outputHeader() |
| 331 | 331 | { |
| 332 | 332 | return "<form " . $this->attributes . ">\n"; |
| 333 | 333 | } |
| 334 | 334 | |
| 335 | - /** |
|
| 336 | - * Output form javascript |
|
| 337 | - * {form.outputJavaScript():h} |
|
| 338 | - * @return string Javascript |
|
| 339 | - */ |
|
| 335 | + /** |
|
| 336 | + * Output form javascript |
|
| 337 | + * {form.outputJavaScript():h} |
|
| 338 | + * @return string Javascript |
|
| 339 | + */ |
|
| 340 | 340 | function outputJavaScript() |
| 341 | 341 | { |
| 342 | 342 | return $this->javascript; |
@@ -441,9 +441,9 @@ discard block |
||
| 441 | 441 | } |
| 442 | 442 | |
| 443 | 443 | |
| 444 | - /** |
|
| 445 | - * XXX: why does it use Flexy when all other stuff here does not depend on it? |
|
| 446 | - */ |
|
| 444 | + /** |
|
| 445 | + * XXX: why does it use Flexy when all other stuff here does not depend on it? |
|
| 446 | + */ |
|
| 447 | 447 | function outputStyle() |
| 448 | 448 | { |
| 449 | 449 | ob_start(); |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * The object being generated |
| 42 | 42 | * @var QuickformForm |
| 43 | 43 | */ |
| 44 | - var $_obj= null; |
|
| 44 | + var $_obj = null; |
|
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | 47 | * Number of sections in the form (i.e. number of headers in it) |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | $this->_obj->requirednote = $form->getRequiredNote(); |
| 122 | 122 | $this->_obj->errors = new StdClass; |
| 123 | 123 | |
| 124 | - if($this->_collectHidden) { |
|
| 124 | + if ($this->_collectHidden) { |
|
| 125 | 125 | $this->_obj->hidden = ''; |
| 126 | 126 | } |
| 127 | 127 | $this->_elementIdx = 1; |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | function renderElement(&$element, $required, $error) |
| 141 | 141 | { |
| 142 | 142 | $elObj = $this->_elementToObject($element, $required, $error); |
| 143 | - if(!empty($error)) { |
|
| 143 | + if (!empty($error)) { |
|
| 144 | 144 | $name = $elObj->name; |
| 145 | 145 | $this->_obj->errors->$name = $error; |
| 146 | 146 | } |
@@ -149,8 +149,8 @@ discard block |
||
| 149 | 149 | |
| 150 | 150 | function renderHidden(&$element) |
| 151 | 151 | { |
| 152 | - if($this->_collectHidden) { |
|
| 153 | - $this->_obj->hidden .= $element->toHtml() . "\n"; |
|
| 152 | + if ($this->_collectHidden) { |
|
| 153 | + $this->_obj->hidden .= $element->toHtml()."\n"; |
|
| 154 | 154 | } else { |
| 155 | 155 | $this->renderElement($element, false, null); |
| 156 | 156 | } |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | function startGroup(&$group, $required, $error) |
| 160 | 160 | { |
| 161 | 161 | $this->_currentGroup = $this->_elementToObject($group, $required, $error); |
| 162 | - if(!empty($error)) { |
|
| 162 | + if (!empty($error)) { |
|
| 163 | 163 | $name = $this->_currentGroup->name; |
| 164 | 164 | $this->_obj->errors->$name = $error; |
| 165 | 165 | } |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | */ |
| 183 | 183 | function _elementToObject(&$element, $required, $error) |
| 184 | 184 | { |
| 185 | - if($this->_elementType) { |
|
| 185 | + if ($this->_elementType) { |
|
| 186 | 186 | $ret = new $this->_elementType; |
| 187 | 187 | } |
| 188 | 188 | $ret->name = $element->getName(); |
@@ -193,8 +193,8 @@ discard block |
||
| 193 | 193 | if (is_array($labels)) { |
| 194 | 194 | $ret->label = array_shift($labels); |
| 195 | 195 | foreach ($labels as $key => $label) { |
| 196 | - $key = is_int($key)? $key + 2: $key; |
|
| 197 | - $ret->{'label_' . $key} = $label; |
|
| 196 | + $key = is_int($key) ? $key + 2 : $key; |
|
| 197 | + $ret->{'label_'.$key} = $label; |
|
| 198 | 198 | } |
| 199 | 199 | } else { |
| 200 | 200 | $ret->label = $labels; |
@@ -202,11 +202,11 @@ discard block |
||
| 202 | 202 | $ret->required = $required; |
| 203 | 203 | $ret->error = $error; |
| 204 | 204 | |
| 205 | - if(isset($this->_elementStyles[$ret->name])) { |
|
| 205 | + if (isset($this->_elementStyles[$ret->name])) { |
|
| 206 | 206 | $ret->style = $this->_elementStyles[$ret->name]; |
| 207 | - $ret->styleTemplate = "styles/". $ret->style .".html"; |
|
| 207 | + $ret->styleTemplate = "styles/".$ret->style.".html"; |
|
| 208 | 208 | } |
| 209 | - if($ret->type == 'group') { |
|
| 209 | + if ($ret->type == 'group') { |
|
| 210 | 210 | $ret->separator = $element->_separator; |
| 211 | 211 | $ret->elements = array(); |
| 212 | 212 | } else { |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | function _storeObject($elObj) |
| 226 | 226 | { |
| 227 | 227 | $name = $elObj->name; |
| 228 | - if(is_object($this->_currentGroup) && $elObj->type != 'group') { |
|
| 228 | + if (is_object($this->_currentGroup) && $elObj->type != 'group') { |
|
| 229 | 229 | $this->_currentGroup->elements[] = $elObj; |
| 230 | 230 | } elseif (isset($this->_currentSection)) { |
| 231 | 231 | $this->_obj->sections[$this->_currentSection]->elements[] = $elObj; |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | |
| 237 | 237 | function setElementStyle($elementName, $styleName = null) |
| 238 | 238 | { |
| 239 | - if(is_array($elementName)) { |
|
| 239 | + if (is_array($elementName)) { |
|
| 240 | 240 | $this->_elementStyles = array_merge($this->_elementStyles, $elementName); |
| 241 | 241 | } else { |
| 242 | 242 | $this->_elementStyles[$elementName] = $styleName; |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | */ |
| 330 | 330 | function outputHeader() |
| 331 | 331 | { |
| 332 | - return "<form " . $this->attributes . ">\n"; |
|
| 332 | + return "<form ".$this->attributes.">\n"; |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | /** |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | function outputStyle() |
| 448 | 448 | { |
| 449 | 449 | ob_start(); |
| 450 | - HTML_Template_Flexy::staticQuickTemplate('styles/' . $this->style . '.html', $this); |
|
| 450 | + HTML_Template_Flexy::staticQuickTemplate('styles/'.$this->style.'.html', $this); |
|
| 451 | 451 | $ret = ob_get_contents(); |
| 452 | 452 | ob_end_clean(); |
| 453 | 453 | return $ret; |
@@ -71,7 +71,7 @@ |
||
| 71 | 71 | * |
| 72 | 72 | * @param mixed Options for the rule |
| 73 | 73 | * @access public |
| 74 | - * @return array first element is code to setup validation, second is the check itself |
|
| 74 | + * @return string[] first element is code to setup validation, second is the check itself |
|
| 75 | 75 | * @abstract |
| 76 | 76 | */ |
| 77 | 77 | function getValidationScript($options = null) |
@@ -33,34 +33,34 @@ |
||
| 33 | 33 | */ |
| 34 | 34 | class HTML_QuickForm_Rule |
| 35 | 35 | { |
| 36 | - /** |
|
| 37 | - * Name of the rule to use in validate method |
|
| 38 | - * |
|
| 39 | - * This property is used in more global rules like Callback and Regex |
|
| 40 | - * to determine which callback and which regex is to be used for validation |
|
| 41 | - * |
|
| 42 | - * @var string |
|
| 43 | - * @access public |
|
| 44 | - */ |
|
| 36 | + /** |
|
| 37 | + * Name of the rule to use in validate method |
|
| 38 | + * |
|
| 39 | + * This property is used in more global rules like Callback and Regex |
|
| 40 | + * to determine which callback and which regex is to be used for validation |
|
| 41 | + * |
|
| 42 | + * @var string |
|
| 43 | + * @access public |
|
| 44 | + */ |
|
| 45 | 45 | var $name; |
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * Validates a value |
|
| 49 | - * |
|
| 50 | - * @access public |
|
| 51 | - * @abstract |
|
| 52 | - */ |
|
| 47 | + /** |
|
| 48 | + * Validates a value |
|
| 49 | + * |
|
| 50 | + * @access public |
|
| 51 | + * @abstract |
|
| 52 | + */ |
|
| 53 | 53 | function validate($value, $options) |
| 54 | 54 | { |
| 55 | 55 | return true; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * Sets the rule name |
|
| 60 | - * |
|
| 61 | - * @param string rule name |
|
| 62 | - * @access public |
|
| 63 | - */ |
|
| 58 | + /** |
|
| 59 | + * Sets the rule name |
|
| 60 | + * |
|
| 61 | + * @param string rule name |
|
| 62 | + * @access public |
|
| 63 | + */ |
|
| 64 | 64 | function setName($ruleName) |
| 65 | 65 | { |
| 66 | 66 | $this->name = $ruleName; |
@@ -73,6 +73,9 @@ |
||
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | |
| 76 | + /** |
|
| 77 | + * @param integer[] $values |
|
| 78 | + */ |
|
| 76 | 79 | function validate($values, $operator = null) |
| 77 | 80 | { |
| 78 | 81 | $operator = $this->_findOperator($operator); |
@@ -35,11 +35,11 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | class HTML_QuickForm_Rule_Compare extends HTML_QuickForm_Rule |
| 37 | 37 | { |
| 38 | - /** |
|
| 39 | - * Possible operators to use |
|
| 40 | - * @var array |
|
| 41 | - * @access private |
|
| 42 | - */ |
|
| 38 | + /** |
|
| 39 | + * Possible operators to use |
|
| 40 | + * @var array |
|
| 41 | + * @access private |
|
| 42 | + */ |
|
| 43 | 43 | var $_operators = array( |
| 44 | 44 | 'eq' => '===', |
| 45 | 45 | 'neq' => '!==', |
@@ -51,13 +51,13 @@ discard block |
||
| 51 | 51 | '!=' => '!==' |
| 52 | 52 | ); |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Returns the operator to use for comparing the values |
|
| 56 | - * |
|
| 57 | - * @access private |
|
| 58 | - * @param string operator name |
|
| 59 | - * @return string operator to use for validation |
|
| 60 | - */ |
|
| 54 | + /** |
|
| 55 | + * Returns the operator to use for comparing the values |
|
| 56 | + * |
|
| 57 | + * @access private |
|
| 58 | + * @param string operator name |
|
| 59 | + * @return string operator to use for validation |
|
| 60 | + */ |
|
| 61 | 61 | function _findOperator($name) |
| 62 | 62 | { |
| 63 | 63 | $name = trim($name); |
@@ -78,9 +78,9 @@ |
||
| 78 | 78 | $operator = $this->_findOperator($operator); |
| 79 | 79 | |
| 80 | 80 | if ('===' != $operator && '!==' != $operator) { |
| 81 | - $compareFn = create_function('$a, $b', 'return floatval($a) ' . $operator . ' floatval($b);'); |
|
| 81 | + $compareFn = create_function('$a, $b', 'return floatval($a) '.$operator.' floatval($b);'); |
|
| 82 | 82 | } else { |
| 83 | - $compareFn = create_function('$a, $b', 'return strval($a) ' . $operator . ' strval($b);'); |
|
| 83 | + $compareFn = create_function('$a, $b', 'return strval($a) '.$operator.' strval($b);'); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | return $compareFn($values[0], $values[1]); |
@@ -9,7 +9,7 @@ |
||
| 9 | 9 | /** |
| 10 | 10 | * Function to check a date |
| 11 | 11 | * @see HTML_QuickForm_Rule |
| 12 | - * @param array $date An array with keys F (month), d (day) and Y (year) |
|
| 12 | + * @param string $date An array with keys F (month), d (day) and Y (year) |
|
| 13 | 13 | * @return boolean True if date is valid |
| 14 | 14 | */ |
| 15 | 15 | function validate($date, $options) |
@@ -6,15 +6,15 @@ |
||
| 6 | 6 | */ |
| 7 | 7 | class Html_Quickform_Rule_Date extends HTML_QuickForm_Rule |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Function to check a date |
|
| 11 | - * @see HTML_QuickForm_Rule |
|
| 12 | - * @param array $date An array with keys F (month), d (day) and Y (year) |
|
| 13 | - * @return boolean True if date is valid |
|
| 14 | - */ |
|
| 15 | - function validate($date, $options) |
|
| 16 | - { |
|
| 17 | - $compareDate = create_function('$a', 'return checkdate($a[\'M\'],$a[\'d\'],$a[\'Y\']);'); |
|
| 9 | + /** |
|
| 10 | + * Function to check a date |
|
| 11 | + * @see HTML_QuickForm_Rule |
|
| 12 | + * @param array $date An array with keys F (month), d (day) and Y (year) |
|
| 13 | + * @return boolean True if date is valid |
|
| 14 | + */ |
|
| 15 | + function validate($date, $options) |
|
| 16 | + { |
|
| 17 | + $compareDate = create_function('$a', 'return checkdate($a[\'M\'],$a[\'d\'],$a[\'Y\']);'); |
|
| 18 | 18 | return $compareDate($date); |
| 19 | - } |
|
| 19 | + } |
|
| 20 | 20 | } |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | * @param mixed $values Can be a scalar or an array of values |
| 175 | 175 | * to be validated |
| 176 | 176 | * @param mixed $options Options used by the rule |
| 177 | - * @param mixed $multiple Whether to validate an array of values altogether |
|
| 177 | + * @param boolean $multiple Whether to validate an array of values altogether |
|
| 178 | 178 | * @access public |
| 179 | 179 | * @return mixed true if no error found, int of valid values (when an array of values is given) or false if error |
| 180 | 180 | */ |
@@ -258,6 +258,7 @@ discard block |
||
| 258 | 258 | * the value |
| 259 | 259 | * @param integer value's index in the array (only used for |
| 260 | 260 | * multielement rules) |
| 261 | + * @param integer $index |
|
| 261 | 262 | * @return array first item is value javascript, second is reset |
| 262 | 263 | */ |
| 263 | 264 | function _getJsValue(&$element, $elementName, $reset = false, $index = null) |
@@ -225,41 +225,41 @@ discard block |
||
| 225 | 225 | list ($jsPrefix, $jsCheck) = $rule->getValidationScript($ruleData['format']); |
| 226 | 226 | if (!isset($ruleData['howmany'])) { |
| 227 | 227 | $js = $jsValue . "\n" . $jsPrefix . |
| 228 | - " if (" . str_replace('{jsVar}', 'value', $jsCheck) . " && !errFlag['{$jsField}']) {\n" . |
|
| 229 | - " errFlag['{$jsField}'] = true;\n" . |
|
| 230 | - " _qfMsg = _qfMsg + '\\n - {$ruleData['message']}';\n" . |
|
| 231 | - $jsReset . |
|
| 232 | - " }\n"; |
|
| 228 | + " if (" . str_replace('{jsVar}', 'value', $jsCheck) . " && !errFlag['{$jsField}']) {\n" . |
|
| 229 | + " errFlag['{$jsField}'] = true;\n" . |
|
| 230 | + " _qfMsg = _qfMsg + '\\n - {$ruleData['message']}';\n" . |
|
| 231 | + $jsReset . |
|
| 232 | + " }\n"; |
|
| 233 | 233 | } else { |
| 234 | 234 | $js = $jsValue . "\n" . $jsPrefix . |
| 235 | - " var res = 0;\n" . |
|
| 236 | - " for (var i = 0; i < value.length; i++) {\n" . |
|
| 237 | - " if (!(" . str_replace('{jsVar}', 'value[i]', $jsCheck) . ")) {\n" . |
|
| 238 | - " res++;\n" . |
|
| 239 | - " }\n" . |
|
| 240 | - " }\n" . |
|
| 241 | - " if (res < {$ruleData['howmany']} && !errFlag['{$jsField}']) {\n" . |
|
| 242 | - " errFlag['{$jsField}'] = true;\n" . |
|
| 243 | - " _qfMsg = _qfMsg + '\\n - {$ruleData['message']}';\n" . |
|
| 244 | - $jsReset . |
|
| 245 | - " }\n"; |
|
| 235 | + " var res = 0;\n" . |
|
| 236 | + " for (var i = 0; i < value.length; i++) {\n" . |
|
| 237 | + " if (!(" . str_replace('{jsVar}', 'value[i]', $jsCheck) . ")) {\n" . |
|
| 238 | + " res++;\n" . |
|
| 239 | + " }\n" . |
|
| 240 | + " }\n" . |
|
| 241 | + " if (res < {$ruleData['howmany']} && !errFlag['{$jsField}']) {\n" . |
|
| 242 | + " errFlag['{$jsField}'] = true;\n" . |
|
| 243 | + " _qfMsg = _qfMsg + '\\n - {$ruleData['message']}';\n" . |
|
| 244 | + $jsReset . |
|
| 245 | + " }\n"; |
|
| 246 | 246 | } |
| 247 | 247 | return $js; |
| 248 | 248 | } // end func getValidationScript |
| 249 | 249 | |
| 250 | 250 | |
| 251 | - /** |
|
| 252 | - * Returns JavaScript to get and to reset the element's value |
|
| 253 | - * |
|
| 254 | - * @access private |
|
| 255 | - * @param HTML_QuickForm_element element being processed |
|
| 256 | - * @param string element's name |
|
| 257 | - * @param bool whether to generate JavaScript to reset |
|
| 258 | - * the value |
|
| 259 | - * @param integer value's index in the array (only used for |
|
| 260 | - * multielement rules) |
|
| 261 | - * @return array first item is value javascript, second is reset |
|
| 262 | - */ |
|
| 251 | + /** |
|
| 252 | + * Returns JavaScript to get and to reset the element's value |
|
| 253 | + * |
|
| 254 | + * @access private |
|
| 255 | + * @param HTML_QuickForm_element element being processed |
|
| 256 | + * @param string element's name |
|
| 257 | + * @param bool whether to generate JavaScript to reset |
|
| 258 | + * the value |
|
| 259 | + * @param integer value's index in the array (only used for |
|
| 260 | + * multielement rules) |
|
| 261 | + * @return array first item is value javascript, second is reset |
|
| 262 | + */ |
|
| 263 | 263 | function _getJsValue(&$element, $elementName, $reset = false, $index = null) |
| 264 | 264 | { |
| 265 | 265 | $jsIndex = isset($index)? '[' . $index . ']': ''; |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | for ($i = 0, $count = count($elements); $i < $count; $i++) { |
| 271 | 271 | $append = ($elements[$i]->getType() == 'select' && $elements[$i]->getMultiple())? '[]': ''; |
| 272 | 272 | $value .= "'" . $element->getElementName($i) . $append . "': true" . |
| 273 | - ($i < $count - 1? ', ': ''); |
|
| 273 | + ($i < $count - 1? ', ': ''); |
|
| 274 | 274 | } |
| 275 | 275 | $value .= |
| 276 | 276 | "};\n" . |
@@ -363,17 +363,17 @@ discard block |
||
| 363 | 363 | |
| 364 | 364 | } elseif ($element->getType() == 'radio') { |
| 365 | 365 | $value = " value{$jsIndex} = '';\n" . |
| 366 | - // Fix for bug #5644 |
|
| 367 | - " var els = 'length' in frm.elements['$elementName']? frm.elements['$elementName']: [ frm.elements['$elementName'] ];\n" . |
|
| 368 | - " for (var i = 0; i < els.length; i++) {\n" . |
|
| 369 | - " if (els[i].checked) {\n" . |
|
| 370 | - " value{$jsIndex} = els[i].value;\n" . |
|
| 371 | - " }\n" . |
|
| 372 | - " }"; |
|
| 366 | + // Fix for bug #5644 |
|
| 367 | + " var els = 'length' in frm.elements['$elementName']? frm.elements['$elementName']: [ frm.elements['$elementName'] ];\n" . |
|
| 368 | + " for (var i = 0; i < els.length; i++) {\n" . |
|
| 369 | + " if (els[i].checked) {\n" . |
|
| 370 | + " value{$jsIndex} = els[i].value;\n" . |
|
| 371 | + " }\n" . |
|
| 372 | + " }"; |
|
| 373 | 373 | if ($reset) { |
| 374 | 374 | $tmp_reset .= " for (var i = 0; i < field.length; i++) {\n" . |
| 375 | - " field[i].checked = field[i].defaultChecked;\n" . |
|
| 376 | - " }"; |
|
| 375 | + " field[i].checked = field[i].defaultChecked;\n" . |
|
| 376 | + " }"; |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | } else { |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | $type = strtolower($type); |
| 90 | 90 | if ($type == 'regex') { |
| 91 | 91 | // Regular expression |
| 92 | - $rule =& $this->getRule('regex'); |
|
| 92 | + $rule = & $this->getRule('regex'); |
|
| 93 | 93 | $rule->addData($ruleName, $data1); |
| 94 | 94 | |
| 95 | 95 | } elseif ($type == 'function' || $type == 'callback') { |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | */ |
| 209 | 209 | function getValidationScript(&$element, $elementName, $ruleData) |
| 210 | 210 | { |
| 211 | - $reset = (isset($ruleData['reset'])) ? $ruleData['reset'] : false; |
|
| 211 | + $reset = (isset($ruleData['reset'])) ? $ruleData['reset'] : false; |
|
| 212 | 212 | $rule = $this->getRule($ruleData['type']); |
| 213 | 213 | if (!is_array($element)) { |
| 214 | 214 | list($jsValue, $jsReset) = $this->_getJsValue($element, $elementName, $reset, null); |
@@ -217,31 +217,31 @@ discard block |
||
| 217 | 217 | $jsReset = ''; |
| 218 | 218 | for ($i = 0; $i < count($element); $i++) { |
| 219 | 219 | list($tmp_value, $tmp_reset) = $this->_getJsValue($element[$i], $element[$i]->getName(), $reset, $i); |
| 220 | - $jsValue .= "\n" . $tmp_value; |
|
| 220 | + $jsValue .= "\n".$tmp_value; |
|
| 221 | 221 | $jsReset .= $tmp_reset; |
| 222 | 222 | } |
| 223 | 223 | } |
| 224 | - $jsField = isset($ruleData['group'])? $ruleData['group']: $elementName; |
|
| 224 | + $jsField = isset($ruleData['group']) ? $ruleData['group'] : $elementName; |
|
| 225 | 225 | list ($jsPrefix, $jsCheck) = $rule->getValidationScript($ruleData['format']); |
| 226 | 226 | if (!isset($ruleData['howmany'])) { |
| 227 | - $js = $jsValue . "\n" . $jsPrefix . |
|
| 228 | - " if (" . str_replace('{jsVar}', 'value', $jsCheck) . " && !errFlag['{$jsField}']) {\n" . |
|
| 229 | - " errFlag['{$jsField}'] = true;\n" . |
|
| 230 | - " _qfMsg = _qfMsg + '\\n - {$ruleData['message']}';\n" . |
|
| 231 | - $jsReset . |
|
| 227 | + $js = $jsValue."\n".$jsPrefix. |
|
| 228 | + " if (".str_replace('{jsVar}', 'value', $jsCheck)." && !errFlag['{$jsField}']) {\n". |
|
| 229 | + " errFlag['{$jsField}'] = true;\n". |
|
| 230 | + " _qfMsg = _qfMsg + '\\n - {$ruleData['message']}';\n". |
|
| 231 | + $jsReset. |
|
| 232 | 232 | " }\n"; |
| 233 | 233 | } else { |
| 234 | - $js = $jsValue . "\n" . $jsPrefix . |
|
| 235 | - " var res = 0;\n" . |
|
| 236 | - " for (var i = 0; i < value.length; i++) {\n" . |
|
| 237 | - " if (!(" . str_replace('{jsVar}', 'value[i]', $jsCheck) . ")) {\n" . |
|
| 238 | - " res++;\n" . |
|
| 239 | - " }\n" . |
|
| 240 | - " }\n" . |
|
| 241 | - " if (res < {$ruleData['howmany']} && !errFlag['{$jsField}']) {\n" . |
|
| 242 | - " errFlag['{$jsField}'] = true;\n" . |
|
| 243 | - " _qfMsg = _qfMsg + '\\n - {$ruleData['message']}';\n" . |
|
| 244 | - $jsReset . |
|
| 234 | + $js = $jsValue."\n".$jsPrefix. |
|
| 235 | + " var res = 0;\n". |
|
| 236 | + " for (var i = 0; i < value.length; i++) {\n". |
|
| 237 | + " if (!(".str_replace('{jsVar}', 'value[i]', $jsCheck).")) {\n". |
|
| 238 | + " res++;\n". |
|
| 239 | + " }\n". |
|
| 240 | + " }\n". |
|
| 241 | + " if (res < {$ruleData['howmany']} && !errFlag['{$jsField}']) {\n". |
|
| 242 | + " errFlag['{$jsField}'] = true;\n". |
|
| 243 | + " _qfMsg = _qfMsg + '\\n - {$ruleData['message']}';\n". |
|
| 244 | + $jsReset. |
|
| 245 | 245 | " }\n"; |
| 246 | 246 | } |
| 247 | 247 | return $js; |
@@ -262,72 +262,72 @@ discard block |
||
| 262 | 262 | */ |
| 263 | 263 | function _getJsValue(&$element, $elementName, $reset = false, $index = null) |
| 264 | 264 | { |
| 265 | - $jsIndex = isset($index)? '[' . $index . ']': ''; |
|
| 266 | - $tmp_reset = $reset? " var field = frm.elements['$elementName'];\n": ''; |
|
| 265 | + $jsIndex = isset($index) ? '['.$index.']' : ''; |
|
| 266 | + $tmp_reset = $reset ? " var field = frm.elements['$elementName'];\n" : ''; |
|
| 267 | 267 | if (is_a($element, 'html_quickform_group')) { |
| 268 | 268 | $value = " _qfGroups['{$elementName}'] = {"; |
| 269 | - $elements =& $element->getElements(); |
|
| 269 | + $elements = & $element->getElements(); |
|
| 270 | 270 | for ($i = 0, $count = count($elements); $i < $count; $i++) { |
| 271 | - $append = ($elements[$i]->getType() == 'select' && $elements[$i]->getMultiple())? '[]': ''; |
|
| 272 | - $value .= "'" . $element->getElementName($i) . $append . "': true" . |
|
| 273 | - ($i < $count - 1? ', ': ''); |
|
| 271 | + $append = ($elements[$i]->getType() == 'select' && $elements[$i]->getMultiple()) ? '[]' : ''; |
|
| 272 | + $value .= "'".$element->getElementName($i).$append."': true". |
|
| 273 | + ($i < $count - 1 ? ', ' : ''); |
|
| 274 | 274 | } |
| 275 | 275 | $value .= |
| 276 | - "};\n" . |
|
| 277 | - " value{$jsIndex} = new Array();\n" . |
|
| 278 | - " var valueIdx = 0;\n" . |
|
| 279 | - " for (var i = 0; i < frm.elements.length; i++) {\n" . |
|
| 280 | - " var _element = frm.elements[i];\n" . |
|
| 281 | - " if (_element.name in _qfGroups['{$elementName}']) {\n" . |
|
| 282 | - " switch (_element.type) {\n" . |
|
| 283 | - " case 'checkbox':\n" . |
|
| 284 | - " case 'radio':\n" . |
|
| 285 | - " if (_element.checked) {\n" . |
|
| 286 | - " value{$jsIndex}[valueIdx++] = _element.value;\n" . |
|
| 287 | - " }\n" . |
|
| 288 | - " break;\n" . |
|
| 289 | - " case 'select-one':\n" . |
|
| 290 | - " if (-1 != _element.selectedIndex) {\n" . |
|
| 291 | - " value{$jsIndex}[valueIdx++] = _element.options[_element.selectedIndex].value;\n" . |
|
| 292 | - " }\n" . |
|
| 293 | - " break;\n" . |
|
| 294 | - " case 'select-multiple':\n" . |
|
| 295 | - " var tmpVal = new Array();\n" . |
|
| 296 | - " var tmpIdx = 0;\n" . |
|
| 297 | - " for (var j = 0; j < _element.options.length; j++) {\n" . |
|
| 298 | - " if (_element.options[j].selected) {\n" . |
|
| 299 | - " tmpVal[tmpIdx++] = _element.options[j].value;\n" . |
|
| 300 | - " }\n" . |
|
| 301 | - " }\n" . |
|
| 302 | - " if (tmpIdx > 0) {\n" . |
|
| 303 | - " value{$jsIndex}[valueIdx++] = tmpVal;\n" . |
|
| 304 | - " }\n" . |
|
| 305 | - " break;\n" . |
|
| 306 | - " default:\n" . |
|
| 307 | - " value{$jsIndex}[valueIdx++] = _element.value;\n" . |
|
| 308 | - " }\n" . |
|
| 309 | - " }\n" . |
|
| 276 | + "};\n". |
|
| 277 | + " value{$jsIndex} = new Array();\n". |
|
| 278 | + " var valueIdx = 0;\n". |
|
| 279 | + " for (var i = 0; i < frm.elements.length; i++) {\n". |
|
| 280 | + " var _element = frm.elements[i];\n". |
|
| 281 | + " if (_element.name in _qfGroups['{$elementName}']) {\n". |
|
| 282 | + " switch (_element.type) {\n". |
|
| 283 | + " case 'checkbox':\n". |
|
| 284 | + " case 'radio':\n". |
|
| 285 | + " if (_element.checked) {\n". |
|
| 286 | + " value{$jsIndex}[valueIdx++] = _element.value;\n". |
|
| 287 | + " }\n". |
|
| 288 | + " break;\n". |
|
| 289 | + " case 'select-one':\n". |
|
| 290 | + " if (-1 != _element.selectedIndex) {\n". |
|
| 291 | + " value{$jsIndex}[valueIdx++] = _element.options[_element.selectedIndex].value;\n". |
|
| 292 | + " }\n". |
|
| 293 | + " break;\n". |
|
| 294 | + " case 'select-multiple':\n". |
|
| 295 | + " var tmpVal = new Array();\n". |
|
| 296 | + " var tmpIdx = 0;\n". |
|
| 297 | + " for (var j = 0; j < _element.options.length; j++) {\n". |
|
| 298 | + " if (_element.options[j].selected) {\n". |
|
| 299 | + " tmpVal[tmpIdx++] = _element.options[j].value;\n". |
|
| 300 | + " }\n". |
|
| 301 | + " }\n". |
|
| 302 | + " if (tmpIdx > 0) {\n". |
|
| 303 | + " value{$jsIndex}[valueIdx++] = tmpVal;\n". |
|
| 304 | + " }\n". |
|
| 305 | + " break;\n". |
|
| 306 | + " default:\n". |
|
| 307 | + " value{$jsIndex}[valueIdx++] = _element.value;\n". |
|
| 308 | + " }\n". |
|
| 309 | + " }\n". |
|
| 310 | 310 | " }\n"; |
| 311 | 311 | if ($reset) { |
| 312 | 312 | $tmp_reset = |
| 313 | - " for (var i = 0; i < frm.elements.length; i++) {\n" . |
|
| 314 | - " var _element = frm.elements[i];\n" . |
|
| 315 | - " if (_element.name in _qfGroups['{$elementName}']) {\n" . |
|
| 316 | - " switch (_element.type) {\n" . |
|
| 317 | - " case 'checkbox':\n" . |
|
| 318 | - " case 'radio':\n" . |
|
| 319 | - " _element.checked = _element.defaultChecked;\n" . |
|
| 320 | - " break;\n" . |
|
| 321 | - " case 'select-one':\n" . |
|
| 322 | - " case 'select-multiple':\n" . |
|
| 323 | - " for (var j = 0; j < _element.options.length; j++) {\n" . |
|
| 324 | - " _element.options[j].selected = _element.options[j].defaultSelected;\n" . |
|
| 325 | - " }\n" . |
|
| 326 | - " break;\n" . |
|
| 327 | - " default:\n" . |
|
| 328 | - " _element.value = _element.defaultValue;\n" . |
|
| 329 | - " }\n" . |
|
| 330 | - " }\n" . |
|
| 313 | + " for (var i = 0; i < frm.elements.length; i++) {\n". |
|
| 314 | + " var _element = frm.elements[i];\n". |
|
| 315 | + " if (_element.name in _qfGroups['{$elementName}']) {\n". |
|
| 316 | + " switch (_element.type) {\n". |
|
| 317 | + " case 'checkbox':\n". |
|
| 318 | + " case 'radio':\n". |
|
| 319 | + " _element.checked = _element.defaultChecked;\n". |
|
| 320 | + " break;\n". |
|
| 321 | + " case 'select-one':\n". |
|
| 322 | + " case 'select-multiple':\n". |
|
| 323 | + " for (var j = 0; j < _element.options.length; j++) {\n". |
|
| 324 | + " _element.options[j].selected = _element.options[j].defaultSelected;\n". |
|
| 325 | + " }\n". |
|
| 326 | + " break;\n". |
|
| 327 | + " default:\n". |
|
| 328 | + " _element.value = _element.defaultValue;\n". |
|
| 329 | + " }\n". |
|
| 330 | + " }\n". |
|
| 331 | 331 | " }\n"; |
| 332 | 332 | } |
| 333 | 333 | |
@@ -335,20 +335,20 @@ discard block |
||
| 335 | 335 | if ($element->getMultiple()) { |
| 336 | 336 | $elementName .= '[]'; |
| 337 | 337 | $value = |
| 338 | - " value{$jsIndex} = new Array();\n" . |
|
| 339 | - " var valueIdx = 0;\n" . |
|
| 340 | - " for (var i = 0; i < frm.elements['{$elementName}'].options.length; i++) {\n" . |
|
| 341 | - " if (frm.elements['{$elementName}'].options[i].selected) {\n" . |
|
| 342 | - " value{$jsIndex}[valueIdx++] = frm.elements['{$elementName}'].options[i].value;\n" . |
|
| 343 | - " }\n" . |
|
| 338 | + " value{$jsIndex} = new Array();\n". |
|
| 339 | + " var valueIdx = 0;\n". |
|
| 340 | + " for (var i = 0; i < frm.elements['{$elementName}'].options.length; i++) {\n". |
|
| 341 | + " if (frm.elements['{$elementName}'].options[i].selected) {\n". |
|
| 342 | + " value{$jsIndex}[valueIdx++] = frm.elements['{$elementName}'].options[i].value;\n". |
|
| 343 | + " }\n". |
|
| 344 | 344 | " }\n"; |
| 345 | 345 | } else { |
| 346 | 346 | $value = " value{$jsIndex} = frm.elements['{$elementName}'].selectedIndex == -1? '': frm.elements['{$elementName}'].options[frm.elements['{$elementName}'].selectedIndex].value;\n"; |
| 347 | 347 | } |
| 348 | 348 | if ($reset) { |
| 349 | 349 | $tmp_reset .= |
| 350 | - " for (var i = 0; i < field.options.length; i++) {\n" . |
|
| 351 | - " field.options[i].selected = field.options[i].defaultSelected;\n" . |
|
| 350 | + " for (var i = 0; i < field.options.length; i++) {\n". |
|
| 351 | + " field.options[i].selected = field.options[i].defaultSelected;\n". |
|
| 352 | 352 | " }\n"; |
| 353 | 353 | } |
| 354 | 354 | |
@@ -362,17 +362,17 @@ discard block |
||
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | } elseif ($element->getType() == 'radio') { |
| 365 | - $value = " value{$jsIndex} = '';\n" . |
|
| 365 | + $value = " value{$jsIndex} = '';\n". |
|
| 366 | 366 | // Fix for bug #5644 |
| 367 | - " var els = 'length' in frm.elements['$elementName']? frm.elements['$elementName']: [ frm.elements['$elementName'] ];\n" . |
|
| 368 | - " for (var i = 0; i < els.length; i++) {\n" . |
|
| 369 | - " if (els[i].checked) {\n" . |
|
| 370 | - " value{$jsIndex} = els[i].value;\n" . |
|
| 371 | - " }\n" . |
|
| 367 | + " var els = 'length' in frm.elements['$elementName']? frm.elements['$elementName']: [ frm.elements['$elementName'] ];\n". |
|
| 368 | + " for (var i = 0; i < els.length; i++) {\n". |
|
| 369 | + " if (els[i].checked) {\n". |
|
| 370 | + " value{$jsIndex} = els[i].value;\n". |
|
| 371 | + " }\n". |
|
| 372 | 372 | " }"; |
| 373 | 373 | if ($reset) { |
| 374 | - $tmp_reset .= " for (var i = 0; i < field.length; i++) {\n" . |
|
| 375 | - " field[i].checked = field[i].defaultChecked;\n" . |
|
| 374 | + $tmp_reset .= " for (var i = 0; i < field.length; i++) {\n". |
|
| 375 | + " field[i].checked = field[i].defaultChecked;\n". |
|
| 376 | 376 | " }"; |
| 377 | 377 | } |
| 378 | 378 | |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | * |
| 146 | 146 | * @since 1.0 |
| 147 | 147 | * @access public |
| 148 | - * @return array of selected values |
|
| 148 | + * @return string of selected values |
|
| 149 | 149 | */ |
| 150 | 150 | function getSelected() |
| 151 | 151 | { |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | /** |
| 209 | 209 | * Sets the value of the form element |
| 210 | 210 | * |
| 211 | - * @param mixed $values Array or comma delimited string of selected values |
|
| 211 | + * @param mixed $value Array or comma delimited string of selected values |
|
| 212 | 212 | * @since 1.0 |
| 213 | 213 | * @access public |
| 214 | 214 | * @return void |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | * |
| 227 | 227 | * @since 1.0 |
| 228 | 228 | * @access public |
| 229 | - * @return array of selected values |
|
| 229 | + * @return string of selected values |
|
| 230 | 230 | */ |
| 231 | 231 | function getValue() |
| 232 | 232 | { |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | * |
| 258 | 258 | * @since 1.0 |
| 259 | 259 | * @access public |
| 260 | - * @return int |
|
| 260 | + * @return string|null |
|
| 261 | 261 | */ |
| 262 | 262 | function getSize() |
| 263 | 263 | { |
@@ -357,12 +357,9 @@ discard block |
||
| 357 | 357 | /** |
| 358 | 358 | * Adds a new OPTION to the SELECT |
| 359 | 359 | * |
| 360 | - * @param string $text Display text for the OPTION |
|
| 361 | - * @param string $value Value for the OPTION |
|
| 362 | - * @param mixed $attributes Either a typical HTML attribute string |
|
| 363 | - * or an associative array |
|
| 364 | 360 | * @since 1.0 |
| 365 | 361 | * @access public |
| 362 | + * @param string $label |
|
| 366 | 363 | * @return void |
| 367 | 364 | */ |
| 368 | 365 | function addOptGroup($options, $label) |
@@ -355,16 +355,16 @@ discard block |
||
| 355 | 355 | |
| 356 | 356 | |
| 357 | 357 | /** |
| 358 | - * Adds a new OPTION to the SELECT |
|
| 359 | - * |
|
| 360 | - * @param string $text Display text for the OPTION |
|
| 361 | - * @param string $value Value for the OPTION |
|
| 362 | - * @param mixed $attributes Either a typical HTML attribute string |
|
| 363 | - * or an associative array |
|
| 364 | - * @since 1.0 |
|
| 365 | - * @access public |
|
| 366 | - * @return void |
|
| 367 | - */ |
|
| 358 | + * Adds a new OPTION to the SELECT |
|
| 359 | + * |
|
| 360 | + * @param string $text Display text for the OPTION |
|
| 361 | + * @param string $value Value for the OPTION |
|
| 362 | + * @param mixed $attributes Either a typical HTML attribute string |
|
| 363 | + * or an associative array |
|
| 364 | + * @since 1.0 |
|
| 365 | + * @access public |
|
| 366 | + * @return void |
|
| 367 | + */ |
|
| 368 | 368 | function addOptGroup($options, $label) |
| 369 | 369 | { |
| 370 | 370 | foreach ($options as $option) { |
@@ -614,10 +614,10 @@ discard block |
||
| 614 | 614 | } |
| 615 | 615 | foreach ($value as $key => $item) { |
| 616 | 616 | $html .= '<input' . $this->_getAttrString(array( |
| 617 | - 'type' => 'hidden', |
|
| 618 | - 'name' => $name, |
|
| 619 | - 'value' => $this->_values[$key] |
|
| 620 | - ) + $idAttr) . ' />'; |
|
| 617 | + 'type' => 'hidden', |
|
| 618 | + 'name' => $name, |
|
| 619 | + 'value' => $this->_values[$key] |
|
| 620 | + ) + $idAttr) . ' />'; |
|
| 621 | 621 | } |
| 622 | 622 | } |
| 623 | 623 | return $html; |
@@ -626,10 +626,10 @@ discard block |
||
| 626 | 626 | // }}} |
| 627 | 627 | // {{{ exportValue() |
| 628 | 628 | |
| 629 | - /** |
|
| 630 | - * We check the options and return only the values that _could_ have been |
|
| 631 | - * selected. We also return a scalar value if select is not "multiple" |
|
| 632 | - */ |
|
| 629 | + /** |
|
| 630 | + * We check the options and return only the values that _could_ have been |
|
| 631 | + * selected. We also return a scalar value if select is not "multiple" |
|
| 632 | + */ |
|
| 633 | 633 | function exportValue(&$submitValues, $assoc = false) |
| 634 | 634 | { |
| 635 | 635 | $value = $this->_findValue($submitValues); |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | if (!empty($attributes['class'])) { |
| 87 | 87 | $oldClass = $attributes['class']; |
| 88 | 88 | } |
| 89 | - $attributes['class'] = $oldClass . ' selectpicker show-tick form-control'; |
|
| 89 | + $attributes['class'] = $oldClass.' selectpicker show-tick form-control'; |
|
| 90 | 90 | $attributes['data-live-search'] = 'true'; |
| 91 | 91 | } |
| 92 | 92 | $columnsSize = isset($attributes['cols-size']) ? $attributes['cols-size'] : null; |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | function getPrivateName() |
| 197 | 197 | { |
| 198 | 198 | if ($this->getAttribute('multiple')) { |
| 199 | - return $this->getName() . '[]'; |
|
| 199 | + return $this->getName().'[]'; |
|
| 200 | 200 | } else { |
| 201 | 201 | return $this->getName(); |
| 202 | 202 | } |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | */ |
| 313 | 313 | function getMultiple() |
| 314 | 314 | { |
| 315 | - return (bool)$this->getAttribute('multiple'); |
|
| 315 | + return (bool) $this->getAttribute('multiple'); |
|
| 316 | 316 | } //end func getMultiple |
| 317 | 317 | |
| 318 | 318 | // }}} |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | function addOption($text, $value, $attributes = null, $return_array = false) |
| 333 | 333 | { |
| 334 | 334 | if (null === $attributes) { |
| 335 | - $attributes = array('value' => (string)$value); |
|
| 335 | + $attributes = array('value' => (string) $value); |
|
| 336 | 336 | } else { |
| 337 | 337 | $attributes = $this->_parseAttributes($attributes); |
| 338 | 338 | if (isset($attributes['selected'])) { |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | $this->_values[] = $value; |
| 345 | 345 | } |
| 346 | 346 | } |
| 347 | - $this->_updateAttrArray($attributes, array('value' => (string)$value)); |
|
| 347 | + $this->_updateAttrArray($attributes, array('value' => (string) $value)); |
|
| 348 | 348 | } |
| 349 | 349 | if ($return_array) { |
| 350 | 350 | return array('text' => $text, 'attr' => $attributes); |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | * @return PEAR_Error on error or true |
| 384 | 384 | * @throws PEAR_Error |
| 385 | 385 | */ |
| 386 | - function loadArray($arr, $values=null) |
|
| 386 | + function loadArray($arr, $values = null) |
|
| 387 | 387 | { |
| 388 | 388 | if (!is_array($arr)) { |
| 389 | 389 | return PEAR::raiseError('Argument 1 of HTML_Select::loadArray is not a valid array'); |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | * @return PEAR_Error on error or true |
| 421 | 421 | * @throws PEAR_Error |
| 422 | 422 | */ |
| 423 | - function loadDbResult(&$result, $textCol=null, $valueCol=null, $values=null) |
|
| 423 | + function loadDbResult(&$result, $textCol = null, $valueCol = null, $values = null) |
|
| 424 | 424 | { |
| 425 | 425 | if (!is_object($result) || !is_a($result, 'db_result')) { |
| 426 | 426 | return PEAR::raiseError('Argument 1 of HTML_Select::loadDbResult is not a valid DB_result'); |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | $this->setValue($values); |
| 430 | 430 | } |
| 431 | 431 | $fetchMode = ($textCol && $valueCol) ? DB_FETCHMODE_ASSOC : DB_FETCHMODE_ORDERED; |
| 432 | - while (is_array($row = $result->fetchRow($fetchMode)) ) { |
|
| 432 | + while (is_array($row = $result->fetchRow($fetchMode))) { |
|
| 433 | 433 | if ($fetchMode == DB_FETCHMODE_ASSOC) { |
| 434 | 434 | $this->addOption($row[$textCol], $row[$valueCol]); |
| 435 | 435 | } else { |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | * @return void |
| 456 | 456 | * @throws PEAR_Error |
| 457 | 457 | */ |
| 458 | - function loadQuery(&$conn, $sql, $textCol=null, $valueCol=null, $values=null) |
|
| 458 | + function loadQuery(&$conn, $sql, $textCol = null, $valueCol = null, $values = null) |
|
| 459 | 459 | { |
| 460 | 460 | if (is_string($conn)) { |
| 461 | 461 | require_once('DB.php'); |
@@ -502,7 +502,7 @@ discard block |
||
| 502 | 502 | * @return PEAR_Error on error or true |
| 503 | 503 | * @throws PEAR_Error |
| 504 | 504 | */ |
| 505 | - function load(&$options, $param1=null, $param2=null, $param3=null, $param4=null) |
|
| 505 | + function load(&$options, $param1 = null, $param2 = null, $param3 = null, $param4 = null) |
|
| 506 | 506 | { |
| 507 | 507 | switch (true) { |
| 508 | 508 | case is_array($options): |
@@ -539,32 +539,32 @@ discard block |
||
| 539 | 539 | $strHtml = ''; |
| 540 | 540 | |
| 541 | 541 | if ($this->getComment() != '') { |
| 542 | - $strHtml .= $tabs . '<!-- ' . $this->getComment() . " //-->\n"; |
|
| 542 | + $strHtml .= $tabs.'<!-- '.$this->getComment()." //-->\n"; |
|
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | if (!$this->getMultiple()) { |
| 546 | 546 | $attrString = $this->_getAttrString($this->_attributes); |
| 547 | 547 | } else { |
| 548 | 548 | $myName = $this->getName(); |
| 549 | - $this->setName($myName . '[]'); |
|
| 549 | + $this->setName($myName.'[]'); |
|
| 550 | 550 | $attrString = $this->_getAttrString($this->_attributes); |
| 551 | 551 | $this->setName($myName); |
| 552 | 552 | } |
| 553 | 553 | |
| 554 | - $strHtml .= $tabs . '<select ' . $attrString . ">\n"; |
|
| 554 | + $strHtml .= $tabs.'<select '.$attrString.">\n"; |
|
| 555 | 555 | |
| 556 | - $strValues = is_array($this->_values)? array_map('strval', $this->_values): array(); |
|
| 556 | + $strValues = is_array($this->_values) ? array_map('strval', $this->_values) : array(); |
|
| 557 | 557 | |
| 558 | 558 | foreach ($this->_options as $option) { |
| 559 | 559 | |
| 560 | 560 | if (!empty($strValues) && in_array($option['attr']['value'], $strValues, true)) { |
| 561 | 561 | $option['attr']['selected'] = 'selected'; |
| 562 | 562 | } |
| 563 | - $strHtml .= $tabs . "<option" . $this->_getAttrString($option['attr']) . '>' . |
|
| 564 | - $option['text'] . "</option>"; |
|
| 563 | + $strHtml .= $tabs."<option".$this->_getAttrString($option['attr']).'>'. |
|
| 564 | + $option['text']."</option>"; |
|
| 565 | 565 | } |
| 566 | 566 | foreach ($this->_optgroups as $optgroup) { |
| 567 | - $strHtml .= $tabs . '<optgroup label="' . $optgroup['label'] . '">'; |
|
| 567 | + $strHtml .= $tabs.'<optgroup label="'.$optgroup['label'].'">'; |
|
| 568 | 568 | foreach ($optgroup['options'] as $option) { |
| 569 | 569 | $text = $option['text']; |
| 570 | 570 | unset($option['text']); |
@@ -573,11 +573,11 @@ discard block |
||
| 573 | 573 | $option['selected'] = 'selected'; |
| 574 | 574 | } |
| 575 | 575 | |
| 576 | - $strHtml .= $tabs . " <option" . $this->_getAttrString($option) . '>' .$text . "</option>"; |
|
| 576 | + $strHtml .= $tabs." <option".$this->_getAttrString($option).'>'.$text."</option>"; |
|
| 577 | 577 | } |
| 578 | 578 | $strHtml .= "</optgroup>"; |
| 579 | 579 | } |
| 580 | - return $strHtml . $tabs . '</select>'; |
|
| 580 | + return $strHtml.$tabs.'</select>'; |
|
| 581 | 581 | } |
| 582 | 582 | } |
| 583 | 583 | |
@@ -602,22 +602,22 @@ discard block |
||
| 602 | 602 | } |
| 603 | 603 | } |
| 604 | 604 | } |
| 605 | - $html = empty($value)? ' ': join('<br />', $value); |
|
| 605 | + $html = empty($value) ? ' ' : join('<br />', $value); |
|
| 606 | 606 | if ($this->_persistantFreeze) { |
| 607 | 607 | $name = $this->getPrivateName(); |
| 608 | 608 | // Only use id attribute if doing single hidden input |
| 609 | 609 | if (1 == count($value)) { |
| 610 | 610 | $id = $this->getAttribute('id'); |
| 611 | - $idAttr = isset($id)? array('id' => $id): array(); |
|
| 611 | + $idAttr = isset($id) ? array('id' => $id) : array(); |
|
| 612 | 612 | } else { |
| 613 | 613 | $idAttr = array(); |
| 614 | 614 | } |
| 615 | 615 | foreach ($value as $key => $item) { |
| 616 | - $html .= '<input' . $this->_getAttrString(array( |
|
| 616 | + $html .= '<input'.$this->_getAttrString(array( |
|
| 617 | 617 | 'type' => 'hidden', |
| 618 | 618 | 'name' => $name, |
| 619 | 619 | 'value' => $this->_values[$key] |
| 620 | - ) + $idAttr) . ' />'; |
|
| 620 | + ) + $idAttr).' />'; |
|
| 621 | 621 | } |
| 622 | 622 | } |
| 623 | 623 | return $html; |
@@ -635,7 +635,7 @@ discard block |
||
| 635 | 635 | $value = $this->_findValue($submitValues); |
| 636 | 636 | if (is_null($value)) { |
| 637 | 637 | $value = $this->getValue(); |
| 638 | - } elseif(!is_array($value)) { |
|
| 638 | + } elseif (!is_array($value)) { |
|
| 639 | 639 | $value = array($value); |
| 640 | 640 | } |
| 641 | 641 | if (is_array($value) && !empty($this->_options)) { |