diff options
Diffstat (limited to 'src/view/FormBuilder.php')
| -rw-r--r-- | src/view/FormBuilder.php | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/src/view/FormBuilder.php b/src/view/FormBuilder.php deleted file mode 100644 index 9a900ce..0000000 --- a/src/view/FormBuilder.php +++ /dev/null | |||
| @@ -1,50 +0,0 @@ | |||
| 1 | <?php | ||
| 2 | // src/view/FormBuilder.php | ||
| 3 | |||
| 4 | declare(strict_types=1); | ||
| 5 | |||
| 6 | use App\Entity\Node; | ||
| 7 | |||
| 8 | class FormBuilder extends AbstractBuilder | ||
| 9 | { | ||
| 10 | static private ?Captcha $captcha = null; | ||
| 11 | |||
| 12 | public function __construct(Node $node){ | ||
| 13 | parent::__construct($node); | ||
| 14 | |||
| 15 | if(!empty($node->getNodeData()->getData())){ | ||
| 16 | extract($node->getNodeData()->getData()); | ||
| 17 | } | ||
| 18 | |||
| 19 | // un seul captcha à la fois! | ||
| 20 | if(!self::$captcha){ | ||
| 21 | self::$captcha = new Captcha; | ||
| 22 | $_SESSION['captcha'] = self::$captcha->getSolution(); | ||
| 23 | } | ||
| 24 | |||
| 25 | // données stockées en vrac dans du JSON et récupérées avec extract => changer ça un jour | ||
| 26 | $smtp_host = $smtp_host ?? Config::$smtp_host; | ||
| 27 | $smtp_secure = $smtp_secure ?? Config::$smtp_secure; | ||
| 28 | $smtp_username = $smtp_username ?? Config::$smtp_username; | ||
| 29 | $email_dest = $email_dest ?? Config::$email_dest; | ||
| 30 | $keep_emails = (bool)($keep_emails ?? false); // (bool) est inutile mais plus clair | ||
| 31 | $retention_period = $this->getRetentionPeriod($retention_period ?? null, App\Entity\Email::DEFAULT_RETENTION_PERIOD); | ||
| 32 | $retention_period_sensible = $this->getRetentionPeriod($retention_period_sensible ?? null, App\Entity\Email::DEFAULT_RETENTION_PERIOD_SENSITIVE); | ||
| 33 | |||
| 34 | $admin_content = ''; | ||
| 35 | if(IS_ADMIN){ | ||
| 36 | ob_start(); | ||
| 37 | require self::VIEWS_PATH . 'form_admin.php'; | ||
| 38 | $admin_content = ob_get_clean(); | ||
| 39 | } | ||
| 40 | |||
| 41 | ob_start(); | ||
| 42 | require self::VIEWS_PATH . $node->getName() . '.php'; | ||
| 43 | $this->html = ob_get_clean(); // pas de concaténation ici, on écrase | ||
| 44 | } | ||
| 45 | |||
| 46 | private function getRetentionPeriod(mixed $period, int $default_period): int | ||
| 47 | { | ||
| 48 | return ($period === null || (int)$period <= 0) ? $default_period : (int)$period; // (int) est nécessaire à cause du stockage JSON | ||
| 49 | } | ||
| 50 | } \ No newline at end of file | ||
