/** Construct a new tree from a given root
*/
- public function __construct(BananaSpoolHead &$root)
+ public function __construct(BananaSpoolHead $root)
{
if (empty($root->children)) {
$this->data = null;
$this->saveToFile($root->id);
}
- private function &builder(BananaSpoolHead &$head)
+ private function &builder(BananaSpoolHead $head)
{
$array = array(array($head->id));
$this->urls[$head->id] = banana_entities(Banana::$page->makeURL(array('group' => Banana::$group,
file_put_contents(BananaTree::filename($id), serialize($this));
}
+ /** Create a reference to a tree image.
+ */
+ static private function makeTreeImg($img, $alt)
+ {
+ return Banana::$page->makeImg(Array('img' => $img, 'alt' => $alt, 'height' => 18, 'width' => 14));
+ }
+
+ /** Add an entry to the static tree association table.
+ */
+ static private function addTreeKind(array& $tree, $ascii, $img)
+ {
+ $tree[$ascii] = array(self::makeTreeImg($img . Banana::$tree_unread, $ascii),
+ self::makeTreeImg($img . Banana::$tree_read, $ascii));
+ }
+
/** Return html to display the tree
*/
public function &show()
if (!is_null($this->displaid) || is_null($this->data)) {
return $this->displaid;
}
- static $t_e, $u_h, $u_ht, $u_vt, $u_l, $u_f, $r_h, $r_ht, $r_vt, $r_l, $r_f;
+ static $t_e, $tree;
+ //$u_h, $u_ht, $u_vt, $u_l, $u_f, $r_h, $r_ht, $r_vt, $r_l, $r_f;
if (!isset($t_e)) {
- $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));
+ $t_e = self::makeTreeImg('e', ' ');
+ $tree = array();
+ self::addTreeKind($tree, '+', 'p2');
+ self::addTreeKind($tree, '-', 'm2');
+ self::addTreeKind($tree, '|', 'l2');
+ self::addTreeKind($tree, '`', 'a2');
+ self::addTreeKind($tree, 't', 't2');
}
$text = '<div class="tree">';
foreach ($this->data as &$line) {
$text .= '<div style="height: 18px">';
+ unset($head);
foreach ($line as &$item) {
if ($item == ' ') {
$text .= $t_e;
} else if (is_array($item)) {
$head =& Banana::$spool->overview[$item[1]];
- switch ($item[0]) {
- case '+': $text .= $head->isread ? $r_ht : $u_ht; break;
- case '-': $text .= $head->isread ? $r_h : $u_h; break;
- case '|': $text .= $head->isread ? $r_l : $u_l; break;
- case '`': $text .= $head->isread ? $r_vt : $u_vt; break;
- case 't': $text .= $head->isread ? $r_f : $u_f; break;
- }
+ $text .= $tree[$item[0]][$head->isread ? 1 : 0];
} else {
$head =& Banana::$spool->overview[$item];
- $text .= '<span style="background-color:' . $head->color . '; text-decoration: none"'
- . ' title="' . $this->title[$item] . '">'
- . '<input type="radio" name="banana_tree" value="' . $head->id . '"';
+ $text .= '<span style="background-color: ' . $head->color . '; text-decoration: none" title="'
+ . $this->title[$item] . '"><input type="radio" name="banana_tree" value="' . $head->id . '"';
if (Banana::$msgshow_javascript) {
$text .= ' onchange="window.location=\'' . $this->urls[$item] . '\'"';
} else {
if (Banana::$artid == $item) {
$text .= ' checked="checked"';
}
+ $last_title = $head->subject;
$text .= '/></span>';
}
}
+ if (function_exists('hook_spoolTagBranch') && isset($head)) {
+ $text .= hook_spoolTagBranch($head);
+ }
$text .= "</div>\n";
}
$text .= '</div>';
*/
static private function filename($id)
{
- return BananaSpool::getPath('tree_' . $id);
+ static $host;
+ if (!isset($host)) {
+ $host = parse_url(Banana::$page->makeURL(array()), PHP_URL_HOST);
+ }
+ return BananaSpool::getPath('tree_' . $id . '_' . $host);
}
/** Read a tree from a file