[SPIP] +2.1.12
[velocampus/web/www.git] / www / ecrire / inc / 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 * une classe definissant un bouton dans la barre du haut de l'interface
17 * privee ou dans un de ses sous menus
18 */
19 // http://doc.spip.org/@Bouton
20 class Bouton {
21 var $icone; /* l'icone a mettre dans le bouton */
22 var $libelle; /* le nom de l'entree d'i18n associe */
23 var $url= null; /* l'url de la page (null => ?exec=nom) */
24 var $urlArg= null; /* arguments supplementaires de l'url */
25 var $url2= null; /* url jscript */
26 var $target= null; /* pour ouvrir dans une fenetre a part */
27 var $sousmenu= null;/* sous barre de boutons / onglets */
28
29 // http://doc.spip.org/@Bouton
30 function Bouton($icone, $libelle, $url=null, $urlArg=null,
31 $url2=null, $target=null) {
32 $this->icone = $icone;
33 $this->libelle= $libelle;
34 $this->url = $url;
35 $this->urlArg = $urlArg;
36 $this->url2 = $url2;
37 $this->target = $target;
38 }
39 }
40
41
42 // http://doc.spip.org/@barre_onglets_rep_depuis
43 function barre_onglets_rep_depuis() {
44
45 $onglets = array();
46 $onglets['statistiques_lang']=
47 new Bouton(null, 'icone_repartition_actuelle');
48 $onglets['debut']=
49 new Bouton(null, 'onglet_repartition_debut',
50 generer_url_ecrire("statistiques_lang","critere=debut"));
51 return $onglets;
52 }
53
54 // http://doc.spip.org/@barre_onglets_stat_depuis
55 function barre_onglets_stat_depuis() {
56 $onglets = array();
57 $onglets['popularite']=
58 new Bouton(null, 'icone_repartition_actuelle',
59 generer_url_ecrire("statistiques_repartition",""));
60 $onglets['debut']=
61 new Bouton(null, 'onglet_repartition_debut',
62 generer_url_ecrire("statistiques_repartition","critere=debut"));
63 return $onglets;
64 }
65
66
67 // http://doc.spip.org/@barre_onglets_administration
68 function barre_onglets_administration() {
69
70 $onglets = array();
71 if (autoriser('sauvegarder')) {
72 $onglets['sauver']=
73 new Bouton('spip-pack-24.png', 'onglet_save_restaur_base',
74 generer_url_ecrire("admin_tech"));
75 }
76 if (autoriser('detruire')) {
77 $onglets['effacer']=
78 new Bouton('supprimer.gif', 'onglet_affacer_base',
79 generer_url_ecrire("admin_effacer"));
80
81 $onglets['declarer']=
82 new Bouton('base-24.gif', 'onglet_declarer_une_autre_base',
83 generer_url_ecrire("admin_declarer"));
84 }
85 return $onglets;
86 }
87
88 // http://doc.spip.org/@barre_onglets_configuration
89 function barre_onglets_configuration() {
90
91 $onglets = array();
92 $onglets['contenu']=
93 new Bouton('racine-site-24.gif', 'onglet_contenu_site',
94 generer_url_ecrire("configuration"));
95 $onglets['interactivite']=
96 new Bouton('forum-interne-24.gif', 'onglet_interactivite',
97 generer_url_ecrire("config_contenu"));
98 $onglets['fonctions']=
99 new Bouton('image-24.gif', 'onglet_fonctions_avances',
100 generer_url_ecrire("config_fonctions"));
101 /*
102 if (true)
103 $onglets['plugins']=
104 new Bouton('plugin-24.gif', 'onglet_plugins',
105 generer_url_ecrire("config_plugins"));
106 */
107 return $onglets;
108 }
109
110
111 // http://doc.spip.org/@barre_onglets_config_lang
112 function barre_onglets_config_lang() {
113
114 $onglets=array();
115 $onglets['langues']=
116 new Bouton('langues-24.gif', 'info_langue_principale',
117 generer_url_ecrire("config_lang"));
118 $onglets['multi']=
119 new Bouton('traductions-24.gif', 'info_multilinguisme',
120 generer_url_ecrire("config_multilang"));
121 $onglets['fichiers']=
122 new Bouton('traductions-24.gif', 'module_fichiers_langues',
123 generer_url_ecrire("lang_raccourcis"));
124 return $onglets;
125 }
126
127
128 function barre_onglets_plugins() {
129
130 $onglets=array();
131 $onglets['plugins_actifs']=
132 new Bouton('plugin-24.gif', 'plugins_actifs_liste',
133 generer_url_ecrire("admin_plugin"));
134 $onglets['admin_plugin']=
135 new Bouton('plugin-24.gif', 'plugins_liste',
136 generer_url_ecrire("admin_plugin","voir=tous"));
137 $onglets['charger_plugin']=
138 new Bouton('spip-pack-24.png', 'plugin_titre_automatique_ajouter',
139 generer_url_ecrire("charger_plugin"));
140 return $onglets;
141 }
142
143
144 /**
145 * definir la liste des onglets dans une page de l'interface privee
146 * on passe la main au pipeline "ajouter_onglets".
147 */
148 // http://doc.spip.org/@definir_barre_onglets
149 function definir_barre_onglets($script) {
150
151 if (function_exists($f = 'barre_onglets_' . $script))
152 $onglets = $f();
153 else $onglets=array();
154
155 // ajouter les onglets issus des plugin via plugin.xml
156 if (function_exists('onglets_plugins')){
157 $liste_onglets_plugins = onglets_plugins();
158
159 foreach($liste_onglets_plugins as $id => $infos){
160 if (($parent = $infos['parent'])
161 && $parent == $script
162 && autoriser('onglet',$id)) {
163 $onglets[$id] = new Bouton(
164 find_in_path($infos['icone']), // icone
165 $infos['titre'], // titre
166 $infos['url']?generer_url_ecrire($infos['url'],$infos['args']?$infos['args']:''):null
167 );
168 }
169 }
170 }
171
172 return pipeline('ajouter_onglets', array('data'=>$onglets,'args'=>$script));
173 }
174
175
176 // http://doc.spip.org/@barre_onglets
177 function barre_onglets($rubrique, $ongletCourant){
178
179 $res = '';
180
181 foreach(definir_barre_onglets($rubrique) as $exec => $onglet) {
182 $url= $onglet->url ? $onglet->url : generer_url_ecrire($exec);
183 $res .= onglet(_T($onglet->libelle), $url, $exec, $ongletCourant, $onglet->icone);
184 }
185
186 return !$res ? '' : (debut_onglet() . $res . fin_onglet());
187 }
188
189 // http://doc.spip.org/@definir_barre_gadgets
190 function definir_barre_gadgets() {
191 global $barre_gadgets;
192 $barre_gadgets= array(
193 // ?????????
194 );
195 }
196
197
198 ?>