3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
6 * Copyright (c) 2001-2011 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
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 \***************************************************************************/
13 if (!defined('_ECRIRE_INC_VERSION')) return;
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);
21 return "<img src='" . chemin_image("$type-24.gif") . "' alt='' />";
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='' />";
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='') {
35 static $titre_des_statuts ='';
36 static $images_des_statuts ='';
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')
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'
55 if ($statut == 'nouveau') return '';
57 $index = array_search($statut, $GLOBALS['liste_des_statuts']);
59 if (!$index) $index = 'info_visiteurs';
61 $img = $images_des_statuts[$index];
62 $alt = $titre_des_statuts[$index];
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;}
70 return http_img_pack($img, $alt, $fond, $titre);
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');
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='' />";
85 // http://doc.spip.org/@puce_statut_rubrique_dist
86 function puce_statut_rubrique_dist($id, $statut, $id_rubrique, $type, $ajax='') {
88 return "<img src='" . chemin_image('rubrique-12.gif') . "' alt='' />";
91 // http://doc.spip.org/@puce_statut_article_dist
92 function puce_statut_article_dist($id, $statut, $id_rubrique, $type='article', $ajax = false) {
95 static $coord = array('publie' => 2,
101 $lang_dir = lang_dir($lang_objet);
105 } else $ajax_node = " id='imgstatut$type$id'";
108 $inser_puce = puce_statut($statut, " width='9' height='9' style='margin: 1px;'$ajax_node");
110 if (!autoriser('publierdans', 'rubrique', $id_rubrique)
111 OR !_ACTIVER_PUCE_RAPIDE
)
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'));
121 $clip = 1+
(11*$coord[$statut]);
124 return "<span class='puce_article_fixe'>"
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'])
136 $nom = "puce_statut_";
138 if ((! _SPIP_AJAX
) AND $type != 'article')
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\"";
147 return "<span class='puce_article' id='$nom$type$id' dir='$lang_dir'$over>"
153 // http://doc.spip.org/@puce_statut_breve_dist
154 function puce_statut_breve_dist($id, $statut, $id_rubrique, $type, $ajax='') {
156 static $coord = array('publie' => 1,
161 $lang_dir = lang_dir($lang_objet);
163 0 => 'puce-orange-breve.gif',
164 1 => 'puce-verte-breve.gif',
165 2 => 'puce-rouge-breve.gif',
166 3 => 'puce-blanche-breve.gif');
172 $title = _T('titre_breve_proposee');
177 $title = _T('titre_breve_publiee');
182 $title = _T('titre_breve_refusee');
190 $type1 = "statut$type$id";
191 $inser_puce = http_img_pack($puce, $title, "id='img$type1' style='margin: 1px;'");
193 if (!autoriser('publierdans','rubrique',$id_rubrique)
194 OR !_ACTIVER_PUCE_RAPIDE
)
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'));
204 $clip = 1+
(11*$coord[$statut]);
207 return "<span class='puce_breve_fixe'>"
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'])
217 $nom = "puce_statut_";
219 if ((! _SPIP_AJAX
) AND $type != 'breve')
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\"";
228 return "<span class='puce_$type' id='$nom$type$id' dir='$lang_dir'$over>"
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,
240 if ($type=='syndic') $type='site';
242 $lang_dir = lang_dir($lang_objet);
244 0 => 'puce-orange-breve.gif',
245 1 => 'puce-verte-breve.gif',
246 2 => 'puce-rouge-breve.gif',
247 3 => 'puce-blanche-breve.gif');
249 $t = sql_getfetsel("syndication", "spip_syndic", "id_syndic=".sql_quote($id));
251 if ($t == 'off' OR $t == 'sus')
258 $puce = 'puce-verte-' . $anim .'.gif';
259 $title = _T('info_site_reference');
262 $puce = 'puce-orange-' . $anim .'.gif';
263 $title = _T('info_site_attente');
267 $puce = 'puce-poubelle-' . $anim .'.gif';
268 $title = _T('info_site_refuse');
271 $type1 = "statut$type$id";
272 $inser_puce = http_img_pack($puce, $title, "id='img$type1' style='margin: 1px;'");
274 if ($anim!='breve' OR !autoriser('publierdans','rubrique',$id_rubrique)
275 OR !_ACTIVER_PUCE_RAPIDE
)
278 // c'est comme les breves :
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'));
287 $clip = 1+
(11*$coord[$statut]);
290 return "<span class='puce_site_fixe'>"
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'])
300 $nom = "puce_statut_";
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\"";
310 return "<span class='puce_$type' id='$nom$type$id' dir='$lang_dir'$over>"
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';
320 else if ($statut == "refuse") {
321 $puce = 'puce-poubelle.gif';
323 else if ($statut == "dispo") { // moderation : a valider
324 $puce = 'puce-rouge.gif';
326 else // i.e. $statut=="off" feed d'un site en mode "miroir"
327 $puce = 'puce-rouge-anim.gif';
329 return http_img_pack($puce, $statut, "class='puce'");
333 // La couleur du statut
334 // http://doc.spip.org/@puce_statut
335 function puce_statut($statut, $atts='') {
338 $img = 'puce-verte.gif';
339 $alt = _T('info_article_publie');
340 return http_img_pack($img, $alt, $atts);
342 $img = 'puce-blanche.gif';
343 $alt = _T('info_article_redaction');
344 return http_img_pack($img, $alt, $atts);
346 $img = 'puce-orange.gif';
347 $alt = _T('info_article_propose');
348 return http_img_pack($img, $alt, $atts);
350 $img = 'puce-rouge.gif';
351 $alt = _T('info_article_refuse');
352 return http_img_pack($img, $alt, $atts);
354 $img = 'puce-poubelle.gif';
355 $alt = _T('info_article_supprime');
356 return http_img_pack($img, $alt, $atts);
358 return http_img_pack($img, $alt, $atts);
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>";