EOF) {
$this->entries[$res->fields[0]] = new NavEntry($res->fields[1], $res->fields[2], $res->fields[3]);
$res->MoveNext();
}
foreach($this->entries as $entry)
if($entry->GetParentId() != 0)
$this->entries[$entry->GetParentId()]->Add($entry);
}
function ParseEntries() {
$ret = '
';
foreach($this->entries as $entry)
if($entry->GetParentId() == 0)
$ret .= $entry->Parse();
$ret .= '
';
return $ret;
}
}
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 GetChildren() {
return $this->children;
}
function GetParentId() {
return $this->parent;
}
function GetText() {
return $this->text;
}
function GetLink() {
return $this->link;
}
function Parse() {
$ccount = 0;
$ret = '';
$a = $GLOBALS['links']->ParseNavLink($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 . '';
}
}
$nav = new Nav;
}
?>