urlHelper = $urlHelper; $this->captchaSession = $captchaSession; $this->captchaPhrase = $captchaPhrase; $this->subscriptionUrlFactory = $subscriptionUrlFactory; $this->formRenderer = $formRenderer; $this->formsRepository = $formsRepository; $this->styles = $styles; } public function getCaptchaPageTitle() { return __("Confirm you’re not a robot", 'mailpoet'); } public function getCaptchaPageContent(string $sessionId) { $this->captchaPhrase->createPhrase($sessionId); $captchaSessionForm = $this->captchaSession->getFormData($sessionId); $showSuccessMessage = !empty($_GET['mailpoet_success']); $showErrorMessage = !empty($_GET['mailpoet_error']); $formId = 0; if (isset($captchaSessionForm['form_id'])) { $formId = (int)$captchaSessionForm['form_id']; } elseif ($showSuccessMessage) { $formId = (int)$_GET['mailpoet_success']; } elseif ($showErrorMessage) { $formId = (int)$_GET['mailpoet_error']; } $formModel = $this->formsRepository->findOneById($formId); if (!$formModel instanceof FormEntity) { return false; } $fields = [ [ 'id' => 'captcha', 'type' => 'text', 'params' => [ 'label' => __('Type in the characters you see in the picture above:', 'mailpoet'), 'value' => '', 'obfuscate' => false, ], ], ]; $submitBlocks = $formModel->getBlocksByTypes(['submit']); $submitLabel = count($submitBlocks) && $submitBlocks[0]['params']['label'] ? $submitBlocks[0]['params']['label'] : __('Subscribe', 'mailpoet'); $form = array_merge( $fields, [ [ 'id' => 'submit', 'type' => 'submit', 'params' => [ 'label' => $submitLabel, ], ], ] ); if ($showSuccessMessage) { // Display a success message in a no-JS flow return $this->renderFormMessages($formModel, $showSuccessMessage); } $formHtml = '
'; $formHtml .= ''; return $formHtml; } private function renderFormMessages( FormEntity $formModel, $showSuccessMessage = false, $showErrorMessage = false ) { $settings = $formModel->getSettings() ?? []; $formHtml = ' '; return $formHtml; } }