[SPIP] +2.1.12
[velocampus/web/www.git] / www / ecrire / inc / puce_statut.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 // http://doc.spip.org/@inc_puce_statut_dist
16 function inc_puce_statut_dist($id_objet, $statut, $id_rubrique, $type, $ajax=false) {
17 if (function_exists($f = "puce_statut_$type")
18 OR function_exists($f = "puce_statut_${type}_dist"))
19 return $f($id_objet, $statut, $id_rubrique, $type, $ajax);
20 else
21 return "<img src='" . chemin_image("$type-24.gif") . "' alt='' />";
22 }
23
24 // http://doc.spip.org/@puce_statut_document_dist
25 function puce_statut_document_dist($id, $statut, $id_rubrique, $type, $ajax='') {
26 return "<img src='" . chemin_image("attachment.gif") . "' alt='' />";
27 }
28
29 // http://doc.spip.org/@puce_statut_auteur_dist
30 // Hack de compatibilite: les appels directs ont un $type != 'auteur'
31 // si l'auteur ne peut pas se connecter
32 // http://doc.spip.org/@puce_statut_auteur_dist
33 function puce_statut_auteur_dist($id, $statut, $id_rubrique, $type, $ajax='') {
34
35 static $titre_des_statuts ='';
36 static $images_des_statuts ='';
37
38 // eviter de retraduire a chaque appel
39 if (!$titre_des_statuts) {
40 $titre_des_statuts = array(
41 "info_administrateurs" => _T('titre_image_administrateur'),
42 "info_redacteurs" => _T('titre_image_redacteur_02'),
43 "info_visiteurs" => _T('titre_image_visiteur'),
44 "info_statut_site_4" => _T('titre_image_auteur_supprime')
45 );
46
47 $images_des_statuts = array(
48 "info_administrateurs" => 'admin-12.gif',
49 "info_redacteurs" =>'redac-12.gif',
50 "info_visiteurs" => 'visit-12.gif',
51 "info_statut_site_4" => 'poubelle.gif'
52 );
53 }
54
55 if ($statut == 'nouveau') return '';
56
57 $index = array_search($statut, $GLOBALS['liste_des_statuts']);
58
59 if (!$index) $index = 'info_visiteurs';
60
61 $img = $images_des_statuts[$index];
62 $alt = $titre_des_statuts[$index];
63
64 if ($type != 'auteur') {
65 $img2 = "croix-rouge.gif";
66 $titre = _T('titre_image_redacteur');
67 $fond = http_style_background($img2, 'top right no-repeat; padding-right: 4px');
68 } else {$fond = ''; $titre = $alt;}
69
70 return http_img_pack($img, $alt, $fond, $titre);
71 }
72
73 // http://doc.spip.org/@bonhomme_statut
74 function bonhomme_statut($row) {
75 $puce_statut = charger_fonction('puce_statut', 'inc');
76 return $puce_statut(0, $row['statut'], 0, 'auteur');
77 }
78
79
80 // http://doc.spip.org/@puce_statut_mot_dist
81 function puce_statut_mot_dist($id, $statut, $id_rubrique, $type, $ajax='') {
82 return "<img src='" . chemin_image('petite-cle.gif') . "' alt='' />";
83 }
84
85 // http://doc.spip.org/@puce_statut_rubrique_dist
86 function puce_statut_rubrique_dist($id, $statut, $id_rubrique, $type, $ajax='') {
87
88 return "<img src='" . chemin_image('rubrique-12.gif') . "' alt='' />";
89 }
90
91 // http://doc.spip.org/@puce_statut_article_dist
92 function puce_statut_article_dist($id, $statut, $id_rubrique, $type='article', $ajax = false) {
93 global $lang_objet;
94
95 static $coord = array('publie' => 2,
96 'prepa' => 0,
97 'prop' => 1,
98 'refuse' => 3,
99 'poubelle' => 4);
100
101 $lang_dir = lang_dir($lang_objet);
102 if (!$id) {
103 $id = $id_rubrique;
104 $ajax_node ='';
105 } else $ajax_node = " id='imgstatut$type$id'";
106
107
108 $inser_puce = puce_statut($statut, " width='9' height='9' style='margin: 1px;'$ajax_node");
109
110 if (!autoriser('publierdans', 'rubrique', $id_rubrique)
111 OR !_ACTIVER_PUCE_RAPIDE)
112 return $inser_puce;
113
114 $titles = array(
115 "blanche" => _T('texte_statut_en_cours_redaction'),
116 "orange" => _T('texte_statut_propose_evaluation'),
117 "verte" => _T('texte_statut_publie'),
118 "rouge" => _T('texte_statut_refuse'),
119 "poubelle" => _T('texte_statut_poubelle'));
120
121 $clip = 1+ (11*$coord[$statut]);
122
123 if ($ajax){
124 return "<span class='puce_article_fixe'>"
125 . $inser_puce
126 . "</span>"
127 . "<span class='puce_article_popup' id='statutdecal$type$id' style='margin-left: -$clip"."px;'>"
128 . afficher_script_statut($id, $type, -1, 'puce-blanche.gif', 'prepa', $titles['blanche'])
129 . afficher_script_statut($id, $type, -12, 'puce-orange.gif', 'prop', $titles['orange'])
130 . afficher_script_statut($id, $type, -23, 'puce-verte.gif', 'publie', $titles['verte'])
131 . afficher_script_statut($id, $type, -34, 'puce-rouge.gif', 'refuse', $titles['rouge'])
132 . afficher_script_statut($id, $type, -45, 'puce-poubelle.gif', 'poubelle', $titles['poubelle'])
133 . "</span>";
134 }
135
136 $nom = "puce_statut_";
137
138 if ((! _SPIP_AJAX) AND $type != 'article')
139 $over ='';
140 else {
141
142 $action = generer_url_ecrire('puce_statut',"",true);
143 $action = "if (!this.puce_loaded) { this.puce_loaded = true; prepare_selec_statut('$nom', '$type', '$id', '$action'); }";
144 $over = "\nonmouseover=\"$action\"";
145 }
146
147 return "<span class='puce_article' id='$nom$type$id' dir='$lang_dir'$over>"
148 . $inser_puce
149 . '</span>';
150 }
151
152
153 // http://doc.spip.org/@puce_statut_breve_dist
154 function puce_statut_breve_dist($id, $statut, $id_rubrique, $type, $ajax='') {
155 global $lang_objet;
156 static $coord = array('publie' => 1,
157 'prop' => 0,
158 'refuse' => 2,
159 'poubelle' => 3);
160
161 $lang_dir = lang_dir($lang_objet);
162 $puces = array(
163 0 => 'puce-orange-breve.gif',
164 1 => 'puce-verte-breve.gif',
165 2 => 'puce-rouge-breve.gif',
166 3 => 'puce-blanche-breve.gif');
167
168 switch ($statut) {
169 case 'prop':
170 $clip = 0;
171 $puce = $puces[0];
172 $title = _T('titre_breve_proposee');
173 break;
174 case 'publie':
175 $clip = 1;
176 $puce = $puces[1];
177 $title = _T('titre_breve_publiee');
178 break;
179 case 'refuse':
180 $clip = 2;
181 $puce = $puces[2];
182 $title = _T('titre_breve_refusee');
183 break;
184 default:
185 $clip = 0;
186 $puce = $puces[3];
187 $title = '';
188 }
189
190 $type1 = "statut$type$id";
191 $inser_puce = http_img_pack($puce, $title, "id='img$type1' style='margin: 1px;'");
192
193 if (!autoriser('publierdans','rubrique',$id_rubrique)
194 OR !_ACTIVER_PUCE_RAPIDE)
195 return $inser_puce;
196
197 $titles = array(
198 "blanche" => _T('texte_statut_en_cours_redaction'),
199 "orange" => _T('texte_statut_propose_evaluation'),
200 "verte" => _T('texte_statut_publie'),
201 "rouge" => _T('texte_statut_refuse'),
202 "poubelle" => _T('texte_statut_poubelle'));
203
204 $clip = 1+ (11*$coord[$statut]);
205
206 if ($ajax){
207 return "<span class='puce_breve_fixe'>"
208 . $inser_puce
209 . "</span>"
210 . "<span class='puce_breve_popup' id='statutdecal$type$id' style='margin-left: -$clip"."px;'>"
211 . afficher_script_statut($id, $type, -1, $puces[0], 'prop', $titles['orange'])
212 . afficher_script_statut($id, $type, -10, $puces[1], 'publie', $titles['verte'])
213 . afficher_script_statut($id, $type, -19, $puces[2], 'refuse', $titles['rouge'])
214 . "</span>";
215 }
216
217 $nom = "puce_statut_";
218
219 if ((! _SPIP_AJAX) AND $type != 'breve')
220 $over ='';
221 else {
222
223 $action = generer_url_ecrire('puce_statut',"",true);
224 $action = "if (!this.puce_loaded) { this.puce_loaded = true; prepare_selec_statut('$nom', '$type', '$id', '$action'); }";
225 $over = "\nonmouseover=\"$action\"";
226 }
227
228 return "<span class='puce_$type' id='$nom$type$id' dir='$lang_dir'$over>"
229 . $inser_puce
230 . '</span>';
231
232 }
233
234 // http://doc.spip.org/@puce_statut_site_dist
235 function puce_statut_site_dist($id, $statut, $id_rubrique, $type, $ajax=''){
236 static $coord = array('publie' => 1,
237 'prop' => 0,
238 'refuse' => 2,
239 'poubelle' => 3);
240 if ($type=='syndic') $type='site';
241
242 $lang_dir = lang_dir($lang_objet);
243 $puces = array(
244 0 => 'puce-orange-breve.gif',
245 1 => 'puce-verte-breve.gif',
246 2 => 'puce-rouge-breve.gif',
247 3 => 'puce-blanche-breve.gif');
248
249 $t = sql_getfetsel("syndication", "spip_syndic", "id_syndic=".sql_quote($id));
250
251 if ($t == 'off' OR $t == 'sus')
252 $anim = 'anim';
253 else
254 $anim = 'breve';
255
256 switch ($statut) {
257 case 'publie':
258 $puce = 'puce-verte-' . $anim .'.gif';
259 $title = _T('info_site_reference');
260 break;
261 case 'prop':
262 $puce = 'puce-orange-' . $anim .'.gif';
263 $title = _T('info_site_attente');
264 break;
265 case 'refuse':
266 default:
267 $puce = 'puce-poubelle-' . $anim .'.gif';
268 $title = _T('info_site_refuse');
269 break;
270 }
271 $type1 = "statut$type$id";
272 $inser_puce = http_img_pack($puce, $title, "id='img$type1' style='margin: 1px;'");
273
274 if ($anim!='breve' OR !autoriser('publierdans','rubrique',$id_rubrique)
275 OR !_ACTIVER_PUCE_RAPIDE)
276 return $inser_puce;
277
278 // c'est comme les breves :
279
280 $titles = array(
281 "blanche" => _T('texte_statut_en_cours_redaction'),
282 "orange" => _T('texte_statut_propose_evaluation'),
283 "verte" => _T('texte_statut_publie'),
284 "rouge" => _T('texte_statut_refuse'),
285 "poubelle" => _T('texte_statut_poubelle'));
286
287 $clip = 1+ (11*$coord[$statut]);
288
289 if ($ajax){
290 return "<span class='puce_site_fixe'>"
291 . $inser_puce
292 . "</span>"
293 . "<span class='puce_site_popup' id='statutdecal$type$id' style='margin-left: -$clip"."px;'>"
294 . afficher_script_statut($id, $type, -1, $puces[0], 'prop', $titles['orange'])
295 . afficher_script_statut($id, $type, -10, $puces[1], 'publie', $titles['verte'])
296 . afficher_script_statut($id, $type, -19, $puces[2], 'refuse', $titles['rouge'])
297 . "</span>";
298 }
299
300 $nom = "puce_statut_";
301
302 if ((! _SPIP_AJAX))
303 $over ='';
304 else {
305 $action = generer_url_ecrire('puce_statut',"",true);
306 $action = "if (!this.puce_loaded) { this.puce_loaded = true; prepare_selec_statut('$nom', '$type', '$id', '$action'); }";
307 $over = "\nonmouseover=\"$action\"";
308 }
309
310 return "<span class='puce_$type' id='$nom$type$id' dir='$lang_dir'$over>"
311 . $inser_puce
312 . '</span>';
313 }
314
315 // http://doc.spip.org/@puce_statut_syndic_article_dist
316 function puce_statut_syndic_article_dist($id_syndic, $statut, $id_rubrique, $type, $ajax=''){
317 if ($statut=='publie') {
318 $puce='puce-verte.gif';
319 }
320 else if ($statut == "refuse") {
321 $puce = 'puce-poubelle.gif';
322 }
323 else if ($statut == "dispo") { // moderation : a valider
324 $puce = 'puce-rouge.gif';
325 }
326 else // i.e. $statut=="off" feed d'un site en mode "miroir"
327 $puce = 'puce-rouge-anim.gif';
328
329 return http_img_pack($puce, $statut, "class='puce'");
330 }
331
332
333 // La couleur du statut
334 // http://doc.spip.org/@puce_statut
335 function puce_statut($statut, $atts='') {
336 switch ($statut) {
337 case 'publie':
338 $img = 'puce-verte.gif';
339 $alt = _T('info_article_publie');
340 return http_img_pack($img, $alt, $atts);
341 case 'prepa':
342 $img = 'puce-blanche.gif';
343 $alt = _T('info_article_redaction');
344 return http_img_pack($img, $alt, $atts);
345 case 'prop':
346 $img = 'puce-orange.gif';
347 $alt = _T('info_article_propose');
348 return http_img_pack($img, $alt, $atts);
349 case 'refuse':
350 $img = 'puce-rouge.gif';
351 $alt = _T('info_article_refuse');
352 return http_img_pack($img, $alt, $atts);
353 case 'poubelle':
354 $img = 'puce-poubelle.gif';
355 $alt = _T('info_article_supprime');
356 return http_img_pack($img, $alt, $atts);
357 }
358 return http_img_pack($img, $alt, $atts);
359 }
360
361 // http://doc.spip.org/@afficher_script_statut
362 function afficher_script_statut($id, $type, $n, $img, $statut, $titre, $act='') {
363 $i = http_wrapper($img);
364 $h = generer_action_auteur("instituer_$type","$id-$statut");
365 $h = "javascript:selec_statut('$id', '$type', $n, '$i', '$h');";
366 $t = supprimer_tags($titre);
367 $inf = getimagesize($i);
368 return "<a href=\"$h\"\ntitle=\"$t\"$act><img src='$i' $inf[3] alt=' '/></a>";
369 }
370
371
372
373 ?>