cfa5af420e9d6f8c7664a99af26a63a51133bcec
5 * Copyright (c) 2003-2004 The SquirrelMail Project Team
6 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 * This contains functions needed to generate html output.
11 * @package squirrelmail
15 * This class needs documenting - volunteers?
16 * @package squirrelmail
19 var $tag, $text, $style, $class,
20 $id, $html_el = array(), $javascript, $xtr_prop;
22 function html($tag='', $text='', $style ='', $class='', $id='',
23 $xtr_prop = '', $javascript = '') {
26 $this->style
= $style;
27 $this->class = $class;
29 $this->xtr_prop
= $xtr_prop;
30 $this->javascript
= $javascript;
33 function htmlAdd($el, $last=true) {
35 $this->html_el
[] = $el;
37 $new_html_el = array();
39 foreach ($this->html_el
as $html_el) {
40 $new_html_el[] = $html_el;
42 $this->html_el
= $new_html_el;
46 function AddChild($tag='', $text='', $style ='', $class='', $id='',
47 $xtr_prop = '', $javascript = '') {
48 $el = new html ($tag, $text, $style, $class, $id, $xtr_prop, $javascript);
52 function FindId($id) {
53 $cnt = count($this->html_el
);
56 for ($i = 0 ; $i < $cnt; $i++
) {
57 if ($this->html_el
[$i]->id
== $id) {
58 $ret = $this->html_el
[$i];
60 } else if (count($this->html_el
[$i]->html_el
)) {
61 $el = $this->html_el
[$i]->FindId($id);
69 function InsToId( $el, $id, $last=true) {
70 $html_el = &$this->FindId($id);
72 $html_el->htmlAdd($el, $last);
76 function scriptAdd($script) {
77 $s = "\n".'<!--'."\n".
80 $el = new html ('script',$s,'','','',array('language' => 'JavaScript',
81 'type' => 'text/javascript'));
85 function echoHtml( $usecss=false, $indent='x') {
87 $indent = ''; $indentmore = '';
89 $indentmore = $indent . ' ';
93 $class = $this->class;
95 $style = $this->style
;
96 $javascript = $this->javascript
;
97 $xtr_prop = $this->xtr_prop
;
100 foreach ($xtr_prop as $k => $v) {
102 $prop.=' '.$k.'="'.$v.'"';
110 foreach ($javascript as $k => $v) { /* here we put the onclick, onmouseover etc entries */
111 $js.=' '.$k.'="'.$v.'";';
115 echo $indent . '<' . $tag;
120 echo ' class="'.$class.'"';
123 echo ' id="'.$id.'"';
128 if ($style && !$usecss && !is_array($style)) {
129 /* last premisse is to prevent 'style="Array"' in the output */
130 echo ' style="'.$style.'"';
139 if ($style && !$usecss) {
140 foreach ($style as $k => $v) {
141 $openstyles .= '<'.$k.'>';
143 foreach ($style as $k => $v) {
144 /* if value of key value = true close the tag */
146 $closestyles .= '</'.$k.'>';
156 $cnt = count($this->html_el
);
159 for($i = 0;$i<$cnt;$i++
) {
160 $el = $this->html_el
[$i];
161 $el->echoHtml($usecss,$indentmore);
167 echo '</'.$tag.'>'."\n";