File:  [Local Repository] / db / prgsrc / drupal / modules / chgk_db / classes / DbTreePrinter.php
Revision 1.1: download - view: text, annotated - select for diffs - revision graph
Sat Apr 24 21:45:51 2010 UTC (14 years, 2 months ago) by roma7
Branches: MAIN
CVS tags: HEAD
Version 2 big update

    1: <?php
    2: /// UNUSED!
    3: class DbTreePrinter {
    4:     private $package = FALSE;
    5:     private $level = 0;
    6:     private $html = '';
    7: 
    8:     public function __construct($package, $level = 0) {
    9:         $this->package = $package;
   10:         $this->level = $level;
   11:     }
   12: 
   13:     private function addString($string) {
   14:         $this->html .= $string;
   15:     }
   16: 
   17:     private function addSpacesToChildrenHtml($count) {
   18:         $this->childrenHtml.=str_repeat(' ',$this->level*4+$count*2);
   19:     }
   20: 
   21:     private function getChildrenHtml() {
   22:       $result = '';
   23:       foreach ($this->package->getChildren() as $child)  {
   24:           $this->addSpacesToChildrenHtml(2);
   25:           $this->addToChildrenHtml(
   26:                   "<li>".$child->htmlTree($level+1)."</li>"
   27:           );
   28:           $this->addNewLineToChildrenHtml();
   29:       }
   30:     }
   31: 
   32:     private function addNewLineToChildrenHtml() {
   33:         $this->childrenHtml.="\n";
   34:     }
   35:     public function getHtml() {
   36:       if ($this->html) {
   37:           return $html;
   38:       }
   39:       $this->html = '';
   40:       $this->addString($this->package->getHtmlLinkForList());
   41:       $childrenHtml = $this->getChildrenHtml();
   42:       if ($children_html) {
   43:           if (!self::NOSPACES) {
   44:               $result.="\n".str_repeat(' ',$level*4+2);
   45:           }
   46:           $result.="<ul>";
   47:           if (!self::NOSPACES) {
   48:               $result.="\n";
   49:           }
   50:           $result.=$children_html;
   51:           if (!self::NOSPACES) {
   52:             $result .= str_repeat(' ',$level*4+2);
   53:           }
   54:           $result.="</ul>";
   55:           if (!self::NOSPACES) {
   56:             $result.="\n".str_repeat(' ',$level*4);
   57:           }
   58:       }
   59:       return $result;
   60:   }
   61: 
   62:     }
   63: }
   64: 
   65: ?>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>