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 | |
parent | 73d5e907a797e976e59f328d4f2fd0b8bfcebde6 (diff) | |
download | neon-ecb8233cd7e9fbacd7614028115161565e841d87.tar neon-ecb8233cd7e9fbacd7614028115161565e841d87.zip |
Die Navigationsleiste ist jetzt eingebaut. Viele Bugs wurden gel?st und einiges ?berarbeitet.
-rw-r--r-- | code/content.inc.php | 18 | ||||
-rw-r--r-- | code/handlers.inc.php | 2 | ||||
-rw-r--r-- | code/links.inc.php | 36 | ||||
-rw-r--r-- | code/message.inc.php | 5 | ||||
-rw-r--r-- | code/nav.inc.php | 92 | ||||
-rw-r--r-- | config/config.inc.php | 2 | ||||
-rw-r--r-- | handlers/default.inc.php (renamed from handlers/default) | 2 | ||||
-rw-r--r-- | index.php | 8 | ||||
-rw-r--r-- | lang/de.inc.php | 5 | ||||
-rw-r--r-- | styles/GreenGrid/style.css | 24 | ||||
-rw-r--r-- | templates/default | 3 |
11 files changed, 179 insertions, 18 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; + } +?> diff --git a/config/config.inc.php b/config/config.inc.php index 3b7a313..5f778d0 100644 --- a/config/config.inc.php +++ b/config/config.inc.php @@ -22,6 +22,6 @@ // page design $config['default_style'] = 'GreenGrid'; - $config['title'] = 'Neon'; + $config['title'] = 'Neon - '; } ?> diff --git a/handlers/default b/handlers/default.inc.php index cb9396f..0ea0a7b 100644 --- a/handlers/default +++ b/handlers/default.inc.php @@ -15,7 +15,7 @@ } function HandleErrorMessage($type, $data = array()) { - return '<span class="error">' . Message($type, $data) . '</span>'; + return array('content' => '<span class="error">' . Message($type, $data) . '</span>', 'title' => Message('error')); } } @@ -4,18 +4,20 @@ include('code/message.inc.php'); include('code/util.inc.php'); include('code/content.inc.php'); + include('code/nav.inc.php'); header('Content-type: text/html;charset=UTF-8'); // provisional $template = 'default'; - $title = $config['title']; $style = $config['default_style']; - $page = $config['home']; + + if($_GET['page']) $page = $_GET['page']; + else $page = $config['home']; $template_data = join('', file('templates/' . $template)); $data = GetPage($page); - echo Subst($template_data, array('title' => $title . ' - ' . $data['title'], 'stylesheet' => 'styles/' . $style . '/style.css', 'content' => $data['content'])); + echo Subst($template_data, array('title' => $config['title'] . $data['title'], 'stylesheet' => 'styles/' . $style . '/style.css', 'content' => $data['content'], 'nav' => $nav->ParseEntries())); ?> diff --git a/lang/de.inc.php b/lang/de.inc.php index 1e14e6f..8a1ab22 100644 --- a/lang/de.inc.php +++ b/lang/de.inc.php @@ -1,5 +1,6 @@ <?PHP - $message['PageNotFound'] = 'Die Seite $page existiert nicht.'; - $message['Forbidden'] = 'Die Seite $page ist geschützt.'; + $message['Error'] = 'Fehler'; + $message['PageNotFound'] = 'Die Seite \'$page\' existiert nicht.'; + $message['Forbidden'] = 'Die Seite \'$page\' ist geschützt.'; $message['InternalError'] = 'Ein interner Fehler ist aufgetreten.'; ?> diff --git a/styles/GreenGrid/style.css b/styles/GreenGrid/style.css index 87aede7..1a702ac 100644 --- a/styles/GreenGrid/style.css +++ b/styles/GreenGrid/style.css @@ -32,28 +32,40 @@ input, textarea, select { div#content { text-align:justify; padding:0.8em; + margin-left:12em; background-color:#000000; border:solid #008000 1px; } div#nav { + position:absolute; width:9.40em; padding:0 0.8em; border:solid #008000 1px; background-color:#000000; } -.nav_cat { +div#nav ul { + padding-left:0; + margin-top:0; + margin-bottom:1em; +} + +div#nav ul li { text-align:center; font-weight:bold; + list-style-type:none; } -.error { - color:#FF0000; +div#nav ul li ul li { + text-align:left; + font-weight:normal; } +div#nav ul li ul li ul { + padding-left:0.8em; +} -.neon_head { - font-weight:bold; - font-size:1.5em; +.error { + color:#FF0000; } diff --git a/templates/default b/templates/default index 36b4022..8768a7e 100644 --- a/templates/default +++ b/templates/default @@ -7,6 +7,9 @@ <link rel="stylesheet" type="text/css" href="$stylesheet" /> </head> <body> + <div id="nav"> + $nav + </div> <div id="content"> $content </div> |