From ecb8233cd7e9fbacd7614028115161565e841d87 Mon Sep 17 00:00:00 2001 From: neoraider Date: Thu, 12 Jan 2006 22:18:03 +0000 Subject: Die Navigationsleiste ist jetzt eingebaut. Viele Bugs wurden gel?st und einiges ?berarbeitet. --- code/content.inc.php | 18 ++++++++-- code/handlers.inc.php | 2 +- code/links.inc.php | 36 ++++++++++++++++++++ code/message.inc.php | 5 +-- code/nav.inc.php | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 148 insertions(+), 5 deletions(-) create mode 100644 code/links.inc.php create mode 100644 code/nav.inc.php (limited to 'code') diff --git a/code/content.inc.php b/code/content.inc.php index c92f1b2..8a20507 100644 --- a/code/content.inc.php +++ b/code/content.inc.php @@ -7,11 +7,25 @@ include('code/handlers.inc.php'); function GetPage($name) { + $user = $GLOBALS['user']; + $res = DBQuery('SELECT access, handler, data FROM pages WHERE name = ?', $name); - if(($res->fields[0] & (1 << $GLOBALS['user']->GetGid())) == 0) - return $GLOBALS['handlers'][$res->fields[1]]->HandleErrorMessage('Forbidden', array('page' => $name)); + if(!$res->RecordCount()) { + $message = $GLOBALS['handlers']['default']->HandleErrorMessage('PageNotFound', array('page' => $name)); + + if(!$message['title']) $message['title'] = $name; + + return $message; + } + if((($user->GetUid() == 0) || ($user->GetGid() != 0)) && ($res->fields[0] & (1 << $user->GetGid())) == 0) { + $message = $GLOBALS['handlers'][$res->fields[1]]->HandleErrorMessage('Forbidden', array('page' => $name)); + + if(!$message['title']) $message['title'] = $name; + + return $message; + } parse_str($res->fields[2], $data); $data['_page'] = $name; diff --git a/code/handlers.inc.php b/code/handlers.inc.php index d259273..018402e 100644 --- a/code/handlers.inc.php +++ b/code/handlers.inc.php @@ -5,7 +5,7 @@ $dir = opendir('handlers'); while($file = readdir($dir)) - if($file[0] != '.') + if($file[0] != '.' && substr($file, -8) == '.inc.php') include('handlers/' . $file); closedir($dir); diff --git a/code/links.inc.php b/code/links.inc.php new file mode 100644 index 0000000..ab3b786 --- /dev/null +++ b/code/links.inc.php @@ -0,0 +1,36 @@ +GetNeonLink(substr($link, 1)); + case '@': + return $this->GetMailtoLink(substr($link, 1)); + case '!': + return ''; + default: + return $this->GetExternalLink($link); + } + } + } + + $links = new Links; + } +?> diff --git a/code/message.inc.php b/code/message.inc.php index 8e0a3f0..e3c648b 100644 --- a/code/message.inc.php +++ b/code/message.inc.php @@ -6,8 +6,9 @@ include('code/util.inc.php'); - $message['PageNotFound'] = 'The page $page does not exist.'; - $message['Forbidden'] = 'The page $page is protected.'; + $message['Error'] = 'Error'; + $message['PageNotFound'] = 'The page \'$page\' does not exist.'; + $message['Forbidden'] = 'The page \'$page\' is protected.'; $message['InternalError'] = 'An internal error has occourred.'; if($config['language'] != 'en') @include('lang/' . $config['language'] . '.inc.php'); 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 @@ +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 = ''; + + 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 = '
  • '; + + $link = $GLOBALS['links']->ParseNavLink($this->link); + + if($link) + $ret .= '' . $this->text . ''; + else + $ret .= $this->text; + + if(count($this->children) > 0) { + $ret .= ''; + } + + return $ret . '
  • '; + } + } + + $nav = new Nav; + } +?> -- cgit v1.2.3