diff options
| author | polo <ordipolo@gmx.fr> | 2025-09-12 15:04:53 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2025-09-12 15:04:53 +0200 |
| commit | de6a28c63d18a72baa044d9385ed3d15afb40ef0 (patch) | |
| tree | 69d25cf3719e540fb23d79b1cbe536e755eb9907 /src/view/FormBuilder.php | |
| parent | efd79d15adef2a27347c25ebb19754e9937f9715 (diff) | |
| download | cms-de6a28c63d18a72baa044d9385ed3d15afb40ef0.tar.gz cms-de6a28c63d18a72baa044d9385ed3d15afb40ef0.tar.bz2 cms-de6a28c63d18a72baa044d9385ed3d15afb40ef0.zip | |
paramètres SMTP en mode admin, possibilité d'utiliser deux formulaires sur la même page
Diffstat (limited to 'src/view/FormBuilder.php')
| -rw-r--r-- | src/view/FormBuilder.php | 53 |
1 files changed, 25 insertions, 28 deletions
diff --git a/src/view/FormBuilder.php b/src/view/FormBuilder.php index 7a2adcb..cb438b9 100644 --- a/src/view/FormBuilder.php +++ b/src/view/FormBuilder.php | |||
| @@ -7,41 +7,38 @@ use App\Entity\Node; | |||
| 7 | 7 | ||
| 8 | class FormBuilder extends AbstractBuilder | 8 | class FormBuilder extends AbstractBuilder |
| 9 | { | 9 | { |
| 10 | static private ?Captcha $captcha = null; | ||
| 11 | |||
| 10 | public function __construct(Node $node) | 12 | public function __construct(Node $node) |
| 11 | { | 13 | { |
| 12 | parent::__construct($node); | 14 | parent::__construct($node); |
| 13 | $viewFile = self::VIEWS_PATH . $node->getName() . '.php'; | ||
| 14 | 15 | ||
| 15 | if(file_exists($viewFile)) | 16 | if(!empty($node->getNodeData()->getData())) |
| 16 | { | 17 | { |
| 17 | if(!empty($node->getNodeData()->getData())) | 18 | extract($node->getNodeData()->getData()); |
| 18 | { | 19 | } |
| 19 | extract($node->getNodeData()->getData()); | 20 | |
| 20 | } | 21 | // un seul captcha à la fois! |
| 21 | 22 | if(!self::$captcha){ | |
| 22 | $captcha = new Captcha; | 23 | self::$captcha = new Captcha; |
| 23 | $_SESSION['captcha'] = $captcha->getSolution(); | 24 | $_SESSION['captcha'] = self::$captcha->getSolution(); |
| 24 | 25 | } | |
| 25 | $email = $email ?? Config::$email_dest; | ||
| 26 | |||
| 27 | $admin_content = ''; | ||
| 28 | if($_SESSION['admin']) | ||
| 29 | { | ||
| 30 | $admin_content = '<div class="admin_form"> | ||
| 31 | <p> | ||
| 32 | <label for="recipient">E-mail de destination de ce formulaire</label> | ||
| 33 | <input id="recipient" type="email" name="recipient" placeholder="mon-adresse@email.fr" value="' . $email . '"> | ||
| 34 | <input type="hidden" id="recipient_hidden" value=""> | ||
| 35 | <button onclick="changeRecipient(' . $node->getNodeData()->getId() . ')">Valider</button> | ||
| 36 | </p> | ||
| 37 | <p><button onclick="sendTestEmail(' . $node->getNodeData()->getId() . ')">Envoi d\'un e-mail de test</button></p> | ||
| 38 | <p class="test_email_success full_width_column"></p> | ||
| 39 | </div>' . "\n"; | ||
| 40 | } | ||
| 41 | 26 | ||
| 27 | $smtp_host = $smtp_host ?? Config::$smtp_host; | ||
| 28 | $smtp_secure = $smtp_secure ?? Config::$smtp_secure; | ||
| 29 | $smtp_username = $smtp_username ?? Config::$smtp_username; | ||
| 30 | $email_dest = $email_dest ?? Config::$email_dest; | ||
| 31 | |||
| 32 | $admin_content = ''; | ||
| 33 | if($_SESSION['admin']) | ||
| 34 | { | ||
| 42 | ob_start(); | 35 | ob_start(); |
| 43 | require $viewFile; | 36 | require self::VIEWS_PATH . 'form_params.php'; |
| 44 | $this->html = ob_get_clean(); // pas de concaténation ici, on écrase | 37 | $admin_content = ob_get_clean(); |
| 45 | } | 38 | } |
| 39 | |||
| 40 | ob_start(); | ||
| 41 | require self::VIEWS_PATH . $node->getName() . '.php'; | ||
| 42 | $this->html = ob_get_clean(); // pas de concaténation ici, on écrase | ||
| 46 | } | 43 | } |
| 47 | } \ No newline at end of file | 44 | } \ No newline at end of file |
