_initSpamProtection(); return $this; } public function setHasSpamProtection($value) { $this->_hasSpamProtection = $value; return $this; } protected function _initSpamProtection() { if ($this->_hasSpamProtection) { $this->_initCookieProtection(); } return $this; } protected function _initCookieProtection() { $fullAlias = Qs_SiteMap::findFirst(null, array('type' => 'FormCookie_'), 'null', 'fullAlias'); if (!$fullAlias) { throw new Qs_Form_Exception('Page for cookie protection is not found!'); } $url = constant('BASE_URL') . '/' . $fullAlias . '?form=' . rawurlencode($this->getId()); /** @var Qs_Doc $doc */ $doc = Zend_Registry::get('doc'); $doc->addStylesheet($url, array('skipPacking' => true)); return $this; } protected function _validateSpamProtection() { if ($this->_hasSpamProtection) { if (!$this->_validateCookieProtection()) { $this->addError($this->_spamProtectionMessage); return false; } } return true; } protected function _validateCookieProtection() { if (!App_FormCookie_View::getCookie($this->getId())) { return false; } return true; } public function validate($data = null) { if (!$this->_validateSpamProtection()) { return false; } return parent::validate($data); } public function validatePartial($data = null) { if (!$this->_validateSpamProtection()) { return false; } return parent::validatePartial($data); } }