Prado\Web\UI\WebControls\TReCaptcha::renderContents PHP Method

renderContents() public method

public renderContents ( $writer )
    public function renderContents($writer)
    {
        $readyscript = 'jQuery(document).trigger(' . TJavaScript::quoteString('captchaready:' . $this->getClientID()) . ')';
        $cs = $this->Page->ClientScript;
        $id = $this->getClientID();
        $divid = $id . '_1_recaptchadiv';
        $writer->write('<div id="' . htmlspecialchars($divid) . '">');
        if (!$this->Page->IsCallback) {
            $writer->write(TJavaScript::renderScriptBlock('var RecaptchaOptions = ' . TJavaScript::jsonEncode($this->getClientSideOptions()) . ';'));
            $html = $this->recaptcha_get_html($this->getPublicKey());
            /*
            reCAPTCHA currently does not support multiple validations per page
            $html = str_replace(
            	array(self::ChallengeFieldName,self::ResponseFieldName),
            	array($this->getChallengeFieldName(),$this->getResponseFieldName()),
            	$html
            );
            */
            $writer->write($html);
            $cs->registerEndScript('ReCaptcha::EventScript', 'jQuery(document).ready(function() { ' . $readyscript . '; } );');
        } else {
            $options = $this->getClientSideOptions();
            $options['callback'] = new TJavaScriptLiteral('function() { ' . $readyscript . '; ' . $this->getCallbackScript() . '; }');
            $cs->registerScriptFile('ReCaptcha::AjaxScript', self::RECAPTCHA_JS);
            $cs->registerEndScript('ReCaptcha::CreateScript::' . $id, implode(' ', array('if (!jQuery(' . TJavaScript::quoteString('#' . $this->getResponseFieldName()) . '))', '{', 'Recaptcha.destroy();', 'Recaptcha.create(', TJavaScript::quoteString($this->getPublicKey()) . ', ', TJavaScript::quoteString($divid) . ', ', TJavaScript::encode($options), ');', '}')));
        }
        $writer->write('</div>');
    }