Added index in class dir to avoid unwanted directory listing. Minor
[squirrelmail.git] / class / html.class
index 80ab1aa3df3fa34473d4e4d277921c635d013990..dcdb805bce4afba897da68643f51f66156a5a9b5 100644 (file)
@@ -5,7 +5,6 @@
  * 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$
@@ -80,7 +79,12 @@ class html {
      $this->htmlAdd($el);
   }
   
-  function echoHtml( $usecss=false, $indent='') {
+  function echoHtml( $usecss=false, $indent='x') {
+    if ($indent == 'x') {
+      $indent = ''; $indentmore = '';
+    } else {
+      $indentmore = $indent . '  ';
+    }
     $tag = $this->tag;
     $text = $this->text;
     $class = $this->class;
@@ -118,49 +122,44 @@ class html {
     if ($xtr_prop) {
        echo ' '.$prop;
     }
-    if ($style && !$usecss) {
+    if ($style && !$usecss && !is_array($style)) {
+       /* last premisse is to prevent 'style="Array"' in the output */
        echo ' style="'.$style.'"';  
     }
     if ($javascript) {
        echo ' '.$js;
     }
     if ($tag) 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;
+
+    $openstyles = '';
+    $closestyles = '';
+    if ($style && !$usecss) {
+       foreach ($style as $k => $v) {
+          $openstyles .= '<'.$k.'>';
+       }
+       foreach ($style as $k => $v) {
+          /* if value of key value = true close the tag */
+         if ($v) {
+             $closestyles .= '</'.$k.'>';
+          }   
        }
     }
+    echo $openstyles;
+
+    if ($text) {
+       echo $text;
+    }
+
     $cnt = count($this->html_el);
     if ($cnt) {
-       if ($style && !$usecss) {
-          foreach ($style as $k => $v) {
-            echo '<'.$k.'>';
-         }
-       }
        echo "\n";
-       $indent.='  ';
        for($i = 0;$i<$cnt;$i++) {
           $el = $this->html_el[$i];
-         $el->echoHtml($usecss,$indent);
-       }
-       if ($style && !$usecss) {       
-          foreach ($style as $k => $v) { /* if value of key value = true close the tag */
-           if ($v) {
-               echo '</'.$v.'>';
-           }   
-         }
+         $el->echoHtml($usecss,$indentmore);
        }
+       echo $indent;
     }
+    echo $closestyles;
     if ($tag) {
        echo '</'.$tag.'>'."\n";
     } else {