author | Dan |
Sat, 15 Mar 2008 14:18:54 -0400 | |
changeset 502 | 7084168f23af |
parent 460 | 3a1c99845ca8 |
child 536 | 218a627eb53e |
permissions | -rw-r--r-- |
1 | 1 |
<?php |
2 |
/** |
|
3 |
* Parse structured wiki text and render into arbitrary formats such as XHTML. |
|
4 |
* |
|
5 |
* PHP versions 4 and 5 |
|
6 |
* |
|
7 |
* @category Text |
|
8 |
* @package Text_Wiki |
|
9 |
* @author Paul M. Jones <pmjones@php.net> |
|
10 |
* @license http://www.gnu.org/licenses/lgpl.html |
|
11 |
* @version CVS: $Id: Wiki.php,v 1.44 2006/03/02 04:04:59 justinpatrin Exp $ |
|
12 |
* @link http://wiki.ciaweb.net/yawiki/index.php?area=Text_Wiki |
|
13 |
* |
|
14 |
* This code was modified for use in Enano. The Text_Wiki engine is licensed |
|
15 |
* under the GNU Lesser General Public License; see |
|
16 |
* http://www.gnu.org/licenses/lgpl.html for details. |
|
17 |
* |
|
18 |
*/ |
|
19 |
||
20 |
require_once ENANO_ROOT.'/includes/wikiengine/Parse.php'; |
|
21 |
require_once ENANO_ROOT.'/includes/wikiengine/Render.php'; |
|
22 |
||
23 |
class Text_Wiki { |
|
24 |
||
25 |
var $rules = array( |
|
26 |
'Prefilter', |
|
27 |
'Delimiter', |
|
28 |
'Code', |
|
29 |
'Function', |
|
30 |
'Html', |
|
31 |
'Raw', |
|
32 |
'Include', |
|
33 |
'Embed', |
|
34 |
'Anchor', |
|
35 |
'Heading', |
|
36 |
'Toc', |
|
37 |
'Horiz', |
|
38 |
'Break', |
|
39 |
'Blockquote', |
|
40 |
'List', |
|
41 |
'Deflist', |
|
42 |
'Table', |
|
43 |
'Image', |
|
44 |
'Phplookup', |
|
45 |
'Center', |
|
46 |
'Newline', |
|
47 |
'Paragraph', |
|
48 |
'Url', |
|
49 |
'Freelink', |
|
50 |
'Interwiki', |
|
51 |
'Wikilink', |
|
52 |
'Colortext', |
|
53 |
'Strong', |
|
54 |
'Bold', |
|
55 |
'Emphasis', |
|
56 |
'Italic', |
|
57 |
'Underline', |
|
58 |
'Tt', |
|
59 |
'Superscript', |
|
60 |
'Subscript', |
|
61 |
'Revise', |
|
62 |
'Tighten' |
|
63 |
); |
|
64 |
||
65 |
var $disable = array( |
|
66 |
'Html', |
|
67 |
'Include', |
|
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
1
diff
changeset
|
68 |
'Embed', |
35 | 69 |
'Tighten', |
142
ca9118d9c0f2
Rebrand as 1.0.2 (Coblynau); internal links are now parsed by RenderMan::parse_internal_links()
Dan
parents:
78
diff
changeset
|
70 |
'Image', |
ca9118d9c0f2
Rebrand as 1.0.2 (Coblynau); internal links are now parsed by RenderMan::parse_internal_links()
Dan
parents:
78
diff
changeset
|
71 |
'Wikilink' |
1 | 72 |
); |
73 |
||
74 |
var $parseConf = array(); |
|
75 |
||
76 |
var $renderConf = array( |
|
77 |
'Docbook' => array(), |
|
78 |
'Latex' => array(), |
|
79 |
'Pdf' => array(), |
|
80 |
'Plain' => array(), |
|
81 |
'Rtf' => array(), |
|
82 |
'Xhtml' => array() |
|
83 |
); |
|
84 |
||
85 |
var $formatConf = array( |
|
86 |
'Docbook' => array(), |
|
87 |
'Latex' => array(), |
|
88 |
'Pdf' => array(), |
|
89 |
'Plain' => array(), |
|
90 |
'Rtf' => array(), |
|
91 |
'Xhtml' => array() |
|
92 |
); |
|
93 |
var $delim = "\xFF"; |
|
94 |
var $tokens = array(); |
|
95 |
var $_countRulesTokens = array(); |
|
96 |
var $source = ''; |
|
97 |
var $parseObj = array(); |
|
98 |
var $renderObj = array(); |
|
99 |
var $formatObj = array(); |
|
100 |
var $path = array( |
|
101 |
'parse' => array(), |
|
102 |
'render' => array() |
|
103 |
); |
|
104 |
var $_dirSep = DIRECTORY_SEPARATOR; |
|
105 |
function Text_Wiki($rules = null) |
|
106 |
{ |
|
107 |
if (is_array($rules)) { |
|
108 |
$this->rules = $rules; |
|
109 |
} |
|
407
35d94240a197
Mass-fixed all AJAX functions to also check the HTTP status code before parsing the response
Dan
parents:
371
diff
changeset
|
110 |
|
35d94240a197
Mass-fixed all AJAX functions to also check the HTTP status code before parsing the response
Dan
parents:
371
diff
changeset
|
111 |
global $plugins; |
438 | 112 |
// This code can be run from the installer, so in some cases $plugins |
113 |
// isn't initted. (Bug in 1.1.2, fixed for 1.1.3) |
|
114 |
if ( is_object($plugins) ) |
|
407
35d94240a197
Mass-fixed all AJAX functions to also check the HTTP status code before parsing the response
Dan
parents:
371
diff
changeset
|
115 |
{ |
438 | 116 |
$code = $plugins->setHook('text_wiki_construct'); |
117 |
foreach ( $code as $cmd ) |
|
118 |
{ |
|
119 |
eval($cmd); |
|
120 |
} |
|
407
35d94240a197
Mass-fixed all AJAX functions to also check the HTTP status code before parsing the response
Dan
parents:
371
diff
changeset
|
121 |
} |
1 | 122 |
|
123 |
$this->addPath( |
|
124 |
'parse', |
|
125 |
$this->fixPath(ENANO_ROOT) . 'includes/wikiengine/Parse/Default/' |
|
126 |
); |
|
127 |
$this->addPath( |
|
128 |
'render', |
|
129 |
$this->fixPath(ENANO_ROOT) . 'includes/wikiengine/Render/' |
|
130 |
); |
|
131 |
||
132 |
} |
|
133 |
||
371
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
parents:
345
diff
changeset
|
134 |
public static function singleton($parser = 'Default', $rules = null) |
1 | 135 |
{ |
136 |
static $only = array(); |
|
137 |
if (!isset($only[$parser])) { |
|
371
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
parents:
345
diff
changeset
|
138 |
$ret = Text_Wiki::factory($parser, $rules); |
1 | 139 |
if (!$ret) { |
140 |
return $ret; |
|
141 |
} |
|
142 |
$only[$parser] =& $ret; |
|
143 |
} |
|
144 |
return $only[$parser]; |
|
145 |
} |
|
146 |
||
371
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
parents:
345
diff
changeset
|
147 |
public static function factory($parser = 'Default', $rules = null) |
1 | 148 |
{ |
149 |
$d=getcwd(); |
|
150 |
chdir(ENANO_ROOT); |
|
151 |
||
152 |
$class = 'Text_Wiki_' . $parser; |
|
460 | 153 |
$c2 = $parser; |
154 |
$file = ENANO_ROOT . '/includes/wikiengine/' . str_replace('_', '/', $c2).'.php'; |
|
1 | 155 |
if (!class_exists($class)) { |
156 |
$fp = @fopen($file, 'r', true); |
|
157 |
if ($fp === false) { |
|
158 |
die_semicritical('Wiki formatting engine error', '<p>Could not find file '.$file.' in include_path</p>'); |
|
159 |
} |
|
160 |
fclose($fp); |
|
161 |
include_once($file); |
|
162 |
if (!class_exists($class)) { |
|
163 |
die_semicritical('Wiki formatting engine error', '<p>Class '.$class.' does not exist after including '.$file.'</p>'); |
|
164 |
} |
|
165 |
} |
|
166 |
||
167 |
chdir($d); |
|
168 |
||
345
4ccdfeee9a11
WiP commit for admin panel localization. All modules up to Admin:UserManager (working down the list) are localized except Admin:ThemeManager, which is due for a rewrite
Dan
parents:
142
diff
changeset
|
169 |
$obj = new $class($rules); |
1 | 170 |
return $obj; |
171 |
} |
|
172 |
||
173 |
function setParseConf($rule, $arg1, $arg2 = null) |
|
174 |
{ |
|
175 |
$rule = ucwords(strtolower($rule)); |
|
176 |
||
177 |
if (! isset($this->parseConf[$rule])) { |
|
178 |
$this->parseConf[$rule] = array(); |
|
179 |
} |
|
180 |
||
181 |
if (is_array($arg1)) { |
|
182 |
$this->parseConf[$rule] = $arg1; |
|
183 |
} else { |
|
184 |
$this->parseConf[$rule][$arg1] = $arg2; |
|
185 |
} |
|
186 |
} |
|
187 |
||
188 |
function getParseConf($rule, $key = null) |
|
189 |
{ |
|
190 |
$rule = ucwords(strtolower($rule)); |
|
191 |
||
192 |
if (! isset($this->parseConf[$rule])) { |
|
193 |
return null; |
|
194 |
} |
|
195 |
||
196 |
if (is_null($key)) { |
|
197 |
return $this->parseConf[$rule]; |
|
198 |
} |
|
199 |
||
200 |
if (isset($this->parseConf[$rule][$key])) { |
|
201 |
return $this->parseConf[$rule][$key]; |
|
202 |
} else { |
|
203 |
return null; |
|
204 |
} |
|
205 |
} |
|
206 |
||
207 |
function setRenderConf($format, $rule, $arg1, $arg2 = null) |
|
208 |
{ |
|
209 |
$format = ucwords(strtolower($format)); |
|
210 |
$rule = ucwords(strtolower($rule)); |
|
211 |
||
212 |
if (! isset($this->renderConf[$format])) { |
|
213 |
$this->renderConf[$format] = array(); |
|
214 |
} |
|
215 |
||
216 |
if (! isset($this->renderConf[$format][$rule])) { |
|
217 |
$this->renderConf[$format][$rule] = array(); |
|
218 |
} |
|
219 |
||
220 |
if (is_array($arg1)) { |
|
221 |
$this->renderConf[$format][$rule] = $arg1; |
|
222 |
} else { |
|
223 |
$this->renderConf[$format][$rule][$arg1] = $arg2; |
|
224 |
} |
|
225 |
} |
|
226 |
||
227 |
function getRenderConf($format, $rule, $key = null) |
|
228 |
{ |
|
229 |
$format = ucwords(strtolower($format)); |
|
230 |
$rule = ucwords(strtolower($rule)); |
|
231 |
||
232 |
if (! isset($this->renderConf[$format]) || |
|
233 |
! isset($this->renderConf[$format][$rule])) { |
|
234 |
return null; |
|
235 |
} |
|
236 |
||
237 |
if (is_null($key)) { |
|
238 |
return $this->renderConf[$format][$rule]; |
|
239 |
} |
|
240 |
||
241 |
if (isset($this->renderConf[$format][$rule][$key])) { |
|
242 |
return $this->renderConf[$format][$rule][$key]; |
|
243 |
} else { |
|
244 |
return null; |
|
245 |
} |
|
246 |
||
247 |
} |
|
248 |
||
249 |
function setFormatConf($format, $arg1, $arg2 = null) |
|
250 |
{ |
|
251 |
if (! is_array($this->formatConf[$format])) { |
|
252 |
$this->formatConf[$format] = array(); |
|
253 |
} |
|
254 |
||
255 |
if (is_array($arg1)) { |
|
256 |
$this->formatConf[$format] = $arg1; |
|
257 |
} else { |
|
258 |
$this->formatConf[$format][$arg1] = $arg2; |
|
259 |
} |
|
260 |
} |
|
261 |
||
262 |
function getFormatConf($format, $key = null) |
|
263 |
{ |
|
264 |
if (! isset($this->formatConf[$format])) { |
|
265 |
return null; |
|
266 |
} |
|
267 |
||
268 |
if (is_null($key)) { |
|
269 |
return $this->formatConf[$format]; |
|
270 |
} |
|
271 |
||
272 |
if (isset($this->formatConf[$format][$key])) { |
|
273 |
return $this->formatConf[$format][$key]; |
|
274 |
} else { |
|
275 |
return null; |
|
276 |
} |
|
277 |
} |
|
278 |
||
279 |
function insertRule($name, $tgt = null) |
|
280 |
{ |
|
281 |
$name = ucwords(strtolower($name)); |
|
282 |
if (! is_null($tgt)) { |
|
283 |
$tgt = ucwords(strtolower($tgt)); |
|
284 |
} |
|
285 |
if (in_array($name, $this->rules)) { |
|
286 |
return null; |
|
287 |
} |
|
288 |
||
289 |
if (! is_null($tgt) && $tgt != '' && |
|
290 |
! in_array($tgt, $this->rules)) { |
|
291 |
return false; |
|
292 |
} |
|
293 |
||
294 |
if (is_null($tgt)) { |
|
295 |
$this->rules[] = $name; |
|
296 |
return true; |
|
297 |
} |
|
298 |
||
299 |
if ($tgt == '') { |
|
300 |
array_unshift($this->rules, $name); |
|
301 |
return true; |
|
302 |
} |
|
303 |
||
304 |
$tmp = $this->rules; |
|
305 |
$this->rules = array(); |
|
306 |
||
307 |
foreach ($tmp as $val) { |
|
308 |
$this->rules[] = $val; |
|
309 |
if ($val == $tgt) { |
|
310 |
$this->rules[] = $name; |
|
311 |
} |
|
312 |
} |
|
313 |
||
314 |
return true; |
|
315 |
} |
|
316 |
||
317 |
function deleteRule($name) |
|
318 |
{ |
|
319 |
$name = ucwords(strtolower($name)); |
|
320 |
$key = array_search($name, $this->rules); |
|
321 |
if ($key !== false) { |
|
322 |
unset($this->rules[$key]); |
|
323 |
} |
|
324 |
} |
|
325 |
||
326 |
function changeRule($old, $new) |
|
327 |
{ |
|
328 |
$old = ucwords(strtolower($old)); |
|
329 |
$new = ucwords(strtolower($new)); |
|
330 |
$key = array_search($old, $this->rules); |
|
331 |
if ($key !== false) { |
|
332 |
$this->deleteRule($new); |
|
333 |
$this->rules[$key] = $new; |
|
334 |
} |
|
335 |
} |
|
336 |
||
337 |
function enableRule($name) |
|
338 |
{ |
|
339 |
$name = ucwords(strtolower($name)); |
|
340 |
$key = array_search($name, $this->disable); |
|
341 |
if ($key !== false) { |
|
342 |
unset($this->disable[$key]); |
|
343 |
} |
|
344 |
} |
|
345 |
||
346 |
function disableRule($name) |
|
347 |
{ |
|
348 |
$name = ucwords(strtolower($name)); |
|
349 |
$key = array_search($name, $this->disable); |
|
350 |
if ($key === false) { |
|
351 |
$this->disable[] = $name; |
|
352 |
} |
|
353 |
} |
|
354 |
||
355 |
function transform($text, $format = 'Xhtml') |
|
356 |
{ |
|
357 |
$this->parse($text); |
|
358 |
return $this->render($format); |
|
359 |
} |
|
360 |
||
361 |
function parse($text) |
|
362 |
{ |
|
363 |
$this->source = $text; |
|
364 |
||
365 |
$this->tokens = array(); |
|
366 |
$this->_countRulesTokens = array(); |
|
367 |
||
368 |
foreach ($this->rules as $name) { |
|
369 |
if (! in_array($name, $this->disable)) { |
|
370 |
$this->loadParseObj($name); |
|
371 |
||
372 |
if (is_object($this->parseObj[$name])) { |
|
373 |
$this->parseObj[$name]->parse(); |
|
374 |
} |
|
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
1
diff
changeset
|
375 |
// For debugging |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
1
diff
changeset
|
376 |
// echo('<p>' . $name . ':</p><pre>'.htmlspecialchars($this->source).'</pre>'); |
1 | 377 |
} |
378 |
} |
|
379 |
} |
|
380 |
||
381 |
function render($format = 'Xhtml') |
|
382 |
{ |
|
383 |
$format = ucwords(strtolower($format)); |
|
384 |
||
385 |
$output = ''; |
|
386 |
||
387 |
$in_delim = false; |
|
388 |
||
389 |
$key = ''; |
|
390 |
||
391 |
$result = $this->loadFormatObj($format); |
|
392 |
if ($this->isError($result)) { |
|
393 |
return $result; |
|
394 |
} |
|
78
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
35
diff
changeset
|
395 |
|
1 | 396 |
if (is_object($this->formatObj[$format])) { |
397 |
$output .= $this->formatObj[$format]->pre(); |
|
398 |
} |
|
399 |
||
400 |
foreach (array_keys($this->_countRulesTokens) as $rule) { |
|
401 |
$this->loadRenderObj($format, $rule); |
|
402 |
} |
|
78
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
35
diff
changeset
|
403 |
|
1 | 404 |
$k = strlen($this->source); |
405 |
for ($i = 0; $i < $k; $i++) { |
|
406 |
||
407 |
$char = $this->source{$i}; |
|
408 |
||
409 |
if ($in_delim) { |
|
410 |
||
411 |
if ($char == $this->delim) { |
|
412 |
||
413 |
$key = (int)$key; |
|
414 |
$rule = $this->tokens[$key][0]; |
|
415 |
$opts = $this->tokens[$key][1]; |
|
416 |
$output .= $this->renderObj[$rule]->token($opts); |
|
417 |
$in_delim = false; |
|
418 |
||
419 |
} else { |
|
420 |
||
421 |
$key .= $char; |
|
422 |
||
423 |
} |
|
424 |
||
425 |
} else { |
|
426 |
||
427 |
if ($char == $this->delim) { |
|
428 |
$key = ''; |
|
429 |
$in_delim = true; |
|
430 |
} else { |
|
431 |
$output .= $char; |
|
432 |
} |
|
433 |
} |
|
434 |
} |
|
435 |
||
436 |
if (is_object($this->formatObj[$format])) { |
|
437 |
$output .= $this->formatObj[$format]->post(); |
|
438 |
} |
|
439 |
||
440 |
return $output; |
|
441 |
} |
|
442 |
||
443 |
function getSource() |
|
444 |
{ |
|
445 |
return $this->source; |
|
446 |
} |
|
447 |
||
448 |
function getTokens($rules = null) |
|
449 |
{ |
|
450 |
if (is_null($rules)) { |
|
451 |
return $this->tokens; |
|
452 |
} else { |
|
453 |
settype($rules, 'array'); |
|
454 |
$result = array(); |
|
455 |
foreach ($this->tokens as $key => $val) { |
|
456 |
if (in_array($val[0], $rules)) { |
|
457 |
$result[$key] = $val; |
|
458 |
} |
|
459 |
} |
|
460 |
return $result; |
|
461 |
} |
|
462 |
} |
|
463 |
||
464 |
function addToken($rule, $options = array(), $id_only = false) |
|
465 |
{ |
|
466 |
static $id; |
|
467 |
if (! isset($id)) { |
|
468 |
$id = 0; |
|
469 |
} else { |
|
470 |
$id ++; |
|
471 |
} |
|
472 |
||
473 |
settype($options, 'array'); |
|
474 |
||
475 |
$this->tokens[$id] = array( |
|
476 |
0 => $rule, |
|
477 |
1 => $options |
|
478 |
); |
|
479 |
if (!isset($this->_countRulesTokens[$rule])) { |
|
480 |
$this->_countRulesTokens[$rule] = 1; |
|
481 |
} else { |
|
482 |
++$this->_countRulesTokens[$rule]; |
|
483 |
} |
|
484 |
||
485 |
if ($id_only) { |
|
486 |
return $id; |
|
487 |
} else { |
|
488 |
return $this->delim . $id . $this->delim; |
|
489 |
} |
|
490 |
} |
|
491 |
||
492 |
function setToken($id, $rule, $options = array()) |
|
493 |
{ |
|
494 |
$oldRule = $this->tokens[$id][0]; |
|
495 |
$this->tokens[$id] = array( |
|
496 |
0 => $rule, |
|
497 |
1 => $options |
|
498 |
); |
|
499 |
if ($rule != $oldRule) { |
|
500 |
if (!($this->_countRulesTokens[$oldRule]--)) { |
|
501 |
unset($this->_countRulesTokens[$oldRule]); |
|
502 |
} |
|
503 |
if (!isset($this->_countRulesTokens[$rule])) { |
|
504 |
$this->_countRulesTokens[$rule] = 1; |
|
505 |
} else { |
|
506 |
++$this->_countRulesTokens[$rule]; |
|
507 |
} |
|
508 |
} |
|
509 |
} |
|
510 |
||
511 |
function loadParseObj($rule) |
|
512 |
{ |
|
513 |
$rule = ucwords(strtolower($rule)); |
|
514 |
$file = $rule . '.php'; |
|
515 |
$class = "Text_Wiki_Parse_$rule"; |
|
516 |
||
517 |
if (! class_exists($class)) { |
|
518 |
$loc = $this->findFile('parse', $file); |
|
519 |
if ($loc) { |
|
520 |
include_once $loc; |
|
521 |
} else { |
|
522 |
$this->parseObj[$rule] = null; |
|
523 |
return $this->error( |
|
524 |
"Parse rule '$rule' not found" |
|
525 |
); |
|
526 |
} |
|
527 |
} |
|
528 |
||
345
4ccdfeee9a11
WiP commit for admin panel localization. All modules up to Admin:UserManager (working down the list) are localized except Admin:ThemeManager, which is due for a rewrite
Dan
parents:
142
diff
changeset
|
529 |
$this->parseObj[$rule] = new $class($this); |
1 | 530 |
|
531 |
} |
|
532 |
||
533 |
function loadRenderObj($format, $rule) |
|
534 |
{ |
|
535 |
$format = ucwords(strtolower($format)); |
|
536 |
$rule = ucwords(strtolower($rule)); |
|
537 |
$file = "$format/$rule.php"; |
|
538 |
$class = "Text_Wiki_Render_$format" . "_$rule"; |
|
539 |
||
540 |
if (! class_exists($class)) { |
|
541 |
$loc = $this->findFile('render', $file); |
|
542 |
if ($loc) { |
|
543 |
include_once $loc; |
|
544 |
} else { |
|
545 |
return $this->error( |
|
546 |
"Render rule '$rule' in format '$format' not found" |
|
547 |
); |
|
548 |
} |
|
549 |
} |
|
550 |
||
345
4ccdfeee9a11
WiP commit for admin panel localization. All modules up to Admin:UserManager (working down the list) are localized except Admin:ThemeManager, which is due for a rewrite
Dan
parents:
142
diff
changeset
|
551 |
$this->renderObj[$rule] = new $class($this); |
1 | 552 |
} |
553 |
||
554 |
function loadFormatObj($format) |
|
555 |
{ |
|
556 |
$format = ucwords(strtolower($format)); |
|
557 |
$file = $format . '.php'; |
|
558 |
$class = "Text_Wiki_Render_$format"; |
|
559 |
||
560 |
if (! class_exists($class)) { |
|
561 |
$loc = $this->findFile('render', $file); |
|
562 |
if ($loc) { |
|
563 |
include_once $loc; |
|
564 |
} else { |
|
565 |
return $this->error( |
|
566 |
"Rendering format class '$class' not found" |
|
567 |
); |
|
568 |
} |
|
569 |
} |
|
570 |
||
345
4ccdfeee9a11
WiP commit for admin panel localization. All modules up to Admin:UserManager (working down the list) are localized except Admin:ThemeManager, which is due for a rewrite
Dan
parents:
142
diff
changeset
|
571 |
$this->formatObj[$format] = new $class($this); |
1 | 572 |
} |
573 |
||
574 |
function addPath($type, $dir) |
|
575 |
{ |
|
576 |
$dir = $this->fixPath($dir); |
|
577 |
if (! isset($this->path[$type])) { |
|
578 |
$this->path[$type] = array($dir); |
|
579 |
} else { |
|
580 |
array_unshift($this->path[$type], $dir); |
|
581 |
} |
|
582 |
} |
|
583 |
||
584 |
function getPath($type = null) |
|
585 |
{ |
|
586 |
if (is_null($type)) { |
|
587 |
return $this->path; |
|
588 |
} elseif (! isset($this->path[$type])) { |
|
589 |
return array(); |
|
590 |
} else { |
|
591 |
return $this->path[$type]; |
|
592 |
} |
|
593 |
} |
|
594 |
||
595 |
function findFile($type, $file) |
|
596 |
{ |
|
597 |
$set = $this->getPath($type); |
|
598 |
||
599 |
foreach ($set as $path) { |
|
600 |
$fullname = $path . $file; |
|
601 |
if (file_exists($fullname) && is_readable($fullname)) { |
|
602 |
return $fullname; |
|
603 |
} |
|
604 |
} |
|
605 |
||
606 |
return false; |
|
607 |
} |
|
608 |
||
609 |
function fixPath($path) |
|
610 |
{ |
|
611 |
$len = strlen($this->_dirSep); |
|
612 |
||
613 |
if (! empty($path) && |
|
614 |
substr($path, -1 * $len, $len) != $this->_dirSep) { |
|
615 |
return $path . $this->_dirSep; |
|
616 |
} else { |
|
617 |
return $path; |
|
618 |
} |
|
619 |
} |
|
620 |
||
621 |
function &error($message) |
|
622 |
{ |
|
623 |
die($message); |
|
624 |
} |
|
625 |
||
626 |
function isError(&$obj) |
|
627 |
{ |
|
371
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
parents:
345
diff
changeset
|
628 |
return ( @get_class($obj) == 'PEAR_Error' ); |
1 | 629 |
} |
630 |
} |
|
631 |
||
632 |
?> |