public function refreshcaptchaAction()
 {
     if ($this->getRequest()->isPost()) {
         $this->_helper->json(Tools_System_Tools::generateCaptcha());
     }
 }
示例#2
0
 protected function _load()
 {
     if (!is_array($this->_options) || empty($this->_options) || !isset($this->_options[0]) || !$this->_options[0] || preg_match('~^\\s*$~', $this->_options[0])) {
         throw new Exceptions_SeotoasterException($this->_translator->translate('You should provide a form name.'));
     }
     if (strtolower($this->_options[0]) == 'conversioncode') {
         return $this->_conversionCode($this->_options);
     }
     $sessionHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('Session');
     $useCaptcha = isset($this->_options[1]) && $this->_options[1] == 'captcha' ? true : false;
     $useRecaptcha = isset($this->_options[1]) && $this->_options[1] == 'recaptcha' ? true : false;
     $uploadLimitSize = is_numeric(end($this->_options)) ? end($this->_options) : self::UPLOAD_LIMIT_SIZE;
     $formMapper = Application_Model_Mappers_FormMapper::getInstance();
     $pageMapper = Application_Model_Mappers_PageMapper::getInstance();
     $form = $formMapper->findByName($this->_options[0]);
     $pageHelper = new Helpers_Action_Page();
     $pageHelper->init();
     if ($useCaptcha || $useRecaptcha) {
         if ($form != null) {
             $form->setCaptcha(1);
             $formMapper->save($form);
         }
         if ($useRecaptcha) {
             $recaptchaTheme = 'red';
             $recaptchaWidgetId = uniqid('recaptcha_widget_');
             if (isset($this->_options[2])) {
                 $recaptchaTheme = $this->_options[2];
                 if ($recaptchaTheme == 'custom') {
                     $this->_view->customRecaptcha = true;
                 }
             }
             $this->_view->recaptchaWidgetId = $recaptchaWidgetId;
             $this->_view->addScriptPath($this->_websiteHelper->getPath() . 'seotoaster_core/application/views/scripts/backend/form/');
             $this->_view->recaptchaCode = Tools_System_Tools::generateRecaptcha($recaptchaTheme, $recaptchaWidgetId);
         }
         if ($useCaptcha) {
             $this->_view->captchaId = Tools_System_Tools::generateCaptcha();
         }
     }
     if (isset($sessionHelper->toasterFormError)) {
         $this->_view->toasterFormError = $sessionHelper->toasterFormError;
         unset($sessionHelper->toasterFormError);
     }
     if (isset($sessionHelper->toasterFormSuccess)) {
         $this->_view->toasterFormSuccess = $sessionHelper->toasterFormSuccess;
         unset($sessionHelper->toasterFormSuccess);
     }
     $trackingConversionUrl = 'form-' . $this->_options[0] . '-thank-you';
     $trackingConversionUrl = $pageHelper->filterUrl($trackingConversionUrl);
     $trackingPageExist = $pageMapper->findByUrl($trackingConversionUrl);
     if ($trackingPageExist instanceof Application_Model_Models_Page) {
         $this->_view->trackingConversionUrl = $trackingConversionUrl;
     }
     $this->_view->useRecaptcha = $useRecaptcha;
     $this->_view->useCaptcha = $useCaptcha;
     $this->_view->form = Application_Model_Mappers_FormMapper::getInstance()->findByName($this->_options[0]);
     $this->_view->allowMidification = Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_ADMINPANEL);
     $this->_view->formName = $this->_options[0];
     $this->_view->uploadLimitSize = $uploadLimitSize;
     $filter = new Zend_Filter_Alnum();
     $this->_view->formId = $filter->filter($this->_options[0]);
     $this->_view->pageId = $this->_toasterOptions['id'];
     $this->_view->websiteTmp = $this->_websiteHelper->getTmp();
     $this->_view->formUrl = $this->_toasterOptions['url'];
     return $this->_view->render('form.phtml');
 }