squirrelmail-webmail  1.4.22
About: SquirrelMail is a standards-based webmail package with strong MIME support, address books, and folder manipulation (written in PHP4).
  Fossies Dox: squirrelmail-webmail-1.4.22.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

html.class.php
Go to the documentation of this file.
1 <?php
2 
18 class html {
21 
22  function html($tag='', $text='', $style ='', $class='', $id='',
23  $xtr_prop = '', $javascript = '') {
24  $this->tag = $tag;
25  $this->text = $text;
26  $this->style = $style;
27  $this->class = $class;
28  $this->id = $id;
29  $this->xtr_prop = $xtr_prop;
30  $this->javascript = $javascript;
31  }
32 
33  function htmlAdd($el, $last=true) {
34  if ($last) {
35  $this->html_el[] = $el;
36  } else {
37  $new_html_el = array();
38  $new_html_el[] = $el;
39  foreach ($this->html_el as $html_el) {
40  $new_html_el[] = $html_el;
41  }
42  $this->html_el = $new_html_el;
43  }
44  }
45 
46  function AddChild($tag='', $text='', $style ='', $class='', $id='',
47  $xtr_prop = '', $javascript = '') {
48  $el = new html ($tag, $text, $style, $class, $id, $xtr_prop, $javascript);
49  $this->htmlAdd($el);
50  }
51 
52  function FindId($id) {
53  $cnt = count($this->html_el);
54  $el = false;
55  if ($cnt) {
56  for ($i = 0 ; $i < $cnt; $i++) {
57  if ($this->html_el[$i]->id == $id) {
58  $ret = $this->html_el[$i];
59  return $ret;
60  } else if (count($this->html_el[$i]->html_el)) {
61  $el = $this->html_el[$i]->FindId($id);
62  }
63  if ($el) return $el;
64  }
65  }
66  return $el;
67  }
68 
69  function InsToId( $el, $id, $last=true) {
70  $html_el = &$this->FindId($id);
71  if ($html_el) {
72  $html_el->htmlAdd($el, $last);
73  }
74  }
75 
76  function scriptAdd($script) {
77  $s = "\n".'<!--'."\n".
78  $script .
79  "\n".'// -->'."\n";
80  $el = new html ('script',$s,'','','',array('language' => 'JavaScript',
81  'type' => 'text/javascript'));
82  $this->htmlAdd($el);
83  }
84 
85  function echoHtml( $usecss=false, $indent='x') {
86  if ($indent == 'x') {
87  $indent = ''; $indentmore = '';
88  } else {
89  $indentmore = $indent . ' ';
90  }
91  $tag = $this->tag;
94  $id = $this->id;
98  if ($xtr_prop) {
99  $prop = '';
100  foreach ($xtr_prop as $k => $v) {
101  if (is_string($k)) {
102  $prop.=' '.$k.'="'.$v.'"';
103  } else {
104  $prop.=' '.$v;
105  }
106  }
107  }
108  if ($javascript) {
109  $js = '';
110  foreach ($javascript as $k => $v) { /* here we put the onclick, onmouseover etc entries */
111  $js.=' '.$k.'="'.$v.'";';
112  }
113  }
114  if ($tag) {
115  echo $indent . '<' . $tag;
116  } else {
117  echo $indent;
118  }
119  if ($class) {
120  echo ' class="'.$class.'"';
121  }
122  if ($id) {
123  echo ' id="'.$id.'"';
124  }
125  if ($xtr_prop) {
126  echo ' '.$prop;
127  }
128  if ($style && !$usecss && !is_array($style)) {
129  /* last premisse is to prevent 'style="Array"' in the output */
130  echo ' style="'.$style.'"';
131  }
132  if ($javascript) {
133  echo ' '.$js;
134  }
135  if ($tag) echo '>';
136 
137  $openstyles = '';
138  $closestyles = '';
139  if ($style && !$usecss) {
140  foreach ($style as $k => $v) {
141  $openstyles .= '<'.$k.'>';
142  }
143  foreach ($style as $k => $v) {
144  /* if value of key value = true close the tag */
145  if ($v) {
146  $closestyles .= '</'.$k.'>';
147  }
148  }
149  }
150  echo $openstyles;
151 
152  if ($text) {
153  echo $text;
154  }
155 
156  $cnt = count($this->html_el);
157  if ($cnt) {
158  echo "\n";
159  for($i = 0;$i<$cnt;$i++) {
160  $el = $this->html_el[$i];
161  $el->echoHtml($usecss,$indentmore);
162  }
163  echo $indent;
164  }
165  echo $closestyles;
166  if ($tag) {
167  echo '</'.$tag.'>'."\n";
168  } else {
169  echo "\n";
170  }
171  }
172 }
173 
$ret
$ret
Definition: webmail.php:172
$cnt
$cnt
Definition: options_identities.php:86
html\htmlAdd
htmlAdd($el, $last=true)
Definition: html.class.php:33
html\$javascript
$javascript
Definition: html.class.php:20
html\scriptAdd
scriptAdd($script)
Definition: html.class.php:76
html
Definition: html.class.php:18
html\$html_el
$html_el
Definition: html.class.php:20
html\echoHtml
echoHtml( $usecss=false, $indent='x')
Definition: html.class.php:85
html\$xtr_prop
$xtr_prop
Definition: html.class.php:20
html\$id
$id
Definition: html.class.php:19
html\AddChild
AddChild($tag='', $text='', $style='', $class='', $id='', $xtr_prop='', $javascript='')
Definition: html.class.php:46
html\FindId
FindId($id)
Definition: html.class.php:52
html\$tag
$tag
Definition: html.class.php:19
html\html
html($tag='', $text='', $style='', $class='', $id='', $xtr_prop='', $javascript='')
Definition: html.class.php:22
html\$text
$text
Definition: html.class.php:19
html\InsToId
InsToId( $el, $id, $last=true)
Definition: html.class.php:69
html\$style
$style
Definition: html.class.php:19
html\$class
$class
Definition: html.class.php:19