3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
6 * Copyright (c) 2001-2014 *
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 function puce_statut_signature_dist($id, $statut, $id_rubrique, $type, $ajax='') {
30 return "<img src='" . chemin_image("visit-12.gif") . "' alt='' />";
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='') {
39 static $titre_des_statuts ='';
40 static $images_des_statuts ='';
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')
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'
59 if ($statut == 'nouveau') return '';
61 $index = array_search($statut, $GLOBALS['liste_des_statuts']);
63 if (!$index) $index = 'info_visiteurs';
65 $img = $images_des_statuts[$index];
66 $alt = $titre_des_statuts[$index];
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;}
74 return http_img_pack($img, $alt, $fond, $titre);
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');
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='' />";
89 // http://doc.spip.org/@puce_statut_rubrique_dist
90 function puce_statut_rubrique_dist($id, $statut, $id_rubrique, $type, $ajax='') {
92 return "<img src='" . chemin_image('rubrique-12.gif') . "' alt='' />";
95 // http://doc.spip.org/@puce_statut_article_dist
96 function puce_statut_article_dist($id, $statut, $id_rubrique, $type='article', $ajax = false) {
99 static $coord = array('publie' => 2,
105 $lang_dir = lang_dir($lang_objet);
109 } else $ajax_node = " id='imgstatut$type$id'";
112 $inser_puce = puce_statut($statut, " width='9' height='9' style='margin: 1px;'$ajax_node");
114 if (!autoriser('publierdans', 'rubrique', $id_rubrique)
115 OR !_ACTIVER_PUCE_RAPIDE
)
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'));
125 $clip = 1+
(11*$coord[$statut]);
128 return "<span class='puce_article_fixe'>"
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'])
140 $nom = "puce_statut_";
142 if ((! _SPIP_AJAX
) AND $type != 'article')
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\"";
151 return "<span class='puce_article' id='$nom$type$id' dir='$lang_dir'$over>"
157 // http://doc.spip.org/@puce_statut_breve_dist
158 function puce_statut_breve_dist($id, $statut, $id_rubrique, $type, $ajax='') {
160 static $coord = array('publie' => 1,
165 $lang_dir = lang_dir($lang_objet);
167 0 => 'puce-orange-breve.gif',
168 1 => 'puce-verte-breve.gif',
169 2 => 'puce-rouge-breve.gif',
170 3 => 'puce-blanche-breve.gif');
176 $title = _T('titre_breve_proposee');
181 $title = _T('titre_breve_publiee');
186 $title = _T('titre_breve_refusee');
194 $type1 = "statut$type$id";
195 $inser_puce = http_img_pack($puce, $title, "id='img$type1' style='margin: 1px;'");
197 if (!autoriser('publierdans','rubrique',$id_rubrique)
198 OR !_ACTIVER_PUCE_RAPIDE
)
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'));
208 $clip = 1+
(11*$coord[$statut]);
211 return "<span class='puce_breve_fixe'>"
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'])
221 $nom = "puce_statut_";
223 if ((! _SPIP_AJAX
) AND $type != 'breve')
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\"";
232 return "<span class='puce_$type' id='$nom$type$id' dir='$lang_dir'$over>"
238 // http://doc.spip.org/@puce_statut_site_dist
239 function puce_statut_site_dist($id, $statut, $id_rubrique, $type, $ajax=''){
241 static $coord = array('publie' => 1,
245 if ($type=='syndic') $type='site';
247 $lang_dir = lang_dir($lang_objet);
249 0 => 'puce-orange-breve.gif',
250 1 => 'puce-verte-breve.gif',
251 2 => 'puce-rouge-breve.gif',
252 3 => 'puce-blanche-breve.gif');
254 $t = sql_getfetsel("syndication", "spip_syndic", "id_syndic=".sql_quote($id));
256 if ($t == 'off' OR $t == 'sus')
263 $puce = 'puce-verte-' . $anim .'.gif';
264 $title = _T('info_site_reference');
267 $puce = 'puce-orange-' . $anim .'.gif';
268 $title = _T('info_site_attente');
272 $puce = 'puce-poubelle-' . $anim .'.gif';
273 $title = _T('info_site_refuse');
276 $type1 = "statut$type$id";
277 $inser_puce = http_img_pack($puce, $title, "id='img$type1' style='margin: 1px;'");
279 if ($anim!='breve' OR !autoriser('publierdans','rubrique',$id_rubrique)
280 OR !_ACTIVER_PUCE_RAPIDE
)
283 // c'est comme les breves :
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'));
292 $clip = 1+
(11*$coord[$statut]);
295 return "<span class='puce_site_fixe'>"
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'])
305 $nom = "puce_statut_";
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\"";
315 return "<span class='puce_$type' id='$nom$type$id' dir='$lang_dir'$over>"
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';
325 else if ($statut == "refuse") {
326 $puce = 'puce-poubelle.gif';
328 else if ($statut == "dispo") { // moderation : a valider
329 $puce = 'puce-rouge.gif';
331 else // i.e. $statut=="off" feed d'un site en mode "miroir"
332 $puce = 'puce-rouge-anim.gif';
334 return http_img_pack($puce, $statut, "class='puce'");
338 // La couleur du statut
339 // http://doc.spip.org/@puce_statut
340 function puce_statut($statut, $atts='') {
343 $img = 'puce-verte.gif';
344 $alt = _T('info_article_publie');
345 return http_img_pack($img, $alt, $atts);
347 $img = 'puce-blanche.gif';
348 $alt = _T('info_article_redaction');
349 return http_img_pack($img, $alt, $atts);
351 $img = 'puce-orange.gif';
352 $alt = _T('info_article_propose');
353 return http_img_pack($img, $alt, $atts);
355 $img = 'puce-rouge.gif';
356 $alt = _T('info_article_refuse');
357 return http_img_pack($img, $alt, $atts);
359 $img = 'puce-poubelle.gif';
360 $alt = _T('info_article_supprime');
361 return http_img_pack($img, $alt, $atts);
363 return http_img_pack($img, $alt, $atts);
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>";