コード例 #1
0
 public function onPreRender($param)
 {
     parent::onPreRender($param);
     $cs = $this->Page->getClientScript();
     $cs->registerPradoScript('validator');
     // communicate validation status to the client side
     $value = $this->_isvalid === false ? '0' : '1';
     $cs->registerHiddenField($this->getClientID() . '_1', $value);
     // update validator display
     if ($control = $this->getValidationTarget()) {
         $fn = 'captchaUpdateValidatorStatus_' . $this->getClientID();
         // check if we need to request a new captcha too
         if ($this->Page->IsCallback) {
             if ($control->getVisible(true)) {
                 if (!is_null($this->_isvalid)) {
                     // if the response has been tested and we reach the pre-render phase
                     // then we need to regenerate the token, because it won't test positive
                     // anymore, even if solves correctly
                     $control->regenerateToken();
                 }
             }
         }
         $cs->registerEndScript($this->getClientID() . '::validate', implode(' ', array('function ' . $fn . '(valid)', '{', '  jQuery(' . TJavaScript::quoteString('#' . $this->getClientID() . '_1') . ').val(valid);', '  Prado.Validation.validateControl(' . TJavaScript::quoteString($control->ClientID) . '); ', '}', '', $this->Page->IsCallback ? $fn . '(' . $value . ');' : '', '', 'jQuery("#' . $control->getClientID() . '").on("keyup", ' . TJavaScript::quoteString('#' . $control->getResponseFieldName()) . ', function() { ', $fn . '("1");', '});')));
     }
 }
コード例 #2
0
ファイル: pradolite.php プロジェクト: tejdeeps/tejcs.com
 public function registerFocusControl($target)
 {
     $this->registerPradoScriptInternal('effects');
     if ($target instanceof TControl) {
         $target = $target->getClientID();
     }
     $id = TJavaScript::quoteString($target);
     $this->_endScripts['prado:focus'] = 'Prado.Element.focus(' . $id . ');';
     $params = func_get_args();
     $this->_page->registerCachingAction('Page.ClientScript', 'registerFocusControl', $params);
 }
コード例 #3
0
ファイル: TReCaptcha.php プロジェクト: ullasnaidu/epro
 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 = 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', 'http://www.google.com/recaptcha/api/js/recaptcha_ajax.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>');
 }