[198] | 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 | include_spip('inc/xml-parser'); |
---|
| 15 | //require(_DIR_PLUGIN_ARTY.'/inc/xml-parser.php'); |
---|
| 16 | |
---|
| 17 | if (!defined("_ECRIRE_INC_VERSION")) return; |
---|
| 18 | include_spip('inc/presentation'); |
---|
| 19 | |
---|
| 20 | function exec_gabarit() { |
---|
| 21 | |
---|
| 22 | $commencer_page = charger_fonction('commencer_page', 'inc'); |
---|
| 23 | echo $commencer_page('« '._T('arty:configuration_des_gabarits').' »', 'configuration', 'magusine'); |
---|
| 24 | |
---|
| 25 | global $connect_statut; |
---|
| 26 | if ($connect_statut != "0minirezo" ) { |
---|
| 27 | echo "<p><b>"._T('arty:acces_a_la_page')."</b></p>"; |
---|
| 28 | fin_page(); |
---|
| 29 | exit; |
---|
| 30 | } |
---|
| 31 | // mazu ici était le if du $_GET['mode']=="ajax" voir dans action/enregister_gabarit.php |
---|
| 32 | if ($_POST['action_form'] == 'supprimer') { |
---|
| 33 | $gabarit = isset($_POST['gabarit']) ? addslashes($_POST['gabarit']) : false; |
---|
| 34 | |
---|
| 35 | if ($gabarit) { |
---|
| 36 | //supprimer les blocs de gabarit_ordre |
---|
| 37 | spip_query("DELETE FROM spip_arty_gabarit_ordre WHERE gabarit='$gabarit'"); |
---|
| 38 | //supprimer l'entrée du gabarit dans gabarit_perso |
---|
| 39 | spip_query("DELETE FROM spip_arty_gabarit_perso WHERE nom='$gabarit'"); |
---|
| 40 | //supprimer les entrées du gabarit dans gabaritassoc |
---|
| 41 | spip_query("DELETE FROM spip_arty_gabaritassoc WHERE gabarit='$gabarit'"); |
---|
| 42 | //echo _T("arty:gabarit_supprime"); |
---|
| 43 | } |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | echo barre_onglets("arty", "gabarit"); |
---|
| 47 | echo debut_gauche("", true); |
---|
| 48 | echo debut_cadre_relief(_DIR_PLUGIN_ARTY.'/images/aide.png', true, "", _T('arty:info')); |
---|
| 49 | echo _T("arty:sideinfo_gabarit"); |
---|
| 50 | echo fin_cadre_relief(true); |
---|
| 51 | |
---|
| 52 | $gabarits=array(); |
---|
| 53 | $gabaritpardefaut=array("sommaire","rubrique","article","groupe","mot","breve"); |
---|
| 54 | $ignore_liste=array(".","..",".DS_Store","^\.[.+]"); |
---|
| 55 | $rep = _DIR_PLUGIN_ARTY."definitions-gabarits"; |
---|
| 56 | $handle = opendir($rep); |
---|
| 57 | while($fichier = readdir($handle)) { |
---|
| 58 | |
---|
| 59 | if (!in_array($fichier, $ignore_liste) && eregi('^[a-zA-Z0-9_-]*\.xml$',$fichier)) { |
---|
| 60 | $p =& new xmlParser(); |
---|
| 61 | $p->parse($rep.'/'.$fichier); |
---|
| 62 | if (!in_array(ereg_replace("\.xml$","",$fichier),$gabaritpardefaut)) { |
---|
| 63 | $gabarits[$p->output[0]['attrs']['TYPE']][]=ereg_replace("\.xml$","",$fichier); |
---|
| 64 | } |
---|
| 65 | $liste_gabarit[]=ereg_replace("\.xml$","",$fichier); |
---|
| 66 | } |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | //gabarits du dossier "pages-custom" (surclassage) |
---|
| 70 | $rep_custom = _DIR_RACINE."pages-custom/gabarits"; |
---|
| 71 | if (file_exists($rep_custom)) { |
---|
| 72 | $handle = opendir($rep_custom); |
---|
| 73 | while($fichier = readdir($handle)) { |
---|
| 74 | if (!in_array($fichier, $ignore_liste) && eregi('^[a-zA-Z0-9_-]*\.xml$',$fichier) && !eregi('^ajout-',$fichier) && !in_array($fichier, $liste_gabarit)) { |
---|
| 75 | $p =& new xmlParser(); |
---|
| 76 | $p->parse($rep_custom.'/'.$fichier); |
---|
| 77 | $nom_gabarit = ereg_replace("\.xml$","",$fichier); |
---|
| 78 | $type_gabarit = $p->output[0]['attrs']['TYPE']; |
---|
| 79 | if (!in_array($nom_gabarit, $gabaritpardefaut) && !in_array($nom_gabarit, $gabarits[$type_gabarit])) { |
---|
| 80 | $gabarits[$type_gabarit][] = ereg_replace("\.xml$","",$fichier); |
---|
| 81 | } |
---|
| 82 | $liste_gabarit[] = ereg_replace("\.xml$","",$fichier); |
---|
| 83 | } |
---|
| 84 | } |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | //gabarits de la base de données |
---|
| 88 | $query = spip_query('SELECT * FROM spip_arty_gabarit_perso'); |
---|
| 89 | while ($row = spip_fetch_array($query)) { |
---|
| 90 | if (!in_array($row['nom'], $liste_gabarit)) { |
---|
| 91 | $liste_gabarit[] = $row['nom']; |
---|
| 92 | //$donnees = unserialize($row['donnees']); |
---|
| 93 | $gabarits[$donnees[0]['attrs']['TYPE']][] = $row['nom']; |
---|
| 94 | } |
---|
| 95 | } |
---|
| 96 | |
---|
| 97 | if ($_POST['action_form'] == "deriver") { |
---|
| 98 | |
---|
| 99 | if (isset($_POST['nom_gabarit']) && isset($_POST['source'])) { |
---|
| 100 | if (in_array($_POST['nom_gabarit'], $liste_gabarit)) { |
---|
| 101 | echo _T("arty:nom_deja_pris"); |
---|
| 102 | } else { |
---|
| 103 | |
---|
| 104 | $source = addslashes($_POST['source']); |
---|
| 105 | |
---|
| 106 | //vérification de la présence d'un gabarit dans pages-custom (surclassage) |
---|
| 107 | $rep = _DIR_PLUGIN_ARTY."definitions-gabarits/"; |
---|
| 108 | $rep_custom = _DIR_RACINE."pages-custom/gabarits/"; |
---|
| 109 | |
---|
| 110 | if (file_exists($rep_custom.$source.".xml")) { |
---|
| 111 | $chemin_gabarit = $rep_custom.$source.".xml"; |
---|
| 112 | } else if (file_exists($rep.$source.".xml")) { |
---|
| 113 | $chemin_gabarit = $rep.$source.".xml"; |
---|
| 114 | } |
---|
| 115 | |
---|
| 116 | if (isset($chemin_gabarit)) { |
---|
| 117 | $p =& new xmlParser(); |
---|
| 118 | $p->parse($chemin_gabarit); |
---|
| 119 | $donnees = $p->output; |
---|
| 120 | } |
---|
| 121 | |
---|
| 122 | if (isset($donnees)) { |
---|
| 123 | |
---|
| 124 | $type_source = addslashes($donnees[0]["attrs"]["TYPE"]); |
---|
| 125 | |
---|
| 126 | if ($type_source == "defaut") { |
---|
| 127 | $donnees[0]["attrs"]["TYPE"] = $source; |
---|
| 128 | $type_source = $source; |
---|
| 129 | } |
---|
| 130 | |
---|
| 131 | $nom = addslashes(trim(ereg_replace("[^a-zA-Z0-9_-]", "", $_POST['nom_gabarit']))); |
---|
| 132 | if (!$nom) { $nom="sansnom"; } // eviter le gabarit sans nom |
---|
| 133 | $donnees = serialize($donnees); |
---|
| 134 | |
---|
| 135 | $result = spip_query("SELECT * FROM spip_arty_gabarit_ordre WHERE gabarit='$source'"); |
---|
| 136 | $blocs = array(); |
---|
| 137 | while ($row = spip_fetch_array($result)) { |
---|
| 138 | $blocs[] = array( |
---|
| 139 | "nom" => addslashes($row['nom']), |
---|
| 140 | "ordre" => (!is_nan((int) $row['ordre'])) ? (int) $row['ordre'] : 0, |
---|
| 141 | "conteneur" => (!is_nan((int) $row['conteneur'])) ? (int) $row['conteneur'] : 0, |
---|
| 142 | "gabarit" => $nom, |
---|
| 143 | "param" => addslashes($row['param']), |
---|
| 144 | ); |
---|
| 145 | } |
---|
| 146 | |
---|
| 147 | if ($blocs) { |
---|
| 148 | $query = "INSERT INTO spip_arty_gabarit_ordre (nom, ordre, conteneur, gabarit, param) VALUES "; |
---|
| 149 | for ($i=0; $i<count($blocs); $i++) { |
---|
| 150 | $query .= "('".$blocs[$i]['nom']."', ".$blocs[$i]['ordre'].", ".$blocs[$i]['conteneur'].", '".$blocs[$i]['gabarit']."', '".$blocs[$i]['param']."')"; |
---|
| 151 | if ($i != count($blocs)-1) { |
---|
| 152 | $query .= ", "; |
---|
| 153 | } |
---|
| 154 | } |
---|
| 155 | |
---|
| 156 | spip_query($query); |
---|
| 157 | spip_query("INSERT INTO spip_arty_gabarit_perso (nom,type,donnees) VALUES ('$nom','$type_source','$source')"); |
---|
| 158 | |
---|
| 159 | // echo _T("arty:nouveau_gabarit_cree"); |
---|
| 160 | |
---|
| 161 | // si on vient de creer le gabarit a partir d'une page d'edition, associer le gabarit |
---|
| 162 | if ($_POST['associer']){ |
---|
| 163 | $leid = (int) $_POST['associer']; |
---|
| 164 | |
---|
| 165 | // supprimer autre entree de gabarit |
---|
| 166 | spip_query("DELETE FROM spip_arty_gabaritassoc WHERE type='$type_source' AND id=$leid"); |
---|
| 167 | spip_query("INSERT INTO spip_arty_gabaritassoc (gabarit,id,type) VALUES ('$nom','$leid','$type_source')"); |
---|
| 168 | } |
---|
| 169 | |
---|
| 170 | $nouveau_gabarit = $nom; |
---|
| 171 | $liste_gabarit[] = $nom; |
---|
| 172 | $donnees = unserialize($donnees); |
---|
| 173 | $gabarits[$donnees[0]['attrs']['TYPE']][] = $nom; |
---|
| 174 | |
---|
| 175 | } |
---|
| 176 | } |
---|
| 177 | } |
---|
| 178 | } |
---|
| 179 | } |
---|
| 180 | |
---|
| 181 | echo debut_cadre_relief(_DIR_PLUGIN_ARTY.'/images/aide.png', true, "", _T('arty:nouveau_gabarit')); |
---|
| 182 | echo "<p style='margin-top:0px; margin-bottom:2px;'>"._T("arty:deriver_gabarit")."</p>"; |
---|
| 183 | |
---|
| 184 | echo "<form action='".generer_url_ecrire('gabarit')."' method='post'>\n"; |
---|
| 185 | echo "<input type='hidden' name='action_form' value='deriver'/>"; |
---|
| 186 | echo "<input type='text' name='nom_gabarit' value='"._T('arty:nom_du_gabarit')."' /><br />"; |
---|
| 187 | |
---|
| 188 | echo "<p style='margin-top:8px; margin-bottom:2px;'>"._T("arty:baser_gabarit_sur")."</p>"; |
---|
| 189 | |
---|
| 190 | echo "<select id='source' name='source'>"; |
---|
| 191 | |
---|
| 192 | |
---|
| 193 | foreach($gabaritpardefaut as $un_gabarit) { |
---|
| 194 | if ($un_gabarit != "sommaire") { |
---|
| 195 | echo '<option name="'.$un_gabarit.'" value="'.$un_gabarit.'">'.$un_gabarit.'</option>'; |
---|
| 196 | } |
---|
| 197 | } |
---|
| 198 | |
---|
| 199 | foreach($gabarits as $nom_type => $types_gabarits) { |
---|
| 200 | if ($nom_type != "defaut") { |
---|
| 201 | $nom_type = "(".$nom_type.")"; |
---|
| 202 | |
---|
| 203 | foreach($types_gabarits as $un_gabarit) { |
---|
| 204 | |
---|
| 205 | if ($nom_type!="()"){ |
---|
| 206 | echo '<option name="'.$un_gabarit.'" value="'.$un_gabarit.'">'.$un_gabarit.' '.$nom_type.'</option>'; |
---|
| 207 | } |
---|
| 208 | } |
---|
| 209 | } |
---|
| 210 | } |
---|
| 211 | echo "</select>"; |
---|
| 212 | echo "<br /><br /><input type='submit' value='"._T("arty:enregistrer")."' class='fondo' />"; |
---|
| 213 | echo "</form>"; |
---|
| 214 | |
---|
| 215 | echo fin_cadre_relief(true); |
---|
| 216 | |
---|
| 217 | |
---|
| 218 | // pour la page principale : nom du gabarit en cours |
---|
| 219 | |
---|
| 220 | if (isset($nouveau_gabarit)) { |
---|
| 221 | $gabarit = $nouveau_gabarit; |
---|
| 222 | } else { |
---|
| 223 | $gabarit=$_GET['gabarit']; |
---|
| 224 | } |
---|
| 225 | if(!in_array($gabarit, $liste_gabarit)) { |
---|
| 226 | $gabarit="sommaire"; |
---|
| 227 | } |
---|
| 228 | |
---|
| 229 | $liste_nonassociee=array("sommaire","article","rubrique","mot","groupe-mots","breve","404","forum","login","recherche","auteur","webmaton-mosaique","webmaton-questions"); |
---|
| 230 | |
---|
| 231 | if (!in_array($gabarit, $liste_nonassociee)){ |
---|
| 232 | lister_associations_gabarit($gabarit); |
---|
| 233 | } |
---|
| 234 | echo debut_droite("", true); |
---|
| 235 | |
---|
| 236 | echo "\n"; |
---|
| 237 | |
---|
| 238 | |
---|
| 239 | echo gros_titre(_T("arty:configuration_des_gabarits")." "._T("arty:".$gabarit), "", false); |
---|
| 240 | |
---|
| 241 | // faire le menu deroulant |
---|
| 242 | |
---|
| 243 | echo "<div id='deroulant-gabarits'>"._T("arty:modifier_un_autre_gabarit").' : <select onchange="window.location.href=\''.generer_url_ecrire("gabarit", "gabarit=").'\'+this.options[this.selectedIndex].value;" class="selecteur-gabarit">'; |
---|
| 244 | |
---|
| 245 | foreach ($gabaritpardefaut as $cegabarit) { |
---|
| 246 | $selected = ($cegabarit == $gabarit) ? 'selected="selected"' : ''; |
---|
| 247 | |
---|
| 248 | echo "<option class='$type' value=\"".$cegabarit."\" $selected>"._T("arty:$cegabarit")."</option>"; |
---|
| 249 | } |
---|
| 250 | |
---|
| 251 | foreach($gabarits as $type) { |
---|
| 252 | foreach($type as $cegabarit) { |
---|
| 253 | $selected = ($cegabarit == $gabarit) ? 'selected="selected"' : ''; |
---|
| 254 | echo "<option class='$type' value=\"".$cegabarit."\" $selected>"._T("arty:$cegabarit")."</option>"; |
---|
| 255 | } |
---|
| 256 | } |
---|
| 257 | echo "</select></div>"; |
---|
| 258 | |
---|
| 259 | //print_r($gabarits); |
---|
| 260 | |
---|
| 261 | charger_gabarit(addslashes($gabarit)); |
---|
| 262 | |
---|
| 263 | echo fin_gauche(); |
---|
| 264 | echo fin_page(); |
---|
| 265 | } |
---|
| 266 | |
---|
| 267 | function charger_gabarit($gabarit) { |
---|
| 268 | |
---|
| 269 | //vérification de la présence d'un gabarit dans pages-custom (surclassage) |
---|
| 270 | $rep = _DIR_PLUGIN_ARTY."definitions-gabarits/"; |
---|
| 271 | $rep_custom = _DIR_RACINE."pages-custom/gabarits/"; |
---|
| 272 | |
---|
| 273 | if (file_exists($rep_custom.$gabarit.".xml")) { |
---|
| 274 | $chemin_gabarit = $rep_custom.$gabarit.".xml"; |
---|
| 275 | $origine=$gabarit; |
---|
| 276 | } else if (file_exists($rep.$gabarit.".xml")) { |
---|
| 277 | $chemin_gabarit = $rep.$gabarit.".xml"; |
---|
| 278 | $origine=$gabarit; |
---|
| 279 | } else { |
---|
| 280 | $query = spip_query("SELECT * FROM spip_arty_gabarit_perso WHERE nom='$gabarit'"); |
---|
| 281 | if (spip_mysql_count($query)) { |
---|
| 282 | $row = spip_fetch_array($query); |
---|
| 283 | $origine = $row['donnees']; |
---|
| 284 | $from_db = $row['type']; |
---|
| 285 | |
---|
| 286 | //retrouve le gabarit d'origine de la declinaison |
---|
| 287 | if (file_exists($rep_custom.$origine.".xml")) { |
---|
| 288 | $chemin_gabarit = $rep_custom.$origine.".xml"; |
---|
| 289 | } else if (file_exists($rep.$origine.".xml")) { |
---|
| 290 | $chemin_gabarit = $rep.$origine.".xml"; |
---|
| 291 | } else { |
---|
| 292 | echo _T("arty:gabarit_origine_non-trouve"); |
---|
| 293 | return false; |
---|
| 294 | } |
---|
| 295 | } |
---|
| 296 | } |
---|
| 297 | |
---|
| 298 | if (isset($chemin_gabarit)) { |
---|
| 299 | $p =& new xmlParser(); |
---|
| 300 | $p->parse($chemin_gabarit); |
---|
| 301 | $donnees = $p->output; |
---|
| 302 | } |
---|
| 303 | |
---|
| 304 | // fichier d'injection simple de bloc sur base du gabarit d'origine (physique) |
---|
| 305 | if (file_exists($rep_custom."ajout-".$origine.".xml")) { |
---|
| 306 | $pajout =& new xmlParser(); |
---|
| 307 | $pajout->parse($rep_custom."ajout-".$origine.".xml"); |
---|
| 308 | $donneesajout = $pajout->output; |
---|
| 309 | $donnees[0][child] = array_merge((array)$donnees[0][child], (array)$donneesajout[0][child]); |
---|
| 310 | } |
---|
| 311 | |
---|
| 312 | if (!isset($donnees)) { |
---|
| 313 | echo _T("arty:gabarit_non-trouve"); |
---|
| 314 | return false; |
---|
| 315 | } |
---|
| 316 | |
---|
| 317 | if (isset($from_db)) { |
---|
| 318 | // formulaire de suppression |
---|
| 319 | echo "<form action='".generer_url_ecrire('gabarit')."' method='post'>\n"; |
---|
| 320 | echo "<input type='hidden' name='action_form' value='supprimer'/>\n"; |
---|
| 321 | echo "<input type='hidden' name='gabarit' value=\"".stripslashes($gabarit)."\" />\n"; |
---|
| 322 | echo "<br /><input type='submit' value='"._T("arty:supprimer")."' class='fondo' />"; |
---|
| 323 | echo "</form>"; |
---|
| 324 | } |
---|
| 325 | |
---|
| 326 | $nom = $donnees[0]['attrs']['NOM']; |
---|
| 327 | |
---|
| 328 | $blocs =array(); |
---|
| 329 | |
---|
| 330 | foreach($donnees[0]['child'] as $ordre => $bloc) { |
---|
| 331 | $blocs[$bloc['content']]=array('ordre'=> $ordre, 'conteneur' => $bloc['attrs']['STATUT'], 'param' => $bloc['attrs']['PARAM'], 'paramdefaut' => $bloc['attrs']['PARAMDEFAUT'],'paramdescr' => $bloc['attrs']['PARAMDESCR'],'paramtext' => $bloc['attrs']['PARAMTEXT'], 'paramvalue' => $bloc['attrs']['PARAMVALUE']); |
---|
| 332 | } |
---|
| 333 | |
---|
| 334 | $resultat=spip_query("SELECT * FROM spip_arty_gabarit_ordre WHERE gabarit='$gabarit'"); |
---|
| 335 | while ($row=spip_fetch_array($resultat)) { |
---|
| 336 | if (in_array($row['nom'], array_keys($blocs))) { |
---|
| 337 | $blocs[$row['nom']]['conteneur']=$row['conteneur']; |
---|
| 338 | $blocs[$row['nom']]['ordre']=$row['ordre']; |
---|
| 339 | $blocs[$row['nom']]['paramdefaut']=$row['param']; // peut crasher |
---|
| 340 | } else { |
---|
| 341 | spip_query("DELETE FROM spip_arty_gabarit_ordre WHERE id_bloc=".$row['id_bloc']); |
---|
| 342 | } |
---|
| 343 | } |
---|
| 344 | |
---|
| 345 | uasort($blocs, "comparerblocs"); |
---|
| 346 | |
---|
| 347 | echo "<div id='general'>\n"; |
---|
| 348 | |
---|
| 349 | //print_r($donnees); |
---|
| 350 | echo "<div id='pageweb'><div id='bandeau'></div>"; |
---|
| 351 | $colonnes = array("contexte1" => 1, "contexte2" =>2, "corps" =>3, "reserve" => 0, "avance" => 4); |
---|
| 352 | |
---|
| 353 | foreach( array_keys($colonnes) as $colonne) { |
---|
| 354 | //boucle pour tous les conteneurs |
---|
| 355 | if($colonne=='reserve') { echo "<br class='clearer'/><div id='footer'></div></div><div id='reserves'>"; |
---|
| 356 | } |
---|
| 357 | |
---|
| 358 | echo "<ul id='$colonne' class='conteneur_bloc'>\n"; |
---|
| 359 | |
---|
| 360 | echo "<li><h3>"._T("arty:$colonne")."</h3></li>\n"; |
---|
| 361 | foreach($blocs as $bloc => $proprietes) { |
---|
| 362 | //on affiche le bloc |
---|
| 363 | if ($proprietes['conteneur']== $colonnes[$colonne]) { |
---|
| 364 | echo "<li id='".$bloc."' class='bloc $colonne' >"; |
---|
| 365 | // poignée |
---|
| 366 | echo "<div class='poignee'></div>"; |
---|
| 367 | echo "<span class='titre-bloc'>"._T("arty:".$bloc)."</span><br />"; |
---|
| 368 | if($proprietes['paramdescr']) { |
---|
| 369 | echo "<p class='option-bloc'>"._T("arty:".$proprietes['paramdescr']); |
---|
| 370 | } |
---|
| 371 | |
---|
| 372 | if (preg_match("/^champ/",$proprietes['param'])) { |
---|
| 373 | // en cas de champ : montrer le champ |
---|
| 374 | echo "<input type='text' name='$bloc' class='selecteur-param' value='"; |
---|
| 375 | echo $proprietes['paramdefaut']; |
---|
| 376 | echo "' style='width:100%' />"; |
---|
| 377 | echo "</p>"; |
---|
| 378 | |
---|
| 379 | } else if (preg_match("/^area/",$proprietes['param'])) { |
---|
| 380 | // en cas de area : montrer le champ |
---|
| 381 | echo "<textarea name='$bloc' class='selecteur-param' rows='4' style='width:100%'>"; |
---|
| 382 | echo $proprietes['paramdefaut']; |
---|
| 383 | echo "</textarea>"; |
---|
| 384 | echo "</p>"; |
---|
| 385 | |
---|
| 386 | } else if ($proprietes['param'] !="") { |
---|
| 387 | // en cas de parametre : montrer le selecteur |
---|
| 388 | echo "<select name='$bloc' class='selecteur-param'>"; |
---|
| 389 | |
---|
| 390 | if (ereg("SELECT",$proprietes['param'])) { |
---|
| 391 | $requete=spip_query($proprietes['param']); |
---|
| 392 | while ($row=spip_fetch_array($requete)) { |
---|
| 393 | echo "<option value='".$row[$proprietes['paramvalue']]."'>".$row[$proprietes['paramtext']]."</option>"; |
---|
| 394 | } |
---|
| 395 | |
---|
| 396 | } else { |
---|
| 397 | // c'est une liste separee par des virgules |
---|
| 398 | $options=explode(",",$proprietes['param']); |
---|
| 399 | foreach($options as $option) { |
---|
| 400 | echo "<option value='$option'"; |
---|
| 401 | if ( trim(strval($option))==trim(strval($proprietes['paramdefaut'])) ) { echo "selected='selected'"; } |
---|
| 402 | echo ">"._T("arty:$option")."</option>"; |
---|
| 403 | |
---|
| 404 | } |
---|
| 405 | } |
---|
| 406 | |
---|
| 407 | echo "</select></p>"; |
---|
| 408 | } |
---|
| 409 | |
---|
| 410 | echo "</li>\n"; |
---|
| 411 | } |
---|
| 412 | } |
---|
| 413 | echo "</ul>\n"; |
---|
| 414 | |
---|
| 415 | if($colonne=='avance'){ |
---|
| 416 | echo "</div>\n"; |
---|
| 417 | } |
---|
| 418 | } |
---|
| 419 | |
---|
| 420 | echo "<br class='clearer' />"; |
---|
| 421 | echo "<div id='bloc_sauver'>"; |
---|
| 422 | echo "<div id='reponse'></div>"; |
---|
| 423 | echo "<img src='"._DIR_IMG_PACK."searching.gif' id='search' style='visibility:hidden' />"; |
---|
| 424 | |
---|
| 425 | echo "<a href=\"javascript:sauver('".$gabarit."'"; |
---|
| 426 | |
---|
| 427 | if ($_POST['retour']){ |
---|
| 428 | // si un retour vers une page est prevu |
---|
| 429 | echo ",'".$_POST['retour']."');\">"; |
---|
| 430 | echo _T("arty:modifier_et_retour"); |
---|
| 431 | } else { |
---|
| 432 | echo ");\">"._T("arty:enregister"); |
---|
| 433 | } |
---|
| 434 | |
---|
| 435 | //echo "<a href=\"javascript:void(0)\" onclick=\"return AjaxSqueeze('?exec=gabarit&action=enregistrer_gabarit','reponse','',event)\">"._T("arty:enregister")."</a>"; |
---|
| 436 | echo "</a></div>"; |
---|
| 437 | echo "</div>\n"; |
---|
| 438 | } |
---|
| 439 | |
---|
| 440 | function testexist($nom, $liste) { |
---|
| 441 | $return=FALSE; |
---|
| 442 | foreach($liste as $bloc) { |
---|
| 443 | if ($bloc['content']==$nom) { |
---|
| 444 | $return=TRUE; |
---|
| 445 | } |
---|
| 446 | } |
---|
| 447 | return $return; |
---|
| 448 | } |
---|
| 449 | |
---|
| 450 | function comparerblocs ($a, $b) { |
---|
| 451 | if ($a['ordre'] == $b['ordre']) return 0; |
---|
| 452 | return ($a['ordre'] < $b['ordre']) ? -1 : 1; |
---|
| 453 | } |
---|
| 454 | |
---|
| 455 | function lister_associations_gabarit($gabarit) |
---|
| 456 | { |
---|
| 457 | |
---|
| 458 | if ($_GET['action_form'] == 'delete_assoc_gabarit' && $_GET['id_check'] == $_SESSION['id_check']) { |
---|
| 459 | $type = isset($_GET['type']) ? addslashes($_GET['type']) : false; |
---|
| 460 | $id = isset($_GET['id']) ? (int) $_GET['id'] : false; |
---|
| 461 | $theme = isset($_GET['gabarit']) ? addslashes($_GET['gabarit']) : false; |
---|
| 462 | if ($type && $id && $theme) { |
---|
| 463 | spip_query("DELETE FROM spip_arty_gabaritassoc WHERE type='$type' AND id=$id AND gabarit='$gabarit'"); |
---|
| 464 | } |
---|
| 465 | } |
---|
| 466 | |
---|
| 467 | echo "<div id=\"div_liste_assoc\">"; |
---|
| 468 | $result = spip_query("SELECT * FROM spip_arty_gabaritassoc WHERE gabarit='$gabarit'"); |
---|
| 469 | |
---|
| 470 | echo debut_cadre_couleur("doc-24.gif", true, "", _T('arty:liste_assoc_gabarit')); |
---|
| 471 | echo "<div class='liste'><table border='0' cellspacing='0' cellpadding='3' width='100%'>"; |
---|
| 472 | if (spip_mysql_count($result) > 0) { |
---|
| 473 | while ($row = spip_fetch_array($result)){ |
---|
| 474 | echo "<tr class='tr_liste'>"; |
---|
| 475 | $type = $row['type']; |
---|
| 476 | $id = $row['id']; |
---|
| 477 | switch ($type) { |
---|
| 478 | case "rubrique": |
---|
| 479 | $rubrique = spip_fetch_array(spip_query("SELECT titre FROM spip_rubriques WHERE id_rubrique=$id")); |
---|
| 480 | $titre = $rubrique['titre']; |
---|
| 481 | $url="?exec=naviguer&id_rubrique=$id"; |
---|
| 482 | break; |
---|
| 483 | |
---|
| 484 | case "article": |
---|
| 485 | $article = spip_fetch_array(spip_query("SELECT titre FROM spip_articles WHERE id_article=$id")); |
---|
| 486 | $titre = $article['titre']; |
---|
| 487 | $url="?exec=articles&id_article=$id"; |
---|
| 488 | break; |
---|
| 489 | |
---|
| 490 | case "groupe": |
---|
| 491 | $groupe = spip_fetch_array(spip_query("SELECT titre FROM spip_groupes_mots WHERE id_groupe=$id")); |
---|
| 492 | $titre = $groupe['titre']; |
---|
| 493 | $url="?exec=mots_tous"; |
---|
| 494 | break; |
---|
| 495 | |
---|
| 496 | case "mot": |
---|
| 497 | $mot = spip_fetch_array(spip_query("SELECT titre FROM spip_mots WHERE id_mot=$id")); |
---|
| 498 | $titre = $mot['titre']; |
---|
| 499 | $url="?exec=mots_tous&id_mot=$id"; |
---|
| 500 | break; |
---|
| 501 | } |
---|
| 502 | |
---|
| 503 | $gabarit = $row['gabarit']; |
---|
| 504 | echo "<td class=\"arial1\"><a href=\"$url\">$titre</a></td>"; |
---|
| 505 | echo "<td class=\"arial1\"> ($type $id)</td>"; |
---|
| 506 | echo "<td class=\"arial1\"><div style='text-align:right;'><a class=\"supprimer\" href='".generer_url_ecrire('gabarit')."&action_form=delete_assoc_gabarit&id_check=".$_SESSION['id_check']."&id=$id&gabarit=$gabarit&type=$type'><img src='../dist/images/croix-rouge.gif' alt='X' width='7' height='7' align='bottom' /></a></div></td>"; |
---|
| 507 | echo "</tr>"; |
---|
| 508 | } |
---|
| 509 | } else { echo "<tr><td class=\"arial1\">"._T("arty:pas_de_page_associee")."</td></tr>"; } |
---|
| 510 | echo "</table></div>"; |
---|
| 511 | |
---|
| 512 | echo fin_cadre_couleur(true); |
---|
| 513 | |
---|
| 514 | echo "</div>"; |
---|
| 515 | } |
---|
| 516 | ?> |
---|