From de6a28c63d18a72baa044d9385ed3d15afb40ef0 Mon Sep 17 00:00:00 2001 From: polo Date: Fri, 12 Sep 2025 15:04:53 +0200 Subject: =?UTF-8?q?param=C3=A8tres=20SMTP=20en=20mode=20admin,=20possibili?= =?UTF-8?q?t=C3=A9=20d'utiliser=20deux=20formulaires=20sur=20la=20m=C3=AAm?= =?UTF-8?q?e=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/view/FormBuilder.php | 53 +++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 28 deletions(-) (limited to 'src/view/FormBuilder.php') 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; class FormBuilder extends AbstractBuilder { + static private ?Captcha $captcha = null; + public function __construct(Node $node) { parent::__construct($node); - $viewFile = self::VIEWS_PATH . $node->getName() . '.php'; - if(file_exists($viewFile)) + if(!empty($node->getNodeData()->getData())) { - if(!empty($node->getNodeData()->getData())) - { - extract($node->getNodeData()->getData()); - } - - $captcha = new Captcha; - $_SESSION['captcha'] = $captcha->getSolution(); - - $email = $email ?? Config::$email_dest; - - $admin_content = ''; - if($_SESSION['admin']) - { - $admin_content = '
-

- - - - -

-

-

-
' . "\n"; - } + extract($node->getNodeData()->getData()); + } + + // un seul captcha à la fois! + if(!self::$captcha){ + self::$captcha = new Captcha; + $_SESSION['captcha'] = self::$captcha->getSolution(); + } + $smtp_host = $smtp_host ?? Config::$smtp_host; + $smtp_secure = $smtp_secure ?? Config::$smtp_secure; + $smtp_username = $smtp_username ?? Config::$smtp_username; + $email_dest = $email_dest ?? Config::$email_dest; + + $admin_content = ''; + if($_SESSION['admin']) + { ob_start(); - require $viewFile; - $this->html = ob_get_clean(); // pas de concaténation ici, on écrase + require self::VIEWS_PATH . 'form_params.php'; + $admin_content = ob_get_clean(); } + + ob_start(); + require self::VIEWS_PATH . $node->getName() . '.php'; + $this->html = ob_get_clean(); // pas de concaténation ici, on écrase } } \ No newline at end of file -- cgit v1.2.3