function puce_statut_site_dist($id, $statut, $id_rubrique, $type, $ajax=''){ global $lang_objet; static $coord = array('publie' => 1, 'prop' => 0, 'refuse' => 2, 'poubelle' => 3); if ($type=='syndic') $type='site'; $lang_dir = lang_dir($lang_objet); $puces = array( 0 => 'puce-orange-breve.gif', 1 => 'puce-verte-breve.gif', 2 => 'puce-rouge-breve.gif', 3 => 'puce-blanche-breve.gif'); $t = sql_getfetsel("syndication", "spip_syndic", "id_syndic=".sql_quote($id)); if ($t == 'off' OR $t == 'sus') $anim = 'anim'; else $anim = 'breve'; switch ($statut) { case 'publie': $puce = 'puce-verte-' . $anim .'.gif'; $title = _T('info_site_reference'); break; case 'prop': $puce = 'puce-orange-' . $anim .'.gif'; $title = _T('info_site_attente'); break; case 'refuse': default: $puce = 'puce-poubelle-' . $anim .'.gif'; $title = _T('info_site_refuse'); break; } $type1 = "statut$type$id"; $inser_puce = http_img_pack($puce, $title, "id='img$type1' style='margin: 1px;'"); if ($anim!='breve' OR !autoriser('publierdans','rubrique',$id_rubrique) OR !_ACTIVER_PUCE_RAPIDE) return $inser_puce; // c'est comme les breves : $titles = array( "blanche" => _T('texte_statut_en_cours_redaction'), "orange" => _T('texte_statut_propose_evaluation'), "verte" => _T('texte_statut_publie'), "rouge" => _T('texte_statut_refuse'), "poubelle" => _T('texte_statut_poubelle')); $clip = 1+ (11*$coord[$statut]); if ($ajax){ return "<span class='puce_site_fixe'>" . $inser_puce . "</span>" . "<span class='puce_site_popup' id='statutdecal$type$id' style='margin-left: -$clip"."px;'>" . afficher_script_statut($id, $type, -1, $puces[0], 'prop', $titles['orange']) . afficher_script_statut($id, $type, -10, $puces[1], 'publie', $titles['verte']) . afficher_script_statut($id, $type, -19, $puces[2], 'refuse', $titles['rouge']) . "</span>"; } $nom = "puce_statut_"; if ((! _SPIP_AJAX)) $over =''; else { $action = generer_url_ecrire('puce_statut',"",true); $action = "if (!this.puce_loaded) { this.puce_loaded = true; prepare_selec_statut('$nom', '$type', '$id', '$action'); }"; $over = "\nonmouseover=\"$action\""; } return "<span class='puce_$type' id='$nom$type$id' dir='$lang_dir'$over>" . $inser_puce . '</span>'; }
/** * Retourne le contenu d'une puce avec changement de statut possible * si on en a l'autorisation, sinon simplement l'image de la puce * * @param int $id * Identifiant de l'objet * @param string $statut * Statut actuel de l'objet * @param int $id_rubrique * Identifiant du parent, une rubrique * @param string $type * Type d'objet * @param bool $ajax * Indique s'il ne faut renvoyer que le coeur du menu car on est * dans une requete ajax suite à un post de changement rapide * @param bool $menu_rapide * Indique si l'on peut changer le statut, ou si on l'affiche simplement * @return string * Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent) **/ function puce_statut_changement_rapide($id, $statut, $id_rubrique, $type = 'article', $ajax = false, $menu_rapide = _ACTIVER_PUCE_RAPIDE) { $src = statut_image($type, $statut); if (!$src) { return $src; } if (!$id or !_SPIP_AJAX or !$menu_rapide) { $ajax_node = ''; } else { $ajax_node = " class='imgstatut{$type}{$id}'"; } $t = statut_titre($type, $statut); $inser_puce = http_img_pack($src, $t, $ajax_node, $t); if (!$ajax_node) { return $inser_puce; } $table = table_objet_sql($type); $desc = lister_tables_objets_sql($table); if (!isset($desc['statut_textes_instituer'])) { return $inser_puce; } if (!function_exists('autoriser')) { include_spip('inc/autoriser'); } // cas ou l'on a un parent connu (devrait disparaitre au profit du second cas plus generique) if ($id_rubrique) { if (!autoriser('publierdans', 'rubrique', $id_rubrique)) { return $inser_puce; } } else { if (!autoriser('instituer', $type, $id, null, array('statut' => 'publie'))) { return $inser_puce; } } $coord = array_flip(array_keys($desc['statut_textes_instituer'])); if (!isset($coord[$statut])) { return $inser_puce; } $unit = 8 + 4; $margin = 4; /* marge a gauche + droite */ $zero = 1 + $margin / 2 + 2; $clip = $zero + $unit * $coord[$statut]; if ($ajax) { $width = $unit * count($desc['statut_textes_instituer']) + $margin; $out = "<span class='puce_objet_fixe {$type}'>" . $inser_puce . "</span>" . "<span class='puce_objet_popup {$type} statutdecal{$type}{$id}' style='width:{$width}px;margin-left:-{$clip}px;'>"; $i = 0; foreach ($desc['statut_textes_instituer'] as $s => $t) { $out .= afficher_script_statut($id, $type, -$zero - $i++ * $unit, statut_image($type, $s), $s, _T($t)); } $out .= "</span>"; return $out; } else { $nom = "puce_statut_"; $action = generer_url_ecrire('puce_statut', "", true); $action = "if (!this.puce_loaded) { this.puce_loaded = true; prepare_selec_statut(this, '{$nom}', '{$type}', '{$id}', '{$action}'); }"; $over = " onmouseover=\"{$action}\""; $lang_dir = lang_dir(lang_typo()); return "<span class='puce_objet {$type}' id='{$nom}{$type}{$id}' dir='{$lang_dir}'{$over}>" . $inser_puce . '</span>'; } }