Exemple #1
0
 /**
  * Change ordering of the displayed messages and apply threading.
  *
  * @param   int    $parent  Parent Id.
  * @param   array  $indent  Indent for the current object.
  *
  * @return  array
  */
 protected function getThreadedOrdering($parent = 0, $indent = array())
 {
     $list = array();
     if (count($indent) == 1 && $this->topic->getTotal() > $this->pagination->limitstart + $this->pagination->limit) {
         $last = -1;
     } else {
         $last = end($this->threaded[$parent]);
     }
     foreach ($this->threaded[$parent] as $mesid) {
         $message = $this->messages[$mesid];
         $skip = $message->id != $this->topic->first_post_id && $message->parent != $this->topic->first_post_id && !isset($this->messages[$message->parent]);
         if ($mesid != $last) {
             // Default sibling edge
             $indent[] = 'crossedge';
         } else {
             // Last sibling edge
             $indent[] = 'lastedge';
         }
         end($indent);
         $key = key($indent);
         if ($skip) {
             $indent[] = 'gap';
         }
         $list[$mesid] = $this->messages[$mesid];
         $list[$mesid]->indent = $indent;
         if (empty($this->threaded[$mesid])) {
             // No children node
             // FIXME: $mesid == $message->thread
             $list[$mesid]->indent[] = $mesid == $message->thread ? 'single' : 'leaf';
         } else {
             // Has children node
             // FIXME: $mesid == $message->thread
             $list[$mesid]->indent[] = $mesid == $message->thread ? 'root' : 'node';
         }
         if (!empty($this->threaded[$mesid])) {
             // Fix edges
             if ($mesid != $last) {
                 $indent[$key] = 'edge';
             } else {
                 $indent[$key] = 'empty';
             }
             if ($skip) {
                 $indent[$key + 1] = 'empty';
             }
             $list += $this->getThreadedOrdering($mesid, $indent);
         }
         if ($skip) {
             array_pop($indent);
         }
         array_pop($indent);
     }
     return $list;
 }