"._T('redcta:acces_a_la_page')."";
fin_page();
exit;
}
traiter_post();
$params= charger_parametres_gen();
echo barre_onglets("redcta", "theme");
echo debut_gauche('', true);
echo debut_cadre_relief(_DIR_PLUGIN_REDCTA.'/images/aide.png', true, "", _T('redcta:info'));
echo _T("redcta:sideinfo_theme");
echo fin_cadre_relief(true);
echo lister_associations();
echo creer_colonne_droite('', true);
echo debut_droite('', true);
echo gros_titre(_T("redcta:choix_du_theme"), "", false);
//liste des themes disponibles
echo debut_cadre_trait_couleur(_DIR_PLUGIN_REDCTA."/images/config.png", true, "", _T('redcta:choixtheme'));
listage_themes();
echo fin_cadre_trait_couleur(true);
echo "
";
// suite : footer, metas, 404
// affiche le formulaire d'upload du bandeau
formulaire_bandeau();
echo debut_cadre_trait_couleur(_DIR_PLUGIN_REDCTA."images/format-indent-more.png", true, "", _T('redcta:footer'));
echo _T('redcta:votre_message_de_footer');
echo "";
echo fin_cadre_trait_couleur(true);
echo "
";
echo debut_cadre_trait_couleur(_DIR_PLUGIN_REDCTA."images/format-indent-more.png", true, "", _T('redcta:logos_bailleurs'));
echo _T('redcta:intro_afficher_logos_bailleurs');
echo "";
echo fin_cadre_trait_couleur(true);
echo "
";
echo debut_cadre_trait_couleur(_DIR_PLUGIN_REDCTA."images/format-indent-more.png", true, "", _T('redcta:metas'));
echo _T('redcta:vos_metas');
echo "";
echo fin_cadre_trait_couleur(true);
echo "
";
echo debut_cadre_trait_couleur(_DIR_PLUGIN_REDCTA."images/emblem-important.png", true, "", _T('redcta:page_404'));
echo _T('redcta:votre_message_page_404');
echo "";
echo fin_cadre_trait_couleur(true);
echo fin_gauche();
echo fin_page();
}
//liste des thèmes dans le répertoire theme
function listage_themes()
{
$params= charger_parametres();
$ignore_liste = Array(".svn", ".", "..",".DS_Store");
$rep = _DIR_PLUGIN_REDCTA."themes";
// affiche le theme courant
echo ""._T("redcta:theme_actuel")."
";
$letheme = explode("|", $params);
if (file_exists($rep.'/'.$letheme[0].'/theme.xml')) {
$p =& new xmlParser();
$p->parse($rep.'/'.$letheme[0].'/theme.xml');
if (file_exists($rep.'/'.$letheme[0].'/illu-theme.jpg')) {
$vignette = "
";
}
$descrip = $p->output[0]['child'][1]['content'];
foreach($p->output[0]['child'] as $prop) {
if ($prop['name'] == "TITRE") {
$titre_theme = $prop['content'];
}
}
if (count($letheme) > 1) {
$nom_decli = ereg_replace("\.css$", "", $letheme[1]);
if (file_exists($rep.'/'.$letheme[0].'/declinaisons/illu-theme-'.$nom_decli.'.jpg')) {
$vignette = "
";
}
foreach($p->output[0]['child'] as $prop) {
if ($prop['name'] == "DECLINAISON") {
if($prop['attrs']['CHEMIN'] == $letheme[1]) {
$titre_declinaison = " ("._T("redcta:en_declinaison")." ".$prop['attrs']['TITRE']." )";
// recherche de la description
foreach($prop['child'] as $num => $propdescr) {
if ($propdescr['name'] == "DESCRIPTION") {
$descrip = $propdescr['content'];
}
}
}
}
}
}
if (!isset($titre_declinaison) && count($letheme) > 1) {
$titre_declinaison = " ("._T("redcta:en_declinaison")." ".$letheme[1]." )";
}
}
echo "
";
echo isset($titre_theme) ? $titre_theme : $letheme[0];
echo isset($titre_declinaison) ? $titre_declinaison : '' ;
echo "
";
echo isset($vignette) ? $vignette : '';
echo isset($descrip) ? $descrip : '';
echo "
";
$ignore_liste = Array(".svn", ".", "..",".DS_Store");
$rep = _DIR_PLUGIN_REDCTA."themes";
$handle = opendir($rep);
print('");
closedir($handle);
}
function traiter_post() {
if ($_POST['footer']) {
if ($_POST['footer']==""){
spip_query("DELETE FROM spip_redcta_parametres WHERE parametre = 'footer'");
}
$value=addslashes($_POST['footer']);
$resultat = spip_query("SELECT * FROM spip_redcta_parametres WHERE parametre='footer'");
if (spip_mysql_count($resultat)) {
spip_query("UPDATE spip_redcta_parametres SET valeur= '$value' WHERE parametre = 'footer'");
} else {
spip_query("INSERT INTO spip_redcta_parametres(parametre, valeur) VALUES('footer', '$value')");
}
}
if ($_POST['action_form']=="404") {
$titre=addslashes($_POST['titre404']);
$texte=addslashes($_POST['texte404']);
if ($titre=="" && $texte=="") {
spip_query("DELETE FROM spip_redcta_parametres WHERE parametre='404'");
} else {
spip_query("INSERT INTO spip_redcta_parametres(parametre, valeur, valeur2) VALUES('404', '$titre', '$texte')");
spip_query("UPDATE spip_redcta_parametres SET valeur= '$titre', valeur2='$texte' WHERE parametre = '404'");
}
}
if ($_POST['action_form']=="metas") {
spip_query("DELETE FROM spip_redcta_parametres WHERE parametre LIKE '%metas'");
$metas = $_POST['metas'];
if (is_array($metas)) {
$i = 0;
foreach($metas as $meta) {
if ($meta['type'] && $meta['valeur']) {
$meta['valeur']=htmlspecialchars($meta['valeur'], ENT_QUOTES);
$meta['type']=htmlspecialchars($meta['type'], ENT_QUOTES);
spip_query("INSERT INTO spip_redcta_parametres (parametre, valeur, valeur2) VALUES ('".$i."metas', '".$meta['type']."', '".$meta['valeur']."')");
$i++;
}
}
}
}
foreach($_POST as $key => $value) {
if ($key=='theme') {
$value=addslashes($value);
$resultat=spip_query("SELECT * FROM spip_redcta_themeassoc WHERE id=0 AND type='rubrique'");
if (spip_mysql_count($resultat)) {
spip_query("UPDATE spip_redcta_themeassoc SET theme= '$value' WHERE id=0 AND type='rubrique'");
} else {
spip_query("INSERT INTO spip_redcta_themeassoc(id, type, theme) VALUES(0, 'rubrique', '$value')");
}
}
if ($key == 'bloc_reseau' || $key == 'logos_bailleurs') {
$value = addslashes($value);
$resultat = spip_query("SELECT * FROM spip_redcta_parametres WHERE parametre='$key'");
if (spip_mysql_count($resultat)) {
spip_query("UPDATE spip_redcta_parametres SET valeur = '$value' WHERE parametre='$key'");
} else {
spip_query("INSERT INTO spip_redcta_parametres(parametre, valeur) VALUES ('$key', '$value')");
}
}
}
}
function charger_parametres() {
$resultat= spip_query("SELECT * FROM spip_redcta_themeassoc WHERE id=0 AND type='rubrique'");
if (spip_mysql_count($resultat)) {
while ($row=spip_fetch_array($resultat)) {
$theme = $row['theme'];
}
} else {
$theme = "";
}
return $theme;
}
function charger_parametres_gen() {
$params=array();
$resultat= spip_query("SELECT * FROM spip_redcta_parametres");
if (spip_mysql_count($resultat)) {
while ($row=spip_fetch_array($resultat)) {
if (ereg("metas$",$row['parametre'])) {
$params["metas"][] = array("type" => $row['valeur'], "valeur" => $row['valeur2']);
} else {
$params[$row['parametre']] = $row['valeur'];
}
}
}
return $params;
}
function formulaire_bandeau()
{
echo "";
echo debut_cadre_trait_couleur(_DIR_PLUGIN_REDCTA."/images/uploadbandeau.png", true, "", _T('redcta:titre_upload_bandeau'));
echo "
"._T('redcta:intro_upload_bandeau')."
";
$bandeau_site = array(_DIR_IMG."/bandeau/bandeau-0.jpg",
_DIR_IMG."/bandeau/bandeau-0.png",
_DIR_IMG."/bandeau/bandeau-0.gif"
);
foreach($bandeau_site as $filePath)
{
if (file_exists($filePath) )
{
$bandeau_actuel = $filePath;
}
}
if($bandeau_actuel )
{
list($rWidth, $rHeight, $rType, $rAttr) = getimagesize($bandeau_actuel);
$ratioImg = image_ratio($rWidth,$rHeight,350,250);
echo "
";
}else{
# Formulaire à la mode CVT
$contexte = array('id_rubrique'=>0,'largeurMax'=>350,'hauteurMax'=>250);
echo recuperer_fond('prive/upload_bandeau', $contexte);
}
echo fin_cadre_trait_couleur(true);
echo "
";
}
function lister_associations()
{
if ($_GET['action'] == 'delete_assoc' && $_GET['id_check'] == $_SESSION['id_check']) {
$type = isset($_GET['type']) ? addslashes($_GET['type']) : false;
$id = isset($_GET['id']) ? (int) $_GET['id'] : false;
$theme = isset($_GET['theme']) ? addslashes($_GET['theme']) : false;
if ($type && $id && $theme) {
spip_query("DELETE FROM spip_redcta_themeassoc WHERE type='$type' AND id=$id AND theme='$theme'");
}
}
echo "";
$result = spip_query("SELECT * FROM spip_redcta_themeassoc WHERE type!='rubrique' OR id!=0");
if (spip_mysql_count($result) > 0) {
echo debut_cadre_couleur("doc-24.gif", true, "", _T('redcta:liste_assoc'));
echo "
";
while ($row = spip_fetch_array($result)){
echo "";
$type = $row['type'];
$id = $row['id'];
switch ($type) {
case "rubrique":
$rubrique = spip_fetch_array(spip_query("SELECT titre FROM spip_rubriques WHERE id_rubrique=$id"));
$titre = $rubrique['titre'];
break;
case "article":
$article = spip_fetch_array(spip_query("SELECT titre FROM spip_articles WHERE id_article=$id"));
$titre = $article['titre'];
break;
case "groupe":
$groupe = spip_fetch_array(spip_query("SELECT titre FROM spip_groupes_mots WHERE id_groupe=$id"));
$titre = $groupe['titre'];
break;
case "mot":
$mot = spip_fetch_array(spip_query("SELECT titre FROM spip_mots WHERE id_mot=$id"));
$titre = $mot['titre'];
break;
}
$theme = $row['theme'];
$nom_theme = ereg_replace("\|", " (", $theme);
$nom_theme = ereg_replace("\.css", ")", $nom_theme);
echo "$titre | ";
echo "$nom_theme | ";
echo " | ";
echo "
";
}
echo "
";
echo fin_cadre_couleur(true);
}
echo "
";
}
?>