From 3b96c48f3dd0eb347d705062c0e6eb153e017619 Mon Sep 17 00:00:00 2001 From: "Pierre Habouzit (MadCoder" Date: Sun, 17 Apr 2005 16:00:02 +0000 Subject: [PATCH] factorize config code a bit git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-549 --- include/platal/globals.inc.php.in | 19 +++++++++++++++++++ include/xnet/globals.inc.php | 26 ++++---------------------- include/xorg/globals.inc.php | 16 +--------------- include/xorg/page.inc.php | 1 + 4 files changed, 25 insertions(+), 37 deletions(-) diff --git a/include/platal/globals.inc.php.in b/include/platal/globals.inc.php.in index 2d17fd0..c7bc5c7 100644 --- a/include/platal/globals.inc.php.in +++ b/include/platal/globals.inc.php.in @@ -70,6 +70,25 @@ class PlatalGlobals extends DiogenesCoreGlobals { $this->session = $sess; } + + function read_config() + { + $array = parse_ini_file($this->root.'/configs/platal.conf', true); + if (!is_array($array)) { + return; + } + + foreach ($array as $cat=>$conf) { + $c = strtolower($cat); + foreach ($conf as $key=>$val) { + if ($c == 'core' && isset($this->$key)) { + $this->$key=$val; + } else { + $this->$c->$key = $val; + } + } + } + } } // }}} diff --git a/include/xnet/globals.inc.php b/include/xnet/globals.inc.php index eb0f066..da31233 100644 --- a/include/xnet/globals.inc.php +++ b/include/xnet/globals.inc.php @@ -33,35 +33,17 @@ class XnetGlobals extends PlatalGlobals function init() { global $globals; -# require_once('xorg/hook.inc.php'); -# require_once('xorg/menu.inc.php'); + require_once('xorg/hook.inc.php'); $globals = new XnetGlobals; $globals->core = new CoreConfig; $globals->root = dirname(dirname(dirname(__FILE__))); -# $globals->hook = new XOrgHook(); -# $globals->menu = new XOrgMenu(); + $globals->hook = new XOrgHook(); -# $globals->hook->config(null); + $globals->hook->config(null); - $array = parse_ini_file($globals->root.'/configs/platal.conf', true); - if (!is_array($array)) { - return; - } - - foreach ($array as $cat=>$conf) { - $c = strtolower($cat); - foreach ($conf as $key=>$val) { - if ($c == 'core' && isset($globals->$key)) { - $globals->$key=$val; - } else { - $globals->$c->$key = $val; - } - } - } + $globals->read_config(); -# $globals->hook->menu(null); - $globals->dbconnect(); if ($globals->debug & 1) { $globals->db->trace_on(); diff --git a/include/xorg/globals.inc.php b/include/xorg/globals.inc.php index 322b8ef..85ab019 100644 --- a/include/xorg/globals.inc.php +++ b/include/xorg/globals.inc.php @@ -44,22 +44,8 @@ class XorgGlobals extends PlatalGlobals $globals->hook->config(null); - $array = parse_ini_file($globals->root.'/configs/platal.conf', true); - if (!is_array($array)) { - return; - } + $globals->read_config(); - foreach ($array as $cat=>$conf) { - $c = strtolower($cat); - foreach ($conf as $key=>$val) { - if ($c == 'core' && isset($globals->$key)) { - $globals->$key=$val; - } else { - $globals->$c->$key = $val; - } - } - } - $globals->hook->menu(null); $globals->dbconnect(); diff --git a/include/xorg/page.inc.php b/include/xorg/page.inc.php index 7dc18f6..86c85b8 100644 --- a/include/xorg/page.inc.php +++ b/include/xorg/page.inc.php @@ -37,6 +37,7 @@ class XorgPage extends PlatalPage function run() { + global $globals; if ($this->_page_type != NO_SKIN) { $this->assign('menu', $globals->menu->menu()); } -- 2.1.4