Changeset 84 for www/is/topologie-gen.php
- Timestamp:
- Jun 23, 2008, 6:22:04 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
www/is/topologie-gen.php
r83 r84 60 60 /** Maximální šířka hranice */ 61 61 var $maxborder = 0; 62 /** Mód provedených operací */ 63 var $mode = 0; 62 64 63 65 /** Vytvoří stromovou strukturu načtením záznamů z databáze */ … … 106 108 } 107 109 110 function calc_pos($node) { 111 if ($this->mode) { 112 return 1.5 + $this->maxborder-$node->rpos+$node->pos; 113 } else return $node->pos; 114 } 115 108 116 function store_node($node) { 109 117 global $Database; 110 118 $first = $node->getFirst(); 111 if ($first) { $first = $ first->pos; } else $first = '-1';119 if ($first) { $first = $this->calc_pos($first); } else $first = '-1'; 112 120 $last = $node->getLast(); 113 if ($last) { $last = $ last->pos; } else $last = '-1';114 $Database->query("INSERT INTO hosts_topology (host, depth, pos, first, last) VALUES (".$node->index.','.$node->level.','.$ node->pos.','.$first.','.$last.");");121 if ($last) { $last = $this->calc_pos($last); } else $last = '-1'; 122 $Database->query("INSERT INTO hosts_topology (host, depth, pos, first, last) VALUES (".$node->index.','.$node->level.','.$this->calc_pos($node).','.$first.','.$last.");"); 115 123 foreach($node->children as $key => $value) { 116 124 $this->store_node($value); … … 145 153 } 146 154 } 155 } 156 157 function right_align($node) { 158 $this->mode = 1; 159 $node->rpos = $this->border[$node->level]; 160 $this->border[$node->level]++; 161 if (count($node->children)>0) { 162 if ($this->border[$node->level +1]>=$this->border[$node->level]) { 163 $node->rpos = $this->border[$node->level+1]; 164 $this->setborder($node->level, $this->border[$node->level+1]+1); 165 } 166 for($key=count($node->children)-1;$key>=0;$key--) { 167 $value = $node->children[$key]; 168 if ((count($value->children)>0) && count($node->order)>0) { 169 $value = $node->order[$value->index]; 170 } 171 if ($key == 0) { 172 if($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1); 173 } 174 $this->right_align($value); 175 if ($key == count($node->children)-1) { 176 if($this->border[$node->level] <= $this->border[$node->level+1]) { 177 $node->rpos = $this->border[$node->level+1]-1; 178 $this->setborder($node->level, $this->border[$node->level+1]); 179 } 180 } 181 } 182 } 183 } 184 185 function reset_border() { 186 foreach($this->border as $key => $value) $this->border[$key] = 0; 187 $this->maxborder = 0; 147 188 } 148 189 … … 247 288 //$mytree->left_align($mytree->rootNode); 248 289 $mytree->reorder($mytree->rootNode); 290 $mytree->reset_border(); 291 $mytree->right_align($mytree->rootNode); 249 292 $mytree->store(); 250 293
Note:
See TracChangeset
for help on using the changeset viewer.