aboutsummaryrefslogtreecommitdiff
path: root/src/view/FormBuilder.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/view/FormBuilder.php')
-rw-r--r--src/view/FormBuilder.php53
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
8class FormBuilder extends AbstractBuilder 8class 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