Changeset 61818 in spip-zone


Ignore:
Timestamp:
May 29, 2012, 2:04:20 PM (7 years ago)
Author:
olivier.gautier@…
Message:

Mise à jour du module de Sauvegarde/Restauration? d'habillage pour SPIP 3

Location:
_squelettes_/eva-web/4_2/eva_habillage/formulaires
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • _squelettes_/eva-web/4_2/eva_habillage/formulaires/evahabillage_sauvegarde.html

    r61805 r61818  
    1919</fieldset>
    2020
     21<?php
     22        $test_presence = sql_select('nom','spip_eva_habillage_themes',"nom != 'Defaut'",'','nom');
     23    $tab_presence = sql_fetch($test_presence);
     24        if ($tab_presence!='') {
     25?>
    2126<h3 class='titrem'><:evahabillage:eva_etape4_restaurer:></h3>
    2227<p>
     28<select name="restaurer_habillage">
     29<?php
     30        $resultat_sauvegarde1 = sql_select('nom','spip_eva_habillage_themes',"nom != 'Defaut'",'','nom');
     31    while ($tab = sql_fetch($resultat_sauvegarde1)) echo '<option value="'.$tab['nom'].'">'.$tab['nom'].'</option>';
     32?>
     33</select>
     34</p>
     35<p style="text-align:center;">
    2336<input type="submit" class="submit" name="sauvegarder" value="<:evahabillage:eva_restaurer:>" />
    2437</p>
     
    2639<h3 class='titrem'><:evahabillage:eva_etape4_supprimer:></h3>
    2740<p>
     41<select name="supprimer_habillage">
     42<?php
     43        $resultat_sauvegarde2 = sql_select('nom','spip_eva_habillage_themes',"nom != 'Defaut'",'','nom');
     44    while ($tab = sql_fetch($resultat_sauvegarde2)) echo '<option value="'.$tab['nom'].'">'.$tab['nom'].'</option>';
     45?>
     46</select>
     47</p>
     48<p style="text-align:center;">
    2849<input type="submit" class="submit" name="sauvegarder" value="<:evahabillage:eva_supprimer:>" />
    2950</p>
     51<?php
     52}
     53?>
    3054</form>
    3155</div>
  • _squelettes_/eva-web/4_2/eva_habillage/formulaires/evahabillage_sauvegarde.php

    r61805 r61818  
    3535                $nom_sauvegarde=_request('sauvegarde_habillage');
    3636                echo $nom_sauvegarde;
    37                 /*
    3837        $nom_habillage_defaut=sql_select("habillage","spip_eva_habillage","sauvegarde = 'Defaut'");
    3938        $tab_habillage_defaut=sql_fetch($nom_habillage_defaut);
     
    4443                $result_valeurs=sql_select("*","spip_eva_habillage_themes","nom='Defaut'");
    4544        $tab_valeurs=sql_fetch($result_valeurs);
     45                include_spip("inc/eva_habillage_definition_themes");
     46                $def_themes = eva_habillage_definition_themes ();
    4647        foreach($def_themes as $habillage_cles => $habillage_inutile) {sql_updateq('spip_eva_habillage_themes',array($habillage_cles => $tab_valeurs[$habillage_cles]),"nom='".mysql_real_escape_string($nom_sauvegarde)."'");}
    4748        sql_delete("spip_eva_habillage_images","nom_habillage='".mysql_real_escape_string($nom_sauvegarde)."'");
     
    4950        while ($tab=sql_fetch($result_images_sauve)) {
    5051            sql_insertq("spip_eva_habillage_images",array('type' => $tab['type'],'nom_habillage' => mysql_real_escape_string($nom_sauvegarde),'nom_div' => $tab['nom_div'], 'nom_image' => $tab['nom_image'], 'pos_x' => $tab['pos_x'],'pos_y' => $tab['pos_y'],'repetition' => $tab['repetition'], 'attach' => $tab['attach']));
    51                         }
    52                 */
     52                }
     53        }
     54        elseif ((_request('sauvegarder')=='Restaurer') AND (_request('restaurer_habillage')!='Defaut')) {
     55                $nom_sauvegarde=_request('restaurer_habillage');
     56                $recherche_habillage_restaure = sql_select('habillage','spip_eva_habillage',"sauvegarde='".mysql_escape_string($nom_sauvegarde)."'");
     57        $tab__habillage_restaure = sql_fetch($recherche_habillage_restaure);
     58        sql_updateq('spip_eva_habillage',array('habillage' => $tab__habillage_restaure['habillage']),"sauvegarde='Defaut'");
     59       
     60        sql_delete('spip_eva_habillage_images',"nom_habillage='Defaut'");
     61        $recherche_images_restaure=sql_select('type,nom_div,nom_image,pos_x,pos_y,repetition,attach','spip_eva_habillage_images',"nom_habillage='".mysql_escape_string($nom_sauvegarde)."'");
     62        while ($tab=sql_fetch($recherche_images_restaure)) {
     63                sql_insertq('spip_eva_habillage_images',array('type' => $tab['type'],'nom_habillage' => 'Defaut','nom_div' => $tab['nom_div'],'nom_image' => $tab['nom_image'],'pos_x' => $tab['pos_x'],'pos_y' => $tab['pos_y'],'repetition' => $tab['repetition'],'attach' => $tab['attach']));
     64        }
     65       
     66        $result_restaure=sql_select('*','spip_eva_habillage_themes',"nom='".mysql_escape_string($nom_sauvegarde)."'");
     67        $tab_restaure=sql_fetch($result_restaure);
     68                include_spip("inc/eva_habillage_definition_themes");
     69                $def_themes = eva_habillage_definition_themes ();
     70        foreach($def_themes as $habillage_cles => $habillage_inutile) {
     71            if (isset($tab_restaure[$habillage_cles])) {sql_updateq('spip_eva_habillage_themes',array($habillage_cles => $tab_restaure[$habillage_cles]),"nom='Defaut'");}
     72            else {sql_updateq('spip_eva_habillage_themes',array($habillage_cles => ''),"nom='Defaut'");}
     73        }
     74                include_spip('inc/eva_habillage_transition_module');
     75                eva_habillage_transition_module();
     76        }
     77        elseif ((_request('sauvegarder')=='Supprimer ?') AND (_request('supprimer_habillage')!='Defaut')) {
     78                $nom_sauvegarde=_request('supprimer_habillage');
     79                sql_delete("spip_eva_habillage","sauvegarde='".mysql_escape_string($nom_sauvegarde)."'");
     80        sql_delete("spip_eva_habillage_themes","nom='".mysql_escape_string($nom_sauvegarde)."'");
     81        sql_delete("spip_eva_habillage_images","nom_habillage='".mysql_escape_string($nom_sauvegarde)."'");
    5382        }
    5483        $res['message_ok'] = _T('config_info_enregistree');
Note: See TracChangeset for help on using the changeset viewer.