5 * Copyright (c) 2002 The SquirrelMail Project Team
6 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * This contains functions needed to generate html output.
16 var $tag, $text, $style, $class,
17 $id, $html_el = array(), $javascript, $xtr_prop;
19 function html($tag='', $text='', $style ='', $class='', $id='',
20 $xtr_prop = '', $javascript = '') {
23 $this->style = $style;
24 $this->class = $class;
26 $this->xtr_prop = $xtr_prop;
27 $this->javascript = $javascript;
30 function htmlAdd($el, $last=true) {
32 $this->html_el[] = $el;
35 $new_html_el = array();
37 foreach ($this->html_el as $html_el) {
38 $new_html_el[] = $html_el;
40 $this->html_el = $new_html_el;
44 function AddChild($tag='', $text='', $style ='', $class='', $id='',
45 $xtr_prop = '', $javascript = '') {
46 $el = new html ($tag, $text, $style, $class, $id, $xtr_prop, $javascript);
50 function FindId($id) {
51 $cnt = count($this->html_el);
54 for ($i = 0 ; $i < $cnt; $i++) {
55 if ($this->html_el[$i]->id == $id) {
56 $ret = $this->html_el[$i];
58 } else if (count($this->html_el[$i]->html_el)) {
59 $el = $this->html_el[$i]->FindId($id);
67 function InsToId( $el, $id, $last=true) {
68 $html_el = &$this->FindId($id);
70 $html_el->htmlAdd($el, $last);
74 function scriptAdd($script) {
75 $s = "\n".'<!--'."\n".
78 $el = new html ('script',$s,''.''.''.array('language' => 'JavaScript',
79 'type' => 'text/javascript'));
83 function echoHtml( $usecss=false, $indent='') {
86 $class = $this->class;
88 $style = $this->style;
89 $javascript = $this->javascript;
90 $xtr_prop = $this->xtr_prop;
93 foreach ($xtr_prop as $k => $v) {
95 $prop.=' '.$k.'="'.$v.'"';
103 foreach ($javascript as $k => $v) { /* here we put the onclick, onmouseover etc entries */
104 $js.=' '.$k.'="'.$v.'";';
108 echo $indent . '<' . $tag;
113 echo ' class="'.$class.'"';
116 echo ' id="'.$id.'"';
121 if ($style && !$usecss) {
122 echo ' style="'.$style.'"';
129 if ($style && !$usecss) { /* if use css then fallback to stylesheet for layout */
130 foreach ($style as $k => $v) {
134 foreach ($style as $k => $v) { /* if value of key value = true close the tag */
143 $cnt = count($this->html_el);
145 if ($style && !$usecss) {
146 foreach ($style as $k => $v) {
152 for($i = 0;$i<$cnt;$i++) {
153 $el = $this->html_el[$i];
154 $el->echoHtml($usecss,$indent);
156 if ($style && !$usecss) {
157 foreach ($style as $k => $v) { /* if value of key value = true close the tag */
165 echo '</'.$tag.'>'."\n";