[SPIP] ~maj SPIP v3.0.17 --> v3.0.19
[lhc/web/clavette_www.git] / www / plugins-dist / textwheel / inc / textwheel.php
1 <?php
2
3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
5 * *
6 * Copyright (c) 2001-2014 *
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 // si une regle change et rend son cache non valide
17 // incrementer ce define au numero de commit concerne
18 // (inconsistence entre la wheel et l'inclusion php)
19 if (!defined('_WHEELS_VERSION')) define('_WHEELS_VERSION',68672);
20
21 //
22 // Definition des principales wheels de SPIP
23 //
24 if (!isset($GLOBALS['spip_wheels'])) {
25 $GLOBALS['spip_wheels'] = array();
26 }
27
28 // Si le tableau des raccourcis existe déjà
29 if (!isset($GLOBALS['spip_wheels']['raccourcis']) OR !is_array($GLOBALS['spip_wheels']['raccourcis']))
30 $GLOBALS['spip_wheels']['raccourcis'] = array(
31 'spip/spip.yaml',
32 'spip/spip-paragrapher.yaml'
33 );
34 else
35 $GLOBALS['spip_wheels']['raccourcis'] = array_merge(
36 array(
37 'spip/spip.yaml',
38 'spip/spip-paragrapher.yaml'
39 ),
40 $GLOBALS['spip_wheels']['raccourcis']
41 );
42
43 if (test_espace_prive ())
44 $GLOBALS['spip_wheels']['raccourcis'][] = 'spip/ecrire.yaml';
45
46 $GLOBALS['spip_wheels']['interdire_scripts'] = array(
47 'spip/interdire-scripts.yaml'
48 );
49
50 $GLOBALS['spip_wheels']['echappe_js'] = array(
51 'spip/echappe-js.yaml'
52 );
53
54 $GLOBALS['spip_wheels']['paragrapher'] = array(
55 'spip/spip-paragrapher.yaml'
56 );
57
58 $GLOBALS['spip_wheels']['listes'] = array(
59 'spip/spip-listes.yaml'
60 );
61
62 //
63 // Methode de chargement d'une wheel SPIP
64 //
65
66 class SPIPTextWheelRuleset extends TextWheelRuleSet {
67 protected function findFile(&$file, $path=''){
68 static $default_path;
69
70 // absolute file path?
71 if (file_exists($file))
72 return $file;
73
74 // file include with texwheels, relative to calling ruleset
75 if ($path AND file_exists($f = $path.$file))
76 return $f;
77
78 return find_in_path($file,'wheels/');
79 }
80
81 public static function &loader($ruleset, $callback = '', $class = 'SPIPTextWheelRuleset') {
82
83 # memoization
84 # attention : le ruleset peut contenir apres loading des chemins relatifs
85 # il faut donc que le cache depende du chemin courant vers la racine de SPIP
86 $key = 'tw-'.md5(_WHEELS_VERSION."-".serialize($ruleset).$callback.$class._DIR_RACINE);
87
88 # lecture du cache
89 include_spip('memoization_options');
90 if (!function_exists('cache_get')) include_spip('inc/memoization-mini');
91 if ((!defined('_VAR_MODE') OR _VAR_MODE!='recalcul')
92 AND $cacheruleset = cache_get($key))
93 return $cacheruleset;
94
95 # calcul de la wheel
96 $ruleset = parent::loader($ruleset, $callback, $class);
97
98 # ecriture du cache
99 cache_set($key, $ruleset);
100
101 return $ruleset;
102 }
103 }
104
105
106 function tw_trig_purger($quoi){
107 if ($quoi=='cache')
108 purger_repertoire(_DIR_CACHE."wheels");
109 return $quoi;
110 }
111
112 ?>