From ffa19c17476a0992a39d94d4d88aaba080e22e78 Mon Sep 17 00:00:00 2001 From: Deltacms Date: Sat, 9 Dec 2023 10:32:20 +0100 Subject: [PATCH] form 5.0 avec tinymce et textes longs --- module/form/form.php | 19 ++++++++++++------- module/form/lang/en/lex_form.php | 2 ++ module/form/lang/es/lex_form.php | 2 ++ module/form/lang/fr/lex_form.php | 4 +++- module/form/view/index/index.php | 30 +++++++++++++++++++++++++++++- 5 files changed, 48 insertions(+), 9 deletions(-) diff --git a/module/form/form.php b/module/form/form.php index 5a1f2ed..8daa8d6 100644 --- a/module/form/form.php +++ b/module/form/form.php @@ -18,7 +18,7 @@ class form extends common { - const VERSION = '4.9'; + const VERSION = '5.0'; const REALNAME = 'Formulaire'; const DELETE = true; const UPDATE = '0.0'; @@ -445,7 +445,7 @@ class form extends common { $this->setData(['module', $this->getUrl(0), 'draft', 'mail', $this->getInput('formInput[' . $index . ']',helper::FILTER_MAIL)]); break; case self::TYPE_TEXTAREA: - $this->setData(['module', $this->getUrl(0), 'draft', 'textarea', $this->getInput('formInput[' . $index . ']',helper::FILTER_STRING_LONG)]); + $this->setData(['module', $this->getUrl(0), 'draft', 'textarea', $this->getInput('formInput[' . $index . ']',helper::FILTER_STRING_LONG_NOSTRIP)]); break; case self::TYPE_DATETIME: $dateTime = time(); @@ -475,7 +475,11 @@ class form extends common { $replyTo = null; $content = ''; $file_name = ''; - foreach($this->getData(['module', $this->getUrl(0), 'input']) as $index => $input) { + foreach($this->getData(['module', $this->getUrl(0), 'input']) as $index => $input) { + + $filter = helper::FILTER_STRING_SHORT; + if( $input['type'] === 'textarea') $filter = helper::FILTER_STRING_LONG_NOSTRIP; + $value = $this->getInput('formInput[' . $index . ']', $filter, $input['required']) === true ? 'X' : $this->getInput('formInput[' . $index . ']', $filter, $input['required']); // premier champ email ajouté au mail en reply si option active if ($this->getData(['module', $this->getUrl(0), 'config', 'replyto']) === true && @@ -557,8 +561,7 @@ class form extends common { } } } - - + // 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 @@ -645,7 +648,8 @@ class form extends common { 'redirect' => $redirect, 'state' => ($sent === true ? true : false), 'vendor' => [ - 'flatpickr' + 'flatpickr', + 'tinymce' ] ]); } @@ -663,7 +667,8 @@ class form extends common { 'showPageContent' => true, 'view' => 'index', 'vendor' => [ - 'flatpickr' + 'flatpickr', + 'tinymce' ], ]); } diff --git a/module/form/lang/en/lex_form.php b/module/form/lang/en/lex_form.php index c20fb63..c9dfd19 100644 --- a/module/form/lang/en/lex_form.php +++ b/module/form/lang/en/lex_form.php @@ -78,6 +78,8 @@ $text['form']['index'][11] = 'The attachment is not a zip document'; $text['form']['index'][12] = ' Fill in the Captcha '; // Initialisation de flatpickr $lang_flatpickr = 'default'; +// Langue d'administration pour tinymce +$lang_admin = 'en_GB'; // Selects $signature = [ 'text' => 'Name of the site', diff --git a/module/form/lang/es/lex_form.php b/module/form/lang/es/lex_form.php index f45a9b9..c1e4be8 100644 --- a/module/form/lang/es/lex_form.php +++ b/module/form/lang/es/lex_form.php @@ -78,6 +78,8 @@ $text['form']['index'][11] = 'El archivo adjunto no es un documento zip'; $text['form']['index'][12] = ' Complete el Captcha '; // Initialisation de flatpickr $lang_flatpickr = 'es'; +// Langue d'administration pour tinymce +$lang_admin = 'es'; // Selects $signature = [ 'text' => 'Nombre del sitio', diff --git a/module/form/lang/fr/lex_form.php b/module/form/lang/fr/lex_form.php index 6491371..42f8841 100644 --- a/module/form/lang/fr/lex_form.php +++ b/module/form/lang/fr/lex_form.php @@ -76,8 +76,10 @@ $text['form']['index'][9] = 'échec le message n\'est pas envoyé car '; $text['form']['index'][10] = 'La pièce jointe n\'est pas un document pdf'; $text['form']['index'][11] = 'La pièce jointe n\'est pas un document zip'; $text['form']['index'][12] = ' Renseignez le Captcha '; -// Initialisation de flatpickr +// Initialisation de flatpickr $lang_flatpickr = 'fr'; +// Langue d'administration pour tinymce +$lang_admin = 'fr_FR'; // Selects $signature = [ 'text' => 'Nom du site', diff --git a/module/form/view/index/index.php b/module/form/view/index/index.php index cec2891..76ee8aa 100644 --- a/module/form/view/index/index.php +++ b/module/form/view/index/index.php @@ -13,6 +13,32 @@ if( isset( $_SESSION['langFrontEnd'])){ $lang_flatpickr = in_array($lang_base, $arrayFlatpickr) ? $lang_base : 'default'; ?>getData(['config', 'i18n', 'langBase']); +if ( !empty($_COOKIE["DELTA_I18N_SITE"])) { + if( $this->getInput('DELTA_I18N_SITE') !== 'base' ) $lang = $this->getInput('DELTA_I18N_SITE'); +} +$lang_page = $lang; +switch ($lang) { + case 'en' : + $lang_page = 'en_GB'; + break; + case 'pt' : + $lang_page = 'pt_PT'; + break; + case 'sv' : + $lang_page = 'sv_SE'; + break; + case 'fr' : + $lang_page = 'fr_FR'; + break; +} +// Si la langue n'est pas supportée par Tinymce la langue d'administration est utilisée +if( ! file_exists( 'core/vendor/tinymce/langs/'.$lang_page.'.js' )){ + $lang_page = $lang_admin; +} +echo ''; + if($this->getData(['module', $this->getUrl(0), 'input'])): ?>
@@ -45,7 +71,9 @@ if($this->getData(['module', $this->getUrl(0), 'input'])): ?> 'formInput_' . $index, 'label' => $input['name'], - 'value' => $this->getData([ 'module', $this->getUrl(0), 'draft', 'textarea']) + 'value' => $this->getData([ 'module', $this->getUrl(0), 'draft', 'textarea']), + 'class' => 'editorWysiwygComment', + 'noDirty' => true ]); ?>