diff options
Diffstat (limited to 'code/nav.inc.php')
-rw-r--r-- | code/nav.inc.php | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/code/nav.inc.php b/code/nav.inc.php index 02d9127..940ced2 100644 --- a/code/nav.inc.php +++ b/code/nav.inc.php @@ -3,33 +3,50 @@ class Nav { var $entries = array(); + var $root_entries = array(); function Nav() { $res = $GLOBALS['db']->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]); - + $this->entries[$res->fields[0]] = new NavEntry($res->fields[1], $res->fields[2], $res->fields[3], $res->fields[4]); + $res->MoveNext(); } foreach($this->entries as $key => $entry) - if($entry->parent != 0) + if($entry->parent == 0) + $this->root_entries[$entry->gid][$entry->text] = &$this->entries[$key]; + elseif(isset($this->entries[$entry->parent])) $this->entries[$entry->parent]->Add(&$this->entries[$key]); } - function ParseEntries() { + function ParseNav($gid, $name) { $ret = '<ul>'; - foreach($this->entries as $entry) - if($entry->parent == 0) - $ret .= $entry->Parse(); + foreach($this->root_entries[$gid][$name]->children as $entry) + $ret .= $entry->Parse(); $ret .= '</ul>'; return $ret; } + function ParseInsert($name, $data) { + $res = $GLOBALS['db']->Execute('SELECT code FROM nav_inserts WHERE name = ?', $name); + + if(!$res->RecordCount()) return ' '; + + ob_start(); + + eval('?>' . $res->fields[0]); + + $ret = ob_get_contents(); + ob_end_clean(); + + return $ret; + } + function ParseLink($text, $link) { if(!$link) return $text; @@ -43,25 +60,21 @@ return $text; case '@': return '<a href="' . $GLOBALS['links']->GetMailtoLink(substr($link, 1)) . '">' . $text . '</a>'; + case '-': + return $this->ParseInsert(substr($link, 1), $text); case '!': - $ret = $GLOBALS['links']->GetNavPage(substr($link, 1)); - - if($ret) - return $ret; - - return $text; - default: - return '<a href="' . $GLOBALS['links']->GetExternalLink($link) . '">' . $text . '</a>'; + return '<a href="' . $GLOBALS['links']->GetExternalLink(substr($link, 1)) . '">' . $text . '</a>'; } } } class NavEntry { - var $parent, $text, $link; + var $parent, $gid, $text, $link; var $children = array(); - function NavEntry($parent, $text, $link) { + function NavEntry($parent, $gid, $text, $link) { $this->parent = $parent; + $this->gid = $gid; $this->text = $text; $this->link = $link; } @@ -72,7 +85,8 @@ function Parse() { $ccount = 0; - if($this->link) $ret = '<li class="nav_' . urlencode($this->link) . '">'; + + if($this->link) $ret = '<li class="nav' . urlencode($this->link[0]) . ' nav_' . urlencode($this->link) . '">'; else $ret = '<li>'; $a = $GLOBALS['nav']->ParseLink($this->text, $this->link); |