'Empty captcha value', self::MISSING_ID => 'Captcha ID field is missing', self::BAD_CAPTCHA => 'Image code is wrong', Qs_Captcha_Image::REFRESH_TITLE => 'Click to refresh image', ]; public function getSession() { if (!isset($this->_session) || (null === $this->_session)) { $id = $this->getId(); if (!class_exists($this->_sessionClass)) { Zend_Loader::loadClass($this->_sessionClass); } $this->_session = new $this->_sessionClass('Zend_Form_Captcha_' . $id); //$this->_session->setExpirationHops(1, null, true); // закоментовано щоб працювала аяксова валідація $this->_session->setExpirationSeconds($this->getTimeout()); } return $this->_session; } public function getFont() { if (null === $this->_font) { $this->_font = BASE_PATH . '/fonts/default.ttf'; } return $this->_font; } public function getDecorator() { return $this->_decorator; } public function setDecorator($decorator) { $this->_decorator = $decorator; return $this; } public function setRefreshUrl($url) { $this->_refreshUrl = $url; return $this; } public function getRefreshUrl() { return $this->_refreshUrl; } public function generate() { $id = parent::generate(); if ($this->_refreshUrl) { $session = $this->getSession(); $session->options = []; $options = get_object_vars($this); unset($options['_id'], $options['_word']); foreach ($options as $name => $value) { if (!is_scalar($value)) { continue; } $session->options[$name] = $value; } } return $id; } public function initRender() { if ($this->_refreshUrl) { /** @var $doc Qs_Doc */ $doc = Zend_Registry::get('doc'); $doc->addScript('js/lib/form-element-captcha.js'); } } public function getImgAlt() { if (null === $this->_imgAlt) { $this->setImgAlt($this->_messageTemplates[Qs_Captcha_Image::REFRESH_TITLE]); } return (string) $this->_imgAlt; } public function setImgAlt($imgAlt) { if (null !== ($translator = $this->getTranslator())) { if ($translator->isTranslated($imgAlt)) { $imgAlt = $translator->translate($imgAlt); } } $this->_imgAlt = $imgAlt; return $this; } public function render(Zend_View_Interface $view = null, $element = null) { $content = ''; if ($this->_refreshUrl) { $content = '' . $content . ''; } return $content; } protected function _setWord($word) { if (APPLICATION_ENV === 'test') { $word = APPLICATION_ENV; } return parent::_setWord($word); } }