当前位置: 首页>>代码示例>>PHP>>正文


PHP ElementInterface::getCaptcha方法代码示例

本文整理汇总了PHP中Zend\Form\ElementInterface::getCaptcha方法的典型用法代码示例。如果您正苦于以下问题:PHP ElementInterface::getCaptcha方法的具体用法?PHP ElementInterface::getCaptcha怎么用?PHP ElementInterface::getCaptcha使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Form\ElementInterface的用法示例。


在下文中一共展示了ElementInterface::getCaptcha方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: render

 /**
  * {@inheritDoc}
  */
 public function render(ElementInterface $element, $options = array())
 {
     $captcha = $element->getCaptcha();
     if ($captcha === null || !$captcha instanceof CaptchaAdapter) {
         throw new \DomainException(sprintf('%s requires that the element has a "captcha" attribute' . ' implementing Zend\\Captcha\\AdapterInterface; none found', __METHOD__));
     }
     $helper = $captcha->getHelperName();
     $renderer = $this->getView();
     if (!method_exists($renderer, 'plugin')) {
         throw new \DomainException(sprintf('%s requires that the renderer implements plugin();' . ' it does not', __METHOD__));
     }
     $helper = $renderer->plugin($helper);
     // Custom CAPTCHA view
     $separator = null;
     if (isset($options['separator'])) {
         $separator = $options['separator'];
     } elseif ($element->getOption('separator')) {
         $separator = $element->getOption('separator');
     }
     if (null !== $separator) {
         $helper->setSeparator($separator);
     }
     $position = null;
     if (isset($options['captcha_position'])) {
         $position = $options['captcha_position'];
     } elseif ($element->getOption('captcha_position')) {
         $position = $element->getOption('captcha_position');
     }
     if (null !== $position) {
         $helper->setCaptchaPosition($position);
     }
     return $helper($element);
 }
开发者ID:Andyyang1981,项目名称:pi,代码行数:36,代码来源:FormCaptcha.php

