[SPIP][PLUGINS] v3.0-->v3.2
[lhc/web/www.git] / www / ecrire / plugins / extraire_boutons.php
1 <?php
2
3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
5 * *
6 * Copyright (c) 2001-2017 *
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')) {
14 return;
15 }
16
17 /**
18 * Analyser un arbre xml et extraire les infos concernant les boutons et onglets
19 *
20 * @param <type> $arbre
21 * @return <type>
22 */
23 function plugins_extraire_boutons_dist($arbre) {
24 $ret = array('bouton' => array(), 'onglet' => array());
25 // recuperer les boutons et onglets si necessaire
26 spip_xml_match_nodes(",^(bouton|onglet)\s,", $arbre, $les_boutons);
27 if (is_array($les_boutons) && count($les_boutons)) {
28 $ret['bouton'] = array();
29 $ret['onglet'] = array();
30 foreach ($les_boutons as $bouton => $val) {
31 $bouton = spip_xml_decompose_tag($bouton);
32 $type = reset($bouton);
33 $bouton = end($bouton);
34 if (isset($bouton['id'])) {
35 $id = $bouton['id'];
36 $val = reset($val);
37 if (is_array($val)) {
38 $ret[$type][$id]['parent'] = isset($bouton['parent']) ? $bouton['parent'] : '';
39 $ret[$type][$id]['position'] = isset($bouton['position']) ? $bouton['position'] : '';
40 $ret[$type][$id]['titre'] = isset($val['titre']) ? trim(spip_xml_aplatit($val['titre'])) : '';
41 $ret[$type][$id]['icone'] = isset($val['icone']) ? trim(end($val['icone'])) : '';
42 $ret[$type][$id]['action'] = isset($val['url']) ? trim(end($val['url'])) : '';
43 $ret[$type][$id]['parametres'] = isset($val['args']) ? trim(end($val['args'])) : '';
44 }
45 }
46 }
47 }
48
49 return $ret;
50 }