diff --git a/sondage/enum.json b/sondage/enum.json new file mode 100644 index 0000000..84d4e02 --- /dev/null +++ b/sondage/enum.json @@ -0,0 +1 @@ +{"name":"sondage","realName":"Sondage","version":"1.2","update":"0.0","delete":true,"dataDirectory":""} \ No newline at end of file diff --git a/sondage/sondage.php b/sondage/sondage.php new file mode 100644 index 0000000..88a0078 --- /dev/null +++ b/sondage/sondage.php @@ -0,0 +1,426 @@ + + * @copyright Copyright (C) 2008-2018, Rémi Jean + * @author Frédéric Tempez + * @copyright Copyright (C) 2018-2020, Frédéric Tempez + * @license GNU General Public License, version 3 + * @link http://zwiicms.com/ + */ + + +class sondage extends common { + + const VERSION = '1.2'; + const REALNAME = 'Sondage'; + const DELETE = true; + const UPDATE = '0.0'; + const DATADIRECTORY = ''; // Contenu localisé inclus par défaut (page.json et module.json) + + public static $actions = [ + 'config' => self::GROUP_MODERATOR, + 'data' => self::GROUP_MODERATOR, + 'result' => self::GROUP_VISITOR, + 'delete' => self::GROUP_MODERATOR, + 'deleteall' => self::GROUP_MODERATOR, + 'index' => self::GROUP_VISITOR, + 'export2csv' => self::GROUP_MODERATOR, + 'output2csv' => self::GROUP_MODERATOR + ]; + + public static $data = []; + + public static $pages = []; + + public static $pagination; + + const TYPE_MAIL = 'mail'; + const TYPE_SELECT = 'select'; + const TYPE_TEXT = 'text'; + const TYPE_TEXTAREA = 'textarea'; + const TYPE_DATETIME = "date"; + const TYPE_CHECKBOX = "checkbox"; + + + public static $types = [ + self::TYPE_TEXT => 'Champ texte', + self::TYPE_TEXTAREA => 'Grand champ texte', + self::TYPE_MAIL => 'Champ mail', + self::TYPE_SELECT => 'Sélection', + self::TYPE_DATETIME => 'Date', + self::TYPE_CHECKBOX => 'Case à cocher' + ]; + // Nombre d'objets par page + public static $itemsList = [ + 6 => '6 réponses', + 9 => '9 réponses', + 18 => '18 réponses' + ]; + + public static $listUsers = [ + ]; + + /** + * Configuration + */ + public function config() { + // Liste des utilisateurs + $userIdsFirstnames = helper::arraycollumn($this->getData(['user']), 'firstname'); + ksort($userIdsFirstnames); + self::$listUsers [] = ''; + foreach($userIdsFirstnames as $userId => $userFirstname) { + self::$listUsers [] = $userId; + } + // Soumission du formulaire + if($this->isPost()) { + // Configuration + // Option sélectionnée sans page choisie + $this->setData([ + 'module', + $this->getUrl(0), + 'config', + [ + 'button' => $this->getInput('formConfigButton'), + 'capcha' => $this->getInput('formConfigCapcha', helper::FILTER_BOOLEAN), + 'group' => $this->getInput('formConfigGroup', helper::FILTER_INT), + 'user' => self::$listUsers [$this->getInput('formConfigUser', helper::FILTER_INT)], + 'mail' => $this->getInput('formConfigMail') , + 'pageId' => $this->getInput('formConfigPageIdToggle', helper::FILTER_BOOLEAN) === true ? $this->getInput('formConfigPageId', helper::FILTER_ID) : '', + 'subject' => $this->getInput('formConfigSubject'), + 'itemsperPage' => $this->getInput('formConfigItemsperPage', helper::FILTER_INT) + ] + ]); + // Génération des données vides + $this->setData(['module', $this->getUrl(0), 'data', []]); + // Génération des champs + $inputs = []; + foreach($this->getInput('formConfigPosition', null) as $index => $position) { + $inputs[] = [ + 'name' => $this->getInput('formConfigName[' . $index . ']'), + 'position' => helper::filter($position, helper::FILTER_INT), + 'required' => $this->getInput('formConfigRequired[' . $index . ']', helper::FILTER_BOOLEAN), + 'type' => $this->getInput('formConfigType[' . $index . ']'), + 'values' => $this->getInput('formConfigValues[' . $index . ']') + ]; + } + $this->setData(['module', $this->getUrl(0), 'input', $inputs]); + // Valeurs en sortie + $this->addOutput([ + 'notification' => 'Modifications enregistrées', + 'redirect' => helper::baseUrl() . $this->getUrl(), + 'state' => true + ]); + } + // Liste des pages + foreach($this->getHierarchy(null, false) as $parentPageId => $childrenPageIds) { + self::$pages[$parentPageId] = $this->getData(['page', $parentPageId, 'title']); + foreach($childrenPageIds as $childKey) { + self::$pages[$childKey] = '    ' . $this->getData(['page', $childKey, 'title']); + } + } + // Valeurs en sortie + $this->addOutput([ + 'title' => 'Configuration du module', + 'vendor' => [ + 'html-sortable', + 'flatpickr' + ], + 'view' => 'config' + ]); + } + + /** + * Données enregistrées + */ + public function data() { + $data = $this->getData(['module', $this->getUrl(0), 'data']); + if(is_array($data)) { + // Pagination + $pagination = helper::pagination($data, $this->getUrl(),$this->getData(['module', $this->getUrl(0),'config', 'itemsperPage'])); + // Liste des pages + self::$pagination = $pagination['pages']; + // Inverse l'ordre du tableau + $dataIds = array_reverse(array_keys($data)); + $data = array_reverse($data); + // Données en fonction de la pagination + for($i = $pagination['first']; $i < $pagination['last']; $i++) { + $content = ''; + foreach($data[$i] as $input => $value) { + $content .= $input . ' : ' . $value . '
'; + } + self::$data[] = [ + $content, + template::button('formDataDelete' . $dataIds[$i], [ + 'class' => 'formDataDelete red', + 'href' => helper::baseUrl() . $this->getUrl(0) . '/delete/' . $dataIds[$i] . '/' . $_SESSION['csrf'], + 'value' => template::ico('cancel') + ]) + ]; + } + } + // Valeurs en sortie + $this->addOutput([ + 'title' => 'Données enregistrées', + 'view' => 'data' + ]); + } + + /** + * Réponses enregistrées + */ + public function result() { + $data = $this->getData(['module', $this->getUrl(0), 'data']); + if($data) { + // Pagination + $pagination = helper::pagination($data, $this->getUrl(),$this->getData(['module', $this->getUrl(0),'config', 'itemsperPage'])); + // Liste des pages + self::$pagination = $pagination['pages']; + // Inverse l'ordre du tableau + $dataIds = array_reverse(array_keys($data)); + $data = array_reverse($data); + // Données en fonction de la pagination + for($i = $pagination['first']; $i < $pagination['last']; $i++) { + $content = ''; + foreach($data[$i] as $input => $value) { + $content .= $input . ' : ' . $value . '
'; + } + self::$data[] = [ + $content + ]; + } + } + // Valeurs en sortie + $this->addOutput([ + 'title' => 'Réponses', + 'view' => 'result' + ]); + } + + /** + * Export CSV + * @author Frédéric Tempez + * @copyright Copyright (C) 2018-2020, Frédéric Tempez + */ + public function export2csv() { + // Jeton incorrect + if ($this->getUrl(2) !== $_SESSION['csrf']) { + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/data', + 'notification' => 'Action interdite' + ]); + } else { + $data = $this->getData(['module', $this->getUrl(0), 'data']); + if ($data !== []) { + $csvfilename = 'data-'.date('dmY').'-'.date('hm').'-'.rand(10,99).'.csv'; + if (!file_exists(self::FILE_DIR.'source/data')) { + mkdir(self::FILE_DIR.'source/data', 0755); + } + $fp = fopen(self::FILE_DIR.'source/data/'.$csvfilename, 'w'); + fputcsv($fp, array_keys($data[1]), ';','"'); + foreach ($data as $fields) { + fputcsv($fp, $fields, ';','"'); + } + fclose($fp); + // Valeurs en sortie + $this->addOutput([ + 'notification' => 'Export CSV effectué dans le gestionnaire de fichiers
sous le nom '.$csvfilename, + 'redirect' => helper::baseUrl() . $this->getUrl(0) .'/data', + 'state' => true + ]); + } else { + $this->addOutput([ + 'notification' => 'Aucune donnée à exporter', + 'redirect' => helper::baseUrl() . $this->getUrl(0) .'/data' + ]); + } + } + } + + + /** + * Suppression + */ + public function deleteall() { + // Jeton incorrect + if ($this->getUrl(2) !== $_SESSION['csrf']) { + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/data', + 'notification' => 'Action interdite' + ]); + } else { + $data = ($this->getData(['module', $this->getUrl(0), 'data'])); + if (count($data) > 0 ) { + // Suppression multiple + for ($i = 1; $i <= count($data) ; $i++) { + echo $this->deleteData(['module', $this->getUrl(0), 'data', $i]); + } + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/data', + 'notification' => 'Données supprimées', + 'state' => true + ]); + } else { + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/data', + 'notification' => 'Aucune donnée à supprimer' + ]); + } + } + } + + + /** + * Suppression + */ + public function delete() { + // Jeton incorrect + if ($this->getUrl(3) !== $_SESSION['csrf']) { + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/data', + 'notification' => 'Action interdite' + ]); + } else { + // La donnée n'existe pas + if($this->getData(['module', $this->getUrl(0), 'data', $this->getUrl(2)]) === null) { + // Valeurs en sortie + $this->addOutput([ + 'access' => false + ]); + } + // Suppression + else { + $this->deleteData(['module', $this->getUrl(0), 'data', $this->getUrl(2)]); + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/data', + 'notification' => 'Donnée supprimée', + 'state' => true + ]); + } + } + } + + + + + /** + * Accueil + */ + public function index() { + // Soumission du formulaire + if($this->isPost()) { + // Check la capcha + if( + $this->getData(['module', $this->getUrl(0), 'config', 'capcha']) + AND $this->getInput('formCapcha', helper::FILTER_INT) !== $this->getInput('formCapchaFirstNumber', helper::FILTER_INT) + $this->getInput('formCapchaSecondNumber', helper::FILTER_INT)) + { + self::$inputNotices['formCapcha'] = 'Incorrect'; + + } + // Préparation le contenu du mail + $data = []; + $content = ''; + foreach($this->getData(['module', $this->getUrl(0), 'input']) as $index => $input) { + // Filtre la valeur + switch($input['type']) { + case self::TYPE_MAIL: + $filter = helper::FILTER_MAIL; + break; + case self::TYPE_TEXTAREA: + $filter = helper::FILTER_STRING_LONG; + break; + case self::TYPE_DATETIME: + $filter = helper::FILTER_STRING_SHORT; // Mettre TYPE_DATETIME pour récupérer un TIMESTAMP + break; + CASE self::TYPE_CHECKBOX: + $filter = helper::FILTER_BOOLEAN; + break; + default: + $filter = helper::FILTER_STRING_SHORT; + } + $value = $this->getInput('formInput[' . $index . ']', $filter, $input['required']); + // Préparation des données pour la création dans la base + $data[$this->getData(['module', $this->getUrl(0), 'input', $index, 'name'])] = $value; + // Préparation des données pour le mail + $content .= '' . $this->getData(['module', $this->getUrl(0), 'input', $index, 'name']) . ' : ' . $value . '
'; + } + // Crée les données + $this->setData(['module', $this->getUrl(0), 'data', helper::increment(1, $this->getData(['module', $this->getUrl(0), 'data'])), $data]); + // Envoi du mail + // Rechercher l'adresse en fonction du mail + $sent = true; + $singleuser = $this->getData(['user', + $this->getData(['module', $this->getUrl(0), 'config', 'user']), + 'mail']); + $singlemail = $this->getData(['module', $this->getUrl(0), 'config', 'mail']); + $group = $this->getData(['module', $this->getUrl(0), 'config', 'group']); + // Verification si le mail peut être envoyé + if( + self::$inputNotices === [] && ( + $group > 0 || + $singleuser !== '' || + $singlemail !== '' ) + ) { + // Utilisateurs dans le groupe + $to = []; + if ($group > 0){ + foreach($this->getData(['user']) as $userId => $user) { + if($user['group'] >= $group) { + $to[] = $user['mail']; + } + } + } + // Utilisateur désigné + if (!empty($singleuser)) { + $to[] = $singleuser; + } + // Mail désigné + if (!empty($singlemail)) { + $to[] = $singlemail; + } + if($to) { + // Sujet du mail + $subject = $this->getData(['module', $this->getUrl(0), 'config', 'subject']); + if($subject === '') { + $subject = 'Nouveau message en provenance de votre site'; + } + // Envoi le mail + $sent = $this->sendMail( + $to, + $subject, + 'Nouveau message en provenance de la page "' . $this->getData(['page', $this->getUrl(0), 'title']) . '" :

' . + $content + ); + } + } + // Redirection + $redirect = $this->getData(['module', $this->getUrl(0), 'config', 'pageId']); + // Valeurs en sortie + $this->addOutput([ + 'notification' => ($sent === true ? 'Formulaire soumis' : $sent), + 'redirect' => $redirect ? helper::baseUrl() . $redirect : '', + 'state' => ($sent === true ? true : null) + ]); + } + // Valeurs en sortie + $this->addOutput([ + 'showBarEditButton' => true, + 'showPageContent' => true, + 'view' => 'index', + 'vendor' => [ + 'flatpickr' + ], + ]); + } +} \ No newline at end of file diff --git a/sondage/vendor/html-sortable/html-sortable.min.js b/sondage/vendor/html-sortable/html-sortable.min.js new file mode 100644 index 0000000..9a96985 --- /dev/null +++ b/sondage/vendor/html-sortable/html-sortable.min.js @@ -0,0 +1 @@ +!function(e,t){"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?module.exports=t():e.sortable=t()}(this,function(){"use strict";function e(e,t,n){var r=null;return 0===t?e:function(){var a=n||this,o=arguments;clearTimeout(r),r=setTimeout(function(){e.apply(a,o)},t)}}var t,n,r,a=[],o=[],i=function(e,t,n){return void 0===n?e&&e.h5s&&e.h5s.data&&e.h5s.data[t]:(e.h5s=e.h5s||{},e.h5s.data=e.h5s.data||{},e.h5s.data[t]=n,void 0)},s=function(e){e.h5s&&delete e.h5s.data};switch(!0){case"matches"in window.Element.prototype:r="matches";break;case"mozMatchesSelector"in window.Element.prototype:r="mozMatchesSelector";break;case"msMatchesSelector"in window.Element.prototype:r="msMatchesSelector";break;case"webkitMatchesSelector"in window.Element.prototype:r="webkitMatchesSelector"}var l=function(e,t){if(!t)return Array.prototype.slice.call(e);for(var n=[],a=0;an){var c=o-n,f=p(e).top;if(id&&r>f+o-c)return}void 0===t.oldDisplay&&(t.oldDisplay=t.style.display),t.style.display="none",i + * @copyright Copyright (C) 2008-2018, Rémi Jean + * @author Frédéric Tempez + * @copyright Copyright (C) 2018-2020, Frédéric Tempez + * @license GNU General Public License, version 3 + * @link http://zwiicms.fr/ + */ + + +/** NE PAS EFFACER +* admin.css +*/ + + +.formConfigInput { + background: #FFF; +} \ No newline at end of file diff --git a/sondage/view/config/config.js.php b/sondage/view/config/config.js.php new file mode 100644 index 0000000..d8154a5 --- /dev/null +++ b/sondage/view/config/config.js.php @@ -0,0 +1,163 @@ +/** + * This file is part of Zwii. + * + * For full copyright and license information, please see the LICENSE + * file that was distributed with this source code. + * + * @author Rémi Jean + * @copyright Copyright (C) 2008-2018, Rémi Jean + * @license GNU General Public License, version 3 + * @link http://zwiicms.com/ + */ + +/** + * Ajout d'un champ + */ +function add(inputUid, input) { + // Nouveau champ + var newInput = $($("#formConfigCopy").html()); + // Ajout de l'ID unique aux champs + newInput.find("a, input, select").each(function() { + var _this = $(this); + _this.attr({ + id: _this.attr("id").replace("[]", "[" + inputUid + "]"), + name: _this.attr("name").replace("[]", "[" + inputUid + "]") + }); + }); + newInput.find("label").each(function() { + var _this = $(this); + _this.attr("for", _this.attr("for").replace("[]", "[" + inputUid + "]")); + }); + // Attribue les bonnes valeurs + if(input) { + // Nom du champ + newInput.find("[name='formConfigName[" + inputUid + "]']").val(input.name); + // Type de champ + newInput.find("[name='formConfigType[" + inputUid + "]']").val(input.type); + // Largeur du champ + newInput.find("[name='formConfigWidth[" + inputUid + "]']").val(input.width); + // Valeurs du champ + newInput.find("[name='formConfigValues[" + inputUid + "]']").val(input.values); + // Champ obligatoire + newInput.find("[name='formConfigRequired[" + inputUid + "]']").prop("checked", input.required); + } + // Ajout du nouveau champ au DOM + $("#formConfigInputs") + .append(newInput.hide()) + .find(".formConfigInput").last().show(); + // Cache le texte d'absence de champ + $("#formConfigNoInput:visible").hide(); + // Check le type + $(".formConfigType").trigger("change"); + // Actualise les positions + position(); +} + +/** + * Calcul des positions + */ +function position() { + $("#formConfigInputs").find(".formConfigPosition").each(function(i) { + $(this).val(i + 1); + }); +} + +/** + * Ajout des champs déjà existant + */ +var inputUid = 0; +var inputs = getData(['module', $this->getUrl(0), 'input'])); ?>; +if(inputs) { + var inputsPerPosition = getData(['module', $this->getUrl(0), 'input']), 'position', 'SORT_ASC')); ?>; + $.each(inputsPerPosition, function(id) { + add(inputUid, inputs[id]); + inputUid++; + }); +} + +/** + * Afficher/cacher les options supplémentaires + */ +$(document).on("click", ".formConfigMoreToggle", function() { + $(this).parents(".formConfigInput").find(".formConfigMore").slideToggle(); +}); + +/** + * Crée un nouveau champ à partir des champs cachés + */ +$("#formConfigAdd").on("click", function() { + add(inputUid); + inputUid++; +}); + +/** + * Actions sur les champs + */ +// Tri entre les champs +sortable("#formConfigInputs", { + forcePlaceholderSize: true, + containment: "#formConfigInputs", + handle: ".formConfigMove" +}); +$("#formConfigInputs") + // Actualise les positions + .on("sortupdate", function() { + position(); + }) + // Suppression du champ + .on("click", ".formConfigDelete", function() { + var inputDOM = $(this).parents(".formConfigInput"); + // Cache le champ + inputDOM.hide(); + // Supprime le champ + inputDOM.remove(); + // Affiche le texte d'absence de champ + if($("#formConfigInputs").find(".formConfigInput").length === 0) { + $("#formConfigNoInput").show(); + } + // Actualise les positions + position(); + }) + // Affiche/cache le champ "Valeurs" en fonction des champs cachés + .on("change", ".formConfigType", function() { + var _this = $(this); + if(_this.val() === "select") { + _this.parents(".formConfigInput").find(".formConfigValuesWrapper").slideDown(); + } + else { + _this.parents(".formConfigInput").find(".formConfigValuesWrapper").slideUp(); + } + }); +// Simule un changement de type au chargement de la page +$(".formConfigType").trigger("change"); + +/** + * Affiche/cache les options de la case à cocher du mail + */ +$("#formConfigMailOptionsToggle").on("change", function() { + if($(this).is(":checked")) { + $("#formConfigMailOptions").slideDown(); + } + else { + $("#formConfigMailOptions").slideUp(function() { + $("#formConfigGroup").val(""); + $("#formConfigSubject").val(""); + $("#formConfigMail").val(""); + $("#formConfigUser").val(""); + }); + } +}).trigger("change"); + +/** + * Affiche/cache les options de la case à cocher de la redirection + */ +$("#formConfigPageIdToggle").on("change", function() { + if($(this).is(":checked")) { + $("#formConfigPageIdWrapper").slideDown(); + } + else { + $("#formConfigPageIdWrapper").slideUp(function() { + $("#formConfigPageId").val(""); + }); + } +}).trigger("change"); \ No newline at end of file diff --git a/sondage/view/config/config.php b/sondage/view/config/config.php new file mode 100644 index 0000000..eeee308 --- /dev/null +++ b/sondage/view/config/config.php @@ -0,0 +1,167 @@ +
+
+ 'formConfigPosition' + ]); ?> +
+
+ template::ico('sort'), + 'class' => 'formConfigMove' + ]); ?> +
+
+ 'Intitulé' + ]); ?> +
+
+ 'formConfigType' + ]); ?> +
+
+ template::ico('gear'), + 'class' => 'formConfigMoreToggle' + ]); ?> +
+
+ template::ico('minus'), + 'class' => 'formConfigDelete' + ]); ?> +
+
+
+ 'Liste des valeurs séparées par des virgules (valeur1,valeur2,...)', + 'class' => 'formConfigValues', + 'classWrapper' => 'displayNone formConfigValuesWrapper' + ]); ?> + +
+
+
+ +
+
+ '', + 'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(0), + 'ico' => 'left', + 'value' => 'Retour' + ]); ?> +
+
+ helper::baseUrl() . $this->getUrl(0) . '/data', + 'value' => 'Gérer les données' + ]); ?> +
+
+ 'green' + ]); ?> +
+
+
+
+
+

