From 2920b501bdcc6e19bb4956e27b6b5ef6b0f8f1e9 Mon Sep 17 00:00:00 2001 From: PiTiLeZarD Date: Wed, 19 Mar 2008 00:06:49 +0100 Subject: [PATCH] Kernel::$info is now filled during boot process --- kernel.php | 49 ++++++++++++++++++++++---------------- site/views/Pages/common/footer.php | 0 site/views/Pages/common/header.php | 0 site/views/Pages/common/page.php | 0 4 files changed, 28 insertions(+), 21 deletions(-) delete mode 100644 site/views/Pages/common/footer.php delete mode 100644 site/views/Pages/common/header.php delete mode 100644 site/views/Pages/common/page.php diff --git a/kernel.php b/kernel.php index 148634c..497aeb6 100644 --- a/kernel.php +++ b/kernel.php @@ -16,6 +16,13 @@ function __($obj, $ret=false) { } } +# redirect function +function redirect($url) { + header('Location: ' . $url); + die(); +} + +# kernel class class Kernel { private static $_instance = null; @@ -29,8 +36,14 @@ class Kernel { public $site = null; public $i18n = null; - public function __constructor() { - + public function __construct() { + $h = $_SERVER['HTTP_HOST']; + + $this->info=array( + "host" => $h, + "dest" => 'live', + "httphost" => "http://".$h."/" + ); } public static function getInstance() { @@ -44,7 +57,7 @@ class Kernel { $this->initVars(); if (empty($bootOrder)) { - $bootOrder = array('PHPConfig', 'IncludePath', 'Zend', 'Domain', 'Infos', 'Config', 'DB', 'Site'); + $bootOrder = array('PHPConfig', 'IncludePath', 'Zend', 'Domain', 'Config', 'DB', 'Site'); } foreach ($bootOrder as $fn) { $fn = 'init' . $fn; @@ -54,6 +67,7 @@ class Kernel { private function initDomain() { + # determine domain or redirect if (!empty($this->VARS['domain'])) { $_SERVER['REQUEST_URI'] = str_replace('/'.$this->VARS['domain'], '/', $_SERVER['REQUEST_URI']); } else { @@ -67,14 +81,20 @@ class Kernel { } else { $url = str_replace('/'.$this->VARS['controller'].'/', '/'.$defaultDomain.'/'.$this->VARS['controller'].'/', $_SERVER['REQUEST_URI']); } - header('Location: ' . $url); - die(); + + redirect($url); } - - $this->locale = new Zend_Locale(Maps::$langlocale[$this->VARS['domain']]); + # locale and i18n + $this->locale = new Zend_Locale(Maps::$langlocale[$this->VARS['domain']]); $moPath = 'resources/locale/'. $this->locale->getLanguage() . '_' . $this->locale->getRegion() .'/LC_MESSAGES/common.mo'; $this->i18n = new Zend_Translate('gettext', $moPath, $this->locale); + + # fill info + $this->info['domain'] = $this->VARS['domain']; + $this->info['httphosti18n'] = "http://".$this->info['httphost']."/".$this->VARS['domain']."/"; + $this->info['locale'] = $this->locale->getLanguage() . '_' . $this->locale->getRegion(); + } private function initPHPConfig() { @@ -148,7 +168,7 @@ class Kernel { } private function initConfig() { - $this->config = new Zend_Config_Ini('config.ini', 'live'); + $this->config = new Zend_Config_Ini('config.ini', $this->info['dest']); } private function initDB() { @@ -163,19 +183,6 @@ class Kernel { $this->db = Zend_Db::factory($dbtype, $params); } - private function initInfos() { - $h = $_SERVER['HTTP_HOST']; - - $this->info=array( - "host"=>$h, - "httphost"=>"http://".$h."/", - "domain"=>$this->VARS['domain'], - "httphosti18n"=>"http://".$h."/".$this->VARS['domain']."/", - "locale" => $this->locale->getLanguage() . '_' . $this->locale->getRegion() - ); - - } - private function initSite() { $this->site = new Site(); } diff --git a/site/views/Pages/common/footer.php b/site/views/Pages/common/footer.php deleted file mode 100644 index e69de29..0000000 diff --git a/site/views/Pages/common/header.php b/site/views/Pages/common/header.php deleted file mode 100644 index e69de29..0000000 diff --git a/site/views/Pages/common/page.php b/site/views/Pages/common/page.php deleted file mode 100644 index e69de29..0000000 -- 2.11.4.GIT