47a56c260e58f37f84f064b8f1ff8db47b89b366
2 /***************************************************************************
3 * Copyright (C) 2003-2004 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 if ($type == SKINNED
) {
58 $this->register_modifier('escape_html', 'escape_html');
59 $this->default_modifiers
[] = '@escape_html';
62 $this->_page_type
= $type;
64 $this->_errors
= array();
65 $this->_failure
= false
;
67 $this->register_prefilter('at_to_globals');
68 $this->register_prefilter('trimwhitespace');
69 $this->addJsLink('javascript/xorg.js');
77 function fakeDiogenes()
79 require_once 'diogenes/diogenes.core.page.inc.php';
80 $this->register_function("extval","diogenes_func_extval");
81 $this->register_function("flags","diogenes_func_flags");
82 $this->register_function("a","diogenes_func_a");
83 $this->register_function("checkbox","diogenes_func_checkbox");
84 $this->register_function("diff","diogenes_func_diff");
85 $this->register_function("menu_item","diogenes_func_menu_item");
86 $this->register_function("tag","diogenes_func_tag");
87 $this->register_function("toolbar","diogenes_func_toolbar");
91 // {{{ function changeTpl()
93 function changeTpl($tpl, $type=SKINNED
)
96 $this->_page_type
= $type;
97 if ($type == SKINNED
) {
98 $this->register_modifier('escape_html', 'escape_html');
99 $this->default_modifiers
= Array('@escape_html');
102 $this->_page_type
= $type;
103 $this->assign('xorg_tpl', $tpl);
107 // {{{ function _run()
111 global $globals, $TIME_BEGIN;
112 $this->assign("xorg_errors", $this->_errors
);
113 $this->assign("xorg_failure", $this->_failure
);
115 if ($this->_page_type
== NO_SKIN
) {
116 $this->display($this->_tpl
);
120 if ($globals->debug
) {
122 if ($globals->debug
& 1) {
123 $this->assign('db_trace', $globals->db
->trace_format($this, 'database-debug.tpl'));
126 $this->assign('validate', urlencode($globals->baseurl
.'/valid.html'));
127 $result = $this->fetch($skin);
128 $ttime = sprintf('Temps total: %.02fs<br />', microtime_float() - $TIME_BEGIN);
129 $replc = "<span class='erreur'>VALIDATION HTML INACTIVE</span><br />";
131 if ($globals->debug
& 2) {
133 $fd = fopen($this->compile_dir
."/valid.html","w");
134 fwrite($fd, $result);
137 exec($globals->spoolroot
."/bin/devel/xhtml.validate.pl ".$this->compile_dir
."/valid.html", $val);
138 foreach ($val as $h) {
139 if (preg_match("/^X-W3C-Validator-Errors: (\d+)$/", $h, $m)) {
140 $replc = '<span style="color: #080;">HTML OK</span><br />';
142 $replc = "<span class='erreur'><a href='http://validator.w3.org/check?uri={$globals->baseurl}"
143 ."/valid.html&ss=1#result'>{$m[1]} ERREUR(S) !!!</a></span><br />";
150 echo str_replace("@HOOK@", $ttime.$replc, $result);
154 $this->display($skin);
159 // {{{ function run()
163 die ("implement me");
167 // {{{ function nb_errs()
171 return count($this->_errors
);
175 // {{{ function trig()
179 $this->_errors
[] = $msg;
183 // {{{ function trig()
185 function trig_run($msg)
192 // {{{ function fail()
197 $this->_failure
= true
;
201 // {{{ function kill()
210 // {{{ function doAuth()
212 function doAuth() { }
215 // {{{ function loadModule()
217 function loadModule($modname)
219 require_once("$modname.inc.php");
223 // {{{ function addJsLink
225 function addJsLink($path)
227 $this->append('xorg_js', $path);
231 // {{{ function addCssLink
233 function addCssLink($path)
235 $this->append('xorg_css', $path);
239 // {{{ function gassign
241 function gassign($varname)
244 $this->assign($varname, $
$varname);
252 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker: