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('diogenes/diogenes.core.page.inc.php');
23 require_once('platal/errors.inc.php');
24 require_once('platal/smarty.plugins.inc.php');
26 // {{{ class PlatalPage
28 class PlatalPage
extends DiogenesCorePage
38 var $config_overwrite = false
;
39 var $use_sub_dirs = false
;
42 // {{{ function PlatalPage()
44 function PlatalPage($tpl, $type=SKINNED
)
48 $this->template_dir
= $globals->spoolroot
."/templates/";
49 $this->compile_dir
= $globals->spoolroot
."/templates_c/";
50 array_unshift($this->plugins_dir
, $globals->spoolroot
."/plugins/");
51 $this->config_dir
= $globals->spoolroot
."/configs/";
53 $this->compile_check
= !empty($globals->debug
);
55 if ($type == SKINNED
) {
56 $this->register_modifier('escape_html', 'escape_html');
57 $this->default_modifiers
[] = '@escape_html';
60 $this->_page_type
= $type;
62 $this->_errors
= new XOrgErrors
;
64 $this->DiogenesCorePage();
65 $this->register_prefilter('at_to_globals');
66 $this->register_prefilter('trimwhitespace');
67 $this->addJsLink('javascript/xorg.js');
73 // {{{ function changeTpl()
75 function changeTpl($tpl, $type=SKINNED
)
78 $this->_page_type
= $type;
79 if ($type == SKINNED
) {
80 $this->register_modifier('escape_html', 'escape_html');
81 $this->default_modifiers
= Array('@escape_html');
84 $this->_page_type
= $type;
85 $this->assign('xorg_tpl', $tpl);
89 // {{{ function _run()
93 global $globals, $TIME_BEGIN;
94 $this->assign("xorg_error", $this->_errors
);
96 if ($this->_page_type
== NO_SKIN
) {
97 $this->display($this->_tpl
);
101 if ($globals->debug
) {
103 if ($globals->debug
& 1) {
104 $this->assign('db_trace', $globals->db
->trace_format($this, 'database-debug.tpl'));
107 $this->assign('validate', urlencode($globals->baseurl
.'/valid.html'));
108 $result = $this->fetch($skin);
109 $ttime = sprintf('Temps total: %.02fs<br />', microtime_float() - $TIME_BEGIN);
110 $replc = "<span class='erreur'>VALIDATION HTML INACTIVE</span><br />";
112 if ($globals->debug
& 2) {
114 $fd = fopen($this->compile_dir
."/valid.html","w");
115 fwrite($fd, $result);
118 exec($globals->spoolroot
."/bin/devel/xhtml.validate.pl ".$this->compile_dir
."/valid.html", $val);
119 foreach ($val as $h) {
120 if (preg_match("/^X-W3C-Validator-Errors: (\d+)$/", $h, $m)) {
121 $replc = '<span style="color: #080;">HTML OK</span><br />';
123 $replc = "<span class='erreur'><a href='http://validator.w3.org/check?uri={$globals->baseurl}"
124 ."/valid.html&ss=1#result'>{$m[1]} ERREUR(S) !!!</a></span><br />";
131 echo str_replace("@HOOK@", $ttime.$replc, $result);
135 $this->display($skin);
140 // {{{ function run()
144 die ("implement me");
148 // {{{ function nb_errs()
152 return count($this->_errors
->errs
);
156 // {{{ function trig()
160 $this->_errors
->trig($msg);
164 // {{{ function trig()
166 function trig_run($msg)
168 $this->_errors
->trig($msg);
173 // {{{ function fail()
177 $this->_errors
->fail($msg);
181 // {{{ function kill()
190 // {{{ function doAuth()
192 function doAuth() { }
195 // {{{ function loadModule()
197 function loadModule($modname)
199 require_once("$modname.inc.php");
203 // {{{ function addJsLink
205 function addJsLink($path)
207 $this->append('xorg_js', $path);
211 // {{{ function addCssLink
213 function addCssLink($path)
215 $this->append('xorg_css', $path);
219 // {{{ function gassign
221 function gassign($varname)
224 $this->assign($varname, $
$varname);
232 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker: