class file for storing/handling html-structures. If we use this class to
authorstekkel <stekkel@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 9 Jul 2002 22:51:28 +0000 (22:51 +0000)
committerstekkel <stekkel@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 9 Jul 2002 22:51:28 +0000 (22:51 +0000)
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 [new file with mode: 0644]

diff --git a/class/html.class b/class/html.class
new file mode 100644 (file)
index 0000000..f44e66e
--- /dev/null
@@ -0,0 +1,106 @@
+<?php
+/**
+ * html.class
+ *
+ * Copyright (c) 2002 The SquirrelMail Project Team
+ * Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ *
+ * This contains functions needed to generate html output.
+ *
+ * $Id$
+ */
+
+
+class html {
+  var $tag, $text, $style, $class,  
+      $id, $html_el = array(), $javascript, $xtr_prop;
+
+  function html($tag='', $text='', $style ='', $class='', $id='',
+                  $xtr_prop = '', $javascript = '') {
+     $this->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 '</'.$v.'>';
+           }   
+         }
+       } 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 '</'.$tag.'>'."\n";
+  }
+}
+
+?>