diff --git a/.gitattributes b/.gitattributes index 898d6063a3f872873f1886e1e2d1ab7c4f27f411..26682b344a7fc87bcb31763a9e1d198f828f6ca9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,9 +1,7 @@ * text=auto !eol action/dupliquer_formulaire.php -text action/editer_formulaire.php -text -action/exporter_analyse_reponses.php -text action/exporter_formulaire.php -text -action/exporter_formulaires_reponses.php -text action/supprimer_formulaire.php -text action/supprimer_formulaires_reponse.php -text action/vider_formulaire.php -text @@ -25,6 +23,10 @@ formulaires/editer_formulaire_champs.html -text formulaires/editer_formulaire_champs.php -text formulaires/editer_formulaire_traitements.html -text formulaires/editer_formulaire_traitements.php -text +formulaires/exporter_formulaire_analyse.html -text +formulaires/exporter_formulaire_analyse.php -text +formulaires/exporter_formulaire_reponses.html -text +formulaires/exporter_formulaire_reponses.php -text formulaires/formidable.html -text formulaires/formidable.php -text formulaires/importer_formulaire.html -text diff --git a/formulaires/exporter_formulaire_analyse.html b/formulaires/exporter_formulaire_analyse.html new file mode 100644 index 0000000000000000000000000000000000000000..65d3bb2a35934148a7a6a0783e75696d79fc6d03 --- /dev/null +++ b/formulaires/exporter_formulaire_analyse.html @@ -0,0 +1,29 @@ +[(#SET{type_export, #ARRAY{csv,<:formidable:reponses_exporter_format_csv:>,xls,<:formidable:reponses_exporter_format_xsl:>}})] + +<div class="formulaire_spip formulaire_#ENV{form}[ formulaire_#ENV{form}-(#ENV{id})]"> + <h3 class="titrem"> + [(#CHEMIN{images/formulaire-analyse-24.png}|balise_img{horizontale})] + <:formidable:analyse_exporter:></h3> + [<p class="reponse_formulaire reponse_formulaire_ok">(#ENV*{message_ok})</p>] + [<p class="reponse_formulaire reponse_formulaire_erreur">(#ENV*{message_erreur})</p>] + + [(#ENV{editable}|oui) + <form method="post" action="#ENV{action}"><div> + #ACTION_FORMULAIRE{#ENV{action}} + <input type="hidden" name="id_formulaire" value="#ID_FORMULAIRE" /> + <ul> + [(#SAISIE{selection, type_export, + label=<:formidable:exporter_formulaire_format_label:>, + datas=#GET{type_export}, + defaut=csv, + cacher_option_intro=oui})] + </ul> + + + [(#REM) ajouter les saisies supplementaires : extra et autre, a cet endroit ] + <!--extra--> + + <p class="boutons"><span class="image_loading"></span><input type="submit" class="submit" value="<:bouton_telecharger:>" /></p> + </div></form> + ] +</div> diff --git a/action/exporter_analyse_reponses.php b/formulaires/exporter_formulaire_analyse.php old mode 100755 new mode 100644 similarity index 78% rename from action/exporter_analyse_reponses.php rename to formulaires/exporter_formulaire_analyse.php index a4e7e923fe279fd1779a7469fd5f03cb5a2a0f2b..70baae570eabd0c879427b9372550c65ee7f7efb --- a/action/exporter_analyse_reponses.php +++ b/formulaires/exporter_formulaire_analyse.php @@ -3,21 +3,44 @@ // Sécurité if (!defined("_ECRIRE_INC_VERSION")) return; +include_spip('inc/formidable'); +include_spip('inc/config'); + +function formulaires_exporter_formulaire_analyse_charger($id_formulaire=0){ + $contexte = array(); + $contexte['id_formulaire'] = intval($id_formulaire); + return $contexte; +} + +function formulaires_exporter_formulaire_analyse_verifier($id_formulaire=0){ + $erreurs = array(); + + return $erreurs; +} + +function formulaires_exporter_formulaire_analyse_traiter($id_formulaire=0){ + $retours = array(); + + if (_request('type_export')=='csv') + action_exporter_analyse_reponses($id_formulaire); + else if (_request('type_export')=='xls') + action_exporter_analyse_reponses($id_formulaire,"TAB"); + + return $retours; +} + + /* - * Exporter l'analyse des réponses d'un formulaire - * @param unknown_type $arg + * Exporter les analyses d'un formulaire (anciennement action/exporter_analyse_reponses_dist) + * @param integer $id_formulaire * @return unknown_type */ -function action_exporter_analyse_reponses_dist($arg=null) { - if (is_null($arg)){ - $securiser_action = charger_fonction('securiser_action', 'inc'); - $arg = $securiser_action(); - } - +function action_exporter_analyse_reponses($id_formulaire,$delim=",") { + // on ne fait des choses seulements si le formulaire existe et qu'il a des enregistrements $ok = false; if ( - $id_formulaire = intval($arg) + $id_formulaire > 0 and $formulaire = sql_fetsel('*','spip_formulaires','id_formulaire = '.$id_formulaire) and $reponses = sql_allfetsel('*', 'spip_formulaires_reponses', 'id_formulaire = '.$id_formulaire.' and statut = '.sql_quote('publie')) ) { @@ -99,10 +122,9 @@ function action_exporter_analyse_reponses_dist($arg=null) { } if ($reponses_completes and $exporter_csv = charger_fonction('exporter_csv', 'inc/', true)){ - $exporter_csv('analyses-formulaire-'.$formulaire['identifiant'], $reponses_completes); + $exporter_csv('analyses-formulaire-'.$formulaire['identifiant'], $reponses_completes, $delim); exit(); } } } - ?> diff --git a/formulaires/exporter_formulaire_reponses.html b/formulaires/exporter_formulaire_reponses.html new file mode 100644 index 0000000000000000000000000000000000000000..44302556f897be277a2d985ab9da580a10cbca21 --- /dev/null +++ b/formulaires/exporter_formulaire_reponses.html @@ -0,0 +1,29 @@ +[(#SET{type_export, #ARRAY{csv,<:formidable:reponses_exporter_format_csv:>,xls,<:formidable:reponses_exporter_format_xsl:>}})] + +<div class="formulaire_spip formulaire_#ENV{form}[ formulaire_#ENV{form}-(#ENV{id})]"> + <h3 class="titrem"> + [(#CHEMIN{images/formulaire-reponses-exporter-24.png}|balise_img{horizontale})] + <:formidable:reponses_exporter:></h3> + [<p class="reponse_formulaire reponse_formulaire_ok">(#ENV*{message_ok})</p>] + [<p class="reponse_formulaire reponse_formulaire_erreur">(#ENV*{message_erreur})</p>] + + [(#ENV{editable}|oui) + <form method="post" action="#ENV{action}"><div> + #ACTION_FORMULAIRE{#ENV{action}} + <input type="hidden" name="id_formulaire" value="#ID_FORMULAIRE" /> + <ul> + [(#SAISIE{selection, type_export, + label=<:formidable:exporter_formulaire_format_label:>, + datas=#GET{type_export}, + defaut=csv, + cacher_option_intro=oui})] + </ul> + + + [(#REM) ajouter les saisies supplementaires : extra et autre, a cet endroit ] + <!--extra--> + + <p class="boutons"><span class="image_loading"></span><input type="submit" class="submit" value="<:bouton_telecharger:>" /></p> + </div></form> + ] +</div> diff --git a/action/exporter_formulaires_reponses.php b/formulaires/exporter_formulaire_reponses.php similarity index 71% rename from action/exporter_formulaires_reponses.php rename to formulaires/exporter_formulaire_reponses.php index c0a71eb9105acb4d75444303561ae7c471aad3c1..98b20b0464064f64e07e2c227e071053e198dea1 100644 --- a/action/exporter_formulaires_reponses.php +++ b/formulaires/exporter_formulaire_reponses.php @@ -3,21 +3,44 @@ // Sécurité if (!defined("_ECRIRE_INC_VERSION")) return; +include_spip('inc/formidable'); +include_spip('inc/config'); + +function formulaires_exporter_formulaire_reponses_charger($id_formulaire=0){ + $contexte = array(); + $contexte['id_formulaire'] = intval($id_formulaire); + return $contexte; +} + +function formulaires_exporter_formulaire_reponses_verifier($id_formulaire=0){ + $erreurs = array(); + + return $erreurs; +} + +function formulaires_exporter_formulaire_reponses_traiter($id_formulaire=0){ + $retours = array(); + + if (_request('type_export')=='csv') + exporter_formulaires_reponses($id_formulaire); + else if (_request('type_export')=='xls') + exporter_formulaires_reponses($id_formulaire,"TAB"); + + return $retours; +} + + /* - * Exporter toutes les réponses d'un formulaire - * @param unknown_type $arg + * Exporter toutes les réponses d'un formulaire (anciennement action/exporter_formulaire_reponses) + * @param integer $id_formulaire * @return unknown_type */ -function action_exporter_formulaires_reponses_dist($arg=null) { - if (is_null($arg)){ - $securiser_action = charger_fonction('securiser_action', 'inc'); - $arg = $securiser_action(); - } +function exporter_formulaires_reponses($id_formulaire,$delim=",") { // on ne fait des choses seulements si le formulaire existe et qu'il a des enregistrements $ok = false; if ( - $id_formulaire = intval($arg) + $id_formulaire > 0 and $formulaire = sql_fetsel('*','spip_formulaires','id_formulaire = '.$id_formulaire) and $reponses = sql_allfetsel('*', 'spip_formulaires_reponses', 'id_formulaire = '.$id_formulaire.' and statut = '.sql_quote('publie')) ) { @@ -76,10 +99,9 @@ function action_exporter_formulaires_reponses_dist($arg=null) { } if ($reponses_completes and $exporter_csv = charger_fonction('exporter_csv', 'inc/', true)){ - $exporter_csv('reponses-formulaire-'.$formulaire['identifiant'], $reponses_completes); + $exporter_csv('reponses-formulaire-'.$formulaire['identifiant'], $reponses_completes,$delim); exit(); } } -} - +} ?> diff --git a/lang/formidable_fr.php b/lang/formidable_fr.php index ee9d335dcd407d74f1c435d92b4eff2ee18a5ed4..59b37c372a718d4b080a12e34eb03d32a7c95f6e 100644 --- a/lang/formidable_fr.php +++ b/lang/formidable_fr.php @@ -74,6 +74,7 @@ $GLOBALS[$GLOBALS['idx_lang']] = array( 'erreur_importer_wcs' => 'Erreur durant l’importation du formulaire W.C.S', 'erreur_importer_yaml' => 'Erreur durant l’importation du fichier YAML', 'erreur_inexistant' => 'Le formulaire n’existe pas.', + 'exporter_formulaire_format_label' => 'Format du fichier', // F 'formulaire_anonyme_explication' => 'Ce formulaire est anonyme, c’est à dire que l’identité de l’utilisateur n’est pas enregistrée.', @@ -132,6 +133,9 @@ $GLOBALS[$GLOBALS['idx_lang']] = array( 'reponses_anonyme' => 'Anonyme', 'reponses_auteur' => 'Utilisateur', 'reponses_exporter' => 'Exporter les réponses', + 'reponses_exporter_format_csv' => 'Tableur .CSV', + 'reponses_exporter_format_xsl' => 'Excel .XSL', + 'reponses_exporter_telecharger' => 'Télécharger', 'reponses_ip' => 'Adresse IP', 'reponses_liste' => 'Liste des réponses', 'reponses_liste_prop' => 'Réponses en attente de validation', diff --git a/paquet.xml b/paquet.xml index a543e3ea9d3534538e9d3f24d53c5b6bc69cb93c..0d3dbb7530d2487db1468d31eb4838606b1e4bac 100644 --- a/paquet.xml +++ b/paquet.xml @@ -1,7 +1,7 @@ <paquet prefix="formidable" categorie="communication" - version="2.8.6" + version="2.8.7" etat="stable" compatibilite="[3.0.0;3.0.*]" logo="images/formidable-64.png" diff --git a/prive/squelettes/extra/formulaires_analyse.html b/prive/squelettes/extra/formulaires_analyse.html index 6c2c0208e66aaa5784fe4433d1f894616cb7047b..5e4aeca666dcf14eb780002247e631c13a4bab42 100755 --- a/prive/squelettes/extra/formulaires_analyse.html +++ b/prive/squelettes/extra/formulaires_analyse.html @@ -1,8 +1,7 @@ <BOUCLE_formulaire(FORMULAIRES){id_formulaire}{tout}> <BOUCLE_autoriser(CONDITION){si #AUTORISER{voir, formulaires_analyse}}> [(#BOITE_OUVRIR{<:formidable:titre_cadre_raccourcis:>,'info'})] -[(#URL_ACTION_AUTEUR{exporter_analyse_reponses,#ID_FORMULAIRE} - |icone_horizontale{<:formidable:analyse_exporter:>,formulaire-analyse-24})] +#FORMULAIRE_EXPORTER_FORMULAIRE_ANALYSE{#ID_FORMULAIRE} #BOITE_FERMER </BOUCLE_autoriser> </BOUCLE_formulaire> diff --git a/prive/squelettes/extra/formulaires_reponses.html b/prive/squelettes/extra/formulaires_reponses.html index b0719a307e177ce66fedbc16e1a94b8aadaabce0..b5673694eabf07c33d634adacb726659314f8381 100644 --- a/prive/squelettes/extra/formulaires_reponses.html +++ b/prive/squelettes/extra/formulaires_reponses.html @@ -3,8 +3,7 @@ [(#GET{ouvre_boite}|oui)[(#BOITE_OUVRIR{<:formidable:titre_cadre_raccourcis:>,'info'})]] <BOUCLE_autoriser_1(CONDITION){si #AUTORISER{voir, formulaires_reponse}}> -[(#URL_ACTION_AUTEUR{exporter_formulaires_reponses,#ID_FORMULAIRE} - |icone_horizontale{<:formidable:reponses_exporter:>,formulaire,formulaire-reponses-exporter-24,center})] +#FORMULAIRE_EXPORTER_FORMULAIRE_REPONSES{#ID_FORMULAIRE} </BOUCLE_autoriser_1> <BOUCLE_autoriser_2(CONDITION){si #AUTORISER{editer, formulaires,#ID_FORMULAIRE}}>