Esempio n. 1
0
 /**
  * The constructor for an interceptor setting the component manager and the configuration.
  *
  * @param \Typoheads\Formhandler\Component\Manager $componentManager
  * @param \Typoheads\Formhandler\Controller\Configuration $configuration
  * @return void
  */
 public function __construct(\Typoheads\Formhandler\Component\Manager $componentManager, \Typoheads\Formhandler\Controller\Configuration $configuration, \Typoheads\Formhandler\Utility\Globals $globals, \Typoheads\Formhandler\Utility\GeneralUtility $utilityFuncs)
 {
     $this->componentManager = $componentManager;
     $this->configuration = $configuration;
     $this->globals = $globals;
     $this->utilityFuncs = $utilityFuncs;
     $this->cObj = $this->globals->getCObj();
 }
 /**
  * Initialize the class. Read GET parameters
  *
  * @return void
  */
 protected function init()
 {
     if (isset($_GET['pid'])) {
         $id = intval($_GET['pid']);
     } else {
         $id = intval($_GET['id']);
     }
     $this->componentManager = GeneralUtility::makeInstance(\Typoheads\Formhandler\Component\Manager::class);
     \Typoheads\Formhandler\Utility\GeneralUtility::initializeTSFE($id);
     $elementUID = intval($_GET['uid']);
     $row = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', 'tt_content', 'uid=' . $elementUID . $GLOBALS['TSFE']->cObj->enableFields('tt_content'));
     if (!empty($row)) {
         $GLOBALS['TSFE']->cObj->data = $row;
         $GLOBALS['TSFE']->cObj->current = 'tt_content_' . $elementUID;
     }
     Globals::setCObj($GLOBALS['TSFE']->cObj);
     $randomID = htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('randomID'));
     Globals::setRandomID($randomID);
     Globals::setAjaxMode(TRUE);
     if (!Globals::getSession()) {
         $ts = $GLOBALS['TSFE']->tmpl->setup['plugin.']['Tx_Formhandler.']['settings.'];
         $sessionClass = \Typoheads\Formhandler\Utility\GeneralUtility::getPreparedClassName($ts['session.'], 'Session\\PHP');
         Globals::setSession($this->componentManager->getComponent($sessionClass));
     }
     $this->settings = Globals::getSession()->get('settings');
     //init ajax
     if ($this->settings['ajax.']) {
         $class = \Typoheads\Formhandler\Utility\GeneralUtility::getPreparedClassName($this->settings['ajax.'], 'AjaxHandler\\JQuery');
         $ajaxHandler = $this->componentManager->getComponent($class);
         Globals::setAjaxHandler($ajaxHandler);
         $ajaxHandler->init($this->settings['ajax.']['config.']);
         $ajaxHandler->initAjax();
     }
 }
 /**
  * Clears the auth code from the given $gp array and
  * the global $gp array
  *
  * @param array $gp
  * @return array
  */
 public function clearAuthCodeFromGP($gp)
 {
     $globalGP = $this->globals->getGP();
     unset($globalGP['authCode']);
     unset($globalGP['authCodeData']);
     unset($globalGP['authCodeRecord']);
     $this->globals->setGP($globalGP);
     unset($gp['authCode']);
     unset($gp['authCodeData']);
     unset($gp['authCodeRecord']);
     return $gp;
 }
 /**
  * Interprets a string. If it starts with a { like {field:fieldname}
  * it calls TYPO3 getData function and returns its value, otherwise returns the string
  *
  * @param string $operand The operand to be interpreted
  * @param array $values The GET/POST values
  * @return string
  */
 public function parseOperand($operand, $values)
 {
     if ($operand[0] == '{') {
         $data = trim($operand, '{}');
         $returnValue = $this->globals->getcObj()->getData($data, $values);
     } else {
         $returnValue = $operand;
     }
     if ($returnValue === NULL) {
         $returnValue = '';
     }
     return $returnValue;
 }
Esempio n. 5
0
 /**
  * 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->componentManager = GeneralUtility::makeInstance(\Typoheads\Formhandler\Component\Manager::class);
     $this->globals = GeneralUtility::makeInstance(\Typoheads\Formhandler\Utility\Globals::class);
     $this->utilityFuncs = GeneralUtility::makeInstance(\Typoheads\Formhandler\Utility\GeneralUtility::class);
     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);
         $this->globals->getCObj()->setCurrentVal($predef);
         if ($setup['usePredef']) {
             $predef = $this->utilityFuncs->getSingle($setup, 'usePredef');
         }
         $this->globals->setPredef($predef);
         $this->globals->setOverrideSettings($setup);
         /*
          * set controller:
          * 1. Default controller
          * 2. TypoScript
          */
         $controller = '\\Typoheads\\Formhandler\\Controller\\Form';
         if ($setup['controller']) {
             $controller = $setup['controller'];
         }
         $controller = $this->componentManager->getComponent($controller);
         if (isset($content)) {
             $controller->setContent($this->componentManager->getComponent($this->utilityFuncs->prepareClassName('Typoheads\\Formhandler\\Controller\\Content'), $content));
         }
         if (strlen($templateFile) > 0) {
             $controller->setTemplateFile($templateFile);
         }
         if (strlen($langFile) > 0) {
             $controller->setLangFiles([$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;
 }
 /**
  * Interprets a string. If it starts with a { like {field:fieldname}
  * it calls TYPO3 getData function and returns its value, otherwise returns the string
  *
  * @param string $operand The operand to be interpreted
  * @param array $values The GET/POST values
  * @return string
  */
 public static function parseOperand($operand, $values)
 {
     if ($operand[0] == '{') {
         $data = trim($operand, '{}');
         $returnValue = \Typoheads\Formhandler\Utility\Globals::getcObj()->getData($data, $values);
     } else {
         $returnValue = $operand;
     }
     if ($returnValue === NULL) {
         $returnValue = '';
     }
     return $returnValue;
 }
 /**
  * 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 = GeneralUtility::makeInstance(\Typoheads\Formhandler\Component\Manager::class);
     \Typoheads\Formhandler\Utility\Globals::setAjaxMode(TRUE);
     \Typoheads\Formhandler\Utility\GeneralUtility::initializeTSFE($this->id);
 }