From d7610c358d074c78e1e8dc25fe0cf0e5e7e1c55e Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Sun, 22 Jun 2008 13:43:30 +0200 Subject: [PATCH] $page is not anymore a global variable. Signed-off-by: Florent Bruneau --- classes/platal.php | 5 ++--- htdocs/xnet.php | 1 - include/applis.func.inc.php | 10 ++++------ include/banana/forum.inc.php | 3 ++- include/banana/hooks.inc.php | 7 +++---- include/banana/moderate.inc.php | 5 +---- include/rss.inc.php | 2 +- include/user.func.inc.php | 7 +++---- include/validations.inc.php | 9 +++------ include/wiki.inc.php | 6 ++++-- modules/carnet.php | 2 +- modules/gadgets/gadgets.inc.php | 5 ++--- modules/payment.php | 4 ++-- modules/profile/general.inc.php | 5 ++--- modules/profile/mentor.inc.php | 6 ++---- modules/profile/page.inc.php | 22 ++++++++-------------- modules/search.php | 7 ++----- modules/search/classes.inc.php | 6 +++--- modules/xnetevents/xnetevents.inc.php | 3 ++- modules/xnetgrp.php | 8 ++++---- 20 files changed, 51 insertions(+), 72 deletions(-) diff --git a/classes/platal.php b/classes/platal.php index 1d5c466..89f8dc6 100644 --- a/classes/platal.php +++ b/classes/platal.php @@ -329,11 +329,10 @@ class Platal static public function &page() { - global $platal, $page; + global $platal; if (is_null(self::$_page)) { $pageclass = PL_PAGE_CLASS; - $page = new $pageclass(); - self::$_page =& $page; + self::$_page = $pageclass(); } return self::$_page; } diff --git a/htdocs/xnet.php b/htdocs/xnet.php index 592ba18..e6daefe 100644 --- a/htdocs/xnet.php +++ b/htdocs/xnet.php @@ -20,7 +20,6 @@ ***************************************************************************/ $GLOBALS['IS_XNET_SITE'] = true; -global $platal, $globals, $page; require_once dirname(__FILE__).'/../include/xnet.inc.php'; diff --git a/include/applis.func.inc.php b/include/applis.func.inc.php index 849adc3..82235db 100644 --- a/include/applis.func.inc.php +++ b/include/applis.func.inc.php @@ -19,8 +19,6 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ -global $page; - function applis_options($current=0) { $html = ''; $res = XDB::iterator("select * from applis_def order by text"); @@ -38,7 +36,7 @@ function _applis_options_smarty($params){ $params['selected'] = 0; return applis_options($params['selected']); } -$page->register_function('applis_options','_applis_options_smarty'); +Platal::page()->register_function('applis_options','_applis_options_smarty'); /** affiche un Array javascript contenant les types de chaque appli @@ -54,7 +52,7 @@ function applis_type(){ } return $html; } -$page->register_function('applis_type','applis_type'); +Platal::page()->register_function('applis_type','applis_type'); /** affiche tous les types possibles d'applis */ @@ -63,7 +61,7 @@ function applis_type_all(){ $arr_appli = $res->fetchOneAssoc(); return str_replace(")","",str_replace("set(","",$arr_appli["Type"])); } -$page->register_function('applis_type_all','applis_type_all'); +Platal::page()->register_function('applis_type_all','applis_type_all'); /** formatte une ecole d'appli pour l'affichage */ @@ -87,7 +85,7 @@ function _applis_fmt($params, &$smarty) { extract($params); return applis_fmt($type, $text, $url); } -$page->register_function('applis_fmt','_applis_fmt'); +Platal::page()->register_function('applis_fmt','_applis_fmt'); // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?> diff --git a/include/banana/forum.inc.php b/include/banana/forum.inc.php index 54502e3..6cd9f77 100644 --- a/include/banana/forum.inc.php +++ b/include/banana/forum.inc.php @@ -174,7 +174,8 @@ class ForumsBanana extends Banana protected function action_updateProfile() { - global $page, $globals; + global $globals; + $page = Platal::page(); if (Post::has('action') && Post::has('banananame') && Post::has('bananasig') && Post::has('bananadisplay') && Post::has('bananamail') diff --git a/include/banana/hooks.inc.php b/include/banana/hooks.inc.php index 987de13..aa44917 100644 --- a/include/banana/hooks.inc.php +++ b/include/banana/hooks.inc.php @@ -200,8 +200,7 @@ function hook_getXFace($headers) function hook_makeJs($src) { - global $page; - $page->addJsLink("$src.js"); + Platal::page()->addJsLink("$src.js"); return ' '; } @@ -290,12 +289,12 @@ class PlatalBananaPage extends BananaPage protected function prepare() { $tpl = parent::prepare(); - global $wiz, $page; + global $wiz; $wiz = new PlWizard('Banana', 'core/plwizard.tpl', true, false); foreach ($this->pages as $name=>&$mpage) { $wiz->addPage($this->handler, $mpage['text'], $name); } - $wiz->apply($page, $this->base, $this->page); + $wiz->apply(Platal::page(), $this->base, $this->page); return $tpl; } } diff --git a/include/banana/moderate.inc.php b/include/banana/moderate.inc.php index 70cc2fa..62c2dbc 100644 --- a/include/banana/moderate.inc.php +++ b/include/banana/moderate.inc.php @@ -89,10 +89,7 @@ class ModerationPage extends BananaPage public function trig($msg) { - global $page; - if ($page) { - $page->trigError($msg); - } + Platal::page()->trigError($msg); return true; } } diff --git a/include/rss.inc.php b/include/rss.inc.php index 0117fc0..3b07d78 100644 --- a/include/rss.inc.php +++ b/include/rss.inc.php @@ -30,7 +30,7 @@ function _rss_encode_date($d) { function init_rss($template, $alias, $hash, $require_uid = true) { - global $page; + $page =& Platal::page(); $page->changeTpl($template, NO_SKIN); $page->register_modifier('rss_date', '_rss_encode_date'); diff --git a/include/user.func.inc.php b/include/user.func.inc.php index b903654..1f8a698 100644 --- a/include/user.func.inc.php +++ b/include/user.func.inc.php @@ -87,8 +87,7 @@ function user_clear_all_subs($user_id, $really_del=true) // Defaut callback to call when a login is not found function _default_user_callback($login) { - global $page; - $page->trigError("Il n'y a pas d'utilisateur avec l'identifiant : $login"); + Platal::page()->trigError("Il n'y a pas d'utilisateur avec l'identifiant : $login"); return; } @@ -99,7 +98,7 @@ function _silent_user_callback($login) function get_user_login($data, $get_forlife = false, $callback = '_default_user_callback') { - global $globals, $page; + global $globals; if (is_numeric($data)) { $res = XDB::query("SELECT alias FROM aliases WHERE type='a_vie' AND id={?}", $data); @@ -171,7 +170,7 @@ function get_user_login($data, $get_forlife = false, $callback = '_default_user_ default: if (S::has_perms()) { $aliases = $res->fetchColumn(); - $page->trigError("Il y a $i utilisateurs avec cette adresse mail : ".join(', ', $aliases)); + Platal::page()->trigError("Il y a $i utilisateurs avec cette adresse mail : ".join(', ', $aliases)); } else { $res->free(); } diff --git a/include/validations.inc.php b/include/validations.inc.php index 9814510..c65e15b 100644 --- a/include/validations.inc.php +++ b/include/validations.inc.php @@ -258,20 +258,17 @@ abstract class Validate protected function trigError($msg) { - global $page; - $page->trigError($msg); + Platal::page()->trigError($msg); } protected function trigWarning($msg) { - global $page; - $page->trigWarning($msg); + Platal::page()->trigWarning($msg); } protected function trigSuccess($msg) { - global $page; - $page->trigSuccess($msg); + Platal::page()->trigSuccess($msg); } // }}} diff --git a/include/wiki.inc.php b/include/wiki.inc.php index 906c0e1..4c42135 100644 --- a/include/wiki.inc.php +++ b/include/wiki.inc.php @@ -138,8 +138,10 @@ function wiki_apply_feed_perms($perm) exit; } -function wiki_apply_perms($perm) { - global $page, $platal, $globals; +function wiki_apply_perms($perm) +{ + global $platal, $globals; + $page =& Platal::page(); switch ($perm) { case 'public': diff --git a/modules/carnet.php b/modules/carnet.php index 78b0b69..417c983 100644 --- a/modules/carnet.php +++ b/modules/carnet.php @@ -195,7 +195,7 @@ class CarnetModule extends PLModule } function searchErrorHandler($explain) { - global $page; + $page =& Platal::page(); $page->trigError($explain); $this->handler_contacts($page); } diff --git a/modules/gadgets/gadgets.inc.php b/modules/gadgets/gadgets.inc.php index 613c2df..a778b3f 100644 --- a/modules/gadgets/gadgets.inc.php +++ b/modules/gadgets/gadgets.inc.php @@ -22,15 +22,14 @@ // iGoogle gadgets helpers. function init_igoogle_xml($template) { - global $page; - $page->changeTpl($template, NO_SKIN); + Platal::page()->changeTpl($template, NO_SKIN); header('Content-Type: application/xml; charset=utf-8'); } function init_igoogle_html($template, $auth = AUTH_PUBLIC) { - global $page; + $page =& Platal::page(); $page->changeTpl('gadgets/ig-skin.tpl', NO_SKIN); $page->register_modifier('escape_html', 'escape_html'); $page->default_modifiers = Array('@escape_html'); diff --git a/modules/payment.php b/modules/payment.php index 9de57d1..f3fcbcf 100644 --- a/modules/payment.php +++ b/modules/payment.php @@ -34,7 +34,7 @@ function cb_erreur($text) { /* sort en affichant une erreur */ function paypal_erreur($text, $send=true) { - global $page, $erreur, $globals; + global $erreur, $globals; if ($erreur) return; $erreur = $text; if (!$send) return; @@ -46,7 +46,7 @@ function paypal_erreur($text, $send=true) $mymail->setTxtBody("\n\n".var_export($_REQUEST,true)); $mymail->send(); - $page->trigError($text); + Platal::page()->trigError($text); } /* http://fr.wikipedia.org/wiki/Formule_de_Luhn */ diff --git a/modules/profile/general.inc.php b/modules/profile/general.inc.php index b00542e..8227f36 100644 --- a/modules/profile/general.inc.php +++ b/modules/profile/general.inc.php @@ -52,9 +52,8 @@ class ProfileNom implements ProfileSetting || $this->matchWord($ini, $new, $newLen) || ($field == 'nom' && $new == 'DE ' . $old); if (!$success) { - global $page; - $page->trigError("Le $field que tu as choisi ($value) est trop loin de ton $field initial ($init)" - . (($init == $current)? "" : " et de ton prénom précédent ($current)")); + Platal::page()->trigError("Le $field que tu as choisi ($value) est trop loin de ton $field initial ($init)" + . (($init == $current)? "" : " et de ton prénom précédent ($current)")); } return $success ? $value : $current; } diff --git a/modules/profile/mentor.inc.php b/modules/profile/mentor.inc.php index 673c3b9..bf577d9 100644 --- a/modules/profile/mentor.inc.php +++ b/modules/profile/mentor.inc.php @@ -42,8 +42,7 @@ class ProfileSecteurs implements ProfileSetting } else if (!is_array($value)) { $value = array(); } else if (count($value) > 10) { - global $page; - $page->trigError("Le nombre de secteurs d'expertise est limité à 10"); + Platal::page()->trigError("Le nombre de secteurs d'expertise est limité à 10"); $success = false; } ksort($value); @@ -90,8 +89,7 @@ class ProfileCountry implements ProfileSetting } else if (!is_array($value)) { $value = array(); } else if (count($value) > 10) { - global $page; - $page->trigError("Le nombre de secteurs d'expertise est limité à 10"); + Platal::page()->trigError("Le nombre de secteurs d'expertise est limité à 10"); $success = false; } ksort($value); diff --git a/modules/profile/page.inc.php b/modules/profile/page.inc.php index 2e785c9..7af2fef 100644 --- a/modules/profile/page.inc.php +++ b/modules/profile/page.inc.php @@ -53,9 +53,8 @@ class ProfileWeb extends ProfileNoSave $value = trim($value); $success = empty($value) || preg_match("{^(https?|ftp)://[a-zA-Z0-9._%#+/?=&~-]+$}i", $value); if (!$success) { - global $page; - $page->trigError('URL Incorrecte : une url doit commencer par http:// ou https:// ou ftp://' - . ' et ne pas contenir de caractères interdits'); + Platal::page()->trigError('URL Incorrecte : une url doit commencer par http:// ou https:// ou ftp://' + . ' et ne pas contenir de caractères interdits'); } return $value; } @@ -72,8 +71,7 @@ class ProfileEmail extends ProfileNoSave require_once 'xorg.misc.inc.php'; $success = empty($value) || isvalid_email($value); if (!$success) { - global $page; - $page->trigError('Adresse Email invalide'); + Platal::page()->trigError('Adresse Email invalide'); } return $value; } @@ -89,8 +87,7 @@ class ProfileTel extends ProfileNoSave } $success = !preg_match('/[<>{}@&#~\/:;?,!§*_`\[\]|%$^=]/', $value, $matches); if (!$success) { - global $page; - $page->trigError('Le numéro de téléphone contient un caractère interdit : ' . pl_entities($matches[0][0])); + Platal::page()->trigError('Le numéro de téléphone contient un caractère interdit : ' . pl_entities($matches[0][0])); } return $value; } @@ -135,16 +132,14 @@ class ProfileDate extends ProfileNoSave } else { $success = preg_match('@(\d{2})/(\d{2})/(\d{4})@', $value, $matches); if (!$success) { - global $page; - $page->trigError("Les dates doivent être au format jj/mm/aaaa"); + Platal::page()->trigError("Les dates doivent être au format jj/mm/aaaa"); } else { $day = (int)$matches[1]; $month = (int)$matches[2]; $year = (int)$matches[3]; $success = ($day > 0 && $day <= 31) && ($month > 0 && $month <= 12) && ($year > 1900 && $year <= 2020); if (!$success) { - global $page; - $page->trigError("La date n'a pas une valeur valide"); + Platal::page()->trigError("La date n'a pas une valeur valide"); } } } @@ -329,9 +324,8 @@ abstract class ProfilePage implements PlWizardPage } return Post::has('next_page') ? PlWizard::NEXT_PAGE : PlWizard::CURRENT_PAGE; } - global $page; - $page->trigError("Certains champs n'ont pas pu être validés, merci de corriger les informations " - . "de ton profil et de revalider ta demande"); + Platal::page()->trigError("Certains champs n'ont pas pu être validés, merci de corriger les informations " + . "de ton profil et de revalider ta demande"); return PlWizard::CURRENT_PAGE; } } diff --git a/modules/search.php b/modules/search.php index 56af880..b5ac4dd 100644 --- a/modules/search.php +++ b/modules/search.php @@ -47,9 +47,7 @@ class SearchModule extends PLModule function form_prepare() { - global $page; - - $page->assign('formulaire',1); + Platal::page()->assign('formulaire',1); } function get_diplomas($school = null) @@ -72,8 +70,7 @@ class SearchModule extends PLModule $types = explode('(',$row[1]); $types = str_replace("'","",substr($types[1],0,-1)); } - global $page; - $page->assign('choix_diplomas', explode(',',$types)); + Platal::page()->assign('choix_diplomas', explode(',',$types)); } function handler_quick(&$page, $action = null, $subaction = null) diff --git a/modules/search/classes.inc.php b/modules/search/classes.inc.php index 91c924d..406664e 100644 --- a/modules/search/classes.inc.php +++ b/modules/search/classes.inc.php @@ -92,7 +92,8 @@ class ThrowError */ private static function defaultHandler($explain) { - global $page, $globals; + global $globals; + $page =& Platal::page(); $page->changeTpl('search/index.tpl'); $page->assign('xorg_title','Polytechnique.org - Annuaire'); $page->assign('baseurl', $globals->baseurl); @@ -253,8 +254,7 @@ class QuickSearch extends SField $s = preg_replace('!\d+!', ' ', $s); $this->strings = preg_split("![^a-zA-Z%]+!",$s, -1, PREG_SPLIT_NO_EMPTY); if (count($this->strings) > 5) { - global $page; - $page->trigWarning("Tu as indiqué trop d'éléments dans ta recherche, seuls les 5 premiers seront pris en compte"); + Platal::page()->trigWarning("Tu as indiqué trop d'éléments dans ta recherche, seuls les 5 premiers seront pris en compte"); $this->strings = array_slice($this->strings, 0, 5); } diff --git a/modules/xnetevents/xnetevents.inc.php b/modules/xnetevents/xnetevents.inc.php index 1303d9c..d179a70 100644 --- a/modules/xnetevents/xnetevents.inc.php +++ b/modules/xnetevents/xnetevents.inc.php @@ -202,7 +202,8 @@ function get_event_participants(&$evt, $item_id, $tri, $limit = '') { function subscribe_lists_event($participate, $uid, $evt) { require_once('user.func.inc.php'); - global $globals,$page; + global $globals; + $page =& Platal::page(); $participant_list = $evt['participant_list']; $absent_list = $evt['absent_list']; diff --git a/modules/xnetgrp.php b/modules/xnetgrp.php index e4e882d..596a0a1 100644 --- a/modules/xnetgrp.php +++ b/modules/xnetgrp.php @@ -771,7 +771,7 @@ class XnetGrpModule extends PLModule function unsubscribe(&$user) { - global $globals, $page; + global $globals; XDB::execute( "DELETE FROM groupex.membres WHERE uid={?} AND asso_id={?}", $user['uid'], $globals->asso('id')); @@ -815,9 +815,9 @@ class XnetGrpModule extends PLModule $mmlist->unsubscribe($liste['list']); } } elseif ($liste['sub']) { - $page->trigWarning("{$user['prenom']} {$user['nom']} a une" - ." demande d'inscription en cours sur la" - ." liste {$liste['list']}@ !"); + Platal::page()->trigWarning("{$user['prenom']} {$user['nom']} a une" + ." demande d'inscription en cours sur la" + ." liste {$liste['list']}@ !"); $warning = true; } } -- 2.1.4