Deltacms/module/form/view/index/index.php

143 lines
5.6 KiB
PHP
Raw Normal View History

2022-03-06 13:35:21 +01:00
<?php
// Lexique
2022-09-11 09:42:42 +02:00
$param = '';
include('./module/form/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_form.php');
2023-06-07 09:04:57 +02:00
// Flatpickr dans la langue en frontend si elle est connue de Flatpickr, y compris en traduction auto
$arrayFlatpickr = ['fr', 'es', 'pt', 'el', 'it'];
if( isset( $_SESSION['langFrontEnd'])){
$lang_base = $_SESSION['langFrontEnd'];
} else {
$lang_base = $this->getData(['config', 'i18n', 'langBase']);
}
$lang_flatpickr = in_array($lang_base, $arrayFlatpickr) ? $lang_base : 'default';
2023-03-22 14:54:21 +01:00
?><script>var lang_flatpickr = "<?php echo $lang_flatpickr; ?>";</script><?php
2023-12-09 10:32:20 +01:00
// Adaptation de la langue dans tinymce pour la r<>daction d'un message en fonction de la langue de la page, originale ou en traduction r<>dig<69>e
$lang = $this->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<72>e par Tinymce la langue d'administration est utilis<69>e
if( ! file_exists( 'core/vendor/tinymce/langs/'.$lang_page.'.js' )){
$lang_page = $lang_admin;
}
echo '<script> var lang_admin = "'.$lang_page.'"; </script>';
2022-09-11 09:42:42 +02:00
if($this->getData(['module', $this->getUrl(0), 'input'])): ?>
2022-05-01 11:45:17 +02:00
<?php echo template::formOpenFile('formForm'); ?>
2022-11-05 09:31:32 +01:00
<div class="humanBot">
2024-01-07 18:20:05 +01:00
<?php $textIndex=0; $selectIndex=0; $checkboxIndex=0;
foreach($this->getData(['module', $this->getUrl(0), 'input']) as $index => $input): ?>
2022-01-31 09:10:49 +01:00
<?php if($input['type'] === $module::TYPE_MAIL): ?>
<?php echo template::mail('formInput[' . $index . ']', [
'id' => 'formInput_' . $index,
2022-05-01 11:45:17 +02:00
'label' => $input['name'],
'value' => $_SESSION['draft']['mail']
2022-01-31 09:10:49 +01:00
]); ?>
<?php elseif($input['type'] === $module::TYPE_SELECT): ?>
<?php
$values = array_flip(explode(',', $input['values']));
foreach($values as $value => $key) {
$values[$value] = trim($value);
}
?>
<?php echo template::select('formInput[' . $index . ']', $values, [
'id' => 'formInput_' . $index,
2022-05-01 11:45:17 +02:00
'label' => $input['name'],
'selected' => isset($_SESSION['draft']['select'][$selectIndex])? $values[$_SESSION['draft']['select'][$selectIndex]] : ''
2024-01-07 18:20:05 +01:00
]);
$selectIndex++; ?>
2022-01-31 09:10:49 +01:00
<?php elseif($input['type'] === $module::TYPE_TEXT): ?>
<?php echo template::text('formInput[' . $index . ']', [
'id' => 'formInput_' . $index,
2022-05-01 11:45:17 +02:00
'label' => $input['name'],
'value' => isset($_SESSION['draft']['text'][$textIndex]) ? $_SESSION['draft']['text'][$textIndex] : ''
2024-01-07 18:20:05 +01:00
]);
$textIndex++; ?>
2022-01-31 09:10:49 +01:00
<?php elseif($input['type'] === $module::TYPE_TEXTAREA): ?>
<?php echo template::textarea('formInput[' . $index . ']', [
'id' => 'formInput_' . $index,
2022-05-01 11:45:17 +02:00
'label' => $input['name'],
'value' => $_SESSION['draft']['textarea'],
2023-12-09 10:32:20 +01:00
'class' => 'editorWysiwygComment',
'noDirty' => true
2022-01-31 09:10:49 +01:00
]); ?>
<?php elseif($input['type'] === $module::TYPE_DATETIME): ?>
<?php echo template::date('formInput[' . $index . ']', [
'id' => 'formInput_' . $index,
'label' => $input['name'],
'value' => $_SESSION['draft']['datetime']
2022-01-31 09:10:49 +01:00
]); ?>
2024-01-07 18:20:05 +01:00
<?php elseif($input['type'] === $module::TYPE_CHECKBOX):
echo template::checkbox('formInput[' . $index . ']', true, $input['name'], [
'checked' => isset($_SESSION['draft']['checkbox'][$checkboxIndex]) ? $_SESSION['draft']['checkbox'][$checkboxIndex] : false
2024-01-07 18:20:05 +01:00
]);
$checkboxIndex++; ?>
2022-05-01 11:45:17 +02:00
<?php elseif($input['type'] === $module::TYPE_FILE): ?>
<label class='formLabel'> <?php echo $input['name']; ?> </label>
<div class="formInputFile">
<input type="hidden" name="MAX_FILE_SIZE" value="5000000">
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="button" id="formFileReset" value="X">
2022-09-02 08:44:18 +02:00
</div>
2022-01-31 09:10:49 +01:00
<?php elseif($input['type'] === $module::TYPE_LABEL): ?>
2022-05-01 11:45:17 +02:00
<p class='formLabel'> <?php echo $input['name']; ?> </p>
2022-01-31 09:10:49 +01:00
<?php endif; ?>
2022-09-02 08:44:18 +02:00
2022-01-31 09:10:49 +01:00
<?php endforeach; ?>
2022-11-05 09:31:32 +01:00
</div>
<?php if( $this->getData(['module', $this->getUrl(0), 'config', 'captcha'])
&& ( $_SESSION['humanBot']==='bot') || $this->getData(['config', 'connect', 'captchaBot'])===false ): ?>
2022-01-31 09:10:49 +01:00
<div class="row">
<div class="col12 textAlignCenter">
2022-11-05 09:31:32 +01:00
<?php echo template::captcha('formCaptcha', ''); ?>
2022-01-31 09:10:49 +01:00
</div>
</div>
<?php endif; ?>
2022-11-05 09:31:32 +01:00
<?php if( $this->getData(['module', $this->getUrl(0), 'config', 'captcha'])
&& $_SESSION['humanBot']==='human' && $this->getData(['config', 'connect', 'captchaBot']) ): ?>
<div class="row formCheckBlue">
<?php echo template::text('formInputBlue', [
'label' => 'Input Blue',
'value' => ''
]); ?>
</div>
<br>
<div class="row formOuter">
<div class="formInner humanCheck">
<?php echo template::checkbox('formHumanCheck', true, $this->getData(['locale', 'captchaSimpleText']), [
'checked' => false,
'help' => $this->getData(['locale', 'captchaSimpleHelp'])
]); ?>
</div>
</div>
<br>
<?php endif; ?>
<div class="row textAlignCenter">
<div class="formInner humanBotClose">
2022-01-31 09:10:49 +01:00
<?php echo template::submit('formSubmit', [
2022-09-11 09:42:42 +02:00
'value' => $this->getData(['module', $this->getUrl(0), 'config', 'button']) ? $this->getData(['module', $this->getUrl(0), 'config', 'button']) : $text['form_view']['index'][0],
2022-01-31 09:10:49 +01:00
'ico' => ''
]); ?>
</div>
</div>
<?php echo template::formClose(); ?>
<?php else: ?>
2022-09-11 09:42:42 +02:00
<?php echo template::speech($text['form_view']['index'][1]); ?>
2023-03-22 14:54:21 +01:00
<?php endif; ?>