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 | |
f12af8ad |
22 | require_once 'smarty/libs/Smarty.class.php'; |
f12af8ad |
23 | require_once 'platal/smarty.plugins.inc.php'; |
0337d704 |
24 | |
25 | // {{{ class PlatalPage |
26 | |
f12af8ad |
27 | class PlatalPage extends Smarty |
0337d704 |
28 | { |
29 | // {{{ properties |
30 | |
31 | var $_page_type; |
32 | var $_tpl; |
33 | var $_errors; |
860fdaec |
34 | var $_failure; |
0337d704 |
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 | |
f12af8ad |
48 | $this->Smarty(); |
796aea34 |
49 | |
0337d704 |
50 | $this->template_dir = $globals->spoolroot."/templates/"; |
7faf6e6a |
51 | $this->compile_dir = $globals->spoolroot."/spool/templates_c/"; |
0337d704 |
52 | array_unshift($this->plugins_dir, $globals->spoolroot."/plugins/"); |
53 | $this->config_dir = $globals->spoolroot."/configs/"; |
54 | |
55 | $this->compile_check = !empty($globals->debug); |
56 | |
57 | if ($type == SKINNED) { |
58 | $this->register_modifier('escape_html', 'escape_html'); |
59 | $this->default_modifiers[] = '@escape_html'; |
60 | } |
61 | |
62 | $this->_page_type = $type; |
63 | $this->_tpl = $tpl; |
860fdaec |
64 | $this->_errors = array(); |
65 | $this->_failure = false; |
0337d704 |
66 | |
0337d704 |
67 | $this->register_prefilter('at_to_globals'); |
68 | $this->register_prefilter('trimwhitespace'); |
69 | $this->addJsLink('javascript/xorg.js'); |
70 | |
71 | $this->doAuth(); |
72 | } |
73 | |
74 | // }}} |
b4315e15 |
75 | // {{{ function fakeDiogenes() |
f12af8ad |
76 | |
77 | function fakeDiogenes() |
78 | { |
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"); |
88 | } |
89 | |
90 | // }}} |
0337d704 |
91 | // {{{ function changeTpl() |
92 | |
93 | function changeTpl($tpl, $type=SKINNED) |
94 | { |
95 | $this->_tpl = $tpl; |
96 | $this->_page_type = $type; |
97 | if ($type == SKINNED) { |
98 | $this->register_modifier('escape_html', 'escape_html'); |
99 | $this->default_modifiers = Array('@escape_html'); |
100 | } |
101 | |
102 | $this->_page_type = $type; |
103 | $this->assign('xorg_tpl', $tpl); |
104 | } |
105 | |
106 | // }}} |
107 | // {{{ function _run() |
108 | |
109 | function _run($skin) |
110 | { |
111 | global $globals, $TIME_BEGIN; |
36f114ef |
112 | |
113 | session_write_close(); |
114 | |
860fdaec |
115 | $this->assign("xorg_errors", $this->_errors); |
116 | $this->assign("xorg_failure", $this->_failure); |
0337d704 |
117 | |
118 | if ($this->_page_type == NO_SKIN) { |
119 | $this->display($this->_tpl); |
120 | exit; |
121 | } |
b4315e15 |
122 | |
123 | if (!$globals->debug) { |
124 | $this->display($skin); |
125 | exit; |
126 | } |
0337d704 |
127 | |
b4315e15 |
128 | if ($globals->debug & 1) { |
129 | $this->assign('db_trace', $globals->db->trace_format($this, 'database-debug.tpl')); |
130 | } |
0337d704 |
131 | |
b4315e15 |
132 | $this->assign('validate', urlencode($globals->baseurl.'/valid.html')); |
133 | $result = $this->fetch($skin); |
36f114ef |
134 | $ttime .= sprintf('Temps total: %.02fs<br />', microtime_float() - $TIME_BEGIN); |
b4315e15 |
135 | $replc = "<span class='erreur'>VALIDATION HTML INACTIVE</span><br />"; |
0337d704 |
136 | |
b4315e15 |
137 | if ($globals->debug & 2) { |
138 | |
139 | $fd = fopen($this->compile_dir."/valid.html","w"); |
140 | fwrite($fd, $result); |
141 | fclose($fd); |
142 | |
143 | exec($globals->spoolroot."/bin/devel/xhtml.validate.pl ".$this->compile_dir."/valid.html", $val); |
144 | foreach ($val as $h) { |
145 | if (preg_match("/^X-W3C-Validator-Errors: (\d+)$/", $h, $m)) { |
146 | $replc = '<span style="color: #080;">HTML OK</span><br />'; |
147 | if ($m[1]) { |
148 | $replc = "<span class='erreur'><a href='http://validator.w3.org/check?uri={$globals->baseurl}" |
149 | ."/valid.html&ss=1#result'>{$m[1]} ERREUR(S) !!!</a></span><br />"; |
0337d704 |
150 | } |
b4315e15 |
151 | break; |
0337d704 |
152 | } |
153 | } |
0337d704 |
154 | } |
155 | |
b4315e15 |
156 | echo str_replace("@HOOK@", $ttime.$replc, $result); |
0337d704 |
157 | exit; |
158 | } |
159 | |
160 | // }}} |
161 | // {{{ function run() |
162 | |
163 | function run() |
164 | { |
165 | die ("implement me"); |
166 | } |
167 | |
168 | // }}} |
169 | // {{{ function nb_errs() |
170 | |
171 | function nb_errs() |
172 | { |
860fdaec |
173 | return count($this->_errors); |
0337d704 |
174 | } |
175 | |
176 | // }}} |
177 | // {{{ function trig() |
178 | |
179 | function trig($msg) |
180 | { |
860fdaec |
181 | $this->_errors[] = $msg; |
0337d704 |
182 | } |
183 | |
184 | // }}} |
185 | // {{{ function trig() |
186 | |
187 | function trig_run($msg) |
188 | { |
860fdaec |
189 | $this->trig($msg); |
0337d704 |
190 | $this->run(); |
191 | } |
192 | |
193 | // }}} |
194 | // {{{ function fail() |
195 | |
196 | function fail($msg) |
197 | { |
860fdaec |
198 | $this->trig($msg); |
199 | $this->_failure = true; |
0337d704 |
200 | } |
201 | |
202 | // }}} |
203 | // {{{ function kill() |
204 | |
205 | function kill($msg) |
206 | { |
207 | $this->fail($msg); |
208 | $this->run(); |
209 | } |
210 | |
211 | // }}} |
212 | // {{{ function doAuth() |
213 | |
214 | function doAuth() { } |
215 | |
216 | // }}} |
217 | // {{{ function loadModule() |
218 | |
219 | function loadModule($modname) |
220 | { |
221 | require_once("$modname.inc.php"); |
222 | } |
223 | |
224 | // }}} |
225 | // {{{ function addJsLink |
226 | |
227 | function addJsLink($path) |
228 | { |
229 | $this->append('xorg_js', $path); |
230 | } |
231 | |
232 | // }}} |
233 | // {{{ function addCssLink |
234 | |
235 | function addCssLink($path) |
236 | { |
237 | $this->append('xorg_css', $path); |
238 | } |
239 | |
240 | // }}} |
241 | // {{{ function gassign |
242 | |
243 | function gassign($varname) |
244 | { |
245 | global $$varname; |
246 | $this->assign($varname, $$varname); |
247 | } |
248 | |
249 | // }}} |
250 | } |
251 | |
252 | // }}} |
253 | |
254 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker: |
255 | ?> |