styleUtils = $styleUtils; $this->settings = $settings; } public function renderStyles(array $form = [], string $prefix = null): string { $html = ''; return $html; } public function renderHTML(array $form = []): string { if (isset($form['body']) && !empty($form['body'])) { return $this->renderBlocks($form['body']); } return ''; } public function getStyles(array $form = []): string { if (isset($form['styles']) && strlen(trim($form['styles'])) > 0) { return strip_tags($form['styles']); } else { return $this->styleUtils->getDefaultStyles(); } } public function renderBlocks(array $blocks = [], bool $honeypotEnabled = true): string { // add honeypot for spambots $html = ($honeypotEnabled) ? '' : ''; foreach ($blocks as $key => $block) { if ($block['type'] == 'submit' && $this->settings->get('captcha.type') === Captcha::TYPE_RECAPTCHA) { $siteKey = $this->settings->get('captcha.recaptcha_site_token'); $html .= '
'; } $html .= $this->renderBlock($block) . PHP_EOL; } return $html; } private function renderBlock(array $block = []): string { $html = ''; switch ($block['type']) { case 'html': $html .= Block\Html::render($block); break; case 'divider': $html .= Block\Divider::render(); break; case 'checkbox': $html .= Block\Checkbox::render($block); break; case 'radio': $html .= Block\Radio::render($block); break; case 'segment': $html .= Block\Segment::render($block); break; case 'date': $html .= Block\Date::render($block); break; case 'select': $html .= Block\Select::render($block); break; case 'text': $html .= Block\Text::render($block); break; case 'textarea': $html .= Block\Textarea::render($block); break; case 'submit': $html .= Block\Submit::render($block); break; } return $html; } }