📄 itstatic.php
字号:
} $this->_tpl->setVariable($varName.'_html', $html); } } // end func renderElement /** * Called when visiting a hidden element * * @param object An HTML_QuickForm_hidden object being visited * @access public * @return void */ function renderHidden(&$element) { if ($this->_tpl->placeholderExists($this->_formName . '_hidden')) { $this->_hidden .= $element->toHtml(); } else { $name = $element->getName(); $name = str_replace(array('[', ']'), array('_', ''), $name); $this->_tpl->setVariable($this->_formName.'_'.$name.'_html', $element->toHtml()); } } // end func renderHidden /** * Called when visiting a group, before processing any group elements * * @param object An HTML_QuickForm_group object being visited * @param bool Whether a group is required * @param string An error message associated with a group * @access public * @return void */ function startGroup(&$group, $required, $error) { $name = $group->getName(); $varName = $this->_formName.'_'.$name; $this->_elementIndex = 0; $html = $this->_tpl->placeholderExists($varName.'_html') ? $group->toHtml() : ''; $label = $group->getLabel(); if ($required) { $this->_renderRequired($label, $html); } if (!empty($error)) { $this->_renderError($label, $html, $error); } if (!empty($html)) { $this->_tpl->setVariable($varName.'_html', $html); } else { // Uses error blocks to set the special groups layout error // <!-- BEGIN form_group_error -->{form_group_error}<!-- END form_group_error --> if (!empty($error)) { if ($this->_tpl->placeholderExists($varName.'_error')) { if ($this->_tpl->blockExists($this->_formName . '_error_block')) { $this->_tpl->setVariable($this->_formName . '_error', $error); $error = $this->_getTplBlock($this->_formName . '_error_block'); } elseif (strpos($this->_error, '{html}') !== false || strpos($this->_error, '{label}') !== false) { $error = str_replace('{error}', $error, $this->_error); } } $this->_tpl->setVariable($varName . '_error', $error); array_pop($this->_errors); } } if (is_array($label)) { foreach ($label as $key => $value) { $this->_tpl->setVariable($varName.'_label_'.$key, $value); } } else { $this->_tpl->setVariable($varName.'_label', $label); } $this->_inGroup = $varName; } // end func startGroup /** * Called when visiting a group, after processing all group elements * * @param object An HTML_QuickForm_group object being visited * @access public * @return void */ function finishGroup(&$group) { $this->_inGroup = ''; } // end func finishGroup /** * Sets the way required elements are rendered * * You can use {label} or {html} placeholders to let the renderer know where * where the element label or the element html are positionned according to the * required tag. They will be replaced accordingly with the right value. * For example: * <font color="red">*</font>{label} * will put a red star in front of the label if the element is required. * * @param string The required element template * @access public * @return void */ function setRequiredTemplate($template) { $this->_required = $template; } // end func setRequiredTemplate /** * Sets the way elements with validation errors are rendered * * You can use {label} or {html} placeholders to let the renderer know where * where the element label or the element html are positionned according to the * error message. They will be replaced accordingly with the right value. * The error message will replace the {error} place holder. * For example: * <font color="red">{error}</font><br />{html} * will put the error message in red on top of the element html. * * If you want all error messages to be output in the main error block, do not specify * {html} nor {label}. * * Groups can have special layouts. With this kind of groups, the renderer will need * to know where to place the error message. In this case, use error blocks like: * <!-- BEGIN form_group_error -->{form_group_error}<!-- END form_group_error --> * where you want the error message to appear in the form. * * @param string The element error template * @access public * @return void */ function setErrorTemplate($template) { $this->_error = $template; } // end func setErrorTemplate /** * Called when an element is required * * This method will add the required tag to the element label and/or the element html * such as defined with the method setRequiredTemplate * * @param string The element label * @param string The element html rendering * @see setRequiredTemplate() * @access private * @return void */ function _renderRequired(&$label, &$html) { if ($this->_tpl->blockExists($tplBlock = $this->_formName . '_required_block')) { if (!empty($label) && $this->_tpl->placeholderExists($this->_formName . '_label', $tplBlock)) { $this->_tpl->setVariable($this->_formName . '_label', is_array($label)? $label[0]: $label); if (is_array($label)) { $label[0] = $this->_getTplBlock($tplBlock); } else { $label = $this->_getTplBlock($tplBlock); } } if (!empty($html) && $this->_tpl->placeholderExists($this->_formName . '_html', $tplBlock)) { $this->_tpl->setVariable($this->_formName . '_html', $html); $html = $this->_getTplBlock($tplBlock); } } else { if (!empty($label) && strpos($this->_required, '{label}') !== false) { if (is_array($label)) { $label[0] = str_replace('{label}', $label[0], $this->_required); } else { $label = str_replace('{label}', $label, $this->_required); } } if (!empty($html) && strpos($this->_required, '{html}') !== false) { $html = str_replace('{html}', $html, $this->_required); } } } // end func _renderRequired /** * Called when an element has a validation error * * This method will add the error message to the element label or the element html * such as defined with the method setErrorTemplate. If the error placeholder is not found * in the template, the error will be displayed in the form error block. * * @param string The element label * @param string The element html rendering * @param string The element error * @see setErrorTemplate() * @access private * @return void */ function _renderError(&$label, &$html, $error) { if ($this->_tpl->blockExists($tplBlock = $this->_formName . '_error_block')) { $this->_tpl->setVariable($this->_formName . '_error', $error); if (!empty($label) && $this->_tpl->placeholderExists($this->_formName . '_label', $tplBlock)) { $this->_tpl->setVariable($this->_formName . '_label', is_array($label)? $label[0]: $label); if (is_array($label)) { $label[0] = $this->_getTplBlock($tplBlock); } else { $label = $this->_getTplBlock($tplBlock); } } elseif (!empty($html) && $this->_tpl->placeholderExists($this->_formName . '_html', $tplBlock)) { $this->_tpl->setVariable($this->_formName . '_html', $html); $html = $this->_getTplBlock($tplBlock); } // clean up after ourselves $this->_tpl->setVariable($this->_formName . '_error', null); } elseif (!empty($label) && strpos($this->_error, '{label}') !== false) { if (is_array($label)) { $label[0] = str_replace(array('{label}', '{error}'), array($label[0], $error), $this->_error); } else { $label = str_replace(array('{label}', '{error}'), array($label, $error), $this->_error); } } elseif (!empty($html) && strpos($this->_error, '{html}') !== false) { $html = str_replace(array('{html}', '{error}'), array($html, $error), $this->_error); } else { $this->_errors[] = $error; } }// end func _renderError /** * Returns the block's contents * * The method is needed because ITX and Sigma implement clearing * the block contents on get() a bit differently * * @param string Block name * @return string Block contents */ function _getTplBlock($block) { $this->_tpl->parse($block); if (is_a($this->_tpl, 'html_template_sigma')) { $ret = $this->_tpl->get($block, true); } else { $oldClear = $this->_tpl->clearCache; $this->_tpl->clearCache = true; $ret = $this->_tpl->get($block); $this->_tpl->clearCache = $oldClear; } return $ret; }} // end class HTML_QuickForm_Renderer_ITStatic?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -