1 | <?php |
---|
2 | |
---|
3 | /***************************************************************************\ |
---|
4 | * SPIP, Systeme de publication pour l'internet * |
---|
5 | * * |
---|
6 | * Copyright (c) 2001-2010 * |
---|
7 | * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * |
---|
8 | * * |
---|
9 | * Ce programme est un logiciel libre distribue sous licence GNU/GPL. * |
---|
10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
---|
11 | \***************************************************************************/ |
---|
12 | |
---|
13 | if (!defined("_ECRIRE_INC_VERSION")) return; |
---|
14 | |
---|
15 | include_spip('engine/textwheel'); |
---|
16 | |
---|
17 | // |
---|
18 | // Definition des principales wheels de SPIP |
---|
19 | // |
---|
20 | |
---|
21 | // Si le tableau des raccourcis existe déjà |
---|
22 | if (!is_array($GLOBALS['spip_wheels']['raccourcis'])) |
---|
23 | $GLOBALS['spip_wheels']['raccourcis'] = array( |
---|
24 | 'spip/spip.yaml', |
---|
25 | 'spip/spip-paragrapher.yaml' |
---|
26 | ); |
---|
27 | else |
---|
28 | $GLOBALS['spip_wheels']['raccourcis'] = array_merge( |
---|
29 | array( |
---|
30 | 'spip/spip.yaml', |
---|
31 | 'spip/spip-paragrapher.yaml' |
---|
32 | ), |
---|
33 | $GLOBALS['spip_wheels']['raccourcis'] |
---|
34 | ); |
---|
35 | |
---|
36 | if (test_espace_prive ()) |
---|
37 | $GLOBALS['spip_wheels']['raccourcis'][] = 'spip/ecrire.yaml'; |
---|
38 | |
---|
39 | $GLOBALS['spip_wheels']['interdire_scripts'] = array( |
---|
40 | 'spip/interdire-scripts.yaml' |
---|
41 | ); |
---|
42 | |
---|
43 | $GLOBALS['spip_wheels']['echappe_js'] = array( |
---|
44 | 'spip/echappe-js.yaml' |
---|
45 | ); |
---|
46 | |
---|
47 | $GLOBALS['spip_wheels']['paragrapher'][] = array( |
---|
48 | 'spip/spip-paragrapher.yaml' |
---|
49 | ); |
---|
50 | |
---|
51 | // |
---|
52 | // Methode de chargement d'une wheel SPIP |
---|
53 | // |
---|
54 | |
---|
55 | class SPIPTextWheelRuleset extends TextWheelRuleSet { |
---|
56 | protected function findFile(&$file, $path=''){ |
---|
57 | static $default_path; |
---|
58 | |
---|
59 | // absolute file path? |
---|
60 | if (file_exists($file)) |
---|
61 | return $file; |
---|
62 | |
---|
63 | // file include with texwheels, relative to calling ruleset |
---|
64 | if ($path AND file_exists($f = $path.$file)) |
---|
65 | return $f; |
---|
66 | |
---|
67 | return find_in_path($file,'wheels/'); |
---|
68 | } |
---|
69 | |
---|
70 | public static function &loader($ruleset, $callback = '', $class = 'SPIPTextWheelRuleset') { |
---|
71 | |
---|
72 | # memoization |
---|
73 | # attention : le ruleset peut contenir apres loading des chemins relatifs |
---|
74 | # il faut donc que le cache depende du chemin courant vers la racine de SPIP |
---|
75 | $key = 'tw-'.md5(serialize($ruleset).$callback.$class._DIR_RACINE); |
---|
76 | |
---|
77 | # lecture du cache |
---|
78 | include_spip('inc/memoization'); |
---|
79 | if (!function_exists('cache_get')) include_spip('inc/memoization-mini'); |
---|
80 | if (!_request('var_mode') |
---|
81 | AND $cacheruleset = cache_get($key)) |
---|
82 | return $cacheruleset; |
---|
83 | |
---|
84 | # calcul de la wheel |
---|
85 | $ruleset = parent::loader($ruleset, $callback, $class); |
---|
86 | |
---|
87 | # ecriture du cache |
---|
88 | cache_set($key, $ruleset); |
---|
89 | |
---|
90 | return $ruleset; |
---|
91 | } |
---|
92 | } |
---|
93 | |
---|
94 | |
---|
95 | ?> |
---|