import v1.1.0_RC2 | 2009-09-20

This commit is contained in:
2019-07-17 22:19:00 +02:00
parent 3b7ba80568
commit 38c146901c
2504 changed files with 101817 additions and 62316 deletions

View File

@ -15,35 +15,36 @@
* @category Zend
* @package Zend_Form
* @subpackage Element
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Captcha.php 17616 2009-08-15 03:28:29Z yoshida@zend.co.jp $
*/
/** Zend_Form_Element_Xhtml */
/** @see Zend_Form_Element_Xhtml */
require_once 'Zend/Form/Element/Xhtml.php';
/** Zend_Captcha_Adapter */
/** @see Zend_Captcha_Adapter */
require_once 'Zend/Captcha/Adapter.php';
/**
* 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
* @package Zend_Form
* @subpackage Element
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @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
* Captcha plugin type constant
*/
const CAPTCHA = 'CAPTCHA';
@ -53,24 +54,24 @@ class Zend_Form_Element_Captcha extends Zend_Form_Element_Xhtml
* @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 +100,7 @@ class Zend_Form_Element_Captcha extends Zend_Form_Element_Xhtml
}
}
}
$this->_captcha = $instance;
$this->_captcha->setName($this->getName());
return $this;
@ -112,18 +113,18 @@ class Zend_Form_Element_Captcha extends Zend_Form_Element_Xhtml
* - 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 +148,8 @@ class Zend_Form_Element_Captcha extends Zend_Form_Element_Xhtml
* 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 +165,11 @@ class Zend_Form_Element_Captcha extends Zend_Form_Element_Xhtml
}
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)
@ -192,13 +193,13 @@ class Zend_Form_Element_Captcha extends Zend_Form_Element_Xhtml
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 +218,15 @@ class Zend_Form_Element_Captcha extends Zend_Form_Element_Xhtml
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 $prefix
* @param string $path
* @param string $type
* @return Zend_Form_Element
* @see Zend_Form_Element::addPrefixPath
*/
@ -246,10 +248,10 @@ class Zend_Form_Element_Captcha extends Zend_Form_Element_Xhtml
return parent::addPrefixPath($prefix, $path, $type);
}
}
/**
* Load default decorators
*
*
* @return void
*/
public function loadDefaultDecorators()
@ -269,9 +271,9 @@ class Zend_Form_Element_Captcha extends Zend_Form_Element_Xhtml
/**
* Is the captcha valid?
*
* @param mixed $value
* @param mixed $context
*
* @param mixed $value
* @param mixed $context
* @return boolean
*/
public function isValid($value, $context = null)