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 | |
62a66dfc |
44 | function PlatalPage($tpl, $type = SKINNED) |
0337d704 |
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 | |
62a66dfc |
86 | function changeTpl($tpl, $type = SKINNED) |
0337d704 |
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 | |
62a66dfc |
106 | switch ($this->_page_type) { |
107 | case NO_SKIN: |
0337d704 |
108 | $this->display($this->_tpl); |
109 | exit; |
62a66dfc |
110 | |
111 | case SIMPLE: |
112 | $page->assign('simple', true); |
113 | case SKINNED: |
801fcad8 |
114 | $this->register_modifier('escape_html', 'escape_html'); |
115 | $this->default_modifiers = Array('@escape_html'); |
0337d704 |
116 | } |
b4315e15 |
117 | |
118 | if (!$globals->debug) { |
119 | $this->display($skin); |
120 | exit; |
121 | } |
a3a049fc |
122 | |
b4315e15 |
123 | if ($globals->debug & 1) { |
124 | $this->assign('db_trace', $globals->db->trace_format($this, 'database-debug.tpl')); |
125 | } |
0337d704 |
126 | |
7da8ef90 |
127 | $this->assign('validate', true); |
b4315e15 |
128 | $result = $this->fetch($skin); |
36f114ef |
129 | $ttime .= sprintf('Temps total: %.02fs<br />', microtime_float() - $TIME_BEGIN); |
b4315e15 |
130 | $replc = "<span class='erreur'>VALIDATION HTML INACTIVE</span><br />"; |
0337d704 |
131 | |
b4315e15 |
132 | if ($globals->debug & 2) { |
133 | |
134 | $fd = fopen($this->compile_dir."/valid.html","w"); |
135 | fwrite($fd, $result); |
136 | fclose($fd); |
a3a049fc |
137 | |
b4315e15 |
138 | exec($globals->spoolroot."/bin/devel/xhtml.validate.pl ".$this->compile_dir."/valid.html", $val); |
139 | foreach ($val as $h) { |
140 | if (preg_match("/^X-W3C-Validator-Errors: (\d+)$/", $h, $m)) { |
141 | $replc = '<span style="color: #080;">HTML OK</span><br />'; |
142 | if ($m[1]) { |
143 | $replc = "<span class='erreur'><a href='http://validator.w3.org/check?uri={$globals->baseurl}" |
144 | ."/valid.html&ss=1#result'>{$m[1]} ERREUR(S) !!!</a></span><br />"; |
0337d704 |
145 | } |
b4315e15 |
146 | break; |
0337d704 |
147 | } |
148 | } |
0337d704 |
149 | } |
150 | |
b4315e15 |
151 | echo str_replace("@HOOK@", $ttime.$replc, $result); |
0337d704 |
152 | exit; |
153 | } |
154 | |
155 | // }}} |
156 | // {{{ function run() |
157 | |
158 | function run() |
159 | { |
160 | die ("implement me"); |
161 | } |
162 | |
163 | // }}} |
164 | // {{{ function nb_errs() |
165 | |
166 | function nb_errs() |
167 | { |
860fdaec |
168 | return count($this->_errors); |
0337d704 |
169 | } |
170 | |
171 | // }}} |
172 | // {{{ function trig() |
173 | |
174 | function trig($msg) |
175 | { |
860fdaec |
176 | $this->_errors[] = $msg; |
0337d704 |
177 | } |
178 | |
179 | // }}} |
180 | // {{{ function trig() |
181 | |
182 | function trig_run($msg) |
183 | { |
860fdaec |
184 | $this->trig($msg); |
0337d704 |
185 | $this->run(); |
186 | } |
187 | |
188 | // }}} |
189 | // {{{ function fail() |
190 | |
191 | function fail($msg) |
192 | { |
860fdaec |
193 | $this->trig($msg); |
194 | $this->_failure = true; |
0337d704 |
195 | } |
196 | |
197 | // }}} |
198 | // {{{ function kill() |
199 | |
200 | function kill($msg) |
201 | { |
202 | $this->fail($msg); |
203 | $this->run(); |
204 | } |
205 | |
206 | // }}} |
0337d704 |
207 | // {{{ function loadModule() |
a3a049fc |
208 | |
0337d704 |
209 | function loadModule($modname) |
210 | { |
211 | require_once("$modname.inc.php"); |
212 | } |
213 | |
214 | // }}} |
215 | // {{{ function addJsLink |
216 | |
217 | function addJsLink($path) |
218 | { |
219 | $this->append('xorg_js', $path); |
220 | } |
221 | |
222 | // }}} |
223 | // {{{ function addCssLink |
224 | |
225 | function addCssLink($path) |
226 | { |
227 | $this->append('xorg_css', $path); |
228 | } |
229 | |
230 | // }}} |
231 | // {{{ function gassign |
a3a049fc |
232 | |
0337d704 |
233 | function gassign($varname) |
234 | { |
235 | global $$varname; |
236 | $this->assign($varname, $$varname); |
237 | } |
238 | |
239 | // }}} |
240 | } |
241 | |
242 | // }}} |
243 | |
244 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker: |
245 | ?> |