menu construction is now a pure hook
authorPierre Habouzit (MadCoder <pierre.habouzit@m4x.org>
Thu, 23 Dec 2004 18:58:47 +0000 (18:58 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:26:48 +0000 (23:26 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-126

14 files changed:
hooks/emails.inc.php [new file with mode: 0644]
hooks/lists.inc.php
hooks/money.inc.php [new file with mode: 0644]
hooks/newsletter.inc.php
hooks/search.inc.php [new file with mode: 0644]
hooks/tmp.inc.php [new file with mode: 0644]
include/conf.d/emails.menu.inc.php [deleted file]
include/conf.d/lists.menu.inc.php [deleted file]
include/conf.d/money.menu.inc.php [deleted file]
include/conf.d/newsletter.menu.inc.php [deleted file]
include/conf.d/search.menu.inc.php [deleted file]
include/conf.d/tmp.menu.inc.php [deleted file]
include/xorg.globals.inc.php.in
include/xorg/menu.inc.php

diff --git a/hooks/emails.inc.php b/hooks/emails.inc.php
new file mode 100644 (file)
index 0000000..13a3a8a
--- /dev/null
@@ -0,0 +1,39 @@
+<?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                *
+ ***************************************************************************/
+
+// {{{ menu HOOK
+
+function emails_menu(&$return)
+{
+    global $globals;
+    $globals->menu->addPrivateEntry(XOM_CUSTOM,   00, 'Mes emails',          'emails.php');
+
+    if ($globals->mail->send_form) {
+        $globals->menu->addPrivateEntry(XOM_SERVICES, 00, 'Envoyer un mail', 'emails/send.php');
+    }
+
+    $globals->menu->addPrivateEntry(XOM_SERVICES, 40, 'Patte cassée',        'emails/broken.php');
+    
+}
+
+// }}}
+
+?>
index 78efd66..f61ed0b 100644 (file)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-// {{{ function lists_subscribe()
+// {{{ menu HOOK
+
+function &lists_menu(&$result)
+{
+    global $globals;
+    $globals->menu->addPrivateEntry(XOM_SERVICES, 20, 'Listes de diffusion',   'listes/');
+}
+
+// }}}
+// {{{ subscribe HOOK
 
 function &lists_subscribe($forlife, $uid, $promo, $password, &$result)
 {
diff --git a/hooks/money.inc.php b/hooks/money.inc.php
new file mode 100644 (file)
index 0000000..4a0b864
--- /dev/null
@@ -0,0 +1,34 @@
+<?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                *
+ ***************************************************************************/
+
+// {{{ menu HOOK
+
+function money_menu(&$result)
+{
+    global $globals;
+    if ($globals->money->mpay_enable) {
+        $globals->menu->addPrivateEntry(XOM_SERVICES, 30, 'Micropaiments', 'paiement/');
+    }
+}
+
+// }}}
+
+?>
index 4557756..4cfd094 100644 (file)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-// {{{ function newsletter_subscirbe()
+// {{{ menu HOOK
+
+function &newsletter_menu(&$result)
+{
+    global $globals;
+    $globals->menu->addPrivateEntry(XOM_INFOS, 0, 'Lettres mensuelles', 'newsletter/');
+}
+
+// }}}
+// {{{ subscribe HOOK
 
 function &newsletter_subscribe($forlife, $uid, $promo, $password, &$result)
 {
diff --git a/hooks/search.inc.php b/hooks/search.inc.php
new file mode 100644 (file)
index 0000000..8726256
--- /dev/null
@@ -0,0 +1,33 @@
+<?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                *
+ ***************************************************************************/
+
+// {{{ menu HOOK
+
+function search_menu(&$result)
+{
+    global $globals;
+    $globals->menu->addPrivateEntry(XOM_GROUPS, 00, 'Annuaire',         'search.php');
+    $globals->menu->addPublicEntry(XOM_EXT,     00, 'Annuaire de l\'X', 'search.php');
+}
+
+// }}}
+
+?>
diff --git a/hooks/tmp.inc.php b/hooks/tmp.inc.php
new file mode 100644 (file)
index 0000000..7eedb8b
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+
+function tmp_menu(&$result)
+{
+    global $globals;
+    $globals->menu->addPrivateEntry(XOM_NO,       10, 'Page d\'accueil',       'login.php');
+
+    $globals->menu->addPrivateEntry(XOM_CUSTOM,   10, 'Mon profil',            'profil.php');
+    $globals->menu->addPrivateEntry(XOM_CUSTOM,   20, 'Mes contacts',          'carnet/mescontacts.php');
+    $globals->menu->addPrivateEntry(XOM_CUSTOM,   30, 'Mon carnet',            'carnet/');
+    $globals->menu->addPrivateEntry(XOM_CUSTOM,   40, 'Mon mot de passe',      'motdepassemd5.php');
+    $globals->menu->addPrivateEntry(XOM_CUSTOM,   50, 'Mes préférences',       'preferences.php');
+
+    $globals->menu->addPrivateEntry(XOM_GROUPS,   10, 'Trombi promo',          'trombipromo.php');
+    $globals->menu->addPrivateEntry(XOM_GROUPS,   20, 'Conseil Pro.',          'referent.php');
+    $globals->menu->addPrivateEntry(XOM_GROUPS,   30, 'Groupes X',             'http://www.polytechnique.net/plan.php');
+    $globals->menu->addPrivateEntry(XOM_GROUPS,   40, 'Web Polytechnicien',    'http://www.polytechnique.net/');
+
+    $globals->menu->addPrivateEntry(XOM_INFOS,    10, 'Documentations',        'docs/');
+    $globals->menu->addPrivateEntry(XOM_INFOS,    20, 'Nous contacter',        'docs/contacts.php');
+    $globals->menu->addPrivateEntry(XOM_INFOS,    30, 'Emploi',                'http://www.manageurs.com/');
+
+    $globals->menu->addPrivateEntry(XOM_ADMIN,    00, 'Marketing',           'marketing/');
+    $globals->menu->addPrivateEntry(XOM_ADMIN,    10, 'Administration',      'admin/');
+    $globals->menu->addPrivateEntry(XOM_ADMIN,    20, 'Clear cache',         'clear_all_cache.php');
+
+    $globals->menu->addPublicEntry(XOM_US,    00, 'Me connecter !',         'login.php');
+    $globals->menu->addPublicEntry(XOM_US,    10, 'M\'inscrire',            'inscription/');
+    $globals->menu->addPublicEntry(XOM_US,    20, 'Pourquoi m\'inscrire ?', 'docs/services.php');
+
+    $globals->menu->addPublicEntry(XOM_EXT,   10, 'Associations X',         'http://www.polytechnique.net/');
+    $globals->menu->addPublicEntry(XOM_EXT,   20, 'Recrutement',            'http://www.manageurs.com/');
+
+    $globals->menu->addPublicEntry(XOM_INFOS, 00, 'A propos du site',       'docs/apropos.php');
+    $globals->menu->addPublicEntry(XOM_INFOS, 10, 'Nous contacter',         'docs/contacts.php');
+    $globals->menu->addPublicEntry(XOM_INFOS, 20, 'FAQ',                    'docs/faq.php');
+}
+?>
diff --git a/include/conf.d/emails.menu.inc.php b/include/conf.d/emails.menu.inc.php
deleted file mode 100644 (file)
index 557f750..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<?php
-$this->addPrivateEntry(XOM_CUSTOM,   00, 'Mes emails',          'emails.php');
-
-if ($globals->mail->send_form) {
-    $this->addPrivateEntry(XOM_SERVICES, 00, 'Envoyer un mail', 'emails/send.php');
-}
-
-$this->addPrivateEntry(XOM_SERVICES, 40, 'Patte cassée',        'emails/broken.php');
-?>
diff --git a/include/conf.d/lists.menu.inc.php b/include/conf.d/lists.menu.inc.php
deleted file mode 100644 (file)
index 7e35aef..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-<?php
-$this->addPrivateEntry(XOM_SERVICES, 20, 'Listes de diffusion',   'listes/');
-?>
diff --git a/include/conf.d/money.menu.inc.php b/include/conf.d/money.menu.inc.php
deleted file mode 100644 (file)
index d07419b..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<?php
-if ($globals->money->mpay_enable) {
-    $this->addPrivateEntry(XOM_SERVICES, 30, 'Micropaiments', 'paiement/');
-}
-?>
diff --git a/include/conf.d/newsletter.menu.inc.php b/include/conf.d/newsletter.menu.inc.php
deleted file mode 100644 (file)
index a17c214..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-<?php
-$this->addPrivateEntry(XOM_INFOS,    00, 'Lettres mensuelles',    'newsletter/');
-?>
diff --git a/include/conf.d/search.menu.inc.php b/include/conf.d/search.menu.inc.php
deleted file mode 100644 (file)
index 0afe4fd..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<?php
-
-$this->addPrivateEntry(XOM_GROUPS, 00, 'Annuaire',         'search.php');
-$this->addPublicEntry(XOM_EXT,     00, 'Annuaire de l\'X', 'search.php');
-
-?>
diff --git a/include/conf.d/tmp.menu.inc.php b/include/conf.d/tmp.menu.inc.php
deleted file mode 100644 (file)
index 4cd0a15..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-$this->addPrivateEntry(XOM_NO,       10, 'Page d\'accueil',       'login.php');
-
-$this->addPrivateEntry(XOM_CUSTOM,   10, 'Mon profil',            'profil.php');
-$this->addPrivateEntry(XOM_CUSTOM,   20, 'Mes contacts',          'carnet/mescontacts.php');
-$this->addPrivateEntry(XOM_CUSTOM,   30, 'Mon carnet',            'carnet/');
-$this->addPrivateEntry(XOM_CUSTOM,   40, 'Mon mot de passe',      'motdepassemd5.php');
-$this->addPrivateEntry(XOM_CUSTOM,   50, 'Mes préférences',       'preferences.php');
-
-$this->addPrivateEntry(XOM_GROUPS,   10, 'Trombi promo',          'trombipromo.php');
-$this->addPrivateEntry(XOM_GROUPS,   20, 'Conseil Pro.',          'referent.php');
-$this->addPrivateEntry(XOM_GROUPS,   30, 'Groupes X',             'http://www.polytechnique.net/plan.php');
-$this->addPrivateEntry(XOM_GROUPS,   40, 'Web Polytechnicien',    'http://www.polytechnique.net/');
-
-$this->addPrivateEntry(XOM_INFOS,    10, 'Documentations',        'docs/');
-$this->addPrivateEntry(XOM_INFOS,    20, 'Nous contacter',        'docs/contacts.php');
-$this->addPrivateEntry(XOM_INFOS,    30, 'Emploi',                'http://www.manageurs.com/');
-
-$this->addPrivateEntry(XOM_ADMIN,    00, 'Marketing',           'marketing/');
-$this->addPrivateEntry(XOM_ADMIN,    10, 'Administration',      'admin/');
-$this->addPrivateEntry(XOM_ADMIN,    20, 'Clear cache',         'clear_all_cache.php');
-
-$this->addPublicEntry(XOM_US,    00, 'Me connecter !',         'login.php');
-$this->addPublicEntry(XOM_US,    10, 'M\'inscrire',            'inscription/');
-$this->addPublicEntry(XOM_US,    20, 'Pourquoi m\'inscrire ?', 'docs/services.php');
-
-$this->addPublicEntry(XOM_EXT,   10, 'Associations X',         'http://www.polytechnique.net/');
-$this->addPublicEntry(XOM_EXT,   20, 'Recrutement',            'http://www.manageurs.com/');
-
-$this->addPublicEntry(XOM_INFOS, 00, 'A propos du site',       'docs/apropos.php');
-$this->addPublicEntry(XOM_INFOS, 10, 'Nous contacter',         'docs/contacts.php');
-$this->addPublicEntry(XOM_INFOS, 20, 'FAQ',                    'docs/faq.php');
-?>
index 31f2857..a1f3f0c 100644 (file)
@@ -86,7 +86,7 @@ class XorgGlobals extends DiogenesCoreGlobals
         }
         
         $globals->hook = new XOrgHook();
-        $globals->menu = new XOrgMenu($globals->root.'/include/conf.d/');
+        $globals->menu = new XOrgMenu();
         $globals->hook->menu(null);
 
         $globals->dbconnect();
index 8256c68..bbfdd37 100644 (file)
@@ -54,7 +54,7 @@ class XOrgMenu
     // }}}
     // {{{ constructor
 
-    function XOrgMenu($path)
+    function XOrgMenu()
     {
         global $globals;
         
@@ -68,10 +68,6 @@ class XOrgMenu
         $this->_ext[XOM_US]       = Array();
         $this->_ext[XOM_EXT]      = Array();
         $this->_ext[XOM_INFOS]    = Array();
-        
-        foreach (glob($path.'*.menu.inc.php') as $inc) {
-            require_once($inc);
-        }
     }
 
     // }}}