diff options
| author | polo <ordipolo@gmx.fr> | 2025-07-04 10:29:45 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2025-07-04 10:29:45 +0200 |
| commit | 3104104e838b7d57de49daba0178b1aefe646548 (patch) | |
| tree | 8af33f7bb83ccfef04b6e82a0fcd687ef475d455 | |
| parent | 2d7bacce891eab0adb0263d598bfe44418788f42 (diff) | |
| download | cms-3104104e838b7d57de49daba0178b1aefe646548.tar.gz cms-3104104e838b7d57de49daba0178b1aefe646548.tar.bz2 cms-3104104e838b7d57de49daba0178b1aefe646548.zip | |
formulaire de contact 4
| -rw-r--r-- | public/css/body.css | 6 | ||||
| -rw-r--r-- | public/css/foot.css | 8 | ||||
| -rw-r--r-- | public/css/form.css | 2 | ||||
| -rw-r--r-- | public/css/head.css | 2 | ||||
| -rw-r--r-- | public/css/menu.css | 2 | ||||
| -rw-r--r-- | public/css/modif_page.css | 2 | ||||
| -rw-r--r-- | public/css/nav.css | 2 | ||||
| -rw-r--r-- | public/css/new_page.css | 2 | ||||
| -rw-r--r-- | public/js/form.js | 23 | ||||
| -rw-r--r-- | src/controller/ajax.php | 15 | ||||
| -rw-r--r-- | src/controller/ajax_admin.php | 22 | ||||
| -rw-r--r-- | src/model/entities/Email.php | 4 | ||||
| -rw-r--r-- | src/model/entities/NodeData.php | 10 | ||||
| -rw-r--r-- | src/view/FormBuilder.php | 22 | ||||
| -rw-r--r-- | src/view/templates/form.php | 2 |
15 files changed, 66 insertions, 58 deletions
diff --git a/public/css/body.css b/public/css/body.css index eb198e6..c3f518a 100644 --- a/public/css/body.css +++ b/public/css/body.css | |||
| @@ -116,7 +116,7 @@ article .logo2 | |||
| 116 | } | 116 | } |
| 117 | .new_content button:hover | 117 | .new_content button:hover |
| 118 | { | 118 | { |
| 119 | background-color: #ffff00; | 119 | background-color: yellow; |
| 120 | border-radius: 4px; | 120 | border-radius: 4px; |
| 121 | } | 121 | } |
| 122 | article img | 122 | article img |
| @@ -137,7 +137,7 @@ button .action_icon | |||
| 137 | } | 137 | } |
| 138 | .action_icon:hover | 138 | .action_icon:hover |
| 139 | { | 139 | { |
| 140 | background-color: #ffff00; | 140 | background-color: yellow; |
| 141 | border-radius: 4px; | 141 | border-radius: 4px; |
| 142 | border: lightgrey 2px outset; | 142 | border: lightgrey 2px outset; |
| 143 | cursor: pointer; | 143 | cursor: pointer; |
| @@ -187,7 +187,7 @@ section button | |||
| 187 | } | 187 | } |
| 188 | section button:hover | 188 | section button:hover |
| 189 | { | 189 | { |
| 190 | background-color: #ffff00; | 190 | background-color: yellow; |
| 191 | border-radius: 4px; | 191 | border-radius: 4px; |
| 192 | cursor: pointer; | 192 | cursor: pointer; |
| 193 | } | 193 | } |
diff --git a/public/css/foot.css b/public/css/foot.css index dd9b953..0eb250e 100644 --- a/public/css/foot.css +++ b/public/css/foot.css | |||
| @@ -28,7 +28,7 @@ footer > div | |||
| 28 | padding: 0 2px; | 28 | padding: 0 2px; |
| 29 | /*background-color: #13aff0ff; | 29 | /*background-color: #13aff0ff; |
| 30 | border-bottom: 3px #fadb11 solid;*/ | 30 | border-bottom: 3px #fadb11 solid;*/ |
| 31 | background-color: #ffff00; | 31 | background-color: yellow; |
| 32 | /*border-bottom: 2px #00a8f3 solid;*/ | 32 | /*border-bottom: 2px #00a8f3 solid;*/ |
| 33 | border-bottom: 2px #ff1d04 solid; | 33 | border-bottom: 2px #ff1d04 solid; |
| 34 | } | 34 | } |
| @@ -58,7 +58,7 @@ footer > div | |||
| 58 | { | 58 | { |
| 59 | /*background-color: #13aff0; | 59 | /*background-color: #13aff0; |
| 60 | border-bottom: 3px #fadb11 solid;*/ | 60 | border-bottom: 3px #fadb11 solid;*/ |
| 61 | background-color: #ffff00; | 61 | background-color: yellow; |
| 62 | /*border-bottom: 2px #00a8f3 solid;*/ | 62 | /*border-bottom: 2px #00a8f3 solid;*/ |
| 63 | border-bottom: 2px #ff1d04 solid; | 63 | border-bottom: 2px #ff1d04 solid; |
| 64 | } | 64 | } |
| @@ -131,7 +131,7 @@ footer > div | |||
| 131 | /*height: 70px;*/ | 131 | /*height: 70px;*/ |
| 132 | width: 100%; | 132 | width: 100%; |
| 133 | margin: auto; | 133 | margin: auto; |
| 134 | background-color: #ffff00; | 134 | background-color: yellow; |
| 135 | position: fixed; | 135 | position: fixed; |
| 136 | bottom: 0px; | 136 | bottom: 0px; |
| 137 | z-index: 1; /* augmenter la valeur si nécessaire */ | 137 | z-index: 1; /* augmenter la valeur si nécessaire */ |
| @@ -149,7 +149,7 @@ footer > div | |||
| 149 | .logged_in button:hover | 149 | .logged_in button:hover |
| 150 | { | 150 | { |
| 151 | cursor: pointer; /* curseur qui touche du doigt */ | 151 | cursor: pointer; /* curseur qui touche du doigt */ |
| 152 | background-color: #ffff00; | 152 | background-color: yellow; |
| 153 | border-radius: 4px; | 153 | border-radius: 4px; |
| 154 | } | 154 | } |
| 155 | .modif_mode | 155 | .modif_mode |
diff --git a/public/css/form.css b/public/css/form.css index d317360..84c73ac 100644 --- a/public/css/form.css +++ b/public/css/form.css | |||
| @@ -24,7 +24,7 @@ | |||
| 24 | } | 24 | } |
| 25 | .form_inputs input[type=submit]:hover | 25 | .form_inputs input[type=submit]:hover |
| 26 | { | 26 | { |
| 27 | background-color: #ffff00; | 27 | background-color: yellow; |
| 28 | border-radius: 4px; | 28 | border-radius: 4px; |
| 29 | cursor: pointer; | 29 | cursor: pointer; |
| 30 | } | 30 | } |
diff --git a/public/css/head.css b/public/css/head.css index eff7de6..a55449a 100644 --- a/public/css/head.css +++ b/public/css/head.css | |||
| @@ -61,5 +61,5 @@ header a | |||
| 61 | 61 | ||
| 62 | .social img:hover | 62 | .social img:hover |
| 63 | { | 63 | { |
| 64 | background-color: #ffff00; | 64 | background-color: yellow; |
| 65 | } | 65 | } |
diff --git a/public/css/menu.css b/public/css/menu.css index 68e2b2a..62e6623 100644 --- a/public/css/menu.css +++ b/public/css/menu.css | |||
| @@ -72,7 +72,7 @@ | |||
| 72 | } | 72 | } |
| 73 | .menu #location:hover, .menu input[type=submit]:hover, .move_entry_icon:hover | 73 | .menu #location:hover, .menu input[type=submit]:hover, .move_entry_icon:hover |
| 74 | { | 74 | { |
| 75 | background-color: #ffff00; | 75 | background-color: yellow; |
| 76 | border-radius: 4px; | 76 | border-radius: 4px; |
| 77 | border: lightgrey 2px outset; | 77 | border: lightgrey 2px outset; |
| 78 | cursor: pointer; | 78 | cursor: pointer; |
diff --git a/public/css/modif_page.css b/public/css/modif_page.css index 77392d2..d6fc23e 100644 --- a/public/css/modif_page.css +++ b/public/css/modif_page.css | |||
| @@ -19,7 +19,7 @@ | |||
| 19 | }*/ | 19 | }*/ |
| 20 | .page_modification form input[type=submit]:hover | 20 | .page_modification form input[type=submit]:hover |
| 21 | { | 21 | { |
| 22 | background-color: #ffff00; | 22 | background-color: yellow; |
| 23 | border-radius: 4px; | 23 | border-radius: 4px; |
| 24 | cursor: pointer; | 24 | cursor: pointer; |
| 25 | } | 25 | } |
diff --git a/public/css/nav.css b/public/css/nav.css index 50bf4af..7f47cff 100644 --- a/public/css/nav.css +++ b/public/css/nav.css | |||
| @@ -72,7 +72,7 @@ ul | |||
| 72 | /*.sub-menu p:hover*/ | 72 | /*.sub-menu p:hover*/ |
| 73 | .nav_main p:hover | 73 | .nav_main p:hover |
| 74 | { | 74 | { |
| 75 | background-color: #ffff00; | 75 | background-color: yellow; |
| 76 | } | 76 | } |
| 77 | .drop-right > a > p:after | 77 | .drop-right > a > p:after |
| 78 | { | 78 | { |
diff --git a/public/css/new_page.css b/public/css/new_page.css index 0cc067a..29d3ad0 100644 --- a/public/css/new_page.css +++ b/public/css/new_page.css | |||
| @@ -19,7 +19,7 @@ | |||
| 19 | } | 19 | } |
| 20 | .new_page #page_location:hover, .new_page input[type=submit]:hover | 20 | .new_page #page_location:hover, .new_page input[type=submit]:hover |
| 21 | { | 21 | { |
| 22 | background-color: #ffff00; | 22 | background-color: yellow; |
| 23 | border-radius: 4px; | 23 | border-radius: 4px; |
| 24 | border: lightgrey 2px outset; | 24 | border: lightgrey 2px outset; |
| 25 | cursor: pointer; | 25 | cursor: pointer; |
diff --git a/public/js/form.js b/public/js/form.js index 0be2313..5c5a164 100644 --- a/public/js/form.js +++ b/public/js/form.js | |||
| @@ -1,10 +1,9 @@ | |||
| 1 | //function sendMessage(){} | 1 | //function sendMessage(){} |
| 2 | 2 | ||
| 3 | // modif des paramètre d'envoi d'e-mail depuis l'espace admin | 3 | // modif des paramètre d'envoi d'e-mail depuis l'espace admin |
| 4 | /*function changeRecipient(id){ | 4 | function changeRecipient(id){ |
| 5 | const email = document.getElementById('recipient').value; | 5 | const email = document.getElementById('recipient').value; |
| 6 | const hidden = document.getElementById('recipient_hidden').value; | 6 | const hidden = document.getElementById('recipient_hidden').value; |
| 7 | const warning = document.querySelector('.no_recipient_warning'); | ||
| 8 | 7 | ||
| 9 | fetch('index.php?action=recipient_email', { | 8 | fetch('index.php?action=recipient_email', { |
| 10 | method: 'POST', | 9 | method: 'POST', |
| @@ -16,7 +15,6 @@ | |||
| 16 | .then(response => response.json()) | 15 | .then(response => response.json()) |
| 17 | .then(data => { | 16 | .then(data => { |
| 18 | if(data.success){ | 17 | if(data.success){ |
| 19 | warning.classList.add('hidden'); | ||
| 20 | toastNotify('Adresse e-mail de destination modifiée'); | 18 | toastNotify('Adresse e-mail de destination modifiée'); |
| 21 | } | 19 | } |
| 22 | else{ | 20 | else{ |
| @@ -26,20 +24,20 @@ | |||
| 26 | .catch(error => { | 24 | .catch(error => { |
| 27 | console.error('Erreur:', error); | 25 | console.error('Erreur:', error); |
| 28 | }); | 26 | }); |
| 29 | }*/ | 27 | } |
| 30 | 28 | ||
| 31 | function sendTestEmail(){ | 29 | function sendTestEmail(id){ |
| 32 | const admin_form = document.querySelector('.admin_form'); | 30 | const admin_form = document.querySelector('.admin_form'); |
| 33 | const test_email_success = document.querySelector('.test_email_success'); | 31 | const test_email_success = document.querySelector('.test_email_success'); |
| 34 | test_email_success.innerHTML = 'Envoi en cours, veuillez patienter'; | 32 | test_email_success.innerHTML = 'Envoi en cours, veuillez patienter'; |
| 35 | test_email_success.style.backgroundColor = '#f0f0f0'; | 33 | test_email_success.style.backgroundColor = 'yellow'; |
| 36 | 34 | ||
| 37 | fetch('index.php?action=test_email', { | 35 | fetch('index.php?action=test_email', { |
| 38 | method: 'POST', | 36 | method: 'POST', |
| 39 | headers: { | 37 | headers: { |
| 40 | 'Content-Type': 'application/json' | 38 | 'Content-Type': 'application/json' |
| 41 | }, | 39 | }, |
| 42 | body: JSON.stringify({}) | 40 | body: JSON.stringify({ id: id}) |
| 43 | }) | 41 | }) |
| 44 | .then(response => response.json()) | 42 | .then(response => response.json()) |
| 45 | .then(data => { | 43 | .then(data => { |
| @@ -47,10 +45,10 @@ function sendTestEmail(){ | |||
| 47 | let color; | 45 | let color; |
| 48 | if(data.success){ | 46 | if(data.success){ |
| 49 | message = 'E-mail de test envoyé avec succès'; | 47 | message = 'E-mail de test envoyé avec succès'; |
| 50 | color = 'lawngreen'; | 48 | color = 'chartreuse'; |
| 51 | } | 49 | } |
| 52 | else{ | 50 | else{ |
| 53 | message = "Erreur à l'envoi de l'e-mail"; | 51 | message = "Erreur à l'envoi de l'e-mail, vérifiez la configuration du serveur"; |
| 54 | color = "orangered" | 52 | color = "orangered" |
| 55 | } | 53 | } |
| 56 | test_email_success.innerHTML = message; | 54 | test_email_success.innerHTML = message; |
| @@ -62,10 +60,10 @@ function sendTestEmail(){ | |||
| 62 | }); | 60 | }); |
| 63 | } | 61 | } |
| 64 | 62 | ||
| 65 | function sendVisitorEmail(){ | 63 | function sendVisitorEmail(id){ |
| 66 | const send_email_success = document.querySelector('.send_email_success'); | 64 | const send_email_success = document.querySelector('.send_email_success'); |
| 67 | send_email_success.innerHTML = 'Envoi en cours, veuillez patienter'; | 65 | send_email_success.innerHTML = 'Envoi en cours, veuillez patienter'; |
| 68 | send_email_success.style.backgroundColor = 'initial'; | 66 | send_email_success.style.backgroundColor = 'yellow'; |
| 69 | 67 | ||
| 70 | const email_name = document.getElementById('email_name').value; | 68 | const email_name = document.getElementById('email_name').value; |
| 71 | const email_address = document.getElementById('email_address').value; | 69 | const email_address = document.getElementById('email_address').value; |
| @@ -83,7 +81,8 @@ function sendVisitorEmail(){ | |||
| 83 | email: email_address, | 81 | email: email_address, |
| 84 | message: email_message, | 82 | message: email_message, |
| 85 | captcha: email_captcha, | 83 | captcha: email_captcha, |
| 86 | hidden: email_hidden | 84 | hidden: email_hidden, |
| 85 | id: id | ||
| 87 | }) | 86 | }) |
| 88 | }) | 87 | }) |
| 89 | .then(response => response.json()) | 88 | .then(response => response.json()) |
diff --git a/src/controller/ajax.php b/src/controller/ajax.php index 7529fe6..8a7cb34 100644 --- a/src/controller/ajax.php +++ b/src/controller/ajax.php | |||
| @@ -8,7 +8,7 @@ use PHPMailer\PHPMailer\Exception; | |||
| 8 | use App\Entity\Email; | 8 | use App\Entity\Email; |
| 9 | 9 | ||
| 10 | // mettre ça ailleurs? | 10 | // mettre ça ailleurs? |
| 11 | function sendEmail(bool $true_email, string $name = '', string $email = '', string $message = ''): bool | 11 | function sendEmail(string $recipient, bool $true_email, string $name = '', string $email = '', string $message = ''): bool |
| 12 | { | 12 | { |
| 13 | $mail = new PHPMailer(true); // true => exceptions | 13 | $mail = new PHPMailer(true); // true => exceptions |
| 14 | $mail->CharSet = 'UTF-8'; | 14 | $mail->CharSet = 'UTF-8'; |
| @@ -35,7 +35,7 @@ function sendEmail(bool $true_email, string $name = '', string $email = '', stri | |||
| 35 | 35 | ||
| 36 | // Expéditeur et destinataire | 36 | // Expéditeur et destinataire |
| 37 | $mail->setFrom(strtolower(Config::$email_from), Config::$email_from_name); // expéditeur | 37 | $mail->setFrom(strtolower(Config::$email_from), Config::$email_from_name); // expéditeur |
| 38 | $mail->addAddress(strtolower(Config::$email_dest), Config::$email_dest_name); // destinataire | 38 | $mail->addAddress(strtolower($recipient), Config::$email_dest_name); // destinataire |
| 39 | 39 | ||
| 40 | // Contenu | 40 | // Contenu |
| 41 | $mail->isHTML(true); | 41 | $mail->isHTML(true); |
| @@ -65,10 +65,9 @@ if($_SERVER['CONTENT_TYPE'] === 'application/json') | |||
| 65 | $data = file_get_contents('php://input'); | 65 | $data = file_get_contents('php://input'); |
| 66 | $json = json_decode($data, true); | 66 | $json = json_decode($data, true); |
| 67 | 67 | ||
| 68 | // requêtes de tinymce ou touchant aux articles | ||
| 69 | if(isset($_GET['action'])) | 68 | if(isset($_GET['action'])) |
| 70 | { | 69 | { |
| 71 | // e-mail envoyé par le formulaire de contact | 70 | /* -- bloc Formulaire -- */ |
| 72 | if($_GET['action'] === 'send_email'){ | 71 | if($_GET['action'] === 'send_email'){ |
| 73 | $captcha_solution = (isset($_SESSION['captcha']) && is_int($_SESSION['captcha'])) ? $_SESSION['captcha'] : 0; | 72 | $captcha_solution = (isset($_SESSION['captcha']) && is_int($_SESSION['captcha'])) ? $_SESSION['captcha'] : 0; |
| 74 | $captcha_try = isset($json['captcha']) ? Captcha::controlInput($json['captcha']) : 0; | 73 | $captcha_try = isset($json['captcha']) ? Captcha::controlInput($json['captcha']) : 0; |
| @@ -77,12 +76,16 @@ if($_SERVER['CONTENT_TYPE'] === 'application/json') | |||
| 77 | $name = htmlspecialchars(trim($json['name'])); | 76 | $name = htmlspecialchars(trim($json['name'])); |
| 78 | $email = strtolower(htmlspecialchars(trim($json['email']))); | 77 | $email = strtolower(htmlspecialchars(trim($json['email']))); |
| 79 | $message = htmlspecialchars(trim($json['message'])); | 78 | $message = htmlspecialchars(trim($json['message'])); |
| 79 | |||
| 80 | // destinataire = e-mail par défaut dans config.ini OU choisi par l'utilisateur | ||
| 81 | $form_data = $entityManager->find('App\Entity\NodeData', $json['id']); | ||
| 82 | $recipient = $form_data->getData()['email'] ?? Config::$email_dest; | ||
| 80 | 83 | ||
| 81 | if($captcha_try != 0 && $captcha_solution != 0 && ($captcha_try === $captcha_solution) | 84 | if($captcha_try != 0 && $captcha_solution != 0 && ($captcha_try === $captcha_solution) |
| 82 | && filter_var($email, FILTER_VALIDATE_EMAIL) && isset($json['hidden']) && empty($json['hidden']) | 85 | && filter_var($email, FILTER_VALIDATE_EMAIL) && isset($json['hidden']) && empty($json['hidden']) |
| 83 | && sendEmail(true, $name, $email, $message)) | 86 | && sendEmail($recipient, true, $name, $email, $message)) |
| 84 | { | 87 | { |
| 85 | $db_email = new Email(strtolower(Config::$email_from), strtolower(Config::$email_dest), $message); | 88 | $db_email = new Email(Config::$email_from, Config::$email_dest, $message); |
| 86 | $entityManager->persist($db_email); | 89 | $entityManager->persist($db_email); |
| 87 | $entityManager->flush(); | 90 | $entityManager->flush(); |
| 88 | echo json_encode(['success' => true]); | 91 | echo json_encode(['success' => true]); |
diff --git a/src/controller/ajax_admin.php b/src/controller/ajax_admin.php index 944e84b..2318ac1 100644 --- a/src/controller/ajax_admin.php +++ b/src/controller/ajax_admin.php | |||
| @@ -197,7 +197,6 @@ if($_SERVER['CONTENT_TYPE'] === 'application/json') | |||
| 197 | $data = file_get_contents('php://input'); | 197 | $data = file_get_contents('php://input'); |
| 198 | $json = json_decode($data, true); | 198 | $json = json_decode($data, true); |
| 199 | 199 | ||
| 200 | // requêtes de tinymce ou touchant aux articles | ||
| 201 | if(isset($_GET['action'])) | 200 | if(isset($_GET['action'])) |
| 202 | { | 201 | { |
| 203 | if($_GET['action'] === 'editor_submit' && isset($json['id']) && isset($json['content'])) | 202 | if($_GET['action'] === 'editor_submit' && isset($json['id']) && isset($json['content'])) |
| @@ -356,13 +355,17 @@ if($_SERVER['CONTENT_TYPE'] === 'application/json') | |||
| 356 | die; | 355 | die; |
| 357 | } | 356 | } |
| 358 | 357 | ||
| 359 | // config formulaire | 358 | |
| 360 | /*elseif($_GET['action'] === 'recipient_email'){ | 359 | /* -- bloc Formulaire -- */ |
| 360 | elseif($_GET['action'] === 'recipient_email'){ | ||
| 361 | $email = htmlspecialchars(trim($json['email'])); | 361 | $email = htmlspecialchars(trim($json['email'])); |
| 362 | 362 | ||
| 363 | if(filter_var($email, FILTER_VALIDATE_EMAIL) && isset($json['hidden']) && empty($json['hidden'])){ | 363 | if((filter_var($email, FILTER_VALIDATE_EMAIL) // nouvel e-mail |
| 364 | || ($json['email'] === '' && !empty(Config::$email_dest))) // e-mail par défaut | ||
| 365 | && isset($json['hidden']) && empty($json['hidden'])) | ||
| 366 | { | ||
| 364 | $form_data = $entityManager->find('App\Entity\NodeData', $json['id']); | 367 | $form_data = $entityManager->find('App\Entity\NodeData', $json['id']); |
| 365 | $form_data->updateData('email', $json['email']); | 368 | $form_data->updateData('email', $email); |
| 366 | $entityManager->persist($form_data); | 369 | $entityManager->persist($form_data); |
| 367 | $entityManager->flush(); | 370 | $entityManager->flush(); |
| 368 | 371 | ||
| @@ -372,10 +375,13 @@ if($_SERVER['CONTENT_TYPE'] === 'application/json') | |||
| 372 | echo json_encode(['success' => false]); | 375 | echo json_encode(['success' => false]); |
| 373 | } | 376 | } |
| 374 | die; | 377 | die; |
| 375 | }*/ | 378 | } |
| 376 | // e-mail de test | ||
| 377 | elseif($_GET['action'] === 'test_email'){ | 379 | elseif($_GET['action'] === 'test_email'){ |
| 378 | if(sendEmail(false, 'nom du visiteur', 'adresse@du_visiteur.fr', "TEST d'un envoi d'e-mail depuis le site web")){ | 380 | // destinataire = e-mail par défaut dans config.ini OU choisi par l'utilisateur |
| 381 | $form_data = $entityManager->find('App\Entity\NodeData', $json['id']); | ||
| 382 | $recipient = $form_data->getData()['email'] ?? Config::$email_dest; | ||
| 383 | |||
| 384 | if(sendEmail($recipient, false, 'nom du visiteur', 'adresse@du_visiteur.fr', "TEST d'un envoi d'e-mail depuis le site web")){ | ||
| 379 | echo json_encode(['success' => true]); | 385 | echo json_encode(['success' => true]); |
| 380 | } | 386 | } |
| 381 | else{ | 387 | else{ |
diff --git a/src/model/entities/Email.php b/src/model/entities/Email.php index c6c2a29..9d87f1f 100644 --- a/src/model/entities/Email.php +++ b/src/model/entities/Email.php | |||
| @@ -33,8 +33,8 @@ class Email | |||
| 33 | private ?\DateTime $date_time ; | 33 | private ?\DateTime $date_time ; |
| 34 | 34 | ||
| 35 | public function __construct(string $sender, string $recipient, string $content){ | 35 | public function __construct(string $sender, string $recipient, string $content){ |
| 36 | $this->sender = $sender; | 36 | $this->sender = strtolower($sender); |
| 37 | $this->recipient = $recipient; | 37 | $this->recipient = strtolower($recipient); |
| 38 | $this->content = $content; | 38 | $this->content = $content; |
| 39 | $this->date_time = new \DateTime(); | 39 | $this->date_time = new \DateTime(); |
| 40 | } | 40 | } |
diff --git a/src/model/entities/NodeData.php b/src/model/entities/NodeData.php index 9d23b8b..758ccb7 100644 --- a/src/model/entities/NodeData.php +++ b/src/model/entities/NodeData.php | |||
| @@ -55,9 +55,15 @@ class NodeData | |||
| 55 | { | 55 | { |
| 56 | $this->data = $data; | 56 | $this->data = $data; |
| 57 | }*/ | 57 | }*/ |
| 58 | public function updateData(string $key, string $value): void | 58 | public function updateData(string $key, string $value = ''): void |
| 59 | { | 59 | { |
| 60 | $this->data[$key] = $value; | 60 | if($value !== ''){ |
| 61 | $this->data[$key] = $value; | ||
| 62 | } | ||
| 63 | // si $value est vide, supprime la clé | ||
| 64 | elseif(isset($this->data[$key])){ | ||
| 65 | unset($this->data[$key]); | ||
| 66 | } | ||
| 61 | } | 67 | } |
| 62 | /*public function setNode(Node $node): void | 68 | /*public function setNode(Node $node): void |
| 63 | { | 69 | { |
diff --git a/src/view/FormBuilder.php b/src/view/FormBuilder.php index 508763b..7a2adcb 100644 --- a/src/view/FormBuilder.php +++ b/src/view/FormBuilder.php | |||
| @@ -22,27 +22,21 @@ class FormBuilder extends AbstractBuilder | |||
| 22 | $captcha = new Captcha; | 22 | $captcha = new Captcha; |
| 23 | $_SESSION['captcha'] = $captcha->getSolution(); | 23 | $_SESSION['captcha'] = $captcha->getSolution(); |
| 24 | 24 | ||
| 25 | $email = $email ?? Config::$email_dest; | ||
| 26 | |||
| 25 | $admin_content = ''; | 27 | $admin_content = ''; |
| 26 | if($_SESSION['admin']) | 28 | if($_SESSION['admin']) |
| 27 | { | 29 | { |
| 28 | $admin_content = '' | 30 | $admin_content = '<div class="admin_form"> |
| 29 | //. '<h3>Configuration du formulaire</h3>' . "\n" | 31 | <p> |
| 30 | . '<div class="admin_form">' . "\n" | 32 | <label for="recipient">E-mail de destination de ce formulaire</label> |
| 31 | /*. '<p> | ||
| 32 | <label for="recipient">E-mail de destination</label> | ||
| 33 | <input id="recipient" type="email" name="recipient" placeholder="mon-adresse@email.fr" value="' . $email . '"> | 33 | <input id="recipient" type="email" name="recipient" placeholder="mon-adresse@email.fr" value="' . $email . '"> |
| 34 | <input type="hidden" id="recipient_hidden" value=""> | 34 | <input type="hidden" id="recipient_hidden" value=""> |
| 35 | <button onclick="changeRecipient(' . $node->getNodeData()->getId() . ')">Valider</button> | 35 | <button onclick="changeRecipient(' . $node->getNodeData()->getId() . ')">Valider</button> |
| 36 | </p> | 36 | </p> |
| 37 | <p> | 37 | <p><button onclick="sendTestEmail(' . $node->getNodeData()->getId() . ')">Envoi d\'un e-mail de test</button></p> |
| 38 | <label for="smtp">Serveur SMTP</label> | 38 | <p class="test_email_success full_width_column"></p> |
| 39 | <input id="smtp" type="text" name="smtp" value="' . $smtp . '"> | 39 | </div>' . "\n"; |
| 40 | <input type="hidden" id="smtp_hidden" value=""> | ||
| 41 | <button onclick="changeSmtp(' . $node->getNodeData()->getId() . ')">Valider</button> | ||
| 42 | </p>' . "\n"*/ | ||
| 43 | . '<p><button onclick="sendTestEmail()">Envoi d\'un e-mail de test</button></p>' . "\n" | ||
| 44 | . '<p class="test_email_success full_width_column"></p>' | ||
| 45 | . '</div>' . "\n"; | ||
| 46 | } | 40 | } |
| 47 | 41 | ||
| 48 | ob_start(); | 42 | ob_start(); |
diff --git a/src/view/templates/form.php b/src/view/templates/form.php index 5f81f6f..bcde2f4 100644 --- a/src/view/templates/form.php +++ b/src/view/templates/form.php | |||
| @@ -25,7 +25,7 @@ | |||
| 25 | <input id="email_hidden" type="hidden" name="email_hidden"> | 25 | <input id="email_hidden" type="hidden" name="email_hidden"> |
| 26 | 26 | ||
| 27 | <div class="full_width_column"> | 27 | <div class="full_width_column"> |
| 28 | <input type="submit" value="Envoyez votre message" onclick="sendVisitorEmail()"> | 28 | <input type="submit" value="Envoyez votre message" onclick="sendVisitorEmail(<?= $node->getNodeData()->getId() ?>)"> |
| 29 | </div> | 29 | </div> |
| 30 | 30 | ||
| 31 | <p class="send_email_success full_width_column"></p> | 31 | <p class="send_email_success full_width_column"></p> |
