source: trunk/spip/2.1/extensions/magusine-portage2.1/arty_affichegauche.php @ 756

Last change on this file since 756 was 756, checked in by guillermoacedo@…, 14 years ago

se agrego la correccion de magusine para 2.1 basica

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