summaryrefslogtreecommitdiffstats
path: root/code
diff options
context:
space:
mode:
authorneoraider <devnull@localhost>2006-01-12 23:18:03 +0100
committerneoraider <devnull@localhost>2006-01-12 23:18:03 +0100
commitecb8233cd7e9fbacd7614028115161565e841d87 (patch)
treed99bda8ce61f34a158470ff23e3da7c678f5a705 /code
parent73d5e907a797e976e59f328d4f2fd0b8bfcebde6 (diff)
downloadneon-ecb8233cd7e9fbacd7614028115161565e841d87.tar
neon-ecb8233cd7e9fbacd7614028115161565e841d87.zip
Die Navigationsleiste ist jetzt eingebaut. Viele Bugs wurden gel?st und einiges ?berarbeitet.
Diffstat (limited to 'code')
-rw-r--r--code/content.inc.php18
-rw-r--r--code/handlers.inc.php2
-rw-r--r--code/links.inc.php36
-rw-r--r--code/message.inc.php5
-rw-r--r--code/nav.inc.php92
5 files changed, 148 insertions, 5 deletions
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 @@
+<?PHP
+ if(!defined('LINKS_INC')) {
+ define('LINKS_INC', 1);
+
+ class Links {
+ function GetNeonLink($page) {
+ return 'index.php?page=' . $page;
+ }
+
+ function GetExternalLink($link) {
+ return $link;
+ }
+
+ function GetMailtoLink($address) {
+ return 'mailto:' . $address;
+ }
+
+ function ParseNavLink($link) {
+ if(!$link) return '';
+
+ switch($link[0]) {
+ case ':':
+ return $this->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 @@
+<?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;
+ }
+?>