summaryrefslogtreecommitdiff
path: root/src/view/FormBuilder.php
blob: 508763b2bf6789f6581c1e116c25a5b81ff36eab (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
45
46
47
48
49
50
51
52
53
<?php
// src/view/FormBuilder.php

declare(strict_types=1);

use App\Entity\Node;

class FormBuilder extends AbstractBuilder
{
    public function __construct(Node $node)
    {
        parent::__construct($node);
        $viewFile = self::VIEWS_PATH . $node->getName() . '.php';
        
        if(file_exists($viewFile))
        {
            if(!empty($node->getNodeData()->getData()))
            {
                extract($node->getNodeData()->getData());
            }

            $captcha = new Captcha;
            $_SESSION['captcha'] = $captcha->getSolution();

            $admin_content = '';
            if($_SESSION['admin'])
            {
                $admin_content = ''
                    //. '<h3>Configuration du formulaire</h3>' . "\n"
                    . '<div class="admin_form">' . "\n"
                    /*. '<p>
                        <label for="recipient">E-mail de destination</label>
                        <input id="recipient" type="email" name="recipient" placeholder="mon-adresse@email.fr" value="' . $email . '">
                        <input type="hidden" id="recipient_hidden" value="">
                        <button onclick="changeRecipient(' . $node->getNodeData()->getId() . ')">Valider</button>
                    </p>
                    <p>
                        <label for="smtp">Serveur SMTP</label>
                        <input id="smtp" type="text" name="smtp" value="' . $smtp . '">
                        <input type="hidden" id="smtp_hidden" value="">
                        <button onclick="changeSmtp(' . $node->getNodeData()->getId() . ')">Valider</button>
                    </p>' . "\n"*/
                    . '<p><button onclick="sendTestEmail()">Envoi d\'un e-mail de test</button></p>' . "\n"
                    . '<p class="test_email_success full_width_column"></p>'
                    . '</div>' . "\n";
            }

            ob_start();
            require $viewFile;
            $this->html = ob_get_clean(); // pas de concaténation ici, on écrase
        }
    }
}