ccc94d83baf04496c419d2ec987d05c35ef755f9
2 /***************************************************************************
3 * Copyright (C) 2003-2006 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 require_once 'smarty/libs/Smarty.class.php';
23 require_once 'platal/smarty.plugins.inc.php';
25 // {{{ class PlatalPage
27 class PlatalPage
extends Smarty
38 var $config_overwrite = false
;
39 var $use_sub_dirs = false
;
42 // {{{ function PlatalPage()
44 function PlatalPage($tpl, $type=SKINNED
)
50 $this->template_dir
= $globals->spoolroot
."/templates/";
51 $this->compile_dir
= $globals->spoolroot
."/spool/templates_c/";
52 array_unshift($this->plugins_dir
, $globals->spoolroot
."/plugins/");
53 $this->config_dir
= $globals->spoolroot
."/configs/";
55 $this->compile_check
= !empty($globals->debug
);
57 $this->_page_type
= $type;
59 $this->_errors
= array();
60 $this->_failure
= false
;
62 $this->register_prefilter('at_to_globals');
63 $this->register_prefilter('trimwhitespace');
64 $this->addJsLink('javascript/xorg.js');
70 // {{{ function fakeDiogenes()
72 function fakeDiogenes()
74 require_once 'diogenes/diogenes.core.page.inc.php';
75 $this->register_function("extval","diogenes_func_extval");
76 $this->register_function("flags","diogenes_func_flags");
77 $this->register_function("a","diogenes_func_a");
78 $this->register_function("checkbox","diogenes_func_checkbox");
79 $this->register_function("diff","diogenes_func_diff");
80 $this->register_function("menu_item","diogenes_func_menu_item");
81 $this->register_function("tag","diogenes_func_tag");
82 $this->register_function("toolbar","diogenes_func_toolbar");
86 // {{{ function changeTpl()
88 function changeTpl($tpl, $type=SKINNED
)
91 $this->_page_type
= $type;
92 $this->_page_type
= $type;
93 $this->assign('xorg_tpl', $tpl);
97 // {{{ function _run()
101 global $globals, $TIME_BEGIN;
103 session_write_close();
105 $this->assign("xorg_errors", $this->_errors
);
106 $this->assign("xorg_failure", $this->_failure
);
108 if ($this->_page_type
== NO_SKIN
) {
109 $this->display($this->_tpl
);
112 $this->register_modifier('escape_html', 'escape_html');
113 $this->default_modifiers
= Array('@escape_html');
116 if (!$globals->debug
) {
117 $this->display($skin);
121 if ($globals->debug
& 1) {
122 $this->assign('db_trace', $globals->db
->trace_format($this, 'database-debug.tpl'));
125 $this->assign('validate', true
);
126 $result = $this->fetch($skin);
127 $ttime .= sprintf('Temps total: %.02fs<br />', microtime_float() - $TIME_BEGIN);
128 $replc = "<span class='erreur'>VALIDATION HTML INACTIVE</span><br />";
130 if ($globals->debug
& 2) {
132 $fd = fopen($this->compile_dir
."/valid.html","w");
133 fwrite($fd, $result);
136 exec($globals->spoolroot
."/bin/devel/xhtml.validate.pl ".$this->compile_dir
."/valid.html", $val);
137 foreach ($val as $h) {
138 if (preg_match("/^X-W3C-Validator-Errors: (\d+)$/", $h, $m)) {
139 $replc = '<span style="color: #080;">HTML OK</span><br />';
141 $replc = "<span class='erreur'><a href='http://validator.w3.org/check?uri={$globals->baseurl}"
142 ."/valid.html&ss=1#result'>{$m[1]} ERREUR(S) !!!</a></span><br />";
149 echo str_replace("@HOOK@", $ttime.$replc, $result);
154 // {{{ function run()
158 die ("implement me");
162 // {{{ function nb_errs()
166 return count($this->_errors
);
170 // {{{ function trig()
174 $this->_errors
[] = $msg;
178 // {{{ function trig()
180 function trig_run($msg)
187 // {{{ function fail()
192 $this->_failure
= true
;
196 // {{{ function kill()
205 // {{{ function doAuth()
207 function doAuth() { }
210 // {{{ function loadModule()
212 function loadModule($modname)
214 require_once("$modname.inc.php");
218 // {{{ function addJsLink
220 function addJsLink($path)
222 $this->append('xorg_js', $path);
226 // {{{ function addCssLink
228 function addCssLink($path)
230 $this->append('xorg_css', $path);
234 // {{{ function gassign
236 function gassign($varname)
239 $this->assign($varname, $
$varname);
247 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker: