aboutsummaryrefslogtreecommitdiff
path: root/src/view/FormBuilder.php
blob: cb438b932a8b0315f999f262479b39ea603d54cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
// src/view/FormBuilder.php

declare(strict_types=1);

use App\Entity\Node;

class FormBuilder extends AbstractBuilder
{
    static private ?Captcha $captcha = null;

    public function __construct(Node $node)
    {
        parent::__construct($node);
        
        if(!empty($node->getNodeData()->getData()))
        {
            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 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
    }
}