html.php.svn-base
来自「j2me is based on j2mepolish, client & se」· SVN-BASE 代码 · 共 1,235 行 · 第 1/3 页
SVN-BASE
1,235 行
* @access public */ function tableCells($data, $oddTrOptions = null, $evenTrOptions = null, $return = false) { if (empty($data[0]) || !is_array($data[0])) { $data = array($data); } static $count = 0; foreach($data as $line) { $count++; $cellsOut = array(); foreach($line as $cell) { $cellsOut[] = sprintf($this->tags['tablecell'], null, $cell); } $options = $this->parseHtmlOptions($count % 2 ? $oddTrOptions : $evenTrOptions); $out[] = sprintf($this->tags['tablerow'], $options, join(' ', $cellsOut)); } return $this->output(join("\n", $out), $return); }/** * Generates a nested unordered list tree from an array. * * @param array $data * @param array $htmlAttributes * @param string $bodyKey * @param string $childrenKey * @param boolean $return Wheter this method should return a value or output it. This overrides AUTO_OUTPUT. * @return mixed Either string or echos the value, depends on AUTO_OUTPUT and $return. If $this->_crumbs is empty, return null. * @access public */ function guiListTree($data, $htmlAttributes = array(), $bodyKey = 'body', $childrenKey = 'children', $return = false) { $out="<ul" . $this->_parseAttributes($htmlAttributes) . ">\n"; foreach($data as $item) { $out .= "<li>{$item[$bodyKey]}\n"; if (isset($item[$childrenKey]) && is_array($item[$childrenKey]) && count($item[$childrenKey])) { $out .= $this->guiListTree($item[$childrenKey], $htmlAttributes, $bodyKey, $childrenKey); } $out .= "</li>\n"; } $out .= "</ul>\n"; return $this->output($out, $return); }/** * Returns value of $fieldName. False if the tag does not exist. * * @param string $fieldName Fieldname as "Modelname/fieldname" string * @return string htmlspecialchars Value of the named tag. * @access public */ function tagValue($fieldName) { $this->setFormTag($fieldName); if (isset($this->params['data'][$this->model][$this->field])) { return h($this->params['data'][$this->model][$this->field]); } elseif(isset($this->data[$this->model][$this->field])) { return h($this->data[$this->model][$this->field]); } return false; }/** * Returns false if given FORM field has no errors. Otherwise it returns the constant set in the array Model->validationErrors. * * @param string $model Model name as string * @param string $field Fieldname as string * @return boolean True on errors. * @access public */ function tagIsInvalid($model, $field) { return empty($this->validationErrors[$model][$field]) ? 0 : $this->validationErrors[$model][$field]; }/** * Returns number of errors in a submitted FORM. * * @return int Number of errors * @access public */ function validate() { $args = func_get_args(); $errors = call_user_func_array(array(&$this, 'validateErrors'), $args); return count($errors); }/** * Validates a FORM according to the rules set up in the Model. * * @return int Number of errors * @access public */ function validateErrors() { $objects = func_get_args(); if (!count($objects)) { return false; } $errors = array(); foreach($objects as $object) { $errors = array_merge($errors, $object->invalidFields($object->data)); } return $this->validationErrors = (count($errors) ? $errors : false); }/** * Returns a formatted error message for given FORM field, NULL if no errors. * * @param string $field A field name, like "Modelname/fieldname" * @param string $text Error message * @return string If there are errors this method returns an error message, else NULL. * @access public */ function tagErrorMsg($field, $text) { $error = 1; $this->setFormTag($field); if ($error == $this->tagIsInvalid($this->model, $this->field)) { return sprintf('<div class="error_message">%s</div>', is_array($text) ? (empty($text[$error - 1]) ? 'Error in field' : $text[$error - 1]) : $text); } else { return null; } }/** * Sets this helper's model and field properties to the slash-separated value-pair in $tagValue. * * @param string $tagValue A field name, like "Modelname/fieldname" * @return * @access public */ function setFormTag($tagValue) { return list($this->model, $this->field) = explode("/", $tagValue); }/** * Returns a space-delimited string with items of the $options array. If a * key of $options array happens to be one of: * + 'compact' * + 'checked' * + 'declare' * + 'readonly' * + 'disabled' * + 'selected' * + 'defer' * + 'ismap' * + 'nohref' * + 'noshade' * + 'nowrap' * + 'multiple' * + 'noresize' * * And its value is one of: * + 1 * + true * + 'true' * * Then the value will be reset to be identical with key's name. * If the value is not one of these 3, the parameter is not output. * * @param array $options Array of options. * @param array $exclude Array of options to be excluded. * @param string $insertBefore String to be inserted before options. * @param string $insertAfter String to be inserted ater options. * @return string * @access protected */ function _parseAttributes($options, $exclude = null, $insertBefore = ' ', $insertAfter = null) { $minimizedAttributes = array('compact', 'checked', 'declare', 'readonly', 'disabled', 'selected', 'defer', 'ismap', 'nohref', 'noshade', 'nowrap', 'multiple', 'noresize'); if (!is_array($exclude)) { $exclude = array(); } if (is_array($options)) { $out = array(); foreach($options as $key => $value) { if (!in_array($key, $exclude)) { if (in_array($key, $minimizedAttributes) && ($value === 1 || $value === true || $value === 'true' || in_array($value, $minimizedAttributes))) { $value = $key; } elseif(in_array($key, $minimizedAttributes)) { continue; } $out[] = "{$key}=\"{$value}\""; } } $out = join(' ', $out); return $out ? $insertBefore . $out . $insertAfter : null; } else { return $options ? $insertBefore . $options . $insertAfter : null; } }/** * @deprecated Name changed to 'textarea'. Version 0.9.2. * @see HtmlHelper::textarea() */ function areaTag($tagName, $cols = 60, $rows = 10, $htmlAttributes = array(), $return = false) { $htmlAttributes['cols']=$cols; $htmlAttributes['rows']=$rows; return $this->textarea($tagName, $htmlAttributes, $return); }/** * @deprecated Name changed to 'charset'. Version 0.9.2. * @see HtmlHelper::charset() */ function charsetTag($charset, $return = false) { return $this->charset($charset, $return); }/** * @deprecated Name changed to 'checkbox'. Version 0.9.2. * @see HtmlHelper::checkbox() */ function checkboxTag($fieldName, $title = null, $htmlAttributes = array(), $return = false) { return $this->checkbox($fieldName, $title, $htmlAttributes, $return); }/** * @deprecated Name changed to 'css'. Version 0.9.2. * @see HtmlHelper::css() */ function cssTag($path, $rel = 'stylesheet', $htmlAttributes = array(), $return = false) { return $this->css($path, $rel, $htmlAttributes, $return); }/** * @deprecated Name changed to 'file'. Version 0.9.2. * @see HtmlHelper::file() */ function fileTag($fieldName, $htmlAttributes = array(), $return = false) { return $this->file($fieldName, $htmlAttributes, $return); }/** * @deprecated Name changed to 'hidden'. Version 0.9.2. * @see HtmlHelper::hidden() */ function hiddenTag($tagName, $value = null, $htmlOptions = null) { $this->setFormTag($tagName); $htmlOptions['value'] = $value ? $value : $this->tagValue($tagName); return $this->output(sprintf($this->tags['hidden'], $this->model, $this->field, $this->parseHtmlOptions($htmlOptions, null, '', ' '))); }/** * @deprecated Name changed to 'image'. Version 0.9.2. * @see HtmlHelper::image() */ function imageTag($path, $alt = null, $htmlAttributes = array(), $return = false) { $htmlAttributes['alt'] = $alt; return $this->image($path, $htmlAttributes, $return); }/** * @deprecated Name changed to 'input'. Version 0.9.2. * @see HtmlHelper::input() */ function inputTag($tagName, $size = 20, $htmlOptions = null) { $this->setFormTag($tagName); $htmlOptions['value'] = isset($htmlOptions['value']) ? $htmlOptions['value'] : $this->tagValue($tagName); $this->tagIsInvalid($this->model, $this->field) ? $htmlOptions['class'] = 'form_error' : null; return $this->output(sprintf($this->tags['input'], $this->model, $this->field, $this->parseHtmlOptions($htmlOptions, null, '', ' '))); }/** * @deprecated Unified with 'link'. Version 0.9.2. * @see HtmlHelper::link() */ function linkOut($title, $url = null, $htmlAttributes = array(), $escapeTitle = true, $return = false) { return $this->link($title, $url, $htmlAttributes, false, $escapeTitle, $return); }/** * @deprecated Unified with 'link'. Version 0.9.2. * @see HtmlHelper::link() */ function linkTo($title, $url, $htmlAttributes = array(), $confirmMessage = false, $escapeTitle = true, $return = false) { return $this->link($title, $url, $htmlAttributes, $confirmMessage, $escapeTitle, $return); }/** * @deprecated Name changed to '_parseAttributes'. Version 0.9.2. * @see HtmlHelper::_parseAttributes() */ function parseHtmlOptions($options, $exclude = null, $insertBefore = ' ', $insertAfter = null) { if (!is_array($exclude)) $exclude=array(); if (is_array($options)) { $out=array(); foreach($options as $k => $v) { if (!in_array($k, $exclude)) { $out[] = "{$k}=\"{$v}\""; } } $out = join(' ', $out); return $out ? $insertBefore . $out . $insertAfter : null; } else { return $options ? $insertBefore . $options . $insertAfter : null; } }/** * @deprecated Name changed to 'password'. Version 0.9.2. * @see HtmlHelper::password() */ function passwordTag($fieldName, $size = 20, $htmlAttributes = array(), $return = false) { $args = func_get_args(); return call_user_func_array(array(&$this, "password"), $args); }/** * @deprecated Name changed to 'radio'. Version 0.9.2. * @see HtmlHelper::radio() */ function radioTags($fieldName, $options, $inbetween = null, $htmlAttributes = array(), $return = false) { return $this->radio($fieldName, $options, $inbetween, $htmlAttributes, $return); }/** * @deprecated Name changed to 'url'. Version 0.9.2. * @see HtmlHelper::url() */ function urlFor($url) { return $this->url($url); }/** * @deprecated Name changed to 'submit'. Version 0.9.2. * @see HtmlHelper::submit() */ function submitTag() { $args = func_get_args(); return call_user_func_array(array(&$this, "submit"), $args); }/************************************************************************* * Moved methods *************************************************************************//** * @deprecated Moved to TextHelper. Version 0.9.2. */ function trim() { die("Method HtmlHelper::trim() was moved to TextHelper::trim()."); }/** * @deprecated Moved to JavascriptHelper. Version 0.9.2. */ function javascriptIncludeTag($url) { die("Method HtmlHelper::javascriptIncludeTag() was moved to JavascriptHelper::link()."); }/** * @deprecated Moved to JavascriptHelper. Version 0.9.2. */ function javascriptTag($script) { die("Method HtmlHelper::javascriptTag() was moved to JavascriptHelper::codeBlock()."); }/** * This is very WYSIWYG unfriendly, use HtmlHelper::url() to get contents of "action" attribute. Version 0.9.2. * @deprecated Version 0.9.2. Will not be available after 1.1.x.x * @see FormHelper::create() */ function formTag($target = null, $type = 'post', $htmlAttributes = array()) { $htmlAttributes['action']=$this->UrlFor($target); $htmlAttributes['method']=$type == 'get' ? 'get' : 'post'; $type == 'file' ? $htmlAttributes['enctype'] = 'multipart/form-data' : null; $token=''; if (isset($this->params['_Token']) && !empty($this->params['_Token'])) { $token = $this->hidden('_Token/key', array('value' => $this->params['_Token']['key']), true); } return sprintf($this->tags['form'], $this->parseHtmlOptions($htmlAttributes, null, '')) . $token; }/** * This should be done using a content filter. * @deprecated Version 0.9.2. Will not be available after 1.1.x.x */ function linkEmail($title, $email = null, $options = null) { // if no $email, then title contains the email. if (empty($email)) $email=$title; $match=array(); // does the address contain extra attributes? preg_match('!^(.*)(\?.*)$!', $email, $match); // plaintext if (empty($options['encode']) || !empty($match[2])) { return sprintf($this->tags['mailto'], $email, $this->parseHtmlOptions($options), $title); } // encoded to avoid spiders else { $email_encoded=null; for($ii = 0; $ii < strlen($email); $ii++) { if (preg_match('!\w!', $email[$ii])) { $email_encoded .= '%' . bin2hex($email[$ii]); } else { $email_encoded .= $email[$ii]; } } $title_encoded=null; for($ii = 0; $ii < strlen($title); $ii++) { $title_encoded .= preg_match('/^[A-Za-z0-9]$/', $title[$ii]) ? '&#x' . bin2hex($title[$ii]) . ';' : $title[$ii]; } return sprintf($this->tags['mailto'], $email_encoded, $this->parseHtmlOptions($options, array('encode')), $title_encoded); } }/** * @deprecated Version 0.9.2. Will not be available after 1.1.x.x */ function tag($name, $options = null, $open = false) { $tag = "<$name " . $this->parseHtmlOptions($options); $tag .= $open ? ">" : " />"; return $tag; }/** * @deprecated Version 0.9.2. Will not be available after 1.1.x.x */ function contentTag($name, $content, $options = null) { return "<$name " . $this->parseHtmlOptions($options) . ">$content</$name>"; }}?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?