X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fplatalpage.php;h=f3661d72c8ad0f59323084e92b0c496de8f37a6c;hb=ea62a1705b554185cbcec232731b5198149b1f50;hp=bf35d60e8757ee3305dad900ebb8172168b845ef;hpb=787bb3d745141f2f85bd947ad7dd775d2c63f908;p=platal.git
diff --git a/classes/platalpage.php b/classes/platalpage.php
index bf35d60..f3661d7 100644
--- a/classes/platalpage.php
+++ b/classes/platalpage.php
@@ -1,6 +1,6 @@
_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->register_prefilter('at_to_globals');
$this->addJsLink('xorg.js');
}
@@ -61,9 +65,9 @@ abstract class PlatalPage extends Smarty
public function changeTpl($tpl, $type = SKINNED)
{
- $this->_tpl = $tpl;
- $this->_page_type = $type;
- $this->assign('xorg_tpl', $tpl);
+ $this->_tpl = $tpl;
+ $this->_page_type = $type;
+ $this->assign('xorg_tpl', $tpl);
}
// }}}
@@ -88,6 +92,7 @@ abstract class PlatalPage extends Smarty
$this->register_prefilter('trimwhitespace');
$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_failure', $this->_failure);
$this->assign('globals', $globals);
@@ -116,10 +121,12 @@ abstract class PlatalPage extends Smarty
$this->assign('simple', true);
case SKINNED:
- $this->register_modifier('escape_html', 'escape_html');
- $this->default_modifiers = Array('@escape_html');
+ $this->register_modifier('escape_html', 'escape_html');
+ $this->default_modifiers = Array('@escape_html');
+ }
+ if (S::i('auth') <= AUTH_PUBLIC) {
+ $this->register_outputfilter('hide_emails');
}
- $this->register_outputfilter('hide_emails');
$this->addJsLink('wiki.js');
header("Accept-Charset: utf-8");
if (Env::v('forceXml')) {
@@ -132,20 +139,24 @@ abstract class PlatalPage extends Smarty
exit;
}
- if ($globals->debug & DEBUG_BT) {
- PlBacktrace::clean();
- $this->assign_by_ref('backtraces', PlBacktrace::$bt);
- }
-
$this->assign('validate', true);
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);
- $replc = "VALIDATION HTML INACTIVE
";
+ $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);
+ $result = str_replace('@@BACKTRACE@@', $this->fetch('skin/common.backtrace.tpl'), $result);
+ } else {
+ $result = str_replace('@@BACKTRACE@@', '', $result);
+ }
+ $replc = "VALIDATION HTML INACTIVE
";
if ($globals->debug & DEBUG_VALID) {
$fd = fopen($this->compile_dir."/valid.html","w");
fwrite($fd, $result);
@@ -285,9 +296,9 @@ function escape_xorgDB(&$item, $key)
function escape_html($string)
{
if (is_string($string)) {
- return htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
+ return htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
} else {
- return $string;
+ return $string;
}
}
@@ -345,6 +356,19 @@ function wiki_include($source, &$smarty)
}
// }}}
+//{{{ function hasPerm
+
+function if_has_perms($source, &$smarty)
+{
+ $source = preg_replace('/\{if([^}]*) (\!?)hasPerms\(([^)]+)\)([^}]*)\}/',
+ '{if\1 \2$smarty.session.perms->hasFlagCombination(\3)\4}',
+ $source);
+ return preg_replace('/\{if([^}]*) (\!?)hasPerm\(([^)]+)\)([^}]*)\}/',
+ '{if\1 \2($smarty.session.perms && $smarty.session.perms->hasFlag(\3))\4}',
+ $source);
+}
+
+// }}}
// {{{
function form_force_encodings($source, &$smarty)