diff options
author | neoraider <devnull@localhost> | 2006-12-09 02:18:00 +0100 |
---|---|---|
committer | neoraider <devnull@localhost> | 2006-12-09 02:18:00 +0100 |
commit | 7be63518bdb86fb747dda20918ef6eab3d30e40c (patch) | |
tree | e9239af6d9efa6d7a2129adb71ca77fb25a0f59d /code | |
parent | fa39bfd963d7d05335d968b0efdfd9bb9a40f132 (diff) | |
download | neon-7be63518bdb86fb747dda20918ef6eab3d30e40c.tar neon-7be63518bdb86fb747dda20918ef6eab3d30e40c.zip |
?bersetzung vereinfacht; alle Seiten ?bersetzt
Diffstat (limited to 'code')
-rw-r--r-- | code/message.inc.php | 19 | ||||
-rw-r--r-- | code/pages.inc.php | 18 | ||||
-rw-r--r-- | code/subst.inc.php | 13 | ||||
-rw-r--r-- | code/util.inc.php | 11 |
4 files changed, 24 insertions, 37 deletions
diff --git a/code/message.inc.php b/code/message.inc.php deleted file mode 100644 index fb9e8fa..0000000 --- a/code/message.inc.php +++ /dev/null @@ -1,19 +0,0 @@ -<?PHP - Uses('util'); - - $GLOBALS['message']['Error'] = 'Error'; - $GLOBALS['message']['PageNotFound'] = 'The page \'$page\' does not exist.'; - $GLOBALS['message']['Forbidden'] = 'The page \'$page\' is protected.'; - $GLOBALS['message']['InternalError'] = 'An internal error has occourred.'; - $GLOBALS['message']['LoginError'] = 'Login failed. Username or password is wrong.'; - - if($config['language'] != 'en') @include('lang/' . $config['language'] . '.inc.php'); - - function Message($type, $data = array()) { - return Subst($GLOBALS['message'][$type], $data); - } - - function ErrorMessage($type, $data = array()) { - return '<span class="error">' . Subst($GLOBALS['message'][$type], $data) . '</span>'; - } -?> diff --git a/code/pages.inc.php b/code/pages.inc.php index e3af67a..549e24c 100644 --- a/code/pages.inc.php +++ b/code/pages.inc.php @@ -1,5 +1,5 @@ <?PHP - Uses('user', 'templates'); + Uses('user', 'templates', 'subst'); class Pages { @@ -9,11 +9,11 @@ function Get($page, $type) { if(!$this->Exists($page, $type)) return array('title' => $page, - 'content' => ErrorMessage('PageNotFound', array('page' => $page))); + 'content' => Subst('<span class="error">{{The page \'' . $page . '\' does not exist.}}</span>')); if(!$this->HasReadAccess($page, $type)) return array('title' => $page, - 'content' => ErrorMessage('Forbidden', array('page' => $page))); + 'content' => Subst('<span class="error">{{The page \'' . $page . '\' is protected.}}</span>')); $pagedata = $this->GetPageData($page, $type); @@ -22,17 +22,19 @@ $data['_page'] = $page; $data['_type'] = $type; - return $GLOBALS['templates'][$pagedata['template']]->GetPage($data); + $ret = $GLOBALS['templates'][$pagedata['template']]->GetPage($data); + + return array('title' => Subst($ret['title']), 'content' => Subst($ret['content'])); } function GetEditor($page, $type, $backlink) { if(!$this->Exists($page, $type)) return array('title' => $page, - 'content' => ErrorMessage('PageNotFound', array('page' => $page))); + 'content' => Subst('<span class="error">{{The page \'' . $page . '\' does not exist.}}</span>')); if(!$this->HasWriteAccess($page, $type)) return array('title' => $page, - 'content' => ErrorMessage('Forbidden', array('page' => $page))); + 'content' => Subst('<span class="error">{{The page \'' . $page . '\' is protected.}}</span>')); $pagedata = $this->GetPageData($page, $type); @@ -41,7 +43,9 @@ $data['_type'] = $type; $data['_backlink'] = $backlink; - return $GLOBALS['templates'][$pagedata['template']]->GetEditor($data); + $ret = $GLOBALS['templates'][$pagedata['template']]->GetEditor($data); + + return array('title' => Subst($ret['title']), 'content' => Subst($ret['content'])); } function Exists($page, $type) { diff --git a/code/subst.inc.php b/code/subst.inc.php new file mode 100644 index 0000000..9696ec9 --- /dev/null +++ b/code/subst.inc.php @@ -0,0 +1,13 @@ +<?PHP + $GLOBALS['messages'] = array(); + + if($GLOBALS['config']['language'] != 'en') @include('lang/' . $GLOBALS['config']['language'] . '.inc.php'); + + function Subst($data) { + $subst = array_map(create_function('$key', 'return \'(\\{\\{\' . $key . \'\\}\\})\';'), array_keys($GLOBALS['messages'])); + + $data = preg_replace($subst, $GLOBALS['messages'], $data); + + return preg_replace('({{(.+?)}})', '$1', $data); + } +?> diff --git a/code/util.inc.php b/code/util.inc.php index 3ee2489..b2cf954 100644 --- a/code/util.inc.php +++ b/code/util.inc.php @@ -1,15 +1,4 @@ <?PHP - function Subst($string, $subst = array()) { - $tr = array('$$' => '$'); - - foreach($subst as $key => $value) - $tr['$' . $key] = $value; - - krsort($tr); - - return strtr($string, $tr); - } - if(get_magic_quotes_gpc()) { function Unquote($string) { return stripslashes($string); |