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