diff options
author | neoraider <devnull@localhost> | 2006-01-12 23:18:03 +0100 |
---|---|---|
committer | neoraider <devnull@localhost> | 2006-01-12 23:18:03 +0100 |
commit | ecb8233cd7e9fbacd7614028115161565e841d87 (patch) | |
tree | d99bda8ce61f34a158470ff23e3da7c678f5a705 /code/nav.inc.php | |
parent | 73d5e907a797e976e59f328d4f2fd0b8bfcebde6 (diff) | |
download | neon-ecb8233cd7e9fbacd7614028115161565e841d87.tar neon-ecb8233cd7e9fbacd7614028115161565e841d87.zip |
Die Navigationsleiste ist jetzt eingebaut. Viele Bugs wurden gel?st und einiges ?berarbeitet.
Diffstat (limited to 'code/nav.inc.php')
-rw-r--r-- | code/nav.inc.php | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/code/nav.inc.php b/code/nav.inc.php new file mode 100644 index 0000000..f6f0782 --- /dev/null +++ b/code/nav.inc.php @@ -0,0 +1,92 @@ +<?PHP + if(!defined('NAV_INC')) { + define('NAV_INC', 1); + + include('code/links.inc.php'); + + class Nav { + var $entries = array(); + + function Nav() { + $res = DBQuery('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 $entry) + if($entry->GetParentId() != 0) + $this->entries[$entry->GetParentId()]->Add($entry); + } + + function ParseEntries() { + $ret = '<ul>'; + + foreach($this->entries as $entry) + if($entry->GetParentId() == 0) + $ret .= $entry->Parse(); + + $ret .= '</ul>'; + + 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() { + $ret = '<li>'; + + $link = $GLOBALS['links']->ParseNavLink($this->link); + + if($link) + $ret .= '<a href="' . $link . '">' . $this->text . '</a>'; + else + $ret .= $this->text; + + if(count($this->children) > 0) { + $ret .= '<ul>'; + + foreach($this->children as $child) + $ret .= $child->Parse(); + + $ret .= '</ul>'; + } + + return $ret . '</li>'; + } + } + + $nav = new Nav; + } +?> |