X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fplatalpage.php;h=eac986a03530661319c36e3c3866960c3058b42f;hb=c828f2ea1f718c619636ff1be4aaa9f91fb4e84f;hp=788e58f5d69defff6ff5028388cbdf59c456cb4a;hpb=d0f6caa3139135d01138f61e602e5712547b4ed8;p=platal.git diff --git a/classes/platalpage.php b/classes/platalpage.php index 788e58f..eac986a 100644 --- a/classes/platalpage.php +++ b/classes/platalpage.php @@ -1,6 +1,6 @@ register_prefilter('at_to_globals'); $this->register_prefilter('trimwhitespace'); + $this->register_prefilter('form_force_encodings'); $this->addJsLink('xorg.js'); } @@ -63,9 +64,9 @@ class PlatalPage extends Smarty 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); } // }}} @@ -81,6 +82,14 @@ class PlatalPage extends Smarty $this->assign('xorg_failure', $this->_failure); $this->assign('globals', $globals); + if (Env::v('display') == 'light') { + $this->_page_type = SIMPLE; + } elseif (Env::v('display') == 'raw') { + $this->_page_type = NO_SKIN; + } elseif (Env::v('display') == 'full') { + $this->_page_typ = SKINNED; + } + switch ($this->_page_type) { case NO_SKIN: error_reporting(0); @@ -96,6 +105,7 @@ class PlatalPage extends Smarty } $this->register_outputfilter('hide_emails'); $this->addJsLink('wiki.js'); + header("Accept-Charset: utf-8"); if (!$globals->debug) { error_reporting(0); @@ -104,17 +114,18 @@ class PlatalPage extends Smarty } if ($globals->debug & 1) { - $this->assign('db_trace', XDB::trace_format($this, 'database-debug.tpl')); + PlBacktrace::clean(); + $this->assign_by_ref('backtraces', PlBacktrace::$bt); } $this->assign('validate', true); error_reporting(0); $result = $this->fetch($skin); - $ttime = sprintf('Temps total: %.02fs
', microtime_float() - $TIME_BEGIN); + $ttime = sprintf('Temps total: %.02fs - Mémoire totale : %dKo
', microtime(true) - $TIME_BEGIN + , memory_get_peak_usage(true) / 1024); $replc = "VALIDATION HTML INACTIVE
"; if ($globals->debug & 2) { - $fd = fopen($this->compile_dir."/valid.html","w"); fwrite($fd, $result); fclose($fd); @@ -182,6 +193,16 @@ class PlatalPage extends Smarty } // }}} + // {{{ function addCssInline + + function addCssInline($css) + { + if (!empty($css)) { + $this->append('xorg_inline_css', $css); + } + } + + // }}} // {{{ function setRssLink function setRssLink($title, $path) @@ -243,64 +264,66 @@ function at_to_globals($tpl_source, &$smarty) function trimwhitespace($source, &$smarty) { - $tags = array('script', 'pre', 'textarea'); - - foreach ($tags as $tag) { - preg_match_all("!<{$tag}[^>]+>.*?!is", $source, ${$tag}); - $source = preg_replace("!<{$tag}[^>]+>.*?!is", "&&&{$tag}&&&", $source); - } + $tags = '(script|pre|textarea)'; + preg_match_all("!<$tags.*?>.*?!ius", $source, $tagsmatches); + $source = preg_replace("!<$tags.*?>.*?!ius", "&&&tags&&&", $source); // remove all leading spaces, tabs and carriage returns NOT // preceeded by a php close tag. $source = preg_replace('/((?)\n)[\s]+/m', '\1', $source); - - foreach ($tags as $tag) { - $source = preg_replace("!&&&{$tag}&&&!e", 'array_shift(${$tag}[0])', $source); - } + $source = preg_replace("!&&&tags&&&!e", 'array_shift($tagsmatches[0])', $source); return $source; } // }}} +// {{{ + +function form_force_encodings($source, &$smarty) +{ + return preg_replace('/Nix.decode("' . addslashes(str_rot13($source)) . '");'; + $source = str_replace("\n", '', $source); + return ''; } function hide_emails($source, &$smarty) { //prevent email replacement in