File indexing completed on 2024-12-22 05:36:41
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Form 0017 * @subpackage Decorator 0018 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0019 * @license http://framework.zend.com/license/new-bsd New BSD License 0020 */ 0021 0022 /** @see Zend_Form_Decorator_Abstract */ 0023 // require_once 'Zend/Form/Decorator/Abstract.php'; 0024 0025 /** 0026 * Captcha generic decorator 0027 * 0028 * Adds captcha adapter output 0029 * 0030 * @category Zend 0031 * @package Zend_Form 0032 * @subpackage Decorator 0033 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0034 * @license http://framework.zend.com/license/new-bsd New BSD License 0035 * @version $Id$ 0036 */ 0037 class Zend_Form_Decorator_Captcha extends Zend_Form_Decorator_Abstract 0038 { 0039 /** 0040 * Render captcha 0041 * 0042 * @param string $content 0043 * @return string 0044 */ 0045 public function render($content) 0046 { 0047 $element = $this->getElement(); 0048 if (!method_exists($element, 'getCaptcha')) { 0049 return $content; 0050 } 0051 0052 $view = $element->getView(); 0053 if (null === $view) { 0054 return $content; 0055 } 0056 0057 $placement = $this->getPlacement(); 0058 $separator = $this->getSeparator(); 0059 0060 $captcha = $element->getCaptcha(); 0061 $markup = $captcha->render($view, $element); 0062 switch ($placement) { 0063 case 'PREPEND': 0064 $content = $markup . $separator . $content; 0065 break; 0066 case 'APPEND': 0067 default: 0068 $content = $content . $separator . $markup; 0069 } 0070 return $content; 0071 } 0072 }