--- library/Zend/Form/Element/Captcha.php (revisión: 16491) +++ library/Zend/Form/Element/Captcha.php (copia de trabajo) @@ -27,11 +27,11 @@ /** * Generic captcha element - * + * * This element allows to insert CAPTCHA into the form in order * to validate that human is submitting the form. The actual * logic is contained in the captcha adapter. - * + * * @see http://en.wikipedia.org/wiki/Captcha * * @category Zend @@ -40,7 +40,7 @@ * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Form_Element_Captcha extends Zend_Form_Element_Xhtml +class Zend_Form_Element_Captcha extends Zend_Form_Element_Xhtml { /** * @const string Captch plugin type constant @@ -53,24 +53,24 @@ * @var Zend_Captcha_Adapter */ protected $_captcha; - + /** * Get captcha adapter - * + * * @return Zend_Captcha_Adapter */ - public function getCaptcha() + public function getCaptcha() { return $this->_captcha; } - + /** * Set captcha adapter - * + * * @param string|array|Zend_Captcha_Adapter $captcha * @param array $options */ - public function setCaptcha($captcha, $options = array()) + public function setCaptcha($captcha, $options = array()) { if ($captcha instanceof Zend_Captcha_Adapter) { $instance = $captcha; @@ -99,7 +99,7 @@ } } } - + $this->_captcha = $instance; $this->_captcha->setName($this->getName()); return $this; @@ -112,18 +112,18 @@ * - string: name of element * - array: options with which to configure element * - Zend_Config: Zend_Config with options for configuring element - * - * @param string|array|Zend_Config $spec + * + * @param string|array|Zend_Config $spec * @return void */ - public function __construct($spec, $options = null) + public function __construct($spec, $options = null) { parent::__construct($spec, $options); $this->setAllowEmpty(true) ->setRequired(true) ->setAutoInsertNotEmptyValidator(false) ->addValidator($this->getCaptcha(), true); - } + } /** * Return all attributes @@ -147,8 +147,8 @@ * Set options * * Overrides to allow passing captcha options - * - * @param array $options + * + * @param array $options * @return Zend_Form_Element_Captcha */ public function setOptions(array $options) @@ -164,11 +164,11 @@ } return parent::setOptions($options); } - + /** * Render form element - * - * @param Zend_View_Interface $view + * + * @param Zend_View_Interface $view * @return string */ public function render(Zend_View_Interface $view = null) @@ -176,29 +176,24 @@ $captcha = $this->getCaptcha(); $captcha->setName($this->getFullyQualifiedName()); - $decorators = $this->getDecorators(); - $decorator = $captcha->getDecorator(); if (!empty($decorator)) { - array_unshift($decorators, $decorator); + $this->addDecorator($decorator); } - $decorator = array('Captcha', array('captcha' => $captcha)); - array_unshift($decorators, $decorator); + $this->addDecorator('Captcha', array('captcha' => $captcha)); - $this->setDecorators($decorators); - $this->setValue($this->getCaptcha()->generate()); return parent::render($view); } - + /** * Retrieve plugin loader for validator or filter chain * - * Support for plugin loader for Captcha adapters - * - * @param string $type + * Support for plugin loader for Captcha adapters + * + * @param string $type * @return Zend_Loader_PluginLoader * @throws Zend_Loader_Exception on invalid type. */ @@ -217,14 +212,14 @@ return parent::getPluginLoader($type); } } - + /** * Add prefix path for plugin loader for captcha adapters * * This method handles the captcha type, the rest is handled by - * the parent - * - * @param string $path + * the parent + * + * @param string $path * @return Zend_Form_Element * @see Zend_Form_Element::addPrefixPath */ @@ -246,10 +241,10 @@ return parent::addPrefixPath($prefix, $path, $type); } } - + /** * Load default decorators - * + * * @return void */ public function loadDefaultDecorators() @@ -269,9 +264,9 @@ /** * Is the captcha valid? - * - * @param mixed $value - * @param mixed $context + * + * @param mixed $value + * @param mixed $context * @return boolean */ public function isValid($value, $context = null)