4 * Le plugin qui lave plus SPIP que SPIP
5 * (c) 2008 Mathieu Marcillaud, Cedric Morin, Romy Tetue
8 * Fonctions integrees au core en branche 2.1 que l'on rend disponible en branche 2.0.x
12 if (!defined("_ECRIRE_INC_VERSION")) return;
14 // s'assurer que les filtres du core sont deja charges
15 // pour eviter tout risque de conflit
16 include_spip('inc/filtres');
18 if (!function_exists('lien_ou_expose')){
20 * une fonction pour generer des menus avec liens
21 * ou un <strong class='on'> non clicable lorsque l'item est selectionne
24 * @param string $libelle
26 * @param string $class
27 * @param string $title
30 function lien_ou_expose($url,$libelle,$on=false,$class="",$title="",$rel=""){
32 ($on ?
"<strong class='on'>":
34 .($title?
" title='".attribut_html($title)."'":'')
35 .($class?
" class='".attribut_html($class)."'":'')
36 .($rel?
" rel='".attribut_html($rel)."'":'')
40 . ($on ?
"</strong>":"</a>");
44 if (!function_exists('filtre_balise_img_dist')){
46 * une fonction pour generer une balise img a partir d'un nom de fichier
50 * @param string $class
53 function filtre_balise_img_dist($img,$alt="",$class=""){
54 $taille = taille_image($img);
55 list($hauteur,$largeur) = $taille;
56 if (!$hauteur OR !$largeur)
59 "<img src='$img' width='$largeur' height='$hauteur'"
60 ." alt='".attribut_html($alt)."'"
61 .($class?
" class='".attribut_html($class)."'":'')
66 if (!function_exists('singulier_ou_pluriel')){
68 * Afficher un message "un truc"/"N trucs"
73 function singulier_ou_pluriel($nb,$chaine_un,$chaine_plusieurs,$var='nb'){
74 if (!$nb=intval($nb)) return "";
75 if ($nb>1) return _T($chaine_plusieurs, array($var => $nb));
76 else return _T($chaine_un);
80 if (!function_exists('filtre_icone_dist')){
82 * un filtre icone mappe sur icone_inline, qui cree une icone a gauche par defaut
83 * le code de icone_inline est grandement reproduit ici car les liens ajax portent simplement une class ajax
84 * lorsque les interfaces sont en squelette, alors que l'implementation d'ajax de des scripts php
88 * @param string $texte
90 * @param string $align
91 * @param string $fonction
94 function filtre_icone_dist($lien, $texte, $fond, $align="", $fonction="", $class="",$javascript=""){
95 $align = $align?
$align:$GLOBALS['spip_lang_left'];
98 if ($fonction == "supprimer.gif") {
99 $style = 'icone36 danger';
102 if (strlen($fonction) < 3) $fonction = "rien.gif";
104 $style .= " " . substr(basename($fond),0,-4);
106 if ($spip_display == 1){
111 else if ($spip_display == 3){
114 $title = "\ntitle=\"$texte\"";
125 if (preg_match("/-([0-9]{1,3})[.](gif|png)$/i",$fond,$match))
127 if ($spip_display != 1 AND $spip_display != 4){
128 if ($fonction != "rien.gif"){
129 $icone = http_img_pack($fonction, $alt, "$title width='$size' height='$size'\n" .
130 http_style_background($fond, "no-repeat center center"));
133 $icone = http_img_pack($fond, $alt, "$title width='$size' height='$size'");
137 // cas d'ajax_action_auteur: faut defaire le boulot
138 // (il faudrait fusionner avec le cas $javascript)
139 if (preg_match(",^<a\shref='([^']*)'([^>]*)>(.*)</a>$,i",$lien,$r))
140 list($x,$lien,$atts,$texte)= $r;
143 if ($align && $align!='center') $align = "float: $align; ";
145 $icone = "<a style='$align' class='$style $class'"
152 . (($spip_display == 3) ?
'' : "<span>$texte</span>")
155 if ($align <> 'center') return $icone;
156 $style = " style='text-align:center;'";
157 return "<div$style>$icone</div>";
162 if (!function_exists('filtre_explode_dist')){
164 * filtre explode pour les squelettes permettant d'ecrire
165 * #GET{truc}|explode{-}
171 function filtre_explode_dist($a,$b){return explode($b,$a);}
174 if (!function_exists('filtre_implode_dist')){
176 * filtre implode pour les squelettes permettant d'ecrire
177 * #GET{truc}|implode{-}
183 function filtre_implode_dist($a,$b){return implode($b,$a);}
186 if (!function_exists('bando_images_background') AND !defined('_DIR_PLUGIN_BANDO')){
187 function bando_images_background(){
192 if (!function_exists('bando_style_prive_theme') AND !defined('_DIR_PLUGIN_BANDO')){
193 function bando_style_prive_theme() {