factorize config code a bit
authorPierre Habouzit (MadCoder <pierre.habouzit@m4x.org>
Sun, 17 Apr 2005 16:00:02 +0000 (16:00 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:28:32 +0000 (23:28 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-549

include/platal/globals.inc.php.in
include/xnet/globals.inc.php
include/xorg/globals.inc.php
include/xorg/page.inc.php

index 2d17fd0..c7bc5c7 100644 (file)
@@ -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;
+                }
+            }
+        }
+    }
 }
 
 // }}}
index eb0f066..da31233 100644 (file)
@@ -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();
index 322b8ef..85ab019 100644 (file)
@@ -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();
index 7dc18f6..86c85b8 100644 (file)
@@ -37,6 +37,7 @@ class XorgPage extends PlatalPage
 
     function run()
     {
+        global $globals;
         if ($this->_page_type != NO_SKIN) {
             $this->assign('menu', $globals->menu->menu());
         }