4 * Gestion des puces d'action rapide de formulaires
6 * @package SPIP\Formidable\Puce_statut
10 * Gestion des puces statuts des formulaires
12 * Retourne le contenu d'une puce avec changement de statut possible
13 * si on en a l'autorisation, sinon simplement l'image de la puce
16 * Identifiant de l'objet
17 * @param string $statut
18 * Statut actuel de l'objet
19 * @param int $id_parent
20 * Identifiant du parent, un formulaire
24 * Indique s'il ne faut renvoyer que le coeur du menu car on est
25 * dans une requete ajax suite à un post de changement rapide
26 * @param bool $menu_rapide
27 * Indique si l'on peut changer le statut, ou si on l'affiche simplement
29 * Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
31 function puce_statut_formulaires_reponse_dist($id, $statut, $id_parent, $type='article', $ajax = false, $menu_rapide=_ACTIVER_PUCE_RAPIDE
) {
33 $src = statut_image($type, $statut);
40 OR !autoriser('instituer', $type, $id)) {
44 $ajax_node = " class='imgstatut$type$id'";
46 $inser_puce = http_img_pack($src,statut_titre($type, $statut),$ajax_node);
51 $table = table_objet_sql($type);
52 $desc = lister_tables_objets_sql($table);
53 if (!isset($desc['statut_textes_instituer']))
56 $coord = array_flip(array_keys($desc['statut_textes_instituer']));
57 if (!isset($coord[$statut]))
60 $unit = 8/*widh de img*/+
4/*padding*/;
61 $margin = 4; /* marge a gauche + droite */
62 $zero = 1 /*border*/ +
$margin/2 +
2 /*padding*/;
63 $clip = $zero+
($unit*$coord[$statut]);
66 $width = $unit*count($desc['statut_textes_instituer'])+
$margin;
67 $out = "<span class='puce_objet_fixe $type'>"
70 . "<span class='puce_objet_popup $type statutdecal$type$id' style='width:{$width}px;margin-left:-{$clip}px;'>";
72 foreach($desc['statut_textes_instituer'] as $s=>$t){
73 $out .= afficher_script_statut($id, $type, -$zero-$i++
*$unit, statut_image($type,$s), $s, _T($t));
80 $nom = "puce_statut_";
81 $action = generer_url_ecrire('puce_statut_formulaires',"",true);
82 $action = "if (!this.puce_loaded) { this.puce_loaded = true; prepare_selec_statut(this, '$nom', '$type', '$id', '$action'); }";
83 $over = " onmouseover=\"$action\"";
85 $lang_dir = lang_dir(isset($GLOBALS['lang_objet']) ?
$GLOBALS['lang_objet'] : "");
86 return "<span class='puce_objet $type' id='$nom$type$id' dir='$lang_dir'$over>"