Figlet.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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_Captcha
  17. * @subpackage Adapter
  18. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. */
  21. /** @see Zend_Captcha_Word */
  22. require_once 'Zend/Captcha/Word.php';
  23. /** @see Zend_Text_Figlet */
  24. require_once 'Zend/Text/Figlet.php';
  25. /**
  26. * Captcha based on figlet text rendering service
  27. *
  28. * Note that this engine seems not to like numbers
  29. *
  30. * @category Zend
  31. * @package Zend_Captcha
  32. * @subpackage Adapter
  33. * @copyright Copyright (c) 2005-2012 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_Captcha_Figlet extends Zend_Captcha_Word
  38. {
  39. /**
  40. * Figlet text renderer
  41. *
  42. * @var Zend_Text_Figlet
  43. */
  44. protected $_figlet;
  45. /**
  46. * Constructor
  47. *
  48. * @param null|string|array|Zend_Config $options
  49. * @return void
  50. */
  51. public function __construct($options = null)
  52. {
  53. parent::__construct($options);
  54. $this->_figlet = new Zend_Text_Figlet($options);
  55. }
  56. /**
  57. * Generate new captcha
  58. *
  59. * @return string
  60. */
  61. public function generate()
  62. {
  63. $this->_useNumbers = false;
  64. return parent::generate();
  65. }
  66. /**
  67. * Display the captcha
  68. *
  69. * @param Zend_View_Interface $view
  70. * @param mixed $element
  71. * @return string
  72. */
  73. public function render(Zend_View_Interface $view = null, $element = null)
  74. {
  75. return '<pre>'
  76. . $this->_figlet->render($this->getWord())
  77. . "</pre>\n";
  78. }
  79. }