[PLUGINS] +set de base
[lhc/web/www.git] / www / plugins / formidable_1_0 / puce_statut / formulaires_reponse.php
1 <?php
2
3 /**
4 * Gestion des puces d'action rapide de formulaires
5 *
6 * @package SPIP\Formidable\Puce_statut
7 **/
8
9 /**
10 * Gestion des puces statuts des formulaires
11 *
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
14 *
15 * @param int $id
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
21 * @param string $type
22 * Type d'objet
23 * @param bool $ajax
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
28 * @return string
29 * Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
30 **/
31 function puce_statut_formulaires_reponse_dist($id, $statut, $id_parent, $type='article', $ajax = false, $menu_rapide=_ACTIVER_PUCE_RAPIDE) {
32
33 $src = statut_image($type, $statut);
34 if (!$src)
35 return $src;
36
37 if (!$id
38 OR !_SPIP_AJAX
39 OR !$menu_rapide
40 OR !autoriser('instituer', $type, $id)) {
41 $ajax_node ='';
42 }
43 else
44 $ajax_node = " class='imgstatut$type$id'";
45
46 $inser_puce = http_img_pack($src,statut_titre($type, $statut),$ajax_node);
47
48 if (!$ajax_node)
49 return $inser_puce;
50
51 $table = table_objet_sql($type);
52 $desc = lister_tables_objets_sql($table);
53 if (!isset($desc['statut_textes_instituer']))
54 return $inser_puce;
55
56 $coord = array_flip(array_keys($desc['statut_textes_instituer']));
57 if (!isset($coord[$statut]))
58 return $inser_puce;
59
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]);
64 if ($ajax){
65
66 $width = $unit*count($desc['statut_textes_instituer'])+$margin;
67 $out = "<span class='puce_objet_fixe $type'>"
68 . $inser_puce
69 . "</span>"
70 . "<span class='puce_objet_popup $type statutdecal$type$id' style='width:{$width}px;margin-left:-{$clip}px;'>";
71 $i=0;
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));
74 }
75 $out .= "</span>";
76 return $out;
77 }
78 else {
79
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\"";
84
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>"
87 . $inser_puce
88 . '</span>';
89 }
90 }
91
92