Replacing tabs with spaces
[squirrelmail.git] / class / html.class.php
index 3e5ed1cd24ad3c9c604377e3b90d53d0e0dad756..5a6ac650443b97c5a7a2d9866acfa004e4c5220b 100644 (file)
@@ -2,16 +2,21 @@
 /**
  * html.class.php
  *
- * Copyright (c) 2002 The SquirrelMail Project Team
+ * Copyright (c) 2003-2005 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$
+ * @version $Id$
+ * @package squirrelmail
  */
 
+/**
+ * This class needs documenting - volunteers?
+ * @package squirrelmail
+ */
 class html {
-  var $tag, $text, $style, $class,  
+  var $tag, $text, $style, $class,
       $id, $html_el = array(), $javascript, $xtr_prop;
 
   function html($tag='', $text='', $style ='', $class='', $id='',
@@ -24,59 +29,59 @@ class html {
      $this->xtr_prop = $xtr_prop;
      $this->javascript = $javascript;
   }
-  
+
   function htmlAdd($el, $last=true) {
      if ($last) {
         $this->html_el[] = $el;
      } else {
-       $new_html_el = array();
-       $new_html_el[] = $el;
-       foreach ($this->html_el as $html_el) {
-          $new_html_el[] = $html_el;
-       }
-       $this->html_el = $new_html_el;
+         $new_html_el = array();
+         $new_html_el[] = $el;
+         foreach ($this->html_el as $html_el) {
+             $new_html_el[] = $html_el;
+         }
+         $this->html_el = $new_html_el;
      }
   }
-  
+
   function AddChild($tag='', $text='', $style ='', $class='', $id='',
                   $xtr_prop = '', $javascript = '') {
      $el = new html ($tag, $text, $style, $class, $id, $xtr_prop, $javascript);
      $this->htmlAdd($el);
   }
-  
+
   function FindId($id) {
      $cnt = count($this->html_el);
      $el = false;
      if ($cnt) {
         for ($i = 0 ; $i < $cnt; $i++) {
-           if ($this->html_el[$i]->id == $id) {
-              $ret = $this->html_el[$i];
-              return $ret;
-           } else if (count($this->html_el[$i]->html_el)) {
-              $el = $this->html_el[$i]->FindId($id);
-           }
-           if ($el) return $el;
+            if ($this->html_el[$i]->id == $id) {
+                $ret = $this->html_el[$i];
+                return $ret;
+            } else if (count($this->html_el[$i]->html_el)) {
+                $el = $this->html_el[$i]->FindId($id);
+            }
+            if ($el) return $el;
         }
      }
      return $el;
-  }     
+  }
 
   function InsToId( $el, $id, $last=true) {
      $html_el = &$this->FindId($id);
      if ($html_el) {
         $html_el->htmlAdd($el, $last);
      }
-  }     
-  
+  }
+
   function scriptAdd($script) {
      $s = "\n".'<!--'."\n".
-         $script .
-         "\n".'// -->'."\n";
+         $script .
+         "\n".'// -->'."\n";
      $el = new html ('script',$s,'','','',array('language' => 'JavaScript',
                                                 'type' => 'text/javascript'));
      $this->htmlAdd($el);
   }
-  
+
   function echoHtml( $usecss=false, $indent='x') {
     if ($indent == 'x') {
       $indent = ''; $indentmore = '';
@@ -94,26 +99,26 @@ class html {
        $prop = '';
        foreach ($xtr_prop as $k => $v) {
           if (is_string($k)) {
-             $prop.=' '.$k.'="'.$v.'"';
-         } else {
-            $prop.=' '.$v;
-         }
+              $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.'";';
        }
     }
-    if ($tag) {          
+    if ($tag) {
        echo $indent . '<' . $tag;
     } else {
        echo $indent;
     }
     if ($class) {
        echo ' class="'.$class.'"';
-    }  
+    }
     if ($id) {
        echo ' id="'.$id.'"';
     }
@@ -122,7 +127,7 @@ class html {
     }
     if ($style && !$usecss && !is_array($style)) {
        /* last premisse is to prevent 'style="Array"' in the output */
-       echo ' style="'.$style.'"';  
+       echo ' style="'.$style.'"';
     }
     if ($javascript) {
        echo ' '.$js;
@@ -137,9 +142,9 @@ class html {
        }
        foreach ($style as $k => $v) {
           /* if value of key value = true close the tag */
-         if ($v) {
+          if ($v) {
              $closestyles .= '</'.$k.'>';
-          }   
+          }
        }
     }
     echo $openstyles;
@@ -153,7 +158,7 @@ class html {
        echo "\n";
        for($i = 0;$i<$cnt;$i++) {
           $el = $this->html_el[$i];
-         $el->echoHtml($usecss,$indentmore);
+          $el->echoHtml($usecss,$indentmore);
        }
        echo $indent;
     }
@@ -165,6 +170,6 @@ class html {
     }
   }
 }
 
-?>
+
+?>
\ No newline at end of file