0337d704 |
1 | <?php |
2 | /*************************************************************************** |
50a40a33 |
3 | * Copyright (C) 2003-2006 Polytechnique.org * |
0337d704 |
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 |
a3a049fc |
30 | |
0337d704 |
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 | |
0337d704 |
57 | $this->_page_type = $type; |
58 | $this->_tpl = $tpl; |
860fdaec |
59 | $this->_errors = array(); |
60 | $this->_failure = false; |
0337d704 |
61 | |
0337d704 |
62 | $this->register_prefilter('at_to_globals'); |
63 | $this->register_prefilter('trimwhitespace'); |
64 | $this->addJsLink('javascript/xorg.js'); |
0337d704 |
65 | } |
66 | |
67 | // }}} |
b4315e15 |
68 | // {{{ function fakeDiogenes() |
a3a049fc |
69 | |
f12af8ad |
70 | function fakeDiogenes() |
71 | { |
72 | require_once 'diogenes/diogenes.core.page.inc.php'; |
73 | $this->register_function("extval","diogenes_func_extval"); |
74 | $this->register_function("flags","diogenes_func_flags"); |
75 | $this->register_function("a","diogenes_func_a"); |
76 | $this->register_function("checkbox","diogenes_func_checkbox"); |
77 | $this->register_function("diff","diogenes_func_diff"); |
78 | $this->register_function("menu_item","diogenes_func_menu_item"); |
79 | $this->register_function("tag","diogenes_func_tag"); |
80 | $this->register_function("toolbar","diogenes_func_toolbar"); |
81 | } |
a3a049fc |
82 | |
f12af8ad |
83 | // }}} |
0337d704 |
84 | // {{{ function changeTpl() |
85 | |
86 | function changeTpl($tpl, $type=SKINNED) |
87 | { |
88 | $this->_tpl = $tpl; |
89 | $this->_page_type = $type; |
0337d704 |
90 | $this->_page_type = $type; |
91 | $this->assign('xorg_tpl', $tpl); |
92 | } |
93 | |
94 | // }}} |
95 | // {{{ function _run() |
96 | |
97 | function _run($skin) |
98 | { |
99 | global $globals, $TIME_BEGIN; |
36f114ef |
100 | |
101 | session_write_close(); |
102 | |
860fdaec |
103 | $this->assign("xorg_errors", $this->_errors); |
104 | $this->assign("xorg_failure", $this->_failure); |
a3a049fc |
105 | |
0337d704 |
106 | if ($this->_page_type == NO_SKIN) { |
107 | $this->display($this->_tpl); |
108 | exit; |
801fcad8 |
109 | } else { |
110 | $this->register_modifier('escape_html', 'escape_html'); |
111 | $this->default_modifiers = Array('@escape_html'); |
0337d704 |
112 | } |
b4315e15 |
113 | |
114 | if (!$globals->debug) { |
115 | $this->display($skin); |
116 | exit; |
117 | } |
a3a049fc |
118 | |
b4315e15 |
119 | if ($globals->debug & 1) { |
120 | $this->assign('db_trace', $globals->db->trace_format($this, 'database-debug.tpl')); |
121 | } |
0337d704 |
122 | |
7da8ef90 |
123 | $this->assign('validate', true); |
b4315e15 |
124 | $result = $this->fetch($skin); |
36f114ef |
125 | $ttime .= sprintf('Temps total: %.02fs<br />', microtime_float() - $TIME_BEGIN); |
b4315e15 |
126 | $replc = "<span class='erreur'>VALIDATION HTML INACTIVE</span><br />"; |
0337d704 |
127 | |
b4315e15 |
128 | if ($globals->debug & 2) { |
129 | |
130 | $fd = fopen($this->compile_dir."/valid.html","w"); |
131 | fwrite($fd, $result); |
132 | fclose($fd); |
a3a049fc |
133 | |
b4315e15 |
134 | exec($globals->spoolroot."/bin/devel/xhtml.validate.pl ".$this->compile_dir."/valid.html", $val); |
135 | foreach ($val as $h) { |
136 | if (preg_match("/^X-W3C-Validator-Errors: (\d+)$/", $h, $m)) { |
137 | $replc = '<span style="color: #080;">HTML OK</span><br />'; |
138 | if ($m[1]) { |
139 | $replc = "<span class='erreur'><a href='http://validator.w3.org/check?uri={$globals->baseurl}" |
140 | ."/valid.html&ss=1#result'>{$m[1]} ERREUR(S) !!!</a></span><br />"; |
0337d704 |
141 | } |
b4315e15 |
142 | break; |
0337d704 |
143 | } |
144 | } |
0337d704 |
145 | } |
146 | |
b4315e15 |
147 | echo str_replace("@HOOK@", $ttime.$replc, $result); |
0337d704 |
148 | exit; |
149 | } |
150 | |
151 | // }}} |
152 | // {{{ function run() |
153 | |
154 | function run() |
155 | { |
156 | die ("implement me"); |
157 | } |
158 | |
159 | // }}} |
160 | // {{{ function nb_errs() |
161 | |
162 | function nb_errs() |
163 | { |
860fdaec |
164 | return count($this->_errors); |
0337d704 |
165 | } |
166 | |
167 | // }}} |
168 | // {{{ function trig() |
169 | |
170 | function trig($msg) |
171 | { |
860fdaec |
172 | $this->_errors[] = $msg; |
0337d704 |
173 | } |
174 | |
175 | // }}} |
176 | // {{{ function trig() |
177 | |
178 | function trig_run($msg) |
179 | { |
860fdaec |
180 | $this->trig($msg); |
0337d704 |
181 | $this->run(); |
182 | } |
183 | |
184 | // }}} |
185 | // {{{ function fail() |
186 | |
187 | function fail($msg) |
188 | { |
860fdaec |
189 | $this->trig($msg); |
190 | $this->_failure = true; |
0337d704 |
191 | } |
192 | |
193 | // }}} |
194 | // {{{ function kill() |
195 | |
196 | function kill($msg) |
197 | { |
198 | $this->fail($msg); |
199 | $this->run(); |
200 | } |
201 | |
202 | // }}} |
0337d704 |
203 | // {{{ function loadModule() |
a3a049fc |
204 | |
0337d704 |
205 | function loadModule($modname) |
206 | { |
207 | require_once("$modname.inc.php"); |
208 | } |
209 | |
210 | // }}} |
211 | // {{{ function addJsLink |
212 | |
213 | function addJsLink($path) |
214 | { |
215 | $this->append('xorg_js', $path); |
216 | } |
217 | |
218 | // }}} |
219 | // {{{ function addCssLink |
220 | |
221 | function addCssLink($path) |
222 | { |
223 | $this->append('xorg_css', $path); |
224 | } |
225 | |
226 | // }}} |
227 | // {{{ function gassign |
a3a049fc |
228 | |
0337d704 |
229 | function gassign($varname) |
230 | { |
231 | global $$varname; |
232 | $this->assign($varname, $$varname); |
233 | } |
234 | |
235 | // }}} |
236 | } |
237 | |
238 | // }}} |
239 | |
240 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker: |
241 | ?> |