From 3b7d2cb2fd40d744a2415a470b4e323d13dd1b63 Mon Sep 17 00:00:00 2001 From: neoraider Date: Mon, 4 Dec 2006 00:11:05 +0000 Subject: Nav-Seiten durch Inserts ersetzt; Editor-Seiten jetzt in Templates. --- code/links.inc.php | 11 +---------- code/nav.inc.php | 50 ++++++++++++++++++++++++++++++++------------------ code/pages.inc.php | 7 ++++--- code/user.inc.php | 9 +++++++-- 4 files changed, 44 insertions(+), 33 deletions(-) (limited to 'code') 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 @@ 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 = ''; 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 '' . $text . ''; + case '-': + return $this->ParseInsert(substr($link, 1), $text); case '!': - $ret = $GLOBALS['links']->GetNavPage(substr($link, 1)); - - if($ret) - return $ret; - - return $text; - default: - return '' . $text . ''; + return '' . $text . ''; } } } 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 = '
  • '; $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); -- cgit v1.2.3