adaniel         Fri Mar 23 20:36:06 2001 EDT

  Modified files:              
    /php4/pear/HTML     Table.php 
  Log:
  added comments to the html output including table nest level, added automatic 
taboffset for 
  cell contents if a subclass of html_common
  
Index: php4/pear/HTML/Table.php
diff -u php4/pear/HTML/Table.php:1.4 php4/pear/HTML/Table.php:1.5
--- php4/pear/HTML/Table.php:1.4        Thu Mar 22 18:14:05 2001
+++ php4/pear/HTML/Table.php    Fri Mar 23 20:36:06 2001
@@ -17,7 +17,7 @@
 // |          Bertrand Mansion <[EMAIL PROTECTED]>                     |
 // +----------------------------------------------------------------------+
 //
-// $Id: Table.php,v 1.4 2001/03/23 02:14:05 adaniel Exp $
+// $Id: Table.php,v 1.5 2001/03/24 04:36:06 adaniel Exp $
 
 require_once "PEAR.php";
 require_once "HTML/Common.php";
@@ -29,10 +29,6 @@
  * @author        Bertrand Mansion <[EMAIL PROTECTED]>
  * @version       1.5
  * @since         PHP 4.0.3pl1
- *
- * Example:
- *   $table = new HTML_Table;
- *   ...
  */
 class HTML_Table extends HTML_Common {
 
@@ -70,7 +66,14 @@
      * @access    private
      */
     var $_cols = 0;
-
+    
+    /**
+     * Tracks the level of nested tables
+     * @var       
+     * @since     1.5
+     * @access    private
+     */
+    var $_nestLevel = 0;
     /**
      * Class constructor
      * @param    array    $attributes        Associative array of table tag attributes
@@ -445,7 +448,13 @@
     function toHtml()
     {
         $tabs = $this->_getTabs();
-        $strHtml .= "\n" . $tabs . "<TABLE" . 
$this->_getAttrString($this->_attributes) . ">\n";
+        $strHtml =
+            "\n" . $tabs . "<!-- BEGIN TABLE LEVEL: $this->_nestLevel -->\n";
+        if ($this->_comment) {
+            $strHtml .= $tabs . "<!-- $this->_comment -->\n";
+        }
+        $strHtml .= 
+            $tabs . "<TABLE" . $this->_getAttrString($this->_attributes) . ">\n";
         if ($this->_structure["caption"]) {
             $attr = $this->_structure["caption"]["attr"];
             $contents = $this->_structure["caption"]["contents"];
@@ -466,6 +475,12 @@
                 $contents = $this->_structure[$i][$j]["contents"];
                 $strHtml .= $tabs . "\t\t<$type" . $this->_getAttrString($attr) . ">";
                 if (is_object($contents)) {
+                    if (is_subclass_of($contents, "html_common")) {
+                        $contents->setTabOffset($this->_tabOffset + 3);
+                        if (get_class($contents) == "html_table" || 
+is_subclass_of($contents, "html_table")) {
+                            $contents->_nestLevel = $this->_nestLevel + 1;
+                        }
+                    }
                     if (method_exists($contents, "toHtml")) {
                         $contents = $contents->toHtml();
                     } elseif (method_exists($contents, "toString")) {
@@ -479,7 +494,8 @@
             }
             $strHtml .= $tabs ."\t</TR>\n";
         }
-        $strHtml .= $tabs . "</TABLE>";
+        $strHtml .= 
+            $tabs . "</TABLE><!-- END TABLE LEVEL: $this->_nestLevel -->";
         return $strHtml;
     } // end func toHtml
 
@@ -514,3 +530,4 @@
 
 } // end class HTML_Table
 ?>
+



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to