summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUrban Müller2010-09-20 14:05:57 +0000
committerUrban Müller2010-09-20 14:05:57 +0000
commitf0969501a889abc254fdc7c8323f63053761fff3 (patch)
treedf6aef01c03589ca1e94cf3d16efc448fd927cbb
parent95874fae89a13d546be7374e955e6552abc87bb5 (diff)
downloaditools-f0969501a889abc254fdc7c8323f63053761fff3.tar.gz
itools-f0969501a889abc254fdc7c8323f63053761fff3.tar.bz2
itools-f0969501a889abc254fdc7c8323f63053761fff3.zip
it_html speedup
-rw-r--r--it_html.class36
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", "&#10;", 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);