X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=www%2Fplugins%2Fformidable%2Fechanger%2Fformulaire%2Fyaml.php;fp=www%2Fplugins%2Fformidable%2Fechanger%2Fformulaire%2Fyaml.php;h=475651587f72633b268c6efa2b57615200ef56fe;hb=c0f18416f529232b5555c6410a8765a5125ebcd3;hp=061f66d5b59b400ba30c22983dbd67695d2e3f11;hpb=50522c53acc9e61a4a7de3a1890c4ba93e2f61b4;p=lhc%2Fweb%2Fwww.git diff --git a/www/plugins/formidable/echanger/formulaire/yaml.php b/www/plugins/formidable/echanger/formulaire/yaml.php index 061f66d5..47565158 100644 --- a/www/plugins/formidable/echanger/formulaire/yaml.php +++ b/www/plugins/formidable/echanger/formulaire/yaml.php @@ -1,46 +1,48 @@ 0){ + + if ($id_formulaire > 0) { // On récupère le formulaire $formulaire = sql_fetsel( '*', 'spip_formulaires', 'id_formulaire = '.$id_formulaire ); - + // On décompresse les trucs sérialisés $formulaire['saisies'] = unserialize($formulaire['saisies']); $formulaire['traitements'] = unserialize($formulaire['traitements']); - + // On envode en yaml $export = yaml_encode($formulaire); } - - Header("Content-Type: text/x-yaml;"); + + Header('Content-Type: text/x-yaml;'); Header('Content-Disposition: attachment; filename=formulaire-'.$formulaire['identifiant'].'.yaml'); - Header("Content-Length: ".strlen($export)); + Header('Content-Length: '.strlen($export)); echo $export; exit(); } -function echanger_formulaire_yaml_importer_dist($fichier){ +function echanger_formulaire_yaml_importer_dist($fichier) { $yaml = ''; lire_fichier($fichier, $yaml); // Si on a bien recupere une chaine on tente de la decoder - if ($yaml){ + if ($yaml) { include_spip('inc/yaml'); $formulaire = yaml_decode($yaml); // Si le decodage marche on importe alors le contenu - if (is_array($formulaire)){ + if (is_array($formulaire)) { include_spip('action/editer_formulaire'); // On enlève les champs inutiles unset($formulaire['id_formulaire']); @@ -50,32 +52,29 @@ function echanger_formulaire_yaml_importer_dist($fichier){ 'spip_formulaires', 'identifiant = '.sql_quote($formulaire['identifiant']) ); - if ($deja){ + if ($deja) { $formulaire['identifiant'] .= '_'.date('Ymd_His'); } - + // On insère un nouveau formulaire $id_formulaire = formulaire_inserer(); // Si ça a marché on transforme les tableaux et on modifie les champs - if ($id_formulaire > 0){ - if (is_array($formulaire['saisies'])){ + if ($id_formulaire > 0) { + if (is_array($formulaire['saisies'])) { $formulaire['saisies'] = serialize($formulaire['saisies']); } - if (is_array($formulaire['traitements'])){ + if (is_array($formulaire['traitements'])) { $formulaire['traitements'] = serialize($formulaire['traitements']); } - + $erreur = formulaire_modifier($id_formulaire, $formulaire); } } } - - if ($id_formulaire and !$erreur){ + + if ($id_formulaire and !$erreur) { return $id_formulaire; - } - else{ + } else { return _T('formidable:erreur_importer_yaml').' : '.$erreur; } } - -?>