0337d704 |
1 | <?php |
2 | /*************************************************************************** |
3 | * Copyright (C) 2003-2004 Polytechnique.org * |
4 | * http://opensource.polytechnique.org/ * |
5 | * * |
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. * |
10 | * * |
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. * |
15 | * * |
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 * |
18 | * Foundation, Inc., * |
19 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * |
20 | ***************************************************************************/ |
21 | |
22 | require_once('diogenes/diogenes.core.page.inc.php'); |
23 | require_once('platal/errors.inc.php'); |
24 | require_once('platal/smarty.plugins.inc.php'); |
25 | |
26 | // {{{ class PlatalPage |
27 | |
28 | class PlatalPage extends DiogenesCorePage |
29 | { |
30 | // {{{ properties |
31 | |
32 | var $_page_type; |
33 | var $_tpl; |
34 | var $_errors; |
35 | |
36 | // defaults |
37 | var $caching = false; |
38 | var $config_overwrite = false; |
39 | var $use_sub_dirs = false; |
40 | |
41 | // }}} |
42 | // {{{ function PlatalPage() |
43 | |
44 | function PlatalPage($tpl, $type=SKINNED) |
45 | { |
46 | global $globals; |
47 | |
48 | $this->template_dir = $globals->spoolroot."/templates/"; |
7faf6e6a |
49 | $this->compile_dir = $globals->spoolroot."/spool/templates_c/"; |
0337d704 |
50 | array_unshift($this->plugins_dir, $globals->spoolroot."/plugins/"); |
51 | $this->config_dir = $globals->spoolroot."/configs/"; |
52 | |
53 | $this->compile_check = !empty($globals->debug); |
54 | |
55 | if ($type == SKINNED) { |
56 | $this->register_modifier('escape_html', 'escape_html'); |
57 | $this->default_modifiers[] = '@escape_html'; |
58 | } |
59 | |
60 | $this->_page_type = $type; |
61 | $this->_tpl = $tpl; |
62 | $this->_errors = new XOrgErrors; |
63 | |
64 | $this->DiogenesCorePage(); |
65 | $this->register_prefilter('at_to_globals'); |
66 | $this->register_prefilter('trimwhitespace'); |
67 | $this->addJsLink('javascript/xorg.js'); |
68 | |
69 | $this->doAuth(); |
70 | } |
71 | |
72 | // }}} |
73 | // {{{ function changeTpl() |
74 | |
75 | function changeTpl($tpl, $type=SKINNED) |
76 | { |
77 | $this->_tpl = $tpl; |
78 | $this->_page_type = $type; |
79 | if ($type == SKINNED) { |
80 | $this->register_modifier('escape_html', 'escape_html'); |
81 | $this->default_modifiers = Array('@escape_html'); |
82 | } |
83 | |
84 | $this->_page_type = $type; |
85 | $this->assign('xorg_tpl', $tpl); |
86 | } |
87 | |
88 | // }}} |
89 | // {{{ function _run() |
90 | |
91 | function _run($skin) |
92 | { |
93 | global $globals, $TIME_BEGIN; |
94 | $this->assign("xorg_error", $this->_errors); |
95 | |
96 | if ($this->_page_type == NO_SKIN) { |
97 | $this->display($this->_tpl); |
98 | exit; |
99 | } |
100 | |
101 | if ($globals->debug) { |
102 | |
103 | if ($globals->debug & 1) { |
104 | $this->assign('db_trace', $globals->db->trace_format($this, 'database-debug.tpl')); |
105 | } |
106 | |
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 />"; |
111 | |
112 | if ($globals->debug & 2) { |
113 | |
114 | $fd = fopen($this->compile_dir."/valid.html","w"); |
115 | fwrite($fd, $result); |
116 | fclose($fd); |
117 | |
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 />'; |
122 | if ($m[1]) { |
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 />"; |
125 | } |
126 | break; |
127 | } |
128 | } |
129 | } |
130 | |
131 | echo str_replace("@HOOK@", $ttime.$replc, $result); |
132 | exit; |
133 | } |
134 | |
135 | $this->display($skin); |
136 | exit; |
137 | } |
138 | |
139 | // }}} |
140 | // {{{ function run() |
141 | |
142 | function run() |
143 | { |
144 | die ("implement me"); |
145 | } |
146 | |
147 | // }}} |
148 | // {{{ function nb_errs() |
149 | |
150 | function nb_errs() |
151 | { |
152 | return count($this->_errors->errs); |
153 | } |
154 | |
155 | // }}} |
156 | // {{{ function trig() |
157 | |
158 | function trig($msg) |
159 | { |
160 | $this->_errors->trig($msg); |
161 | } |
162 | |
163 | // }}} |
164 | // {{{ function trig() |
165 | |
166 | function trig_run($msg) |
167 | { |
168 | $this->_errors->trig($msg); |
169 | $this->run(); |
170 | } |
171 | |
172 | // }}} |
173 | // {{{ function fail() |
174 | |
175 | function fail($msg) |
176 | { |
177 | $this->_errors->fail($msg); |
178 | } |
179 | |
180 | // }}} |
181 | // {{{ function kill() |
182 | |
183 | function kill($msg) |
184 | { |
185 | $this->fail($msg); |
186 | $this->run(); |
187 | } |
188 | |
189 | // }}} |
190 | // {{{ function doAuth() |
191 | |
192 | function doAuth() { } |
193 | |
194 | // }}} |
195 | // {{{ function loadModule() |
196 | |
197 | function loadModule($modname) |
198 | { |
199 | require_once("$modname.inc.php"); |
200 | } |
201 | |
202 | // }}} |
203 | // {{{ function addJsLink |
204 | |
205 | function addJsLink($path) |
206 | { |
207 | $this->append('xorg_js', $path); |
208 | } |
209 | |
210 | // }}} |
211 | // {{{ function addCssLink |
212 | |
213 | function addCssLink($path) |
214 | { |
215 | $this->append('xorg_css', $path); |
216 | } |
217 | |
218 | // }}} |
219 | // {{{ function gassign |
220 | |
221 | function gassign($varname) |
222 | { |
223 | global $$varname; |
224 | $this->assign($varname, $$varname); |
225 | } |
226 | |
227 | // }}} |
228 | } |
229 | |
230 | // }}} |
231 | |
232 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker: |
233 | ?> |