From 53ef1f992a81acdba1007531315e7e13d1ba0973 Mon Sep 17 00:00:00 2001 From: stekkel Date: Tue, 9 Jul 2002 22:51:28 +0000 Subject: [PATCH] class file for storing/handling html-structures. If we use this class to store our html objects (tables etc) then we can easy make use of css with full support of the non-css browsers. Also very usefull for future templates. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@3081 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- class/html.class | 106 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 class/html.class diff --git a/class/html.class b/class/html.class new file mode 100644 index 00000000..f44e66ee --- /dev/null +++ b/class/html.class @@ -0,0 +1,106 @@ +tag = $tag; + $this->text = $text; + $this->style = $style; + $this->class = $class; + $this->id = $id; + $this->xtr_prop = $xtr_prop; + $this->javascript = $javascript; + } + + function htmlAdd($el) { + $this->html_el[] = $el; + } + + + function echoHtml( $usecss=false, $indent='') { + $tag = $this->tag; + $text = $this->text; + $class = $this->class; + $id = $this->id; + $style = $this->style; + $javascript = $this->javascript; + $xtr_prop = $this->xtr_prop; + if ($xtr_prop) { + $prop = ''; + foreach ($xtr_prop as $k => $v) { + if (is_string($k)) { + $prop.=' '.$k.'="'.$v.'"'; + } else { + $prop.=' '.$v; + } + } + } + if ($javascript) { + $js = ''; + foreach ($javascript as $k => $v) { /* here we put the onclick, onmouseover etc entries */ + $js.=' '.$k.'="'.$v.'";'; + } + } + + echo $indent . '<' . $tag; + if ($class) { + echo ' class="'.$class.'"'; + } + if ($id) { + echo ' id="'.$id.'"'; + } + if ($xtr_prop) { + echo ' '.$prop; + } + if ($style && !$usecss) { + echo ' style="'.$style.'"'; + } + if ($javascript) { + echo ' '.$js; + } + echo '>'; + if ($text) { + if ($style && !$usecss) { /* if use css then fallback to stylesheet for layout */ + foreach ($style as $k => $v) { + echo '<'.$k.'>'; + } + echo $text; + foreach ($style as $k => $v) { /* if value of key value = true close the tag */ + if ($v) { + echo ''; + } + } + } else { + echo $text; + } + } + $cnt = count($this->html_el); + if ($cnt) { + echo "\n"; + $indent.=' '; + for($i = 0;$i<$cnt;$i++) { + $el = $this->html_el[$i]; + $el->echoHtml($usecss,$indent); + } + } + echo ''."\n"; + } +} + + +?> -- 2.25.1