/** * Renders the captcha image and its textfields * * @return string */ public function render() { // Render image tag $this->tag->reset(); $this->tag->setTagName("img"); $this->tag->addAttributes($this->getAttributes("image", array("src" => $this->captchaService->create($this->arguments["width"], $this->arguments["height"]), "width" => $this->arguments["width"], "height" => $this->arguments["height"], "style" => "width: " . $this->arguments["width"] . "px; height: " . $this->arguments["height"] . "px;"))); $markup = str_replace("{image}", $this->tag->render(), $this->arguments["markup"]); // Render phrase textfield $this->tag->reset(); $this->tag->setTagName("input"); $this->tag->addAttributes($this->getAttributes("phrase", array("name" => $this->arguments["name"] . "[phrase]", "type" => "text", "autocomplete" => "off"))); $markup = str_replace("{phrase}", $this->tag->render(), $markup); // Render phrase textfield $this->tag->reset(); $this->tag->setTagName("input"); $this->tag->addAttributes($this->getAttributes("hash", array("name" => $this->arguments["name"] . "[hash]", "type" => "hidden", "value" => $this->captchaService->getPhraseHash()))); return str_replace("{hash}", $this->tag->render(), $markup); }
/** * Renders hidden form fields for referrer information about * the current request. * * @return string Hidden fields with referrer information */ protected function renderHiddenReferrerFields() { $tagBuilder = new TagBuilder('input'); $tagBuilder->addAttribute('type', 'hidden'); $tagBuilder->addAttribute('name', $this->prefixFieldName('__state')); $serializedFormState = base64_encode(serialize($this->arguments['object']->getFormState())); $tagBuilder->addAttribute('value', $this->hashService->appendHmac($serializedFormState)); return $tagBuilder->render(); }