source: trunk/spip/esqueleto-redcta/plugins/magusine/arty_affichegauche.php @ 79

Last change on this file since 79 was 79, checked in by guille, 15 years ago
  • Property svn:executable set to *
File size: 22.5 KB
Line 
1<?php
2// importe la fonction creer_repertoire_documents, qui retourne le chemin vers un dossier donné dans le répertoire img, et le crée si nécessaire
3include_spip('inc/getdocument');
4include_spip('inc/layer');
5include_spip('inc/upload-image');
6include_spip('inc/xml-parser');
7
8include_spip('inc/arty_upload_bandeau');
9
10function arty_ajouterfonctionnalites($flux) {
11
12global $connect_statut;
13//print_r($flux);
14  if ($connect_statut == "0minirezo" ) {
15       
16       
17    if (isset($flux['args']['id_groupe']) && $flux['args']['exec'] == "mots_types"){
18       
19                $flux['data'] .= formulaire_logo($flux['args']['id_groupe']);
20                $flux['data'] .= bloc_formulaire_themes('groupe', $flux['args']['id_groupe'], "?exec=mots_type&id_groupe=".$flux['args']['id_groupe']);
21                $flux['data'] .= formulaire_bloc_libre('groupe', $flux['args']['id_groupe'],"?exec=mots_type&id_groupe=".$flux['args']['id_groupe']);
22                $flux['data'] .= bloc_gabarit('groupe-mots', $flux['args']['id_groupe'],"?exec=mots_type&id_groupe=".$flux['args']['id_groupe']);
23             
24    }
25 
26    if (isset($flux['args']['id_article']) && $flux['args']['exec'] == "articles"){
27      $flux['data'] .= bloc_formulaire_themes('article', $flux['args']['id_article'], "?exec=articles&id_article=".$flux['args']['id_article']);
28                $flux['data'] .= formulaire_bloc_libre('article', $flux['args']['id_article'],"?exec=articles&id_article=".$flux['args']['id_article']);
29                $flux['data'] .= bloc_gabarit('article', $flux['args']['id_article'],"?exec=articles&id_article=".$flux['args']['id_article']);
30             
31    }
32   
33    if (isset($flux['args']['id_rubrique']) && $flux['args']['exec'] == "naviguer"){
34        $flux['data'] .= formulaire_bandeau($flux['args']['id_rubrique']);
35        $flux['data'] .= bloc_formulaire_themes('rubrique', $flux['args']['id_rubrique'], "?exec=naviguer&id_rubrique=".$flux['args']['id_rubrique']);
36                  $flux['data'] .= formulaire_bloc_libre('rubrique', $flux['args']['id_rubrique'],"?exec=naviguer&id_rubrique=".$flux['args']['id_rubrique']);
37                  if ($flux['args']['id_rubrique']) {
38        $flux['data'] .= bloc_gabarit('rubrique', $flux['args']['id_rubrique'],"?exec=naviguer&id_rubrique=".$flux['args']['id_rubrique']);
39                  }
40    }
41   
42    if (isset($flux['args']['id_mot']) && $flux['args']['exec'] == "mots_edit"){
43        $flux['data'] .= bloc_gabarit('mot', $flux['args']['id_mot'],"?exec=mots_edit&id_mot=".$flux['args']['id_mot']);
44        $flux['data'] .= bloc_formulaire_themes('mot', $flux['args']['id_mot'], "?exec=mots_edit&id_mot=".$flux['args']['id_mot']);
45    }
46   
47  }
48
49$flux['data'] .= "";
50
51
52return $flux;
53
54}
55
56function formulaire_bloc_libre($type, $id, $url_retour) {
57        if (isset($_POST['action']) && isset($_POST['bloclibre'])) {
58                if($_POST['action'] == 'associer_bloc_libre' && !is_nan($_POST['bloclibre'])) {
59                                //on peut sauver
60                                if ($type == "rubrique" && $id == 0 && isset($_POST['lang'])) {
61                                  $resultat = spip_query("SELECT * FROM spip_arty_bloclibreassoc WHERE lang='".addslashes($_POST['lang'])."' AND type='$type' AND id=$id AND id_bloc_libre=".$_POST['bloclibre']);
62                                if (!spip_num_rows($resultat)) {
63            spip_query("INSERT INTO spip_arty_bloclibreassoc (id_bloc_libre, type, id, lang) VALUES (".$_POST['bloclibre'].",'$type',$id, '".addslashes($_POST['lang'])."')");
64          }
65                                } else {
66                                $resultat = spip_query("SELECT * FROM spip_arty_bloclibreassoc WHERE type='$type' AND id=$id AND id_bloc_libre=".$_POST['bloclibre']);
67                                if (!spip_num_rows($resultat)) {
68            spip_query("INSERT INTO spip_arty_bloclibreassoc (id_bloc_libre, type, id) VALUES (".$_POST['bloclibre'].",'$type',$id)");         
69                                }
70             }
71          }
72        }
73       
74        if (isset($_POST['action']) && isset($_POST['bloclibre'])) {
75                if($_POST['action'] == 'dissocier_bloclibre' && !is_nan($_POST['bloclibre'])) {
76            if (isset($_POST["lang"])) {
77                          spip_query("DELETE FROM spip_arty_bloclibreassoc WHERE lang='".addslashes($_POST["lang"])."' AND type='$type' AND id=$id AND id_bloc_libre=".$_POST['bloclibre']);
78                        } else {
79        spip_query("DELETE FROM spip_arty_bloclibreassoc WHERE type='$type' AND id=$id AND id_bloc_libre=".$_POST['bloclibre']);
80      }
81                }       
82        }
83       
84                if ($_POST['action']=='nouveaubloc' && isset($_POST['titre']) && isset($_POST['texte']) ) {
85               
86                $titre=trim(addslashes($_POST['titre']));
87                $texte=trim(addslashes($_POST['texte']));
88                $lien=trim(addslashes($_POST['lien']));
89               
90                if($lien=="http://") { $lien=""; }
91 
92                if ($titre!="" ) {//&& $texte!="") {
93                        spip_query("INSERT INTO spip_arty_bloclibre(titre, contenu,lien) VALUES('$titre', '$texte', '$lien')");
94                         $result = spip_query("SELECT LAST_INSERT_ID();");
95                         if ($result){
96                                $arr = spip_fetch_array($result);
97                                $id_last = (int) current($arr);
98                               
99                        if (!is_nan($id_last)){
100                                echo traiter_upload_image('illu_bloc_libre','illu-bloc-libre',$id_last);
101                               
102                                $resultat = spip_query("SELECT * FROM spip_arty_bloclibreassoc WHERE type='$type' AND id=$id AND id_bloc_libre=".$id_last);
103                                if (!spip_num_rows($resultat)) {
104                               
105                                if ($type == "rubrique" && $id == 0 && isset($_POST['lang'])) {
106                                          spip_query("INSERT INTO spip_arty_bloclibreassoc (id_bloc_libre, type, id, lang) VALUES (".$id_last.",'$type',$id, '".addslashes($_POST['lang'])."')");
107                                        } else {                               
108                                        spip_query("INSERT INTO spip_arty_bloclibreassoc (id_bloc_libre, type, id) VALUES (".$id_last.",'$type',$id)");
109                                }
110                        }
111                                        }
112                         }               
113                }
114        }
115       
116        $result=spip_query("SELECT * FROM spip_arty_bloclibre");
117        $balancemoica ="";
118        if (spip_num_rows($result)) {
119                $balancemoica = debut_cadre_trait_couleur(_DIR_PLUGIN_ARTY."/images/config.png", true, "", _T('arty:associer_un_bloc_libre'));
120                $balancemoica .= ""._T('arty:intro_associer_bloc_libre')."<br />";
121    $balancemoica .= "<form action='$url_retour' method='post'>";
122                $balancemoica .= "<select name='bloclibre' class='forml'>";
123                while ($row=spip_fetch_array($result)) {
124                        $balancemoica .= "<option value='".$row['id_bloc_libre']."'>".htmlspecialchars($row['titre'])."</option>";
125                }
126                $balancemoica .= "</select>";
127                $balancemoica .= "<input type='hidden' name='action' value='associer_bloc_libre'>";     
128       
129       
130        if ($type == "rubrique" && $id == 0) {
131   
132       $leslangues_menu=explode(",",$GLOBALS['meta']['langues_utilisees']);
133       $def = $GLOBALS['meta']['langue_site'];
134       
135      $balancemoica .= "<br /><br />"._T('arty:langue_bloc_assoc');
136      $balancemoica .= '<br /><select name="lang" class="forml">';
137     
138      foreach($leslangues_menu as $fullname) {
139        $balancemoica .= "<option value='$fullname' ".(($def==$fullname)?'selected="selected"':'').">".$GLOBALS['codes_langues'][$fullname]."</option>";
140      }
141        $balancemoica .= "</select><br />";
142     
143    }
144       
145                $balancemoica .= "<input type='submit' class='fondo' value='"._T('arty:ajouter')."' /></form>";
146               
147                $resultat=spip_query("SELECT * FROM spip_arty_bloclibreassoc WHERE  type='$type' AND id=$id");
148                if (spip_num_rows($resultat)) {
149                $balancemoica .= "<br />"._T('arty:blocs_libres_deja_associes');
150                $balancemoica .= "<ul style='padding-left:0px;'>";
151                        while ($row=spip_fetch_array($resultat)) {
152                                $lebloc=spip_query("SELECT * FROM spip_arty_bloclibre WHERE id_bloc_libre =".$row['id_bloc_libre']);
153                                $lebloc=spip_fetch_array($lebloc);
154                                $balancemoica .= "<li style='font-size:10px;'>&mdash; ".htmlspecialchars($lebloc['titre']);
155                                $balancemoica .= $row['lang'] ? " <span style='color:#888'>[".$row['lang']."]</span>" : '';
156                                $balancemoica .= "<form style='display:inline;' action='".generer_url_ecrire('avance')."#".$row['id_bloc_libre']."' method='post'>";
157                                $balancemoica .= "<input type='hidden' name='retour' value='$url_retour' />";
158                                $balancemoica .= "<input type='hidden' name='bloc' value='".$row['id_bloc_libre']."' />";
159        if (_SPIP_AJAX) {
160                            $balancemoica .= "<img src='"._DIR_PLUGIN_ARTY."/images/mod.png' alt='M' title='"._T('arty:modifier_ce_bloc')."' class='bouton-modifier' style='margin-left:3px; cursor: pointer;' />";
161                        } else {
162                                  $balancemoica .= "<input type='submit' value='"._T('arty:modifier_ce_bloc')."' />";
163                                }
164                                $balancemoica .= "</form>";
165                                $balancemoica .= "<form style='display:inline;' action='$url_retour' method='post' style='display:inline;'>";
166                                $balancemoica .= "<input type='hidden' name='action' value='dissocier_bloclibre'>";
167                                if ($row['lang']) {
168          $balancemoica .= "<input type='hidden' name='lang' value='".$row["lang"]."'>"; 
169        }
170                                $balancemoica .= "<input type='hidden' name='bloclibre' value='".$row['id_bloc_libre']."'>";
171                        if (_SPIP_AJAX) {
172                            $balancemoica .= "<img src='"._DIR_IMG_PACK."/croix-rouge.gif' alt='X' title='"._T("arty:supprimer")."' style='margin-left:2px; cursor: pointer;' class='bouton-supprimer' />";
173                        } else {
174                                $balancemoica .= "<input type='submit' value='X'/>";
175                        }
176                                $balancemoica .= "</form></li>";
177                        }
178                $balancemoica .= "</ul>";
179                if (_SPIP_AJAX) {
180                $balancemoica .= "<script type='text/javascript'>
181                jQuery('.bouton-supprimer').each(function(){
182                        jQuery(this).click(function(){
183                                jQuery(this).parent().submit();
184                                })
185                        })
186                jQuery('.bouton-modifier').each(function(){
187                        jQuery(this).click(function(){
188                                jQuery(this).parent().submit();
189                                })
190                        })
191                </script>";
192                        }
193               
194                }
195                $balancemoica .= fin_cadre_trait_couleur(TRUE);
196        }
197       
198        $balancemoica .= debut_cadre_trait_couleur(_DIR_PLUGIN_ARTY."/images/config.png", true, "", _T('arty:creer_bloc_et_associer'));
199  $texte .= _T('arty:entrez_donnees_nouveau_bloc');
200  $texte .= "<form action='".$url_retour."' method='post' enctype=\"multipart/form-data\">\n";
201  $texte .= "<input type='hidden' name='action' value='nouveaubloc' />";
202  $texte .= "<input type='text' name='titre' value='"._T('arty:titre')."' onfocus='this.value=&#34;&#34;;' maxlength='255' size='27' />";
203  $texte .= "<textarea name='texte' cols='20' rows='4'></textarea>"; 
204  $texte .= "<br /><br />"._T('arty:bloc_lien')."<br />";
205  $texte .= "<input type='text' name='lien' value='http://' maxlength='255' size='27' />";
206  $texte .= "<br /><br />"._T('arty:bloc_image')."<br />";
207  $texte .= "<input type=\"file\" name=\"illu_bloc_libre\" size=\"13\" /><br />";
208 
209        if ($type == "rubrique" && $id == 0) {
210   
211       $leslangues_menu=explode(",",$GLOBALS['meta']['langues_utilisees']);
212       $def = $GLOBALS['meta']['langue_site'];
213       
214      $texte .= _T('arty:langue_bloc');
215      $texte .= '<br /><select name="lang" class="forml">';
216     
217      foreach($leslangues_menu as $fullname) {
218        $texte .= "<option value='$fullname' ".(($def==$fullname)?'selected="selected"':'').">".$GLOBALS['codes_langues'][$fullname]."</option>";
219      }
220        $texte .= "</select>";
221    }
222 
223  $texte .= "<br /><input type='submit' value='"._T("arty:enregistrer")."' class='fondo' />";
224  $texte .= "</form>";
225 
226  $balancemoica .= block_parfois_visible("creer_bloc", _T("arty:intro_creer_bloc"), $texte, '', false);
227  $balancemoica .= fin_cadre_trait_couleur(TRUE);
228       
229       
230        return $balancemoica;
231}
232
233// formulaire d'ajout/remplacement/suppression d'un bandeau à la rubrique
234function formulaire_logo($id_groupe)
235{
236  $texte = "<p>"._T('arty:intro_up_logo')."</p>";
237  traiter_suppression_logo($id_groupe);
238  $message = _T(traiter_upload_image('logo','logo-groupe',$id_groupe));
239  $texte .= ($message) ? "<p style=\"font-weight:bold;\">".$message."</p>" : "";
240 
241  $visible = false;
242 
243  $chem = creer_repertoire_documents("logo-groupe");
244  $handle = @opendir($chem); 
245  while($fichier = @readdir($handle)) {
246    if (ereg("^logo-$id_groupe\.(jpg|png|gif)$", $fichier)) {
247      $logo = $fichier;
248    }
249  }
250  if (!isset($logo)){
251    $texte .= "<p>"._T("arty:aucun_logo_rub")."</p>";
252  } else {
253    $visible = true;
254    $result = _T("arty:logo_actuel").":<br /><img width=\"190\" src=\""._DIR_DOC."logo-groupe/$logo?".uniqid(rand())."\" />"; // le nombre aléatoire permet d'éviter que le navigateur affiche la version en cache de l'image.
255    $result .= "<p>[<a href=\"?exec=mots_type&id_groupe=$id_groupe&action=supprimer_logo&id_check=".$_SESSION['id_check']."\">"._T('arty:supprimer_logo')."</a>]</p>";
256    $texte .= $result;
257  }
258  $texte .= "<form action=\"?exec=mots_type&amp;id_groupe=$id_groupe\" method=\"post\" enctype=\"multipart/form-data\">";
259  $texte .= "<input type=\"file\" name=\"logo\" id=\"logo\" size=\"13\" /><br />";
260  $texte .= "<div style=\"text-align:right;\"><input class=\"fondo\" name=\"filesubmit\" type=\"submit\" value=\""._T('arty:enregistrer')."\" /></div>";
261  $texte .= "</form>";
262  $data = debut_cadre_couleur("vignette-24.png", true, "", _T('arty:titre_up_rub_logo'));
263  $data .= block_parfois_visible("logo", _T("arty:invit_up_rub_logo"), $texte, '', $visible);
264        $data .= fin_cadre_couleur(true);
265
266        return $data;
267}
268
269
270function bloc_gabarit($type, $id, $url_retour) 
271{
272       
273        if (isset($_POST['action']) && isset($_POST['gabarit'])) {
274                if($_POST['action'] == 'changer_gabarit' && trim($_POST['gabarit'])!="") {
275                                //on peut sauver
276                                spip_query("DELETE FROM spip_arty_gabaritassoc WHERE type='$type' AND id=$id");
277                                if ($_POST['gabarit'] !='gabarit_default') {
278                                spip_query("INSERT INTO spip_arty_gabaritassoc (gabarit, type, id) VALUES ('".addslashes(trim($_POST['gabarit']))."','$type',$id)");
279                                }
280                }       
281        }
282       
283        $resultat = spip_query("SELECT * FROM spip_arty_gabaritassoc WHERE type='$type' AND id=$id");
284        if (spip_num_rows($resultat)) {
285                $row=spip_fetch_array($resultat);
286                $gabarit_actuel=$row['gabarit'];
287        } else { $gabarit_actuel='gabarit_default'; }
288       
289  $ignore_liste = Array(".svn", ".", "..");
290  $rep = _DIR_PLUGIN_ARTY."definitions-gabarits";
291  $handle = opendir($rep);
292 
293  $balancemoica = debut_cadre_trait_couleur(_DIR_PLUGIN_ARTY."/images/config.png", true, "", _T('arty:associer_un_gabarit'));
294  $balancemoica .= _T('arty:intro_associer_gabarit')."<br /><br />";
295  $balancemoica .= _T('arty:choisissez_un_gabarit').":<br />";
296  $balancemoica .="<form action='$url_retour' method='post'>";
297 
298  $gabarits=array();
299  $gabaritpardefaut=array("sommaire","rubrique","article");
300  $ignore_liste=array(".","..",".DS_Store");
301        $rep = _DIR_PLUGIN_ARTY."definitions-gabarits";
302  $handle = opendir($rep);
303  while($fichier = readdir($handle)) {
304 
305    if (!in_array($fichier, $ignore_liste) && eregi('^[a-zA-Z0-9_-]*\.xml$',$fichier)) {
306      $p =& new xmlParser();
307                  $p->parse($rep.'/'.$fichier);
308                  if (!in_array(ereg_replace("\.xml$","",$fichier),$gabaritpardefaut)) {
309                    $gabarits[$p->output[0]['attrs']['TYPE']][] = ereg_replace("\.xml$","",$fichier);
310                  }
311                  $liste_gabarit[]=ereg_replace("\.xml$","",$fichier);
312      } 
313  }
314 
315  //gabarits du dossier "pages-custom" (surclassage)
316  $rep_custom = _DIR_RACINE."pages-custom/gabarits";
317  if (file_exists($rep_custom)) {
318    $handle = opendir($rep_custom);
319    while($fichier = readdir($handle)) {
320      if (!in_array($fichier, $ignore_liste) && eregi('^[a-zA-Z0-9_-]*\.xml$',$fichier) && !in_array($fichier, $liste_gabarit)) {
321        $p =& new xmlParser();
322                $p->parse($rep_custom.'/'.$fichier);
323                $nom_gabarit = ereg_replace("\.xml$","",$fichier);
324                $type_gabarit = $p->output[0]['attrs']['TYPE'];
325                if (!in_array($nom_gabarit, $gabaritpardefaut) && !in_array($nom_gabarit, $gabarits[$type_gabarit])) {
326                 $gabarits[$type_gabarit][] = ereg_replace("\.xml$","",$fichier);
327                }
328        $liste_gabarit[] = ereg_replace("\.xml$","",$fichier);
329      }
330     }
331  }
332  //gabarits de la base de données
333  $query = spip_query('SELECT * FROM spip_arty_gabarit_perso');
334  while ($row = spip_fetch_array($query)) {
335    if (!in_array($row['nom'], $liste_gabarit)) {
336      $liste_gabarit[] = $row['nom'];
337      $donnees = $row['type'];
338      $gabarits[$donnees][] = $row['nom'];
339    }
340  }
341  // faire le menu deroulant
342  $leselect="";
343  $leselect .="<select name='gabarit' class='forml'>";
344  $leselect .="<option value='gabarit_default'>"._T('arty:gabarit_par_defaut')."</option>";
345  foreach($gabarits as $nom => $typegabarit) {
346        if ($type == $nom) {
347         foreach($typegabarit as $cegabarit) {
348           $leselect .="<option class='$type' value='$cegabarit' ".(($cegabarit ==$gabarit_actuel)?"selected='selected' " : "").">"._T("arty:$cegabarit")."</option>";
349         }
350        }
351  }
352 
353  $leselect .="</select>";
354 
355  $balancemoica .= $leselect;
356   
357  $balancemoica .="<input type='hidden' name='action' value='changer_gabarit' />";       
358  $balancemoica .= "<br /><input class='fondo' type='submit' value='"._T('arty:bouton_changer_gabarit')."' /><br />";
359  $balancemoica .="</form>";
360 
361  // bouton de modification du gabarit + retour
362  $balancemoica .= "<form action='?exec=gabarit&amp;gabarit=";
363  if ($gabarit_actuel=="gabarit_default"){
364  $balancemoica .= "$type";
365  } else {
366  $balancemoica .= "$gabarit_actuel";
367  }
368  $balancemoica .= "' method='post'>";
369  $balancemoica .= "<input name='retour' value='$url_retour' type='hidden'>";
370  $balancemoica .= "<br /><input class='fondo' type='submit' value='"._T('arty:editer_ce_gabarit')."' />";
371  $balancemoica .= "</form>";
372$balancemoica .= fin_cadre_couleur(true);
373
374// formulaire de creation d'un gabarit à partir de la page
375  $balancemoica .= debut_cadre_trait_couleur(_DIR_PLUGIN_ARTY."/images/config.png", true, "", _T('arty:creer_gabarit_et_associer'));
376
377        $balancemoica .= "<form action='".generer_url_ecrire('gabarit')."' method='post'>\n";
378        $balancemoica .= "<input name='retour' value='$url_retour' type='hidden'>";
379        $balancemoica .= "<p style='margin-top:0px; margin-bottom:2px;'>"._T("arty:deriver_gabarit")."</p>";
380$balancemoica .= "<input type='hidden' name='associer' value='". $id ."'/>";
381  $balancemoica .= "<input type='hidden' name='action' value='deriver'/>";
382  $balancemoica .= "<input type='text' name='nom_gabarit' value='"._T('arty:nom_du_gabarit')."' /><br />";
383 
384  $balancemoica .= "<p style='margin-top:8px; margin-bottom:2px;'>"._T("arty:baser_gabarit_sur")."</p>";
385  $balancemoica .= "<select id='source' name='source' class='forml'>";
386 
387  foreach($gabaritpardefaut as $un_gabarit) {
388    if ($un_gabarit == $type) {
389      $balancemoica .= '<option name="'.$un_gabarit.'" value="'.$un_gabarit.'">'.$un_gabarit.'</option>';
390    }
391  }
392  foreach($gabarits as $nom_type => $types_gabarits) {
393      foreach($types_gabarits as $un_gabarit) {
394        if ($nom_type == $type){
395        $balancemoica .= '<option name="'.$un_gabarit.'" value="'.$un_gabarit.'">'.$un_gabarit.' '.$nom_type.'</option>';
396        }
397    }
398  }
399  $balancemoica .= "</select>";
400  $balancemoica .= "<br /><input type='submit' value='"._T("arty:enregistrer")."' class='fondo' />";
401  $balancemoica .= "</form>";
402 
403$balancemoica .= "</form>";     
404
405
406
407  $balancemoica .= fin_cadre_couleur(true);
408 
409  closedir($handle);
410 
411  return $balancemoica;
412}
413
414function bloc_formulaire_themes($type, $id, $url_retour) {
415       
416        if (isset($_POST['action']) && isset($_POST['theme'])) {
417                if($_POST['action'] == 'changer_theme' && trim($_POST['theme'])!="") {
418                        //print_r($_POST);
419                                //on peut sauver
420                                spip_query("DELETE FROM spip_arty_themeassoc WHERE type='$type' AND id=$id");
421                                if ($_POST['theme'] !='theme_default') {
422                                spip_query("INSERT INTO spip_arty_themeassoc (theme, type, id) VALUES ('".addslashes(trim($_POST['theme']))."','$type',$id)");
423                                }
424                               
425                }       
426        }
427       
428        $resultat = spip_query("SELECT * FROM spip_arty_themeassoc WHERE type='$type' AND id=$id");
429        if (spip_num_rows($resultat)) {
430                $row=spip_fetch_array($resultat);
431                $theme=$row['theme'];
432        } else { $theme='theme_default'; }
433       
434  $ignore_liste = Array(".svn", ".", "..",".DS_Store");
435  $rep = _DIR_PLUGIN_ARTY."themes";
436  $handle = opendir($rep);
437 
438  $balancemoica = debut_cadre_trait_couleur(_DIR_PLUGIN_ARTY."/images/config.png", true, "", _T('arty:associer_un_theme'));
439  $balancemoica .="<form action='$url_retour' method='post'>";
440  $balancemoica .="<select name='theme' class='forml'>";
441  $balancemoica .="<option value='theme_default'>"._T('arty:theme_par_defaut')."</option>";
442  while($fichier = readdir($handle)) {
443   
444      if (in_array($fichier, $ignore_liste)) {
445      } else if (is_dir($rep.'/'.$fichier)) {
446               
447        if (file_exists($rep.'/'.$fichier.'/theme.xml')) {
448                               
449 $p =& new xmlParser();
450 $p->parse($rep.'/'.$fichier.'/theme.xml');
451 //print_r($p->output);
452 
453 foreach($p->output[0]['child'] as $id => $tag) {
454        if ($tag['name'] == "TITRE") {
455                $balancemoica .="<option value='".$fichier."' ".(($fichier==$theme)?"selected='selected' ": '').">".$tag["content"]."</option>";
456        }
457       
458        if ($tag['name'] == "DECLINAISON") {
459                $balancemoica .="<option value='".$fichier."|".$tag["attrs"]["CHEMIN"]."' ".(($fichier."|".$tag["attrs"]["CHEMIN"]==$theme)?"selected='selected' ": '')."> - ".$tag["attrs"]["TITRE"]."</option>";
460                }
461               
462        }
463        }}}
464 
465  $balancemoica .="</select>"; 
466  $balancemoica .="<input type='hidden' name='action' value='changer_theme' />";         
467  $balancemoica .= "<input class='fondo' type='submit' value='"._T('arty:bouton_changer_theme')."' />";
468  $balancemoica .= fin_cadre_couleur(true);
469  $balancemoica .="</form>";
470 
471  closedir($handle);
472 
473  return $balancemoica;
474}
475
476// formulaire d'ajout/remplacement/suppression d'un bandeau à la rubrique
477function formulaire_bandeau($id_rubrique)
478{
479  $texte = "<p>"._T('arty:intro_up_rub_bandeau')."</p>";
480  traiter_suppression_bandeau($id_rubrique);
481  $message = _T(traiter_upload_bandeau($id_rubrique));
482  $texte .= ($message) ? "<p style=\"font-weight:bold;\">".$message."</p>" : "";
483 
484  $visible = false;
485 
486  $chem = creer_repertoire_documents("bandeau");
487  $handle = @opendir($chem); 
488  while($fichier = @readdir($handle)) {
489    if (ereg("^bandeau-$id_rubrique\.(jpg|png|gif)$", $fichier)) {
490      $bandeau = $fichier;
491    } 
492   
493    if (ereg("^bandeau\.(jpg|png|gif)$", $fichier) && !$id_rubrique) {
494      $bandeau = $fichier;
495    }
496  }
497 
498  if (!isset($bandeau)){
499    $texte .= "<p>"._T("arty:aucun_bandeau_rub")."</p>";
500  } else {
501    $visible = true;
502    $result = _T("arty:bandeau_actuel").":<br /><img width=\"190\" src=\""._DIR_DOC."bandeau/$bandeau?".uniqid(rand())."\" />"; // le nombre aléatoire permet d'éviter que le navigateur affiche la version en cache de l'image.
503    $result .= "<p>[<a href=\"?exec=naviguer&id_rubrique=$id_rubrique&action=supprimer_bandeau&id_check=".$_SESSION['id_check']."\">"._T('arty:supprimer_bandeau')."</a>]</p>";
504    $texte .= $result;
505  }
506  $texte .= "<form action=\"?exec=naviguer&amp;id_rubrique=$id_rubrique\" method=\"post\" enctype=\"multipart/form-data\">";
507  $texte .= "<input type=\"file\" name=\"bandeau\" id=\"bandeau\" size=\"13\" /><br />";
508  $texte .= "<div style=\"text-align:right;\"><input class=\"fondo\" name=\"filesubmit\" type=\"submit\" value=\""._T('arty:enregistrer')."\" /></div>";
509  $texte .= "</form>";
510  $data = debut_cadre_couleur("vignette-24.png", true, "", _T('arty:titre_up_rub_bandeau'));
511  $data .= block_parfois_visible("bandeau", _T("arty:invit_up_rub_bandeau"), $texte, '', $visible);
512        $data .= fin_cadre_couleur(true);
513
514        return $data;
515}
516
517?>
Note: See TracBrowser for help on using the repository browser.