Stub file for Gujarati, includes numeral conversion table
[lhc/web/wiklou.git] / PHPTAL-NP-0.7.0 / libs / PHPTAL.php
1 <?php
2 /* vim: set expandtab tabstop=4 shiftwidth=4: */
3 //
4 // Copyright (c) 2003 Laurent Bedubourg
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library 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 GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // Authors: Laurent Bedubourg <laurent.bedubourg@free.fr>
21 //
22
23 /*
24 * This file:
25 *
26 * - Include PHPTAL dependencies
27 * - Define PHPTAL attributes
28 * - Define PHPTAL aliases
29 * - Define PHPTAL rules
30 *
31 * @author Laurent Bedubourg <laurent.bedubourg@free.fr>
32 */
33
34 $__d = dirname(__FILE__);
35 if( defined( 'MEDIAWIKI' ) ) {
36 define('PT_IP', $IP.'/PHPTAL-NP-0.7.0/libs');
37 }
38 require_once "PEAR.php";
39
40 if (OS_WINDOWS) {
41 define('PHPTAL_PATH_SEP', '\\');
42 } else {
43 define('PHPTAL_PATH_SEP', '/');
44 }
45
46 function _phptal_os_path_join()
47 {
48 $args = func_get_args();
49 return join(PHPTAL_PATH_SEP, $args);
50 }
51
52 require_once 'Types/Errors.php';
53 require_once 'Types/OString.php';
54
55 require_once _phptal_os_path_join($__d, 'PHPTAL', 'Cache.php');
56 require_once _phptal_os_path_join($__d, 'PHPTAL', 'Context.php');
57 require_once _phptal_os_path_join($__d, 'PHPTAL', 'Filter.php');
58 require_once _phptal_os_path_join($__d, 'PHPTAL', 'LoopControler.php');
59 require_once _phptal_os_path_join($__d, 'PHPTAL', 'OutputControl.php');
60 require_once _phptal_os_path_join($__d, 'PHPTAL', 'Template.php');
61 require_once _phptal_os_path_join($__d, 'PHPTAL', 'Macro.php');
62 require_once _phptal_os_path_join($__d, 'PHPTAL', 'I18N.php');
63
64 require_once _phptal_os_path_join($__d, 'PHPTAL', 'SourceResolver.php');
65 require_once _phptal_os_path_join($__d, 'PHPTAL', 'SourceLocator.php');
66
67
68 define('PHPTAL_VERSION', '0.7.0');
69 define('PHPTAL_MARK', str_replace('.', '_', PHPTAL_VERSION) . '_');
70
71 if (strtoupper(substr(PHP_OS, 0, 3)) == "WIN") {
72 $default_temp = "C:\\Windows\\Temp";
73 } else {
74 $default_temp = "/tmp";
75 }
76 if( getenv( 'TMP' ) == "" ) {
77 if( is_writable( $default_temp ) ) {
78 define('PHPTAL_DEFAULT_CACHE_DIR', $default_temp.DIRECTORY_SEPARATOR);
79 } else {
80 global $wgUploadDirectory;
81 define('PHPTAL_DEFAULT_CACHE_DIR', $wgUploadDirectory.DIRECTORY_SEPARATOR);
82 }
83 } else {
84 define('PHPTAL_DEFAULT_CACHE_DIR', getenv("TMP") . DIRECTORY_SEPARATOR);
85 }
86
87 if( !is_writable (PHPTAL_DEFAULT_CACHE_DIR) )
88 die( htmlspecialchars(
89 'Can\'t find a writable temp directory for the XHTML template. ' .
90 'Check that the TMP environment variable points to a writable directory, ' .
91 'or that the default temp dir (' . $default_temp . ') exists and is writable.' ) );
92
93 /**
94 * This define is used to select the templates output format.
95 *
96 * There's few differences between XHTML and XML but they these differences can
97 * break some browsers output.
98 *
99 * Default PHPTAL output mode is XHTML.
100 */
101 define('PHPTAL_XHTML', 1);
102
103 /**
104 * This define is used to select the templates output format.
105 *
106 * The XML mode does not worry about XHTML specificity and echo every entity
107 * in a <entity></entity> format.
108 */
109 define('PHPTAL_XML', 2);
110
111 /**
112 * @var _phptal_namespaces
113 * @type array
114 *
115 * This array contains the list of all known attribute namespaces, if an
116 * attribute belonging to one of this namespaces is not recognized by PHPTAL,
117 * an exception will be raised.
118 *
119 * These namespaces will be drop from resulting xml/xhtml unless the parser
120 * is told to keep them.
121 *
122 * @access private
123 * @static 1
124 */
125 global $_phptal_namespaces;
126 $_phptal_namespaces = array('TAL', 'METAL', 'I18N', 'PHPTAL');
127
128
129 define('_PHPTAL_SURROUND', 1);
130 define('_PHPTAL_REPLACE', 2);
131 define('_PHPTAL_CONTENT', 3);
132
133 /**
134 * @var _phptal_dictionary
135 * @type hashtable
136 *
137 * This dictionary contains ALL known PHPTAL attributes. Unknown attributes
138 * will be echoed in result as xhtml/xml ones.
139 *
140 * The value define how and when the attribute handler will be called during
141 * code generation.
142 *
143 * @access private
144 * @static 1
145 */
146 global $_phptal_dictionary;
147 $_phptal_dictionary = array(
148 'TAL:DEFINE' => _PHPTAL_REPLACE, // set a context variable
149 'TAL:CONDITION' => _PHPTAL_SURROUND, // print tag content only when condition true
150 'TAL:REPEAT' => _PHPTAL_SURROUND, // repeat over an iterable
151 'TAL:CONTENT' => _PHPTAL_CONTENT, // replace tag content
152 'TAL:REPLACE' => _PHPTAL_REPLACE, // replace entire tag
153 'TAL:ATTRIBUTES' => _PHPTAL_REPLACE, // dynamically set tag attributes
154 'TAL:OMIT-TAG' => _PHPTAL_SURROUND, // omit to print tag but not its content
155 'TAL:COMMENT' => _PHPTAL_SURROUND, // do nothing
156 'TAL:ON-ERROR' => _PHPTAL_SURROUND, // replace content with this if error occurs
157
158 'METAL:DEFINE-MACRO' => _PHPTAL_SURROUND, // define a template macro
159 'METAL:USE-MACRO' => _PHPTAL_REPLACE, // use a template macro
160 'METAL:DEFINE-SLOT' => _PHPTAL_SURROUND, // define a macro slot
161 'METAL:FILL-SLOT' => _PHPTAL_SURROUND, // fill a macro slot
162
163 'PHPTAL:INCLUDE' => _PHPTAL_REPLACE, // include an external template
164 'PHPTAL:SRC-INCLUDE' => _PHPTAL_CONTENT, // include external file without parsing
165
166 'I18N:TRANSLATE' => _PHPTAL_CONTENT, // translate some data using GetText package
167 'I18N:NAME' => _PHPTAL_SURROUND, // prepare a translation name
168 'I18N:ATTRIBUTES' => _PHPTAL_REPLACE, // translate tag attributes values
169 );
170
171 /**
172 * @var _phptal_aliases
173 * @type hashtable
174 *
175 * Create aliases for attributes. If an alias is found during parsing, the
176 * matching phptal attribute will be used.
177 *
178 * @access private
179 * @static 1
180 */
181 global $_phptal_aliases;
182 $_phptal_aliases = array(
183 'TAL:INCLUDE' => 'PHPTAL:INCLUDE',
184 'TAL:SRC-INCLUDE'=> 'PHPTAL:SRC-INCLUDE',
185 );
186
187 /**
188 * @var _phptal_rules_order
189 * @type hashtable
190 *
191 * This rule associative array represents both ordering and exclusion
192 * mecanism for template attributes.
193 *
194 * All known attributes must appear here and must be associated with
195 * an occurence priority.
196 *
197 * When more than one phptal attribute appear in the same tag, they
198 * will execute in following order.
199 *
200 * @access private
201 * @static 1
202 */
203 global $_phptal_rules_order;
204 $_phptal_rules_order = array(
205 'TAL:OMIT-TAG' => 0, // surround -> $tag->disableHeadFootPrint()
206
207 'TAL:ON-ERROR' => 1, // surround
208
209 'METAL:DEFINE-MACRO' => 3, // surround
210 'TAL:DEFINE' => 3, // replace
211 'I18N:NAME' => 3, // replace
212 'I18N:TRANSLATE' => 3, // content
213
214 'TAL:CONDITION' => 4, // surround
215
216 'TAL:REPEAT' => 5, // surround
217
218 'I18N:ATTRIBUTES' => 6, // replace
219 'TAL:ATTRIBUTES' => 6, // replace
220 'TAL:REPLACE' => 6, // replace
221 'METAL:USE-MACRO' => 6, // replace
222 'PHPTAL:SRC-INCLUDE' => 6, // replace
223 'PHPTAL:INCLUDE' => 6, // replace
224 'METAL:DEFINE-SLOT' => 6, // replace
225 'METAL:FILL-SLOT' => 6, // replace
226
227 'TAL:CONTENT' => 7, // content
228
229 'TAL:COMMENT' => 8, // surround
230 );
231
232 /**
233 * @var _phptal_xhtml_content_free_tags
234 * @type array
235 *
236 * This array contains XHTML tags that must be echoed in a &lt;tag/&gt; form
237 * instead of the &lt;tag&gt;&lt;/tag&gt; form.
238 *
239 * In fact, some browsers does not support the later form so PHPTAL
240 * ensure these tags are correctly echoed.
241 */
242 global $_phptal_xhtml_empty_tags;
243 $_phptal_xhtml_empty_tags = array(
244 'AREA',
245 'BASE',
246 'BASEFONT',
247 'BR',
248 'COL',
249 'FRAME',
250 'HR',
251 'IMG',
252 'INPUT',
253 'ISINDEX',
254 'LINK',
255 'META',
256 'PARAM',
257 );
258
259 /**
260 * @var _phptal_xhtml_boolean_attributes
261 * @type array
262 *
263 * This array contains XHTML attributes that must be echoed in a minimized
264 * form. Some browsers (non HTML4 compliants are unable to interpret those
265 * attributes.
266 *
267 * The output will definitively not be an xml document !!
268 * PreFilters should be set to modify xhtml input containing these attributes.
269 */
270 global $_phptal_xhtml_boolean_attributes;
271 $_phptal_xhtml_boolean_attributes = array(
272 'compact',
273 'nowrap',
274 'ismap',
275 'declare',
276 'noshade',
277 'checked',
278 'disabled',
279 'readonly',
280 'multiple',
281 'selected',
282 'noresize',
283 'defer'
284 );
285
286 /**
287 * Shortcut to PHPTAL_Template for lazzy ones (me first).
288 */
289 class PHPTAL extends PHPTAL_Template {}
290
291 /**
292 * PEAR compliant class name.
293 */
294 class HTML_Template_PHPTAL extends PHPTAL_Template {}
295
296 /**
297 * PEAR compliant class name.
298 */
299 class HTML_Template_PHPTAL_Filter extends PHPTAL_Filter {}
300
301 /**
302 * PEAR compliant class name.
303 */
304 class HTML_Template_PHPTAL_SourceLocator extends PHPTAL_SourceLocator {}
305
306 /**
307 * PEAR compliant class name.
308 */
309 class HTML_Template_PHPTAL_SourceResolver extends PHPTAL_SourceResolver {}
310
311
312 ?>