X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fplatalpage.php;h=f3bb2fa760d3225c9af81d673484f937d4bce242;hb=06df222b7962dd5b71b34ec1dd078276d7327dbc;hp=42b6fcd9edb02bf4618c86d2d8f1012335a5544a;hpb=908db125b895b963213e75c16d6428d36e866b04;p=platal.git diff --git a/classes/platalpage.php b/classes/platalpage.php index 42b6fcd..f3bb2fa 100644 --- a/classes/platalpage.php +++ b/classes/platalpage.php @@ -1,6 +1,6 @@ compile_check = !empty($globals->debug); $this->changeTpl($tpl, $type); - $this->_errors = array(); + $this->_errors = array('errors' => array()); $this->_jsonVars = array(); $this->_failure = false; if ($globals->mode != 'rw') { - $this->_errors[] = "En raison d'une maintenance, une partie des fonctionnalités du site sont actuellement" - . " désactivée, en particuliers aucune donnée ne sera sauvegardée"; + $this->trigError("En raison d'une maintenance, une partie des fonctionnalités du site sont" + . " actuellement désactivée, en particuliers aucune donnée ne sera sauvegardée"); } $this->register_prefilter('at_to_globals'); $this->addJsLink('xorg.js'); + $this->addJsLink('jquery.js'); } // }}} @@ -93,7 +94,8 @@ abstract class PlatalPage extends Smarty $this->register_prefilter('form_force_encodings'); $this->register_prefilter('wiki_include'); $this->register_prefilter('if_has_perms'); - $this->assign('xorg_errors', $this->_errors); + $this->assign('xorg_triggers', $this->_errors); + $this->assign('xorg_errors', $this->nb_errs()); $this->assign('xorg_failure', $this->_failure); $this->assign('globals', $globals); @@ -124,7 +126,9 @@ abstract class PlatalPage extends Smarty $this->register_modifier('escape_html', 'escape_html'); $this->default_modifiers = Array('@escape_html'); } - $this->register_outputfilter('hide_emails'); + if (S::i('auth') <= AUTH_PUBLIC) { + $this->register_outputfilter('hide_emails'); + } $this->addJsLink('wiki.js'); header("Accept-Charset: utf-8"); if (Env::v('forceXml')) { @@ -141,9 +145,11 @@ abstract class PlatalPage extends Smarty if (!($globals->debug & DEBUG_SMARTY)) { error_reporting(0); } + $START_SMARTY = microtime(true); $result = $this->fetch($skin); - $ttime = sprintf('Temps total: %.02fs - Mémoire totale : %dKo
', microtime(true) - $TIME_BEGIN - , memory_get_peak_usage(true) / 1024); + $ttime = sprintf('Temps total: %.02fs (Smarty %.02fs) - Mémoire totale : %dKo
', + microtime(true) - $TIME_BEGIN, microtime(true) - $START_SMARTY, + memory_get_peak_usage(true) / 1024); if ($globals->debug & DEBUG_BT) { PlBacktrace::clean(); $this->assign_by_ref('backtraces', PlBacktrace::$bt); @@ -182,15 +188,33 @@ abstract class PlatalPage extends Smarty public function nb_errs() { - return count($this->_errors); + return count($this->_errors['errors']); } // }}} // {{{ function trig() - public function trig($msg) + private function trig($msg, $type = 'errors') + { + if (!isset($this->_errors[$type])) { + $this->_errors[$type] = array(); + } + $this->_errors[$type][] = $msg; + } + + public function trigError($msg) + { + $this->trig($msg, 'errors'); + } + + public function trigWarning($msg) + { + $this->trig($msg, 'warnings'); + } + + public function trigSuccess($msg) { - $this->_errors[] = $msg; + $this->trig($msg, 'success'); } // }}} @@ -201,7 +225,7 @@ abstract class PlatalPage extends Smarty global $platal; $this->assign('platal', $platal); - $this->trig($msg); + $this->trigError($msg); $this->_failure = true; $this->run(); }