/** * Renders the CSV. * * @return void */ public function process() { $this->pdf = $this->componentManager->getComponent('Tx_Formhandler_Template_TCPDF'); $this->pdf->setHeaderText(Tx_Formhandler_StaticFuncs::getSingle($this->settings, 'headerText')); $this->pdf->setFooterText(Tx_Formhandler_StaticFuncs::getSingle($this->settings, 'footerText')); $this->pdf->AddPage(); $this->pdf->SetFont('Helvetica', '', 12); $view = $this->componentManager->getComponent('Tx_Formhandler_View_PDF'); $this->filename = FALSE; if (intval($this->settings['storeInTempFile']) === 1) { $this->outputPath = t3lib_div::getIndpEnv('TYPO3_DOCUMENT_ROOT'); if ($this->settings['customTempOutputPath']) { $this->outputPath .= Tx_Formhandler_StaticFuncs::sanitizePath($this->settings['customTempOutputPath']); } else { $this->outputPath .= '/typo3temp/'; } $this->filename = $this->outputPath . $this->settings['filePrefix'] . Tx_Formhandler_StaticFuncs::generateHash() . '.pdf'; $this->filenameOnly = Tx_Formhandler_StaticFuncs::getSingle($this->settings, 'staticFileName'); if (strlen($this->filenameOnly) === 0) { $this->filenameOnly = basename($this->filename); } } $this->formhandlerSettings = Tx_Formhandler_Globals::$settings; $suffix = $this->formhandlerSettings['templateSuffix']; $this->templateCode = Tx_Formhandler_StaticFuncs::readTemplateFile(FALSE, $this->formhandlerSettings); if ($suffix) { $view->setTemplate($this->templateCode, 'PDF' . $suffix); } if (!$view->hasTemplate()) { $view->setTemplate($this->templateCode, 'PDF'); } if (!$view->hasTemplate()) { Tx_Formhandler_StaticFuncs::throwException('no_pdf_template'); } $view->setComponentSettings($this->settings); $content = $view->render($this->gp, array()); $this->pdf->writeHTML($content); $returns = $this->settings['returnFileName']; if ($this->filename !== FALSE) { $this->pdf->Output($this->filename, 'F'); $downloadpath = $this->filename; if ($returns) { return $downloadpath; } $downloadpath = str_replace(t3lib_div::getIndpEnv('TYPO3_DOCUMENT_ROOT'), '', $downloadpath); header('Location: ' . $downloadpath); exit; } else { $this->pdf->Output('formhandler.pdf', 'D'); exit; } }
/** * Returns the final template code for given mode and suffix with substituted markers. * * @param string $mode user/admin * @param string $suffix plain/html * @return string The template code */ protected function parseTemplate($mode, $suffix) { $viewClass = $this->settings['view']; if (!$viewClass) { $viewClass = 'Tx_Formhandler_View_Mail'; } /* @var $view Tx_Formhandler_AbstractView */ $view = $this->componentManager->getComponent($viewClass); $view->setLangFiles(Tx_Formhandler_Globals::$langFiles); $view->setPredefined($this->predefined); $view->setComponentSettings($this->settings); $templateCode = Tx_Formhandler_Globals::$templateCode; if ($this->settings['templateFile']) { $templateCode = Tx_Formhandler_StaticFuncs::readTemplateFile(FALSE, $this->settings); } if ($this->settings[$mode]['templateFile']) { $templateCode = Tx_Formhandler_StaticFuncs::readTemplateFile(FALSE, $this->settings[$mode]); } $view->setTemplate($templateCode, 'EMAIL_' . strtoupper($mode) . '_' . strtoupper($suffix) . Tx_Formhandler_Globals::$templateSuffix); if (!$view->hasTemplate()) { $view->setTemplate($templateCode, 'EMAIL_' . strtoupper($mode) . '_' . strtoupper($suffix)); if (!$view->hasTemplate()) { Tx_Formhandler_StaticFuncs::debugMessage('no_mail_template', array($mode, $suffix), 2); } } return $view->render($this->gp, array('mode' => $mode, 'suffix' => $suffix)); }
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; } }