[SPIP] +2.1.12
[velocampus/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-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 * Analyser un arbre xml et extraire les infos concernant les boutons et onglets
17 *
18 * @param <type> $arbre
19 * @return <type>
20 */
21 function plugins_extraire_boutons_dist($arbre){
22 $ret = array('bouton'=>array(),'onglet'=>array());
23 // recuperer les boutons et onglets si necessaire
24 spip_xml_match_nodes(",^(bouton|onglet)\s,",$arbre,$les_boutons);
25 if (is_array($les_boutons) && count($les_boutons)){
26 $ret['bouton'] = array();
27 $ret['onglet'] = array();
28 foreach($les_boutons as $bouton => $val) {
29 $bouton = spip_xml_decompose_tag($bouton);
30 $type = reset($bouton);
31 $bouton = end($bouton);
32 if (isset($bouton['id'])){
33 $id = $bouton['id'];
34 $val = reset($val);
35 if(is_array($val)){
36 $ret[$type][$id]['parent'] = isset($bouton['parent'])?$bouton['parent']:'';
37 $ret[$type][$id]['position'] = isset($bouton['position'])?$bouton['position']:'';
38 $ret[$type][$id]['titre'] = isset($val['titre'])?trim(spip_xml_aplatit($val['titre'])):'';
39 $ret[$type][$id]['icone'] = isset($val['icone'])?trim(end($val['icone'])):'';
40 $ret[$type][$id]['url'] = isset($val['url'])?trim(end($val['url'])):'';
41 $ret[$type][$id]['args'] = isset($val['args'])?trim(end($val['args'])):'';
42 }
43 }
44 }
45 }
46 return $ret;
47 }
48
49
50 ?>