diff options
author | Urban Müller | 2010-09-20 14:05:57 +0000 |
---|---|---|
committer | Urban Müller | 2010-09-20 14:05:57 +0000 |
commit | f0969501a889abc254fdc7c8323f63053761fff3 (patch) | |
tree | df6aef01c03589ca1e94cf3d16efc448fd927cbb /it_html.class | |
parent | 95874fae89a13d546be7374e955e6552abc87bb5 (diff) | |
download | itools-f0969501a889abc254fdc7c8323f63053761fff3.tar.gz itools-f0969501a889abc254fdc7c8323f63053761fff3.tar.bz2 itools-f0969501a889abc254fdc7c8323f63053761fff3.zip |
it_html speedup
Diffstat (limited to 'it_html.class')
-rw-r--r-- | it_html.class | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/it_html.class b/it_html.class index be13fe4..4c1fbae 100644 --- a/it_html.class +++ b/it_html.class @@ -72,7 +72,15 @@ function it_html($p = array()) foreach (array_merge(explode(',', $this->p['tags']), explode(',', $this->p['moretags'])) as $func) { if (!function_exists($func) && $func) - $code[$func] = "function $func() { \$args = func_get_args(); return \$GLOBALS['{$this->p['name']}']->_tag('$func', \$args); }"; + { + if (!$this->p['prettyprint'] && $this->p['charset'] == "iso-8859-1" && $this->p['htmltype'] == "html" && !$GLOBALS['debug_srclines']) + { + $emptycloser = preg_match('/^(a|div|iframe|pre|script|span|td|textarea)$/i', $func) ? "</$func>" : ""; + $code[$func] = "function $func() { \$args = func_get_args(); return \$GLOBALS['{$this->p['name']}']->_tag_fast('$func', \$args, '$emptycloser'); }"; + } + else + $code[$func] = "function $func() { \$args = func_get_args(); return \$GLOBALS['{$this->p['name']}']->_tag('$func', \$args); }"; + } } # Create global functions for it_html methods @@ -250,6 +258,32 @@ function _parse_args($args) /** * INTERNAL: Create html tag from name and args array (the arguments of the parent function) */ +function _tag_fast($name, $args, $emptycloser) +{ + foreach ($args as $arg) + { + if (is_array($arg)) + { + foreach ($arg as $key => $value) + { + if (is_string($value)) + { + if (preg_match('/[<>&"\x00-\x08\x0a-\x0c\x0e-\x1f\x80-\x9f]/', $value)) # WARNING: copy/pasted from Q() + $attrs .= " $key=\"" . str_replace("\n", " ", it_html::latinize($value)) . '"'; + else + $attrs .= " $key=\"$value\""; + } + else if ($value === true) + $attrs .= " $key"; + } + } + else + $content .= $arg; + } + + return isset($content) ? "<$name$attrs>$content</$name>" : "<$name$attrs>$content$emptycloser"; +} + function _tag($name, $args) { list($data, $attr) = $this->_parse_args($args); |