require_once 'smarty/libs/Smarty.class.php';
-class PlatalPage extends Smarty
+abstract class PlatalPage extends Smarty
{
private $_page_type;
private $_tpl;
$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;
$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);
if (Env::has('json') && count($this->_jsonVars)) {
return $this->jsonDisplay();
}
-
+
if (Env::v('display') == 'light') {
$this->_page_type = SIMPLE;
} elseif (Env::v('display') == 'raw') {
switch ($this->_page_type) {
case NO_SKIN:
- error_reporting(0);
+ if (!($globals->debug & DEBUG_SMARTY)) {
+ error_reporting(0);
+ }
$this->display($this->_tpl);
exit;
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');
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<br />', microtime(true) - $TIME_BEGIN
, memory_get_peak_usage(true) / 1024);
$replc = "<span class='erreur'>VALIDATION HTML INACTIVE</span><br />";
- if ($globals->debug & 2) {
+ if ($globals->debug & DEBUG_VALID) {
$fd = fopen($this->compile_dir."/valid.html","w");
fwrite($fd, $result);
fclose($fd);
exit;
}
+ abstract public function run();
+
// }}}
// {{{ function nb_errs()
{
if (!empty($css)) {
$this->append('xorg_inline_css', $css);
- }
+ }
}
// }}}
{
$this->_jsonVars[$var] = $value;
}
+
+ // }}}
}
function escape_xorgDB(&$item, $key)
/**
* default smarty plugin, used to auto-escape dangerous html.
- *
+ *
* < --> <
* > --> >
* " --> "
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;
}
}
$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);
}
// }}}
$source = str_replace("\n", '', $source);
return '<script type="text/javascript">//<![CDATA[' . "\n" .
'Nix.decode("' . addslashes(str_rot13($source)) . '");' . "\n" .
- '//]]></script>';
+ '//]]></script>';
}
function hide_emails($source, &$smarty)
{
+ if (!strpos($source, '@')) {
+ return $source;
+ }
+
//prevent email replacement in <script> and <textarea>
$tags = '(script|textarea|select)';
preg_match_all("!<$tags.*?>.*?</(\\1)>!ius", $source, $tagsmatches);
$source = preg_replace("!<[^>]+[-a-z0-9_+.]+@[-a-z0-9_.]+.+?>!ius", '&&&misc&&&', $source);
//catch !
- $source = preg_replace('!([-a-z0-9_+.]+@[-a-z0-9_.]+)!iue', '_hide_email("\1")', $source);
+ $source = preg_replace('!([-a-z0-9_+.]+@[-a-z0-9_.]+)!iue', '_hide_email("\1")', $source);
$source = preg_replace('!&&&ahref&&&!e', '_hide_email(array_shift($ahref[0]))', $source);
// restore data