Example #1
0
 public function placeNode(IThreadedForum $tf, $saveLost = true){
     $inserted = false;
     $count = sizeof($this->forum);
     if ($tf->getChildOf() == 0){
         $i=0;
         for( ; $i<$count && !$inserted; $i++){
             $thisNode = $this->forum[$i]->getNode();
             if ($thisNode->getChildOf() == 0){
                 if ($thisNode->isGreaterThan($tf)){
                     _Array::insert($this->forum, new ForumNode($tf, 0), $i);
                     $inserted = true;
                 }
             }
         }
         if (!$inserted){
             _Array::insert($this->forum, new ForumNode($tf, 0), $i);
             $inserted = true;
         }
     } else {
         $parentFound = false;
         $indent = 0;
         $i=0;
         for( ; $i<$count && !$inserted; $i++){
             $thisNode = $this->forum[$i]->getNode();
             if (!$parentFound){
                 if ($tf->getChildOf() == $thisNode->getID()){
                     $parentFound = true;
                     $indent = $this->forum[$i]->getIndent();
                 }
             } else {
                 if ($thisNode->getChildOf() == $tf->getChildOf()){
                     $foundBro = true;
                     if (!$tf->isGreaterThan($thisNode)){
                         _Array::insert($this->forum, new ForumNode($tf, $indent+1), $i);
                         $inserted = true;
                     }
                 } else {
                     _Array::insert($this->forum, new ForumNode($tf, $indent+1), $i);
                     $inserted = true;
                 }
             }
         }
         if ($parentFound && !$inserted){
             _Array::insert($this->forum, new ForumNode($tf, $indent+1), $i);
             $inserted = true;
         }
     }
     if (!$inserted && $saveLost){
         array_push($this->lost, $tf);
     }
     return $inserted;
 }
Example #2
0
 public function isGreaterThan(IThreadedForum $node){ return $this->getRank() > $node->getGreaterCompare(); }