/** * 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; }
public function main() { $this->init(); if ($this->fieldname) { $randomID = t3lib_div::_GP('randomID'); Tx_Formhandler_Globals::$randomID = $randomID; $this->componentManager = Tx_Formhandler_Component_Manager::getInstance(); $validator = $this->componentManager->getComponent('Tx_Formhandler_Validator_Ajax'); print $validator->validateAjax($this->fieldname, $this->value); } }
/** * Main method of the class. * * @return string The HTML list of remaining files to be displayed in the form */ public function main() { $this->init(); if ($this->fieldname) { $this->globals->setCObj($GLOBALS['TSFE']->cObj); $randomID = htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('randomID')); $this->globals->setRandomID($randomID); $this->componentManager = Tx_Formhandler_Component_Manager::getInstance(); if (!$this->globals->getSession()) { $ts = $GLOBALS['TSFE']->tmpl->setup['plugin.']['Tx_Formhandler.']['settings.']; $sessionClass = $this->utilityFuncs->getPreparedClassName($ts['session.'], 'Session_PHP'); $this->globals->setSession($this->componentManager->getComponent($sessionClass)); } $validator = $this->componentManager->getComponent('Tx_Formhandler_Validator_Ajax'); $errors = array(); $valid = $validator->validateAjax($this->fieldname, $this->value, $errors); $this->settings = $this->globals->getSession()->get('settings'); $content = ''; if ($valid) { $content = $this->utilityFuncs->getSingle($this->settings['ajax.']['config.'], 'ok'); if (strlen($content) === 0) { $content = '<img src="' . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('formhandler') . 'Resources/Images/ok.png' . '" />'; } else { $gp = array($_GET['field'] => $_GET['value']); $view = $this->initView($content); $content = $view->render($gp, $errors); } $content = '<span class="success">' . $content . '</span>'; } else { $content = $this->utilityFuncs->getSingle($this->settings['ajax.']['config.'], 'notOk'); if (strlen($content) === 0) { $content = '<img src="' . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('formhandler') . 'Resources/Images/notok.png' . '" />'; } else { $view = $this->initView($content); $gp = array($_GET['field'] => $_GET['value']); $content = $view->render($gp, $errors); } $content = '<span class="error">' . $content . '</span>'; } print $content; } }
/** * Initialize the class. Read GET parameters * * @return void */ protected function init() { if (isset($_GET['pid'])) { $this->id = intval($_GET['pid']); } else { $this->id = intval($_GET['id']); } $this->componentManager = Tx_Formhandler_Component_Manager::getInstance(); $this->globals = Tx_Formhandler_Globals::getInstance(); $this->utilityFuncs = Tx_Formhandler_UtilityFuncs::getInstance(); tslib_eidtools::connectDB(); $this->utilityFuncs->initializeTSFE($this->id); $elementUID = intval($_GET['uid']); $row = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', 'tt_content', 'uid=' . $elementUID . ' AND pid=' . $this->id . $GLOBALS['TSFE']->cObj->enableFields('tt_content')); if (!empty($row)) { $GLOBALS['TSFE']->cObj->data = $row; $GLOBALS['TSFE']->cObj->current = 'tt_content_' . $elementUID; } $this->globals->setCObj($GLOBALS['TSFE']->cObj); $randomID = htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('randomID')); $this->globals->setRandomID($randomID); $this->globals->setAjaxMode(TRUE); if (!$this->globals->getSession()) { $ts = $GLOBALS['TSFE']->tmpl->setup['plugin.']['Tx_Formhandler.']['settings.']; $sessionClass = $this->utilityFuncs->getPreparedClassName($ts['session.'], 'Session_PHP'); $this->globals->setSession($this->componentManager->getComponent($sessionClass)); } $this->settings = $this->globals->getSession()->get('settings'); $this->langFiles = $this->utilityFuncs->readLanguageFiles(array(), $this->settings); //init ajax if ($this->settings['ajax.']) { $class = $this->utilityFuncs->getPreparedClassName($this->settings['ajax.'], 'AjaxHandler_JQuery'); $ajaxHandler = $this->componentManager->getComponent($class); $this->globals->setAjaxHandler($ajaxHandler); $ajaxHandler->init($this->settings['ajax.']['config.']); $ajaxHandler->initAjax(); } }
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(); } }
/** * Generates the module content * * @return void */ function moduleContent() { switch ((string) $this->MOD_SETTINGS['function']) { case 1: // Render content: $componentManager = Tx_Formhandler_Component_Manager::getInstance(); $controllerClass = 'Tx_Formhandler_Controller_Backend'; $controller = $componentManager->getComponent($controllerClass); $controller->setId($this->id); $content = $controller->process(); $this->content .= $this->doc->section('', $content, 0, 1); break; case 2: // Render content: $componentManager = Tx_Formhandler_Component_Manager::getInstance(); $controllerClass = 'Tx_Formhandler_Controller_BackendClearLogs'; $controller = $componentManager->getComponent($controllerClass); $controller->setId($this->id); $content = $controller->process(); $this->content .= $this->doc->section('', $content, 0, 1); break; case 3: $content = '<div align=center><strong>Menu item #3...</strong></div>'; $this->content .= $this->doc->section('Message #3:', $content, 0, 1); break; } }
/** * 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; $this->globals = Tx_Formhandler_Globals::getInstance(); $this->utilityFuncs = Tx_Formhandler_UtilityFuncs::getInstance(); 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'); $this->globals->setCObj($this->cObj); if ($setup['usePredef']) { $predef = $this->utilityFuncs->getSingle($setup, 'usePredef'); } $this->globals->getCObj()->setCurrentVal($predef); $this->globals->setPredef($predef); $this->globals->setOverrideSettings($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 = $this->utilityFuncs->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) { \TYPO3\CMS\Core\Utility\GeneralUtility::sysLog($e->getFile() . '(' . $e->getLine() . ')' . ' ' . $e->getMessage(), 'formhandler', \TYPO3\CMS\Core\Utility\GeneralUtility::SYSLOG_SEVERITY_ERROR); $result = $this->utilityFuncs->getTranslatedMessage($this->globals->getLangFiles(), 'fe-exception'); if (!$result) { $result = '<div style="color:red; font-weight: bold">' . $this->utilityFuncs->getExceptionMessage('fe-exception') . '</div>'; } if ($this->globals->getSession() && $this->globals->getSession()->get('debug')) { $result = '<div style="color:red; font-weight: bold">' . $e->getMessage() . '</div>'; $result .= '<div style="color:red; font-weight: bold">File: ' . $e->getFile() . '(' . $e->getLine() . ')</div>'; $result .= '<div style="color:red; font-weight: bold">' . $e->getTraceAsString() . '</div>'; } } if ($this->globals->getSession() && $this->globals->getSession()->get('debug')) { $debuggers = $this->globals->getDebuggers(); foreach ($debuggers as $idx => $debugger) { $debugger->outputDebugLog(); } } return $result; }
/** * Initialize the class. Read GET parameters * * @return void */ protected function init() { $this->fieldName = htmlspecialchars($_GET['field']); $this->uploadedFileName = htmlspecialchars($_GET['uploadedFileName']); if (isset($_GET['pid'])) { $this->id = intval($_GET['pid']); } else { $this->id = intval($_GET['id']); } $this->componentManager = Tx_Formhandler_Component_Manager::getInstance(); $this->globals = Tx_Formhandler_Globals::getInstance(); $this->utilityFuncs = Tx_Formhandler_UtilityFuncs::getInstance(); tslib_eidtools::connectDB(); $this->utilityFuncs->initializeTSFE($this->id); $this->globals->setCObj($GLOBALS['TSFE']->cObj); $randomID = htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('randomID')); $this->globals->setRandomID($randomID); if (!$this->globals->getSession()) { $ts = $GLOBALS['TSFE']->tmpl->setup['plugin.']['Tx_Formhandler.']['settings.']; $sessionClass = $this->utilityFuncs->getPreparedClassName($ts['session.'], 'Session_PHP'); $this->globals->setSession($this->componentManager->getComponent($sessionClass)); } $this->settings = $this->globals->getSession()->get('settings'); $this->langFiles = $this->utilityFuncs->readLanguageFiles(array(), $this->settings); //init ajax if ($this->settings['ajax.']) { $class = $this->utilityFuncs->getPreparedClassName($this->settings['ajax.'], 'AjaxHandler_JQuery'); $ajaxHandler = $this->componentManager->getComponent($class); $this->globals->setAjaxHandler($ajaxHandler); $ajaxHandler->init($this->settings['ajax.']['config.']); $ajaxHandler->initAjax(); } }