Execute('SELECT * FROM nav ORDER BY id');
while(!$res->EOF) {
$this->entries[$res->fields[0]] = new NavEntry($res->fields[1], $res->fields[2], $res->fields[3]);
$res->MoveNext();
}
foreach($this->entries as $key => $entry)
if($entry->parent != 0)
$this->entries[$entry->parent]->Add(&$this->entries[$key]);
}
function ParseEntries() {
$ret = '
';
foreach($this->entries as $entry)
if($entry->parent == 0)
$ret .= $entry->Parse();
$ret .= '
';
return $ret;
}
function ParseLink($text, $link) {
if(!$link) return $text;
switch($link[0]) {
case ':':
$ret = $GLOBALS['links']->GetNeonLink(substr($link, 1));
if($ret)
return '' . $text . '';
return $text;
case '@':
return '' . $text . '';
case '!':
$ret = $GLOBALS['links']->GetNavPage(substr($link, 1));
if($ret)
return $ret;
return $text;
default:
return '' . $text . '';
}
}
}
class NavEntry {
var $parent, $text, $link;
var $children = array();
function NavEntry($parent, $text, $link) {
$this->parent = $parent;
$this->text = $text;
$this->link = $link;
}
function Add($entry) {
array_push($this->children, &$entry);
}
function Parse() {
$ccount = 0;
if($this->link) $ret = '';
else $ret = '';
$a = $GLOBALS['nav']->ParseLink($this->text, $this->link);
$ret .= $a;
if(count($this->children) > 0) {
$ret .= '';
foreach($this->children as $child) {
$cret = $child->Parse();
if($cret) {
$ret .= $cret;
$ccount++;
}
}
$ret .= '
';
}
if(!$ccount && $a == $this->text)
return '';
return $ret . '';
}
}
$GLOBALS['nav'] = new Nav;
?>