ZF-11522: Allow changing label on Zend_Captcha_Dumb
Description
Hi,
I'm creating a captcha field in a Zend_Form with Zend_Captcha_Dumb, but it has a static phrase that is present to the user. I sugest this because I try to create a class to extend Dumb, but I cannot use and validate it in a Zend_Form_Element, so, things became more complicated to a little change.
So, I think that is much useful to create a $_label attribute to the class, that can be or not setted by the programmer, and the class code will be like this...
/** @see Zend_Captcha_Word */
require_once 'Zend/Captcha/Word.php';
/**
* Example dumb word-based captcha
*
* Note that only rendering is necessary for word-based captcha
*
* @category Zend
* @package Zend_Captcha
* @subpackage Adapter
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Dumb.php 23775 2011-03-01 17:25:24Z ralph $
*/
class Zend_Captcha_Dumb extends Zend_Captcha_Word {
/**
* A label can be setted to the captcha phrase.
* @attr string $_label
*/
protected $_label;
/**
* Set the label for the captcha.
*
* @param string $label
*/
public function setLabel($label)
{
$this->_label = $label;
}
public function getLabel()
{
return ($this->_label != "") ? $this->_label : "Please type this word backwards:";
}
/**
* Render the captcha.
*
* @param Zend_View_Interface $view
* @param mixed $element
* @return string
*/
public function render(Zend_View_Interface $view = null, $element = null)
{
return $this->getLabel() . ': '
. strrev($this->getWord())
. '';
}
}
Comments
Posted by Adam Lundrigan (adamlundrigan) on 2011-07-05T15:53:38.000+0000
You will need to sign and submit a CLA before we can apply your suggested improvement. See here: http://framework.zend.com/wiki/display/…
Posted by Adam Lundrigan (adamlundrigan) on 2011-11-15T03:11:09.000+0000
Simple fix suggested. Original poster unresponsive. Is it OK for me to re-implement suggestion without having OP sign a CLA?
Posted by Adam Lundrigan (adamlundrigan) on 2012-05-05T00:07:40.000+0000
Attached patch containing updated fix and a pair of unit tests. All {{Zend_Captcha}} tests still pass after change is applied.
Posted by Adam Lundrigan (adamlundrigan) on 2012-05-05T00:39:18.000+0000
Fixed in trunk (1.12.0): r24747 r24748 Merged to release-1.11 (1.11.12): r24749