X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=classes%2Fplatalpage.php;h=bf35d60e8757ee3305dad900ebb8172168b845ef;hb=2dcac0f527e8207d754af8974d81b2bce3f433d9;hp=3cb32a2a01b2686ec889b1ac0e5d9ce05508fa05;hpb=60979eb75d10a4bb4ff0ce7ef8ec9fa6bee70f65;p=platal.git
diff --git a/classes/platalpage.php b/classes/platalpage.php
index 3cb32a2..bf35d60 100644
--- a/classes/platalpage.php
+++ b/classes/platalpage.php
@@ -21,7 +21,7 @@
require_once 'smarty/libs/Smarty.class.php';
-class PlatalPage extends Smarty
+abstract class PlatalPage extends Smarty
{
private $_page_type;
private $_tpl;
@@ -47,8 +47,7 @@ class PlatalPage extends Smarty
$this->compile_check = !empty($globals->debug);
- $this->_page_type = $type;
- $this->_tpl = $tpl;
+ $this->changeTpl($tpl, $type);
$this->_errors = array();
$this->_jsonVars = array();
$this->_failure = false;
@@ -88,6 +87,7 @@ class PlatalPage extends Smarty
$this->register_prefilter('trimwhitespace');
$this->register_prefilter('form_force_encodings');
+ $this->register_prefilter('wiki_include');
$this->assign('xorg_errors', $this->_errors);
$this->assign('xorg_failure', $this->_failure);
$this->assign('globals', $globals);
@@ -95,7 +95,7 @@ class PlatalPage extends Smarty
if (Env::has('json') && count($this->_jsonVars)) {
return $this->jsonDisplay();
}
-
+
if (Env::v('display') == 'light') {
$this->_page_type = SIMPLE;
} elseif (Env::v('display') == 'raw') {
@@ -106,7 +106,9 @@ class PlatalPage extends Smarty
switch ($this->_page_type) {
case NO_SKIN:
- error_reporting(0);
+ if (!($globals->debug & DEBUG_SMARTY)) {
+ error_reporting(0);
+ }
$this->display($this->_tpl);
exit;
@@ -115,7 +117,7 @@ class PlatalPage extends Smarty
case SKINNED:
$this->register_modifier('escape_html', 'escape_html');
- $this->default_modifiers = Array('@escape_html');
+ $this->default_modifiers = Array('@escape_html');
}
$this->register_outputfilter('hide_emails');
$this->addJsLink('wiki.js');
@@ -130,19 +132,21 @@ class PlatalPage extends Smarty
exit;
}
- if ($globals->debug & 1) {
+ if ($globals->debug & DEBUG_BT) {
PlBacktrace::clean();
$this->assign_by_ref('backtraces', PlBacktrace::$bt);
}
$this->assign('validate', true);
- error_reporting(0);
+ if (!($globals->debug & DEBUG_SMARTY)) {
+ error_reporting(0);
+ }
$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
";
- if ($globals->debug & 2) {
+ if ($globals->debug & DEBUG_VALID) {
$fd = fopen($this->compile_dir."/valid.html","w");
fwrite($fd, $result);
fclose($fd);
@@ -164,6 +168,8 @@ class PlatalPage extends Smarty
exit;
}
+ abstract public function run();
+
// }}}
// {{{ function nb_errs()
@@ -216,7 +222,7 @@ class PlatalPage extends Smarty
{
if (!empty($css)) {
$this->append('xorg_inline_css', $css);
- }
+ }
}
// }}}
@@ -251,6 +257,8 @@ class PlatalPage extends Smarty
{
$this->_jsonVars[$var] = $value;
}
+
+ // }}}
}
function escape_xorgDB(&$item, $key)
@@ -268,7 +276,7 @@ function escape_xorgDB(&$item, $key)
/**
* default smarty plugin, used to auto-escape dangerous html.
- *
+ *
* < --> <
* > --> >
* " --> "
@@ -277,10 +285,9 @@ function escape_xorgDB(&$item, $key)
function escape_html($string)
{
if (is_string($string)) {
- $transtbl = Array('<' => '<', '>' => '>', '"' => '"', '\'' => ''');
- return strtr($string, $transtbl);
+ return htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
} else {
- return $string;
+ return $string;
}
}
@@ -324,7 +331,17 @@ function trimwhitespace($source, &$smarty)
$source = preg_replace('/((?)\n)[\s]+/m', '\1', $source);
$source = preg_replace("!&&&tags&&&!e", 'array_shift($tagsmatches[0])', $source);
- return $source;
+ return $source;
+}
+
+// }}}
+// {{{ function wiki_include
+
+function wiki_include($source, &$smarty)
+{
+ return preg_replace('/\{include( [^}]*)? wiki=([^} ]+)(.*?)\}/ui',
+ '{include\1 file="../spool/wiki.d/cache_\2.tpl"\3 included=1}',
+ $source);
}
// }}}
@@ -345,11 +362,15 @@ function _hide_email($source)
$source = str_replace("\n", '', $source);
return '';
+ '//]]>';
}
function hide_emails($source, &$smarty)
{
+ if (!strpos($source, '@')) {
+ return $source;
+ }
+
//prevent email replacement in