[SPIP] +2.1.12
[velocampus/web/www.git] / www / ecrire / plugins / get_infos.php
1 <?php
2
3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
5 * *
6 * Copyright (c) 2001-2011 *
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 /**
16 * lecture du fichier de configuration d'un plugin
17 *
18 * @staticvar array $infos
19 * @staticvar array $plugin_xml_cache
20 * @param string $plug
21 * @param bool $force_reload
22 * @param string $dir_plugins
23 * @param string $filename
24 * @return array
25 */
26 function plugins_get_infos_dist($plug, $force_reload=false, $dir_plugins = _DIR_PLUGINS, $filename='plugin.xml'){
27
28 static $cache='';
29 static $filecache = '';
30
31 if ($cache===''){
32 $filecache = _DIR_TMP."plugin_xml_cache.gz";
33 if (is_file($filecache)){
34 lire_fichier($filecache, $contenu);
35 $cache = unserialize($contenu);
36 }
37 if (!is_array($cache)) $cache = array();
38 }
39 $force_reload |= !isset($cache[$dir_plugins][$plug]['filemtime']);
40
41 $desc = "$dir_plugins$plug/$filename";
42 if (!file_exists($desc))
43 return false;
44 $time = intval(@filemtime($desc));
45
46 if (!$force_reload
47 AND ($time > 0)
48 AND ($time <= $cache[$dir_plugins][$plug]['filemtime'])) {
49 return $cache[$dir_plugins][$plug];
50 }
51
52 include_spip('inc/xml');
53 $arbre = ($time < 0) ? false : spip_xml_load($desc);
54 $verifie_conformite = charger_fonction('verifie_conformite','plugins');
55 $verifie_conformite($plug, $arbre, $dir_plugins);
56
57 include_spip('inc/charsets');
58
59 $ret = array('nom' => charset2unicode(spip_xml_aplatit($arbre['nom'])),
60 'version' => trim(end($arbre['version'])),
61 'filemtime' => $time
62 );
63
64 if (isset($arbre['auteur']))
65 $ret['auteur'] = spip_xml_aplatit($arbre['auteur']);
66 if (isset($arbre['icon']))
67 $ret['icon'] = trim(spip_xml_aplatit($arbre['icon']));
68 if (isset($arbre['description']))
69 $ret['description'] = spip_xml_aplatit($arbre['description']);
70 if (isset($arbre['lien']))
71 $ret['lien'] = join(' ',$arbre['lien']);
72 if (isset($arbre['etat']))
73 $ret['etat'] = trim(end($arbre['etat']));
74 if (isset($arbre['options']))
75 $ret['options'] = $arbre['options'];
76 if (isset($arbre['licence']))
77 $ret['licence'] = spip_xml_aplatit($arbre['licence']);
78 if (isset($arbre['install']))
79 $ret['install'] = $arbre['install'];
80 if (isset($arbre['config']))
81 $ret['config'] = spip_xml_aplatit($arbre['config']);
82 if (isset($arbre['meta']))
83 $ret['meta'] = spip_xml_aplatit($arbre['meta']);
84 if (isset($arbre['fonctions']))
85 $ret['fonctions'] = $arbre['fonctions'];
86 $ret['prefix'] = trim(array_pop($arbre['prefix']));
87 if (isset($arbre['pipeline']))
88 $ret['pipeline'] = $arbre['pipeline'];
89 if (isset($arbre['erreur']))
90 $ret['erreur'] = $arbre['erreur'];
91 if (isset($arbre['version_base']))
92 $ret['version_base'] = trim(end($arbre['version_base']));
93 $ret['necessite'] = $arbre['necessite'];
94 $ret['utilise'] = $arbre['utilise'];
95 $ret['path'] = $arbre['path'];
96 if (isset($arbre['noisette']))
97 $ret['noisette'] = $arbre['noisette'];
98
99 $extraire_boutons = charger_fonction('extraire_boutons','plugins');
100 $les_boutons = $extraire_boutons($arbre);
101 $ret['bouton'] = $les_boutons['bouton'];
102 $ret['onglet'] = $les_boutons['onglet'];
103
104 $ret['traduire'] = $arbre['traduire'];
105
106 if (isset($arbre['erreur'])) {
107 spip_log("get_infos $plug " . @join(' ', $arbre['erreur']));
108 } else {
109 $cache[$dir_plugins][$plug] = $ret;
110 ecrire_fichier($filecache, serialize($cache));
111 }
112 return $ret;
113 }
114 ?>