From 62a66dfc26089fb5c15f36617c40e82380c052f0 Mon Sep 17 00:00:00 2001 From: x2000habouzit Date: Sat, 22 Jul 2006 19:51:41 +0000 Subject: [PATCH] remove the too complicated thing for menu, use a good old template instead. remove all menu related thingies. create a new kind of page: SIMPLE, and convert the ugly 'simple' assignments git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@570 839d8a87-29fc-0310-9880-83ba4fa771e5 --- hooks/README | 3 - hooks/banana.inc.php | 9 --- hooks/emails.inc.php | 18 ----- hooks/lists.inc.php | 9 --- hooks/money.inc.php | 12 ---- hooks/newsletter.inc.php | 9 --- hooks/search.inc.php | 10 --- hooks/tmp.inc.php | 39 ----------- include/platal.inc.php | 3 +- include/platal/page.inc.php | 12 ++-- include/xorg.inc.php | 8 +-- include/xorg/globals.inc.php | 4 -- include/xorg/hook.inc.php | 29 +------- include/xorg/menu.inc.php | 119 --------------------------------- modules/geoloc.php | 3 +- modules/profile.php | 6 +- modules/register.php | 3 +- modules/search.php | 6 +- templates/skin/common.bandeau.head.tpl | 1 - templates/skin/common.menu.tpl | 94 ++++++++++++++++++++++++++ templates/skin/default.tpl | 17 +---- templates/skin/espace.tpl | 19 +----- templates/skin/humlinux.tpl | 19 +----- templates/skin/linux.tpl | 19 +----- templates/skin/liteskin.tpl | 19 +----- templates/skin/nbviolet.tpl | 19 +----- templates/skin/newxorg.tpl | 19 +----- templates/skin/oldtimes.tpl | 19 +----- templates/skin/openweb.tpl | 19 +----- templates/skin/sharky.tpl | 19 +----- templates/skin/spectral.tpl | 19 +----- templates/skin/trapped.tpl | 19 +----- 32 files changed, 137 insertions(+), 486 deletions(-) delete mode 100644 include/xorg/menu.inc.php create mode 100644 templates/skin/common.menu.tpl diff --git a/hooks/README b/hooks/README index 86ad06b..5ae46ff 100644 --- a/hooks/README +++ b/hooks/README @@ -2,9 +2,6 @@ config() function used to create new config entries in $globals. usually, a module need to create a ....Config class to store the defaults. -menu() - function used to add entries to $globals->menu - subscribe($forlife, $uid, $promo, $pass) triggered when a user subscription is sucessfull diff --git a/hooks/banana.inc.php b/hooks/banana.inc.php index 15615c4..588a94b 100644 --- a/hooks/banana.inc.php +++ b/hooks/banana.inc.php @@ -43,15 +43,6 @@ function banana_config() } // }}} -// {{{ menu HOOK - -function banana_menu() -{ - global $globals; - $globals->menu->addPrivateEntry(XOM_SERVICES, 10, 'Forums & PA', 'banana/'); -} - -// }}} // {{{ subscribe HOOK function banana_subscribe($forlife, $uid, $promo, $password) diff --git a/hooks/emails.inc.php b/hooks/emails.inc.php index 1a2f5a3..996eedf 100644 --- a/hooks/emails.inc.php +++ b/hooks/emails.inc.php @@ -31,8 +31,6 @@ class MailConfig var $alias_dom = ''; var $alias_dom2 = ''; - var $send_form = true; - function shorter_domain() { if (empty($this->domain2) || strlen($this->domain2)>strlen($this->domain)) { @@ -51,20 +49,4 @@ function emails_config() $globals->mail = new MailConfig; } // }}} -// {{{ menu HOOK - -function emails_menu() -{ - global $globals; - $globals->menu->addPrivateEntry(XOM_CUSTOM, 00, 'Mes emails', 'emails'); - - if ($globals->mail->send_form) { - $globals->menu->addPrivateEntry(XOM_SERVICES, 00, 'Envoyer un mail', 'emails/send'); - } - - $globals->menu->addPrivateEntry(XOM_SERVICES, 40, 'Patte cassée', 'emails/broken'); - -} - -// }}} ?> diff --git a/hooks/lists.inc.php b/hooks/lists.inc.php index f209ecb..a84448d 100644 --- a/hooks/lists.inc.php +++ b/hooks/lists.inc.php @@ -42,15 +42,6 @@ function lists_config() } // }}} -// {{{ menu HOOK - -function lists_menu() -{ - global $globals; - $globals->menu->addPrivateEntry(XOM_SERVICES, 20, 'Listes de diffusion', 'lists'); -} - -// }}} // {{{ subscribe HOOK function lists_subscribe($forlife, $uid, $promo, $password) diff --git a/hooks/money.inc.php b/hooks/money.inc.php index 7549511..5390aef 100644 --- a/hooks/money.inc.php +++ b/hooks/money.inc.php @@ -42,17 +42,5 @@ function money_config() } // }}} -// {{{ menu HOOK - - -function money_menu() -{ - global $globals; - if ($globals->money->mpay_enable) { - $globals->menu->addPrivateEntry(XOM_SERVICES, 30, 'Télépaiements', 'payment'); - } -} - -// }}} ?> diff --git a/hooks/newsletter.inc.php b/hooks/newsletter.inc.php index bdaaec5..e88f50c 100644 --- a/hooks/newsletter.inc.php +++ b/hooks/newsletter.inc.php @@ -38,15 +38,6 @@ function newsletter_config() { } // }}} -// {{{ menu HOOK - -function newsletter_menu() -{ - global $globals; - $globals->menu->addPrivateEntry(XOM_INFOS, 0, 'Lettres mensuelles', 'nl'); -} - -// }}} // {{{ subscribe HOOK function newsletter_subscribe($forlife, $uid, $promo, $password) diff --git a/hooks/search.inc.php b/hooks/search.inc.php index f102adb..26b7d22 100644 --- a/hooks/search.inc.php +++ b/hooks/search.inc.php @@ -47,15 +47,5 @@ function search_subscribe($forlife, $uid, $promo, $pass) user_reindex($uid); } // }}} -// {{{ menu HOOK - -function search_menu() -{ - global $globals; - $globals->menu->addPrivateEntry(XOM_GROUPS, 00, 'Annuaire', 'search'); - $globals->menu->addPublicEntry(XOM_EXT, 00, 'Annuaire de l\'X', 'search'); -} - -// }}} ?> diff --git a/hooks/tmp.inc.php b/hooks/tmp.inc.php index 6f75b57..def0722 100644 --- a/hooks/tmp.inc.php +++ b/hooks/tmp.inc.php @@ -19,49 +19,10 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ -function tmp_menu() -{ - global $globals; - - $globals->menu->addPrivateEntry(XOM_CUSTOM, 10, 'Mon profil', 'profile/edit'); - $globals->menu->addPrivateEntry(XOM_CUSTOM, 20, 'Mes contacts', 'carnet/contacts'); - $globals->menu->addPrivateEntry(XOM_CUSTOM, 30, 'Mon carnet', 'carnet/'); - $globals->menu->addPrivateEntry(XOM_CUSTOM, 40, 'Mon mot de passe', 'password'); - $globals->menu->addPrivateEntry(XOM_CUSTOM, 50, 'Mes préférences', 'prefs'); - - $globals->menu->addPrivateEntry(XOM_GROUPS, 10, 'Trombi promo', 'trombi'); - $globals->menu->addPrivateEntry(XOM_GROUPS, 20, 'Conseil Pro.', 'referent/search'); - if ($globals->geoloc->use_map()) - $globals->menu->addPrivateEntry(XOM_GROUPS, 10, 'Planisphère', 'geoloc/'); - $globals->menu->addPrivateEntry(XOM_GROUPS, 30, 'Groupes X', 'http://www.polytechnique.net/plan'); - - $globals->menu->addPrivateEntry(XOM_INFOS, 10, 'Documentations', 'Docs/'); - $globals->menu->addPrivateEntry(XOM_INFOS, 20, 'Nous contacter', 'Docs/NousContacter'); - $globals->menu->addPrivateEntry(XOM_INFOS, 30, 'Carrières', 'Docs/Emploi'); - - $globals->menu->addPrivateEntry(XOM_ADMIN, 00, 'Marketing', 'marketing'); - $globals->menu->addPrivateEntry(XOM_ADMIN, 10, 'Administration', 'admin/'); - $globals->menu->addPrivateEntry(XOM_ADMIN, 20, 'Clear cache', 'purge_cache'); - $globals->menu->addPrivateEntry(XOM_ADMIN, 30, 'Trackers', 'http://trackers.polytechnique.org'); - $globals->menu->addPrivateEntry(XOM_ADMIN, 40, 'Support', 'http://support.polytechnique.org'); - - $globals->menu->addPublicEntry(XOM_US, 00, 'Me connecter !', 'events'); - $globals->menu->addPublicEntry(XOM_US, 10, 'M\'inscrire', 'register/'); - $globals->menu->addPublicEntry(XOM_US, 20, 'Pourquoi m\'inscrire ?', 'Docs/PourquoiM\'Inscrire'); - - $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'); - $globals->menu->addPublicEntry(XOM_INFOS, 10, 'Nous contacter', 'Docs/NousContacter'); - $globals->menu->addPublicEntry(XOM_INFOS, 20, 'FAQ', 'Docs/FAQ'); -} - // {{{ subscribe HOOK function tmp_subscribe($forlife, $uid, $promo, $password) { - require_once('notifs.inc.php'); register_watch_op($uid, WATCH_INSCR); inscription_notifs_base($uid); diff --git a/include/platal.inc.php b/include/platal.inc.php index 93cf3cb..b4d0491 100644 --- a/include/platal.inc.php +++ b/include/platal.inc.php @@ -35,7 +35,8 @@ define('PERMS_USER', 'user'); define('PERMS_ADMIN', 'admin'); define('SKINNED', 0); -define('NO_SKIN', 1); +define('SIMPLE', 1); +define('NO_SKIN', 2); require_once('platal/env.inc.php'); diff --git a/include/platal/page.inc.php b/include/platal/page.inc.php index d37f4df..ccbd60c 100644 --- a/include/platal/page.inc.php +++ b/include/platal/page.inc.php @@ -41,7 +41,7 @@ class PlatalPage extends Smarty // }}} // {{{ function PlatalPage() - function PlatalPage($tpl, $type=SKINNED) + function PlatalPage($tpl, $type = SKINNED) { global $globals; @@ -83,7 +83,7 @@ class PlatalPage extends Smarty // }}} // {{{ function changeTpl() - function changeTpl($tpl, $type=SKINNED) + function changeTpl($tpl, $type = SKINNED) { $this->_tpl = $tpl; $this->_page_type = $type; @@ -103,10 +103,14 @@ class PlatalPage extends Smarty $this->assign("xorg_errors", $this->_errors); $this->assign("xorg_failure", $this->_failure); - if ($this->_page_type == NO_SKIN) { + switch ($this->_page_type) { + case NO_SKIN: $this->display($this->_tpl); exit; - } else { + + case SIMPLE: + $page->assign('simple', true); + case SKINNED: $this->register_modifier('escape_html', 'escape_html'); $this->default_modifiers = Array('@escape_html'); } diff --git a/include/xorg.inc.php b/include/xorg.inc.php index 8c121dc..e655036 100644 --- a/include/xorg.inc.php +++ b/include/xorg.inc.php @@ -31,7 +31,7 @@ require_once('platal/page.inc.php'); class XorgPage extends PlatalPage { - function XorgPage($tpl, $type=SKINNED) + function XorgPage($tpl, $type = SKINNED) { $this->PlatalPage($tpl, $type); } @@ -39,9 +39,7 @@ class XorgPage extends PlatalPage function run() { global $globals; - if ($this->_page_type != NO_SKIN) { - $this->assign('menu', $globals->menu->menu()); - } + $this->assign('globals', $globals); $this->_run('skin/'.S::v('skin', 'default.tpl')); } } @@ -55,7 +53,7 @@ class XorgAdmin extends XorgPage { // {{{ function XorgAdmin() - function XorgAdmin($tpl, $type=SKINNED) + function XorgAdmin($tpl, $type = SKINNED) { $this->XorgPage($tpl, $type); check_perms(); diff --git a/include/xorg/globals.inc.php b/include/xorg/globals.inc.php index 6e85264..5ad3363 100644 --- a/include/xorg/globals.inc.php +++ b/include/xorg/globals.inc.php @@ -34,19 +34,15 @@ class XorgGlobals extends PlatalGlobals { global $globals; require_once('xorg/hook.inc.php'); - require_once('xorg/menu.inc.php'); $globals = new XorgGlobals; $globals->core = new CoreConfig; $globals->hook = new XOrgHook(); - $globals->menu = new XOrgMenu(); $globals->hook->config(null); $globals->read_config(); - $globals->hook->menu(null); - $globals->dbconnect(); if ($globals->debug & 1) { $globals->db->trace_on(); diff --git a/include/xorg/hook.inc.php b/include/xorg/hook.inc.php index 77a4ad4..c992f45 100644 --- a/include/xorg/hook.inc.php +++ b/include/xorg/hook.inc.php @@ -46,7 +46,7 @@ class XOrgHook { // {{{ properties - + /** * list of all the modules names that have implemented some reactions to our triggers * @@ -54,7 +54,7 @@ class XOrgHook * @access private */ var $_mods = Array(); - + // }}} // {{{ constructor XOrgHook() @@ -85,17 +85,6 @@ class XOrgHook } // }}} - // {{{ function menu - - function menu() - { - foreach ($this->_mods as $mod) { - if (!function_exists($mod.'_menu')) continue; - call_user_func($mod.'_menu'); - } - } - - // }}} // {{{ function subscribe function subscribe($forlife, $uid, $promo, $pass) @@ -107,20 +96,6 @@ class XOrgHook } // }}} - // {{{ function prefs - - function prefs() - { - $res = Array(); - foreach ($this->_mods as $mod) { - if (!function_exists($mod.'_prefs')) continue; - $res = array_merge($res, call_user_func($mod.'_prefs')); - } - usort($res, create_function('$a, $b', 'return strcmp($a["weight"], $b["weight"]);')); - return $res; - } - - // }}} } // }}} diff --git a/include/xorg/menu.inc.php b/include/xorg/menu.inc.php deleted file mode 100644 index 8e81558..0000000 --- a/include/xorg/menu.inc.php +++ /dev/null @@ -1,119 +0,0 @@ - - * @access public - */ - -class XOrgMenu -{ - // {{{ properties - - var $_ext = Array(); - var $_int = Array(); - - // }}} - // {{{ constructor - - function XOrgMenu() - { - $this->_int[XOM_NO] = array(); - $this->_int[XOM_CUSTOM] = array(); - $this->_int[XOM_SERVICES] = array(); - $this->_int[XOM_GROUPS] = array(); - $this->_int[XOM_INFOS] = array(); - $this->_int[XOM_ADMIN] = array(); - - $this->_ext[XOM_US] = array(); - $this->_ext[XOM_EXT] = array(); - $this->_ext[XOM_INFOS] = array(); - } - - // }}} - // {{{ function addPublicEntry - - function addPublicEntry($head, $prio, $text, $url) - { - $this->_ext[$head][] = Array($prio, 'text' => $text, 'url' => $url); - } - - // }}} - // {{{ function addPrivateEntry - - function addPrivateEntry($head, $prio, $text, $url) - { - $this->_int[$head][] = Array($prio, 'text' => $text, 'url' => $url); - } - - // }}} - // {{{ function menu() - - function menu() - { - $res = S::logged() ? $this->_int : $this->_ext; - if (S::identified()) { - $res[XOM_NO][] = Array(0, 'text' => 'Déconnexion', - 'url' => 'exit'); - } elseif (Cookie::has('ORGaccess')) { - $res[XOM_NO][] = Array(0, 'text' => 'Déconnexion totale', - 'url' => 'exit/forget'); - } - if (!S::has_perms()) { - unset($res[XOM_ADMIN]); - } - foreach (array_keys($res) as $key) { - if (empty($res[$key])) { - unset($res[$key]); - } else { - sort($res[$key]); - } - } - return $res; - } - - // }}} -} - -// }}} - -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker: -?> diff --git a/modules/geoloc.php b/modules/geoloc.php index 3ea7f4f..370a121 100644 --- a/modules/geoloc.php +++ b/modules/geoloc.php @@ -151,8 +151,7 @@ class GeolocModule extends PLModule // to debug sql use the next line if (Env::has('debug')) { - $page->changeTpl('geoloc/getData.tpl'); - $page->assign('simple', true); + $page->changeTpl('geoloc/getData.tpl', SIMPLE); } else { header("Content-type: text/xml"); $page->changeTpl('geoloc/getData.tpl', NO_SKIN); diff --git a/modules/profile.php b/modules/profile.php index 36f5205..0727241 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -161,8 +161,7 @@ class ProfileModule extends PLModule global $globals; require_once 'user.func.inc.php'; - $page->changeTpl('fiche.tpl'); - $page->assign('simple', true); + $page->changeTpl('fiche.tpl', SIMPLE); $view = 'private'; if (!S::logged() || Env::get('view') == 'public') $view = 'public'; @@ -403,8 +402,7 @@ class ProfileModule extends PLModule return PL_NOT_FOUND; } - $page->changeTpl('fiche_referent.tpl'); - $page->assign('simple', true); + $page->changeTpl('fiche_referent.tpl', SIMPLE); $res = XDB::query( "SELECT prenom, nom, user_id, promo, cv, a.alias AS bestalias diff --git a/modules/register.php b/modules/register.php index 93575fe..d2ca34f 100644 --- a/modules/register.php +++ b/modules/register.php @@ -146,8 +146,7 @@ class RegisterModule extends PLModule } $_SESSION['sub_state'] = $sub_state; - $page->changeTpl('register/step'.intval($sub_state['step']).'.tpl'); - $page->assign('simple', true); + $page->changeTpl('register/step'.intval($sub_state['step']).'.tpl', SIMPLE); if (isset($err)) { $page->trig($err); } diff --git a/modules/search.php b/modules/search.php index 6024d6f..e48af11 100644 --- a/modules/search.php +++ b/modules/search.php @@ -193,11 +193,7 @@ class SearchModule extends PLModule require_once 'geoloc.inc.php'; - $page->changeTpl('search/index.tpl'); - - if ($mode == 'mini') { - $page->assign('simple', true); - } + $page->changeTpl('search/index.tpl', $mode == 'mini' ? SIMPLE : SKINNED); $page->assign('advanced',1); $page->assign('public_directory',0); diff --git a/templates/skin/common.bandeau.head.tpl b/templates/skin/common.bandeau.head.tpl index 1839a42..6ef56a1 100644 --- a/templates/skin/common.bandeau.head.tpl +++ b/templates/skin/common.bandeau.head.tpl @@ -20,7 +20,6 @@ {* *} {**************************************************************************} - {literal}