summaryrefslogtreecommitdiffstats
path: root/code
diff options
context:
space:
mode:
authorneoraider <devnull@localhost>2006-12-04 01:11:05 +0100
committerneoraider <devnull@localhost>2006-12-04 01:11:05 +0100
commit3b7d2cb2fd40d744a2415a470b4e323d13dd1b63 (patch)
tree45dc49f5501c13d0e967e41bafb54e9f0dfad0a9 /code
parenta55cccfbc9ba53fb4b4b28586cfeb9e5e035a6a7 (diff)
downloadneon-3b7d2cb2fd40d744a2415a470b4e323d13dd1b63.tar
neon-3b7d2cb2fd40d744a2415a470b4e323d13dd1b63.zip
Nav-Seiten durch Inserts ersetzt; Editor-Seiten jetzt in Templates.
Diffstat (limited to 'code')
-rw-r--r--code/links.inc.php11
-rw-r--r--code/nav.inc.php50
-rw-r--r--code/pages.inc.php7
-rw-r--r--code/user.inc.php9
4 files changed, 44 insertions, 33 deletions
diff --git a/code/links.inc.php b/code/links.inc.php
index cb264cd..6c6fcd8 100644
--- a/code/links.inc.php
+++ b/code/links.inc.php
@@ -1,5 +1,5 @@
<?PHP
- Uses('user');
+ Uses('user', 'pages');
class Links {
function GetNeonLink($page, $extra = '', $html = true) {
@@ -26,15 +26,6 @@
function GetMailtoLink($address) {
return 'mailto:' . $address;
}
-
- function GetNavPage($page) {
- if($GLOBALS['pages']->HasReadAccess($page, 'n')) {
- $page = $GLOBALS['pages']->Get($page, 'n');
- return $page['content'];
- }
-
- return '';
- }
}
$GLOBALS['links'] = new Links;
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 '&nbsp;';
+
+ 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);
diff --git a/code/pages.inc.php b/code/pages.inc.php
index 2024303..e3af67a 100644
--- a/code/pages.inc.php
+++ b/code/pages.inc.php
@@ -6,7 +6,7 @@
var $pages = array();
- function Get($page, $type, $extra = null) {
+ function Get($page, $type) {
if(!$this->Exists($page, $type))
return array('title' => $page,
'content' => ErrorMessage('PageNotFound', array('page' => $page)));
@@ -22,7 +22,7 @@
$data['_page'] = $page;
$data['_type'] = $type;
- return $GLOBALS['templates'][$pagedata['template']]->Get($data);
+ return $GLOBALS['templates'][$pagedata['template']]->GetPage($data);
}
function GetEditor($page, $type, $backlink) {
@@ -39,8 +39,9 @@
$data = $pagedata['data'];
$data['_page'] = $page;
$data['_type'] = $type;
+ $data['_backlink'] = $backlink;
- return $this->Get($pagedata['template'], 'e', array('_data' => $data, '_backlink' => $backlink));
+ return $GLOBALS['templates'][$pagedata['template']]->GetEditor($data);
}
function Exists($page, $type) {
diff --git a/code/user.inc.php b/code/user.inc.php
index 7c9b907..cc04268 100644
--- a/code/user.inc.php
+++ b/code/user.inc.php
@@ -73,13 +73,18 @@
}
function IsAdmin($id = -1) {
- if($id < 0) return ($this->uid != 0 && $this->gid == 0);
+ if($id < 0) return ($this->gid == -1);
- return ($id != 0 && $this->GetGid($id) == 0);
+ return ($this->GetGid($id) == -1);
+ }
+
+ function GetUid() {
+ return $this->uid;
}
function GetGid($id = -1) {
if($id < 0) return $this->gid;
+ if($id == 0) return 0;
$res = $GLOBALS['db']->Execute('SELECT gid FROM users WHERE id = ?', $id);