$page is not anymore a global variable.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 22 Jun 2008 11:43:30 +0000 (13:43 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 22 Jun 2008 11:43:30 +0000 (13:43 +0200)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
20 files changed:
classes/platal.php
htdocs/xnet.php
include/applis.func.inc.php
include/banana/forum.inc.php
include/banana/hooks.inc.php
include/banana/moderate.inc.php
include/rss.inc.php
include/user.func.inc.php
include/validations.inc.php
include/wiki.inc.php
modules/carnet.php
modules/gadgets/gadgets.inc.php
modules/payment.php
modules/profile/general.inc.php
modules/profile/mentor.inc.php
modules/profile/page.inc.php
modules/search.php
modules/search/classes.inc.php
modules/xnetevents/xnetevents.inc.php
modules/xnetgrp.php

index 1d5c466..89f8dc6 100644 (file)
@@ -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;
     }
index 592ba18..e6daefe 100644 (file)
@@ -20,7 +20,6 @@
  ***************************************************************************/
 
 $GLOBALS['IS_XNET_SITE'] = true;
-global $platal, $globals, $page;
 
 require_once dirname(__FILE__).'/../include/xnet.inc.php';
 
index 849adc3..82235db 100644 (file)
@@ -19,8 +19,6 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-global $page;
-
 function applis_options($current=0) {
     $html = '<option value="-1"></option>';
     $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:
 ?>
index 54502e3..6cd9f77 100644 (file)
@@ -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')
index 987de13..aa44917 100644 (file)
@@ -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;
     }
 }
index 70cc2fa..62c2dbc 100644 (file)
@@ -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;
     }
 }
index 0117fc0..3b07d78 100644 (file)
@@ -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');
 
index b903654..1f8a698 100644 (file)
@@ -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();
                 }
index 9814510..c65e15b 100644 (file)
@@ -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);
     }
 
     // }}}
index 906c0e1..4c42135 100644 (file)
@@ -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':
index 78b0b69..417c983 100644 (file)
@@ -195,7 +195,7 @@ class CarnetModule extends PLModule
     }
 
     function searchErrorHandler($explain) {
-        global $page;
+        $page =& Platal::page();
         $page->trigError($explain);
         $this->handler_contacts($page);
     }
index 613c2df..a778b3f 100644 (file)
 // 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');
index 9de57d1..f3fcbcf 100644 (file)
@@ -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 */
index b00542e..8227f36 100644 (file)
@@ -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;
     }
index 673c3b9..bf577d9 100644 (file)
@@ -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);
index 2e785c9..7af2fef 100644 (file)
@@ -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;
     }
 }
index 56af880..b5ac4dd 100644 (file)
@@ -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)
index 91c924d..406664e 100644 (file)
@@ -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);
         }
 
index 1303d9c..d179a70 100644 (file)
@@ -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'];
index e4e882d..596a0a1 100644 (file)
@@ -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;
             }
         }