Configuration

+ 'Laissez vide afin de conserver le texte par défaut.', + 'label' => 'Texte du bouton de soumission', + 'value' => $this->getData(['module', $this->getUrl(0), 'config', 'button']) + ]); ?> + (bool) $this->getData(['module', $this->getUrl(0), 'config', 'group']) || + !empty($this->getData(['module', $this->getUrl(0), 'config', 'user'])) || + !empty($this->getData(['module', $this->getUrl(0), 'config', 'mail'])), + 'help' => 'Sélectionnez au moins un groupe, un utilisateur ou saississez un email.' + ]); ?> +
+
+
+ 'Laissez vide afin de conserver le texte par défaut.', + 'label' => 'Sujet du mail', + 'value' => $this->getData(['module', $this->getUrl(0), 'config', 'subject']) + ]); ?> +
+
+ + Destinataires : +
+
+ 'Les groupes hiérarchiques à partir du groupe :', + 'selected' => $this->getData(['module', $this->getUrl(0), 'config', 'group']), + 'help' => 'Editeurs = éditeurs + administrateurs
Membres = membres + éditeurs + administrateurs' + ]); ?> +
+
+
+
+ 'Un membre :', + 'selected' => array_search($this->getData(['module', $this->getUrl(0), 'config', 'user']),$module::$listUsers) + ]); ?> +
+
+
+
+ 'Une adresse email ou une liste de diffusion:', + 'value' => $this->getData(['module', $this->getUrl(0), 'config', 'mail']) + ]); ?> +
+
+
+ (bool) $this->getData(['module', $this->getUrl(0), 'config', 'pageId']) + ]); ?> +
+ 'displayNone', + 'label' => 'Sélectionner une page du site :', + 'selected' => $this->getData(['module', $this->getUrl(0), 'config', 'pageId']) + ]); ?> +
+
+
+ $this->getData(['module', $this->getUrl(0), 'config', 'capcha']) + ]); ?> +
+
+ 'Pagination des réponses', + 'selected' => $this->getData(['module', $this->getUrl(0),'config', 'itemsperPage']) + ]); ?> +
+
+
+
+

