/**
  * The main method called by the controller
  *
  * @return array The probably modified GET/POST parameters
  */
 public function process()
 {
     $isSpam = $this->doCheck();
     if ($isSpam) {
         $this->log(TRUE);
         if ($this->settings['redirectPage']) {
             Tx_Formhandler_Globals::$session->reset();
             Tx_Formhandler_Staticfuncs::doRedirect($this->settings['redirectPage'], $this->settings['correctRedirectUrl'], $this->settings['additionalParams.']);
             return 'Lousy spammer!';
         } else {
             $view = $this->componentManager->getComponent('Tx_Formhandler_View_AntiSpam');
             $view->setLangFiles(Tx_Formhandler_Globals::$langFiles);
             $view->setPredefined($this->predefined);
             $templateCode = Tx_Formhandler_Globals::$templateCode;
             $view->setTemplate($templateCode, 'ANTISPAM');
             if (!$view->hasTemplate()) {
                 Tx_Formhandler_StaticFuncs::throwException('spam_detected');
                 return 'Lousy spammer!';
             }
             $content = $view->render($this->gp, array());
             Tx_Formhandler_Globals::$session->reset();
             return $content;
         }
     }
     return $this->gp;
 }
 /**
  * The main method called by the controller
  *
  * @return array The probably modified GET/POST parameters
  */
 public function process()
 {
     //read redirect page
     $redirectPage = Tx_Formhandler_StaticFuncs::getSingle($this->settings, 'redirectPage');
     if (!isset($redirectPage)) {
         return $this->gp;
     }
     Tx_Formhandler_Globals::$session->reset();
     Tx_Formhandler_Staticfuncs::doRedirect($redirectPage, $this->settings['correctRedirectUrl'], $this->settings['additionalParams.']);
     exit;
 }
 protected function init()
 {
     $this->settings = $this->getSettings();
     $this->formValuesPrefix = Tx_Formhandler_StaticFuncs::getSingle($this->settings, 'formValuesPrefix');
     Tx_Formhandler_Globals::$formID = Tx_Formhandler_StaticFuncs::getSingle($this->settings, 'formID');
     Tx_Formhandler_Globals::$formValuesPrefix = $this->formValuesPrefix;
     //set debug mode
     $isDebugMode = Tx_Formhandler_StaticFuncs::getSingle($this->settings, 'debug');
     $this->debugMode = intval($isDebugMode) === 1;
     $sessionClass = 'Tx_Formhandler_Session_PHP';
     if ($this->settings['session.']) {
         $sessionClass = Tx_Formhandler_StaticFuncs::prepareClassName($this->settings['session.']['class']);
     }
     Tx_Formhandler_Globals::$session = $this->componentManager->getComponent($sessionClass);
     $this->gp = Tx_Formhandler_Staticfuncs::getMergedGP();
     $randomID = $this->gp['randomID'];
     if (!$randomID) {
         $randomID = Tx_Formhandler_StaticFuncs::generateRandomID();
     }
     Tx_Formhandler_Globals::$randomID = $randomID;
     $action = t3lib_div::_GP('action');
     if (Tx_Formhandler_Globals::$formValuesPrefix) {
         $temp = t3lib_div::_GP(Tx_Formhandler_Globals::$formValuesPrefix);
         $action = $temp['action'];
     }
     if (Tx_Formhandler_Globals::$session->get('finished') && !$action) {
         Tx_Formhandler_Globals::$session->reset();
         unset($_GET[Tx_Formhandler_Globals::$formValuesPrefix]);
         unset($_GET['id']);
         Tx_Formhandler_StaticFuncs::doRedirect($GLOBALS['TSFE']->id, FALSE, $_GET);
         exit;
     }
     $this->parseConditions();
     $this->initializeDebuggers();
     $this->getStepInformation();
     $currentStepFromSession = Tx_Formhandler_Globals::$session->get('currentStep');
     $prevStep = $currentStepFromSession;
     if (intval($prevStep) !== intval($currentStepFromSession)) {
         $this->currentStep = 1;
         $this->lastStep = 1;
         Tx_Formhandler_StaticFuncs::throwException('You messed with the steps!');
     }
     $this->mergeGPWithSession(FALSE, $this->currentStep);
     $this->parseConditions();
     //read template file
     $this->templateFile = Tx_Formhandler_StaticFuncs::readTemplateFile($this->templateFile, $this->settings);
     Tx_Formhandler_Globals::$templateCode = $this->templateFile;
     $this->langFiles = Tx_Formhandler_StaticFuncs::readLanguageFiles($this->langFiles, $this->settings);
     Tx_Formhandler_Globals::$langFiles = $this->langFiles;
     $this->validateConfig();
     Tx_Formhandler_Globals::$settings = $this->settings;
     //set debug mode again cause it may have changed in specific step settings
     $this->debugMode = intval($this->settings['debug']) === 1;
     Tx_Formhandler_Globals::$session->set('debug', $this->debugMode);
     Tx_Formhandler_StaticFuncs::debugMessage('using_prefix', array($this->formValuesPrefix));
     //init view
     $viewClass = $this->settings['view'];
     if (!$viewClass) {
         $viewClass = 'Tx_Formhandler_View_Form';
     }
     Tx_Formhandler_StaticFuncs::debugMessage('using_view', array($viewClass));
     Tx_Formhandler_StaticFuncs::debugMessage('current_gp', array(), 1, $this->gp);
     $this->storeSettingsInSession();
     $this->mergeGPWithSession(FALSE, $this->currentStep);
     //set submitted
     $this->submitted = $this->isFormSubmitted();
     if (!$this->submitted) {
         $this->reset();
     }
     // set stylesheet file(s)
     $this->addCSS();
     // add JavaScript file(s)
     $this->addJS();
     Tx_Formhandler_StaticFuncs::debugMessage('current_session_params', array(), 1, (array) Tx_Formhandler_Globals::$session->get('values'));
     $viewClass = Tx_Formhandler_StaticFuncs::prepareClassName($viewClass);
     $this->view = $this->componentManager->getComponent($viewClass);
     $this->view->setLangFiles($this->langFiles);
     $this->view->setSettings($this->settings);
     Tx_Formhandler_Globals::$gp = $this->gp;
     //init ajax
     if ($this->settings['ajax.']) {
         $class = $this->settings['ajax.']['class'];
         if (!$class) {
             $class = 'Tx_Formhandler_AjaxHandler_JQuery';
         }
         Tx_Formhandler_StaticFuncs::debugMessage('using_ajax', array($class));
         $class = Tx_Formhandler_StaticFuncs::prepareClassName($class);
         $ajaxHandler = $this->componentManager->getComponent($class);
         Tx_Formhandler_Globals::$ajaxHandler = $ajaxHandler;
         $ajaxHandler->init($this->settings['ajax.']['config.']);
         $ajaxHandler->initAjax();
     }
     if (!$this->gp['randomID']) {
         $this->gp['randomID'] = Tx_Formhandler_Globals::$randomID;
     }
 }