adjustments wrt sessions + configs
authorPierre Habouzit (MadCoder <pierre.habouzit@m4x.org>
Sun, 17 Apr 2005 15:48:16 +0000 (15:48 +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-548

include/platal/page.inc.php
include/xnet.inc.php [new file with mode: 0644]
include/xnet/globals.inc.php [new file with mode: 0644]
include/xnet/session.inc.php [new file with mode: 0644]
include/xorg/page.inc.php

index 16732ba..48cf158 100644 (file)
@@ -98,8 +98,6 @@ class PlatalPage extends DiogenesCorePage
             exit;
         }
         
-        $this->assign('menu', $globals->menu->menu());
-
         if ($globals->debug) {
 
             if ($globals->debug & 1) {
diff --git a/include/xnet.inc.php b/include/xnet.inc.php
new file mode 100644 (file)
index 0000000..5c0dc66
--- /dev/null
@@ -0,0 +1,29 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2004 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************/
+
+require_once('platal.inc.php');
+require_once('xnet/globals.inc.php');
+require_once('xnet/session.inc.php');
+XnetGlobals::init();
+XnetSession::init();
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
+?>
diff --git a/include/xnet/globals.inc.php b/include/xnet/globals.inc.php
new file mode 100644 (file)
index 0000000..eb0f066
--- /dev/null
@@ -0,0 +1,76 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2004 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************/
+
+require_once('platal/globals.inc.php');
+
+// {{{ class XorgGlobals
+
+class XnetGlobals extends PlatalGlobals
+{
+    function XnetGlobals()
+    {
+        $this->PlatalGlobals('XnetSession');
+    }
+
+    function init()
+    {
+        global $globals;
+#        require_once('xorg/hook.inc.php');
+#        require_once('xorg/menu.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->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->hook->menu(null);
+
+        $globals->dbconnect();
+        if ($globals->debug & 1) {
+            $globals->db->trace_on();
+        }
+        $globals->xdb =& new XOrgDB;
+    }
+}
+
+// }}}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
+?>
diff --git a/include/xnet/session.inc.php b/include/xnet/session.inc.php
new file mode 100644 (file)
index 0000000..bd395a3
--- /dev/null
@@ -0,0 +1,65 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2004 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************/
+
+require_once('diogenes/diogenes.core.session.inc.php');
+require_once('diogenes/diogenes.misc.inc.php');
+
+// {{{ class XorgSession
+
+class XnetSession extends DiogenesCoreSession
+{
+    // {{{ function XorgSession()
+
+    function XorgSession()
+    {
+       $this->DiogenesCoreSession();
+       if (!Session::has('uid')) {
+           try_cookie();
+        }
+       set_skin();
+    }
+
+    // }}}
+    // {{{ function init
+    
+    function init() {
+        @session_start();
+        if (!Session::has('session')) {
+            $_SESSION['session'] = new XorgSession;
+        }
+    }
+    
+    // }}}
+    // {{{ function destroy()
+    
+    function destroy() {
+        @session_destroy();
+        unset($_SESSION);
+        XorgSession::init();
+    }
+    
+    // }}}
+}
+
+// }}}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
+?>
index 014ec4b..7dc18f6 100644 (file)
@@ -37,6 +37,9 @@ class XorgPage extends PlatalPage
 
     function run()
     {
+        if ($this->_page_type != NO_SKIN) {
+            $this->assign('menu', $globals->menu->menu());
+        }
         $this->_run('skin/'.Session::get('skin'));
     }