/** * Main method of the dispatcher. This method is called as a user function. * * @return string rendered view * @param string $content * @param array $setup The TypoScript config */ public function main($content, $setup) { $this->pi_USER_INT_obj = 1; try { //init flexform $this->pi_initPIflexForm(); /* * Parse values from flexform: * - Template file * - Translation file * - Predefined form * - E-mail settings * - Required fields * - Redirect page */ $templateFile = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'template_file', 'sDEF'); $langFile = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'lang_file', 'sDEF'); $predef = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'predefined', 'sDEF'); Tx_Formhandler_Globals::$predef = $predef; Tx_Formhandler_Globals::$cObj = $this->cObj; Tx_Formhandler_Globals::$overrideSettings = $setup; $this->componentManager = Tx_Formhandler_Component_Manager::getInstance(); /* * set controller: * 1. Default controller * 2. TypoScript */ $controller = 'Tx_Formhandler_Controller_Form'; if ($setup['controller']) { $controller = $setup['controller']; } $controller = Tx_Formhandler_StaticFuncs::prepareClassName($controller); $controller = $this->componentManager->getComponent($controller); if (isset($content)) { $controller->setContent($this->componentManager->getComponent('Tx_Formhandler_Content', $content)); } if (strlen($templateFile) > 0) { $controller->setTemplateFile($templateFile); } if (strlen($langFile) > 0) { $controller->setLangFiles(array($langFile)); } if (strlen($predef) > 0) { $controller->setPredefined($predef); } $result = $controller->process(); } catch (Exception $e) { $result = '<div style="color:red; font-weight: bold">Caught exception: ' . $e->getMessage() . '</div>'; $result .= '<div style="color:red; font-weight: bold">File: ' . $e->getFile() . '(' . $e->getLine() . ')</div>'; } if (Tx_Formhandler_Globals::$session && Tx_Formhandler_Globals::$session->get('debug')) { foreach (Tx_Formhandler_Globals::$debuggers as $idx => $debugger) { $debugger->outputDebugLog(); } } return $result; }
protected function init() { $this->fieldName = $_GET['field']; $this->uploadedFileName = $_GET['uploadedFileName']; if (isset($_GET['pid'])) { $this->id = intval($_GET['pid']); } else { $this->id = intval($_GET['id']); } $this->componentManager = Tx_Formhandler_Component_Manager::getInstance(); tslib_eidtools::connectDB(); $this->initializeTSFE($this->id); Tx_Formhandler_Globals::$cObj = $GLOBALS['TSFE']->cObj; $randomID = t3lib_div::_GP('randomID'); Tx_Formhandler_Globals::$randomID = $randomID; if (!Tx_Formhandler_Globals::$session) { $ts = $GLOBALS['TSFE']->tmpl->setup['plugin.']['Tx_Formhandler.']['settings.']; $sessionClass = 'Tx_Formhandler_Session_PHP'; if ($ts['session.']) { $sessionClass = Tx_Formhandler_StaticFuncs::prepareClassName($ts['session.']['class']); } Tx_Formhandler_Globals::$session = $this->componentManager->getComponent($sessionClass); } $this->settings = Tx_Formhandler_Globals::$session->get('settings'); //init ajax if ($this->settings['ajax.']) { $class = $this->settings['ajax.']['class']; if (!$class) { $class = 'Tx_Formhandler_AjaxHandler_JQuery'; } $class = Tx_Formhandler_StaticFuncs::prepareClassName($class); $ajaxHandler = $this->componentManager->getComponent($class); Tx_Formhandler_Globals::$ajaxHandler = $ajaxHandler; $ajaxHandler->init($this->settings['ajax.']['config.']); $ajaxHandler->initAjax(); } }