*prechod na novsiu verziu ZF
[sport-group.git] / library / Zend / Form / Decorator / Captcha.php
blob2207532cd4f156d56ab9adda6bb13a49ccf8cabf
1 <?php
2 /**
3 * Zend Framework
5 * LICENSE
7 * This source file is subject to the new BSD license that is bundled
8 * with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
15 * @category Zend
16 * @package Zend_Form
17 * @subpackage Decorator
18 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
22 /** Zend_Form_Decorator_Abstract */
23 require_once 'Zend/Form/Decorator/Abstract.php';
25 /**
26 * Captcha generic decorator
28 * Adds captcha adapter output
30 * @category Zend
31 * @package Zend_Form
32 * @subpackage Decorator
33 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
34 * @license http://framework.zend.com/license/new-bsd New BSD License
35 * @version $Id: Captcha.php 16971 2009-07-22 18:05:45Z mikaelkael $
37 class Zend_Form_Decorator_Captcha extends Zend_Form_Decorator_Abstract
39 /**
40 * Render captcha
42 * @param string $content
43 * @return string
45 public function render($content)
47 $element = $this->getElement();
48 if (!method_exists($element, 'getCaptcha')) {
49 return $content;
52 $view = $element->getView();
53 if (null === $view) {
54 return $content;
57 $placement = $this->getPlacement();
58 $separator = $this->getSeparator();
60 $captcha = $element->getCaptcha();
61 $markup = $captcha->render($view, $element);
62 switch ($placement) {
63 case 'PREPEND':
64 $content = $markup . $separator . $content;
65 break;
66 case 'APPEND':
67 default:
68 $content = $content . $separator . $markup;
70 return $content;