Liste des champs

+
+ +
+
+
+
+ template::ico('plus') + ]); ?> +
+
+
+
+
+ +
Module version n° + +
diff --git a/sondage/view/data/data.css b/sondage/view/data/data.css new file mode 100644 index 0000000..805e915 --- /dev/null +++ b/sondage/view/data/data.css @@ -0,0 +1,18 @@ +/** + * This file is part of Zwii. + * + * For full copyright and license information, please see the LICENSE + * file that was distributed with this source code. + * + * @author Rémi Jean + * @copyright Copyright (C) 2008-2018, Rémi Jean + * @author Frédéric Tempez + * @copyright Copyright (C) 2018-2020, Frédéric Tempez + * @license GNU General Public License, version 3 + * @link http://zwiicms.fr/ + */ + + +/** NE PAS EFFACER +* admin.css +*/ \ No newline at end of file diff --git a/sondage/view/data/data.js.php b/sondage/view/data/data.js.php new file mode 100644 index 0000000..91d0e04 --- /dev/null +++ b/sondage/view/data/data.js.php @@ -0,0 +1,31 @@ +/** + * This file is part of Zwii. + * + * For full copyright and license information, please see the LICENSE + * file that was distributed with this source code. + * + * @author Rémi Jean + * @copyright Copyright (C) 2008-2018, Rémi Jean + * @license GNU General Public License, version 3 + * @link http://zwiicms.com/ + */ + +/** + * Confirmation de suppression + */ +$(".formDataDelete").on("click", function() { + var _this = $(this); + return core.confirm("Êtes-vous sûr de vouloir supprimer cette donnée ?", function() { + $(location).attr("href", _this.attr("href")); + }); +}); + +/** + * Confirmation de suppression de toutes les donénes + */ +$(".formDataDeleteAll").on("click", function() { + var _this = $(this); + return core.confirm("Êtes-vous sûr de vouloir supprimer toutes les données ?", function() { + $(location).attr("href", _this.attr("href")); + }); +}); \ No newline at end of file diff --git a/sondage/view/data/data.php b/sondage/view/data/data.php new file mode 100644 index 0000000..2039172 --- /dev/null +++ b/sondage/view/data/data.php @@ -0,0 +1,35 @@ +
+
+ '', + 'href' => helper::baseUrl() . $this->getUrl(0) . '/config', + 'ico' => 'left', + 'value' => 'Retour' + ]); ?> +
+
+ 'formDataDeleteAll red', + 'href' => helper::baseUrl() . $this->getUrl(0) . '/deleteall' . '/' . $_SESSION['csrf'], + 'ico' => 'cancel', + 'value' => 'Tout effacer' + ]); ?> +
+
+ 'blue', + 'href' => helper::baseUrl() . $this->getUrl(0) . '/export2csv' . '/' . $_SESSION['csrf'], + 'ico' => 'download', + 'value' => 'Export CSV' + ]); ?> +
+
+ + + + + + +
Version n° + +
\ No newline at end of file diff --git a/sondage/view/index/index.js.php b/sondage/view/index/index.js.php new file mode 100644 index 0000000..699b183 --- /dev/null +++ b/sondage/view/index/index.js.php @@ -0,0 +1,24 @@ +/** + * This file is part of Zwii. + * + * For full copyright and license information, please see the LICENSE + * file that was distributed with this source code. + * + * @author Frédéric Tempez + * @copyright Copyright (C) 2008-2018, Frédéric Tempez + * @license GNU General Public License, version 3 + * @link http://zwiicms.com/ + */ + +/** + * Paramétrage du format de date + */ +$(function() { + $(".datepicker").flatpickr({ + altInput: true, + altFormat: "d/m/Y", + enableTime: false, + locale: "fr", + dateFormat: "d/m/Y" + }); +}); diff --git a/sondage/view/index/index.php b/sondage/view/index/index.php new file mode 100644 index 0000000..3de963d --- /dev/null +++ b/sondage/view/index/index.php @@ -0,0 +1,67 @@ +getData(['module', $this->getUrl(0), 'input'])): ?> + + getData(['module', $this->getUrl(0), 'input']) as $index => $input): ?> + + 'formInput_' . $index, + 'label' => $input['name'] + ]); ?> + + $key) { + $values[$value] = trim($value); + } + ?> + 'formInput_' . $index, + 'label' => $input['name'] + ]); ?> + + 'formInput_' . $index, + 'label' => $input['name'] + ]); ?> + + 'formInput_' . $index, + 'label' => $input['name'] + ]); ?> + + 'formInput_' . $index, + 'label' => $input['name'], + 'vendor' => 'flatpickr' + ]); ?> + + + + + getData(['module', $this->getUrl(0), 'config', 'capcha'])): ?> +
+
+ +
+
+ +
+
+ 'Réponses', + 'class' => 'blue', + 'href' => helper::baseUrl() . $this->getUrl(0) . '/result' . '/' . $_SESSION['csrf'] + ]); ?> +
+
+ $this->getData(['module', $this->getUrl(0), 'config', 'button']) ? $this->getData(['module', $this->getUrl(0), 'config', 'button']) : 'Envoyer', + 'ico' => '', + 'class' => 'green' + ]); ?> +
+
+ + + + \ No newline at end of file diff --git a/sondage/view/result/result.php b/sondage/view/result/result.php new file mode 100644 index 0000000..966fd1a --- /dev/null +++ b/sondage/view/result/result.php @@ -0,0 +1,19 @@ +
+
+ '', + 'href' => helper::baseUrl() . $this->getUrl(0), + 'ico' => 'left', + 'value' => 'Retour' + ]); ?> +
+
+ + + + + + +
Version n° + +
\ No newline at end of file