示例2: render

 /**
  * Override
  * 
  * Render the captcha
  *
  * @param  ElementInterface $element
  * @throws Exception\DomainException
  * @return string
  */
 public function render(ElementInterface $element)
 {
     //we could also set the separator here to break between the inputs and the image.
     //$this->setSeparator('')
     $captcha = $element->getCaptcha();
     if ($captcha === null || !$captcha instanceof CaptchaAdapter) {
         throw new DomainException(sprintf('%s requires that the element has a "captcha" attribute of type Recruitment\\Model\\CaptchaImage;
     none found', __METHOD__));
     }
     $captcha->generate();
     $imgAttributes = array('width' => $captcha->getWidth(), 'height' => $captcha->getHeight(), 'alt' => $captcha->getImgAlt(), 'src' => $captcha->getImgUrl() . $captcha->getId() . $captcha->getSuffix(), 'class' => 'thumbnail center-block');
     if ($element->hasAttribute('id')) {
         $imgAttributes['id'] = $element->getAttribute('id') . '-image';
     }
     $closingBracket = $this->getInlineClosingBracket();
     $img = sprintf('<img  %s%s ', $this->createAttributesString($imgAttributes), $closingBracket);
     $position = $this->getCaptchaPosition();
     $separator = $this->getSeparator();
     $captchaInput = $this->renderCaptchaInputs($element);
     $pattern = '%s' . '<div class="input-group">' . '%s%s' . '<span class="input-group-btn">' . '<button id="' . $element->getAttribute('id') . '-refresh' . '" class="btn btn-default" type="button">' . '<i class="ion-loop"></i>' . '</button>' . '</span>' . '</div>';
     if ($position == self::CAPTCHA_PREPEND) {
         return sprintf($pattern, $captchaInput, $separator, $img);
     }
     return sprintf($pattern, $img, $separator, $captchaInput);
 }
开发者ID:CATSInformatica,项目名称:CatsSys,代码行数:34,代码来源:CaptchaImage.php

示例3: render

 /**
  * {@inheritDoc}
  */
 public function render(ElementInterface $element)
 {
     $captcha = $element->getCaptcha();
     if ($captcha === null || !$captcha instanceof CaptchaAdapter) {
         throw new Exception\DomainException(sprintf('%s requires that the element has a "captcha" attribute' . ' of type Zend\\Captcha\\Image; none found', __METHOD__));
     }
     // Generates ID, but NOT word and image
     $captcha->generate();
     // Generates URL to access image, and image won't be generated until the URL is accessed
     $imgSrc = $captcha->getImgUrl() . '?id=' . $captcha->getId();
     $imgAttributes = array('width' => $captcha->getWidth(), 'height' => $captcha->getHeight(), 'src' => $imgSrc, 'onclick' => sprintf('this.src=\'%s&refresh=\'+Math.random()', $imgSrc), 'style' => 'cursor: pointer; vertical-align: middle;', 'alt' => __('CAPTCHA image'), 'title' => __('Click to refresh CAPTCHA'));
     if ($element->hasAttribute('id')) {
         $imgAttributes['id'] = $element->getAttribute('id') . '-image';
     } else {
         $imgAttributes['id'] = $captcha->getId() . '-image';
     }
     $closingBracket = $this->getInlineClosingBracket();
     $img = sprintf('<img %s%s', $this->createAttributesString($imgAttributes), $closingBracket);
     $position = $this->getCaptchaPosition();
     $separator = $this->getSeparator();
     $captchaInput = $this->renderCaptchaInputs($element);
     $pattern = '%s%s%s';
     if ($position == static::CAPTCHA_PREPEND) {
         return sprintf($pattern, $captchaInput, $separator, $img);
     }
     return sprintf($pattern, $img, $separator, $captchaInput);
 }
开发者ID:Andyyang1981,项目名称:pi,代码行数:30,代码来源:Image.php

示例4: render

 /**
  * @param ElementInterface $element
  *
  * @return string
  */
 public function render(ElementInterface $element)
 {
     /** @var \Zf3Php7Recaptcha\ReCaptcha $captcha */
     $captcha = $element->getCaptcha();
     $pubkey = $captcha->getPubkey();
     $theme = $captcha->getTheme();
     $html = '<div class="g-recaptcha" data-sitekey="' . $pubkey . '" data-theme="' . $theme . '"></div>';
     //Add the js for the recaptcha api
     $this->view->headScript()->appendFile('https://www.google.com/recaptcha/api.js');
     return $html;
 }
开发者ID:nocvp,项目名称:zf3-php7-recaptcha-v2,代码行数:16,代码来源:ReCaptcha.php

示例5: render

 /**
  * Render a form captcha for an element
  *
  * @param  ElementInterface $element
  * @throws Exception\DomainException if the element does not compose a captcha, or the renderer does not implement plugin()
  * @return string
  */
 public function render(ElementInterface $element)
 {
     $captcha = $element->getCaptcha();
     if ($captcha === null || !$captcha instanceof CaptchaAdapter) {
         throw new Exception\DomainException(sprintf('%s requires that the element has a "captcha" attribute implementing Zend\\Captcha\\AdapterInterface; none found', __METHOD__));
     }
     $helper = $captcha->getHelperName();
     $renderer = $this->getView();
     if (!method_exists($renderer, 'plugin')) {
         throw new Exception\DomainException(sprintf('%s requires that the renderer implements plugin(); it does not', __METHOD__));
     }
     $helper = $renderer->plugin($helper);
     return $helper($element);
 }
开发者ID:Flesh192,项目名称:magento,代码行数:21,代码来源:FormCaptcha.php

示例6: renderCaptchaInputs

 /**
  * Render captcha form elements for the given element
  *
  * Creates and returns:
  * - Hidden input with captcha identifier (name[id])
  * - Text input for entering captcha value (name[input])
  *
  * More specific renderers will consume this and render it.
  *
  * @param  ElementInterface $element
  * @throws Exception\DomainException
  * @return string
  */
 protected function renderCaptchaInputs(ElementInterface $element)
 {
     $name = $element->getName();
     if ($name === null || $name === '') {
         throw new Exception\DomainException(sprintf('%s requires that the element has an assigned name; none discovered', __METHOD__));
     }
     $attributes = $element->getAttributes();
     $captcha = $element->getCaptcha();
     if ($captcha === null || !$captcha instanceof CaptchaAdapter) {
         throw new Exception\DomainException(sprintf('%s requires that the element has a "captcha" attribute implementing Zend\\Captcha\\AdapterInterface; none found', __METHOD__));
     }
     $hidden = $this->renderCaptchaHidden($captcha, $attributes);
     $input = $this->renderCaptchaInput($captcha, $attributes);
     return $hidden . $input;
 }
开发者ID:eltondias,项目名称:Relogio,代码行数:28,代码来源:AbstractWord.php

示例7: render

 /**
  * @param ElementInterface $element
  *
  * @return string
  */
 public function render(ElementInterface $element)
 {
     $captcha = $element->getCaptcha();
     if ($captcha === null || !$captcha instanceof AdapterInterface) {
         throw new Exception\DomainException(sprintf('%s requires that the element has a "captcha" attribute implementing Zend\\Captcha\\AdapterInterface', __METHOD__));
     }
     $name = $element->getName();
     $id = $element->getAttribute('id') ? $element->getAttribute('id') : $name;
     $captchaPattern = '<div %s></div>';
     $captchaAttributes = $this->createAttributesString(array('class' => 'g-recaptcha ' . $element->getAttribute('class'), 'data-sitekey' => $captcha->getSiteKey(), 'data-theme' => $captcha->getTheme(), 'data-type' => $captcha->getType(), 'data-callback' => $captcha->getCallback()));
     $captchaElement = sprintf($captchaPattern, $captchaAttributes);
     $input = $this->renderHiddenInput($id, $name);
     $js = $this->renderJsCallback($captcha->getCallback(), $id);
     return $captchaElement . $input . $js;
 }
开发者ID:srggroup,项目名称:zf2nocaptcha,代码行数:20,代码来源:NoCaptchaHelper.php

示例8: render

 /**
  * Render ReCaptcha form elements
  *
  * @param  ElementInterface $element
  * @throws Exception\DomainException
  * @return string
  */
 public function render(ElementInterface $element)
 {
     $attributes = $element->getAttributes();
     $captcha = $element->getCaptcha();
     if ($captcha === null || !$captcha instanceof CaptchaAdapter) {
         throw new Exception\DomainException(sprintf('%s requires that the element has a "captcha" attribute implementing Zend\\Captcha\\AdapterInterface; none found', __METHOD__));
     }
     $name = $element->getName();
     $id = isset($attributes['id']) ? $attributes['id'] : $name;
     $responseName = empty($name) ? 'recaptcha_response_field' : $name . '[recaptcha_response_field]';
     $responseId = $id . '-response';
     $markup = $captcha->getService()->getHtml($name);
     $hidden = $this->renderHiddenInput($responseName, $responseId);
     $js = $this->renderJsEvents($responseId);
     return $hidden . $markup . $js;
 }
开发者ID:guenterh,项目名称:vufind,代码行数:23,代码来源:ReCaptcha.php

示例9: render

 /**
  * Render the captcha
  *
  * @param  ElementInterface $element
  * @throws Exception\DomainException
  * @return string
  */
 public function render(ElementInterface $element)
 {
     $captcha = $element->getCaptcha();
     if ($captcha === null || !$captcha instanceof CaptchaAdapter) {
         throw new Exception\DomainException(sprintf('%s requires that the element has a "captcha" attribute of type Zend\\Captcha\\Figlet; none found', __METHOD__));
     }
     $captcha->generate();
     $figlet = sprintf('<pre>%s</pre>', $captcha->getFiglet()->render($captcha->getWord()));
     $position = $this->getCaptchaPosition();
     $separator = $this->getSeparator();
     $captchaInput = $this->renderCaptchaInputs($element);
     $pattern = '%s%s%s';
     if ($position == self::CAPTCHA_PREPEND) {
         return sprintf($pattern, $captchaInput, $separator, $figlet);
     }
     return sprintf($pattern, $figlet, $separator, $captchaInput);
 }
开发者ID:idwsdta,项目名称:INIT-frame,代码行数:24,代码来源:Figlet.php

示例10: render

 /**
  * Render the captcha
  *
  * @param  ElementInterface $element
  * @throws Exception\DomainException
  * @return string
  */
 public function render(ElementInterface $element)
 {
     $captcha = $element->getCaptcha();
     if ($captcha === null || !$captcha instanceof CaptchaAdapter) {
         throw new Exception\DomainException(sprintf('%s requires that the element has a "captcha" attribute of type Zend\\Captcha\\Image; none found', __METHOD__));
     }
     $captcha->generate();
     $imgAttributes = array('width' => $captcha->getWidth(), 'height' => $captcha->getHeight(), 'alt' => $captcha->getImgAlt(), 'src' => $captcha->getImgUrl() . $captcha->getId() . $captcha->getSuffix());
     $closingBracket = $this->getInlineClosingBracket();
     $img = sprintf('<img %s%s', $this->createAttributesString($imgAttributes), $closingBracket);
     $position = $this->getCaptchaPosition();
     $separator = $this->getSeparator();
     $captchaInput = $this->renderCaptchaInputs($element);
     $pattern = '%s%s%s';
     if ($position == self::CAPTCHA_PREPEND) {
         return sprintf($pattern, $captchaInput, $separator, $img);
     }
     return sprintf($pattern, $img, $separator, $captchaInput);
 }
开发者ID:Baft,项目名称:Zend-Form,代码行数:26,代码来源:Image.php

示例11: render

 /**
  * {@inheritDoc}
  */
 public function render(ElementInterface $element)
 {
     $captcha = $element->getCaptcha();
     if ($captcha === null || !$captcha instanceof CaptchaAdapter) {
         throw new Exception\DomainException(sprintf('%s requires that the element has a "captcha" attribute ' . 'implementing %s; none found', __METHOD__, CaptchaAdapter::class));
     }
     $helper = $captcha->getHelperName();
     $renderer = $this->getView();
     if (!method_exists($renderer, 'plugin')) {
         throw new Exception\DomainException(sprintf('%s requires that the renderer implements plugin(); it does not', __METHOD__));
     }
     $helper = $renderer->plugin($helper);
     if ($helper instanceof TranslatorAwareInterface) {
         $rollbackTextDomain = $helper->getTranslatorTextDomain();
         $helper->setTranslatorTextDomain($this->getTranslatorTextDomain());
     }
     $markup = parent::render($element);
     if ($helper instanceof TranslatorAwareInterface) {
         $helper->setTranslatorTextDomain($rollbackTextDomain);
     }
     return $markup;
 }
开发者ID:coolms,项目名称:common,代码行数:25,代码来源:FormCaptcha.php


注:本文中的Zend\Form\ElementInterface::getCaptcha方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。