|
|
@@ -20,19 +20,19 @@
|
|
|
* @version $Id$
|
|
|
*/
|
|
|
|
|
|
-/** 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
|
|
|
@@ -41,7 +41,7 @@ require_once 'Zend/Captcha/Adapter.php';
|
|
|
* @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
|
|
|
@@ -54,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;
|
|
|
@@ -100,7 +100,7 @@ class Zend_Form_Element_Captcha extends Zend_Form_Element_Xhtml
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
$this->_captcha = $instance;
|
|
|
$this->_captcha->setName($this->getName());
|
|
|
return $this;
|
|
|
@@ -113,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
|
|
|
@@ -148,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)
|
|
|
@@ -165,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)
|
|
|
@@ -193,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.
|
|
|
*/
|
|
|
@@ -218,14 +218,14 @@ 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 $path
|
|
|
* @return Zend_Form_Element
|
|
|
* @see Zend_Form_Element::addPrefixPath
|
|
|
*/
|
|
|
@@ -247,10 +247,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()
|
|
|
@@ -270,9 +270,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)
|