~chroot64bit/zivios/gentoo-experimental

« back to all changes in this revision

Viewing changes to application/library/Zend/Form/Decorator/Captcha/Word.php

  • Committer: Mustafa A. Hashmi
  • Date: 2008-12-04 13:32:21 UTC
  • Revision ID: mhashmi@zivios.org-20081204133221-0nd1trunwevijj38
Inclusion of new installation framework with ties to zend layout and dojo layout

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/**
 
3
 * Zend Framework
 
4
 *
 
5
 * LICENSE
 
6
 *
 
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.
 
14
 *
 
15
 * @category   Zend
 
16
 * @package    Zend_Form
 
17
 * @subpackage Decorator
 
18
 * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
 
19
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 
20
 */
 
21
 
 
22
/** Zend_Form_Decorator_Abstract */
 
23
require_once 'Zend/Form/Decorator/Abstract.php';
 
24
 
 
25
/**
 
26
 * Word-based captcha decorator
 
27
 * 
 
28
 * Adds hidden field for ID and text input field for captcha text
 
29
 *
 
30
 * @category   Zend
 
31
 * @package    Zend_Form
 
32
 * @subpackage Element
 
33
 * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
 
34
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 
35
 * @version    $Id: $
 
36
 */
 
37
class Zend_Form_Decorator_Captcha_Word extends Zend_Form_Decorator_Abstract
 
38
{
 
39
    /**
 
40
     * Render captcha
 
41
     * 
 
42
     * @param  string $content 
 
43
     * @return string
 
44
     */
 
45
    public function render($content)
 
46
    {
 
47
        $element = $this->getElement();
 
48
        $view    = $element->getView();
 
49
        if (null === $view) {
 
50
            return $content;
 
51
        }
 
52
 
 
53
        $name = $element->getFullyQualifiedName();
 
54
 
 
55
        $hiddenName = $name . '[id]';
 
56
        $textName   = $name . '[input]';
 
57
 
 
58
        $placement = $this->getPlacement();
 
59
        $separator = $this->getSeparator();
 
60
 
 
61
        $hidden = $view->formHidden($hiddenName, $element->getValue(), $element->getAttribs());
 
62
        $text   = $view->formText($textName, '', $element->getAttribs());
 
63
        switch ($placement) {
 
64
            case 'PREPEND':
 
65
                $content = $hidden . $separator . $text . $separator . $content;
 
66
                break;
 
67
            case 'APPEND':
 
68
            default:
 
69
                $content = $content . $separator . $hidden . $separator . $text;
 
70
        }
 
71
        return $content;
 
72
    }
 
73
}