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