Пример #1
0
 /**
  * Generate <div> with ReCaptcha from render.
  *
  * @param boolean $useRecaptcha Boolean of active state, for compact templating
  *
  * @return string $html
  */
 public function html($useRecaptcha = true)
 {
     if (!isset($useRecaptcha) || !$useRecaptcha) {
         return false;
     }
     if ($this->recaptcha->getPublicKey() === null) {
         throw new Exception('Missing public key');
     }
     $host = \ZendService\Recaptcha\Recaptcha::API_SERVER;
     $params = $this->recaptcha->getParams();
     if ((bool) $params['ssl'] === true) {
         $host = \ZendService\Recaptcha\Recaptcha::API_SECURE_SERVER;
     }
     $errorPart = '';
     if (!empty($params['error'])) {
         $errorPart = '&error=' . urlencode($params['error']);
     }
     $options = $this->recaptcha->getOptions();
     if (!empty($options)) {
         $encoded = \Zend\Json\Json::encode($options);
     } else {
         $encoded = "{}";
     }
     $challengeField = 'recaptcha_challenge_field';
     $responseField = 'recaptcha_response_field';
     if (!empty($name)) {
         $challengeField = $name . '[' . $challengeField . ']';
         $responseField = $name . '[' . $responseField . ']';
     }
     return $this->view->render('Service/recaptcha.phtml', ['challengeField' => $challengeField, 'errorPart' => $errorPart, 'host' => $host, 'options' => $encoded, 'publicKey' => $this->recaptcha->getPublicKey(), 'responseField' => $responseField, 'theme' => $options['theme'], 'useRecaptcha' => $useRecaptcha]);
 }
Пример #2
0
 /**
  * Generate <div> with ReCaptcha from render.
  *
  * @param boolean $useRecaptcha Boolean of active state, for compact templating
  *
  * @return string $html
  */
 public function html($useRecaptcha = true)
 {
     if (!isset($useRecaptcha) || !$useRecaptcha) {
         return false;
     }
     return $this->recaptcha->getHtml();
 }
Пример #3
0
 /**
  * Generate <div> with ReCaptcha from render.
  *
  * @param bool $useRecaptcha Boolean of active state, for compact templating
  * @param bool $wrapHtml     Include prefix and suffix?
  *
  * @return string $html
  */
 public function html($useRecaptcha = true, $wrapHtml = true)
 {
     if (!isset($useRecaptcha) || !$useRecaptcha) {
         return false;
     }
     if (!$wrapHtml) {
         return $this->recaptcha->getHtml();
     }
     return $this->prefixHtml . $this->recaptcha->getHtml() . $this->suffixHtml;
 }
Пример #4
0
 /**
  * Constructor
  *
  * @param \ZendService\Recaptcha\Recaptcha $rc     Custom formatted Recaptcha
  * @param \VuFind\Config                   $config Config object
  */
 public function __construct($rc, $config)
 {
     $this->prefixHtml = '<div class="form-group">' . '<div class="col-sm-9 col-sm-offset-3">';
     $this->suffixHtml = '</div></div>';
     parent::__construct($rc, $config);
 }