-
- private function &_buildTree(BananaSpoolHead &$head) {
- static $t_e, $u_h, $u_ht, $u_vt, $u_l, $u_f, $r_h, $r_ht, $r_vt, $r_l, $r_f;
- if (!isset($spfx_f)) {
- $t_e = Banana::$page->makeImg(Array('img' => 'e', 'alt' => ' ', 'height' => 18, 'width' => 14));
- $u_h = Banana::$page->makeImg(Array('img' => 'h2', 'alt' => '-', 'height' => 18, 'width' => 14));
- $u_ht = Banana::$page->makeImg(Array('img' => 'T2', 'alt' => '+', 'height' => 18, 'width' => 14));
- $u_vt = Banana::$page->makeImg(Array('img' => 't2', 'alt' => '`', 'height' => 18, 'width' => 14));
- $u_l = Banana::$page->makeImg(Array('img' => 'l2', 'alt' => '|', 'height' => 18, 'width' => 14));
- $u_f = Banana::$page->makeImg(Array('img' => 'f2', 'alt' => 't', 'height' => 18, 'width' => 14));
- $r_h = Banana::$page->makeImg(Array('img' => 'h2r', 'alt' => '-', 'height' => 18, 'width' => 14));
- $r_ht = Banana::$page->makeImg(Array('img' => 'T2r', 'alt' => '+', 'height' => 18, 'width' => 14));
- $r_vt = Banana::$page->makeImg(Array('img' => 't2r', 'alt' => '`', 'height' => 18, 'width' => 14));
- $r_l = Banana::$page->makeImg(Array('img' => 'l2r', 'alt' => '|', 'height' => 18, 'width' => 14));
- $r_f = Banana::$page->makeImg(Array('img' => 'f2r', 'alt' => 't', 'height' => 18, 'width' => 14));
- }
- $style = 'background-color:' . $head->color . '; text-decoration: none';
- $text = '<span style="' . $style . '" title="' . banana_entities($head->name . ', ' . $this->formatDate($head))
- . '"><input type="radio" name="banana_tree" '
- . (Banana::$msgshow_javascript ? 'onchange="window.location=\'' .
- banana_entities(Banana::$page->makeURL(array('group' => $this->group, 'artid' => $head->id))) . '\'"'
- : ' disabled="disabled"')
- . ' /></span>';
- $array = array($text);
- foreach ($head->children as $key=>&$msg) {
- $tree =& $this->_buildTree($msg);
- $last = $key == count($head->children) - 1;
- foreach ($tree as $kt=>&$line) {
- if ($kt === 0 && $key === 0 && !$last) {
- $array[0] .= ($msg->isread ? $r_ht : $u_ht) . $line;
- } else if($kt === 0 && $key === 0) {
- $array[0] .= ($msg->isread ? $r_h : $u_h) . $line;
- } else if ($kt === 0 && $last) {
- $array[] = $t_e . ($msg->isread ? $r_vt : $u_vt) . $line;
- } else if ($kt === 0) {
- $array[] = $t_e . ($msg->isread ? $r_f : $u_f) . $line;
- } else if ($last) {
- $array[] = $t_e . $t_e . $line;
- } else {
- $array[] = $t_e . ($msg->isread ? $r_l : $u_l) . $line;
- }
- }
- unset($tree);
- }
- return $array;
- }
-
- /** build the spool tree associated with the given message
- */
- public function &buildTree($id, $force = false) {
- $root =& $this->root($id);
- $id = $root->id;
- if (!$force && isset($this->trees[$id])) {
- return $this->trees[$id];
- } else {
- $tree =& $this->_buildTree($root);
- $tree = '<div class="tree"><div style="height:18px">'
- . implode("</div>\n<div style=\"height:18px\">", $tree)
- . '</div></div>';
- return $tree;
- }
- }
-
- /** computes linear post index
- * @param $_id INTEGER MSGNUM of post
- * @return INTEGER linear index of post
- */
- public function getNdX($_id)
- {
- $ndx = 1;
- $id_cur = $_id;
- while (true) {
- $id_parent = $this->overview[$id_cur]->parent;
- if (is_null($id_parent)) break;
- $pos = array_search($id_cur, $this->overview[$id_parent]->children);
-
- for ($i = 0; $i < $pos ; $i++) {
- $ndx += $this->overview[$this->overview[$id_parent]->children[$i]]->desc;
- }
- $ndx++; //noeud père
-
- $id_cur = $id_parent;
- }
-
- foreach ($this->roots as $i) {
- if ($i==$id_cur) {
- break;
- }
- $ndx += $this->overview[$i]->desc;
- }
- return $ndx;
- }
-