/** * Validates that up to x files get uploaded via the specified upload field. * * @param array &$check The TypoScript settings for this error check * @param string $name The field name * @param array &$gp The current GET/POST parameters * @return string The error string */ public function check(&$check, $name, &$gp) { $checkFailed = ''; $files = Tx_Formhandler_Globals::$session->get('files'); $settings = Tx_Formhandler_Globals::$session->get('settings'); $currentStep = Tx_Formhandler_Globals::$session->get('currentStep'); $lastStep = Tx_Formhandler_Globals::$session->get('lastStep'); $maxCount = Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'maxCount'); if (is_array($files[$name]) && count($files[$name]) >= $maxCount && $currentStep == $lastStep) { $found = FALSE; foreach ($_FILES as $idx => $info) { if (strlen($info['name'][$name]) > 0) { $found = TRUE; } } if ($found) { $checkFailed = $this->getCheckFailed($check); } } elseif (is_array($files[$name]) && $currentStep > $lastStep) { foreach ($_FILES as $idx => $info) { if (strlen($info['name'][$name]) > 0 && count($files[$name]) >= $maxCount) { $checkFailed = $this->getCheckFailed($check); } } } return $checkFailed; }
/** * Logs the given values. * * @return void */ public function process() { //set params $table = "tx_formhandler_log"; $fields['ip'] = t3lib_div::getIndpEnv('REMOTE_ADDR'); if (isset($this->settings['disableIPlog']) && intval($this->settings['disableIPlog']) == 1) { $fields['ip'] = NULL; } $fields['tstamp'] = time(); $fields['crdate'] = time(); $fields['pid'] = Tx_Formhandler_StaticFuncs::getSingle($this->settings, 'pid'); if (!$fields['pid']) { $fields['pid'] = $GLOBALS['TSFE']->id; } ksort($this->gp); $keys = array_keys($this->gp); $serialized = serialize($this->gp); $hash = md5(serialize($keys)); $fields['params'] = $serialized; $fields['key_hash'] = $hash; if (intval($this->settings['markAsSpam']) == 1) { $fields['is_spam'] = 1; } //query the database $res = $GLOBALS['TYPO3_DB']->exec_INSERTquery($table, $fields); $insertedUID = $GLOBALS['TYPO3_DB']->sql_insert_id(); $sessionValues = array('inserted_uid' => $insertedUID, 'inserted_tstamp' => $fields['tstamp'], 'key_hash' => $hash); Tx_Formhandler_Globals::$session->setMultiple($sessionValues); if (!$this->settings['nodebug']) { Tx_Formhandler_StaticFuncs::debugMessage('logging', array($table, implode(',', $fields))); if (strlen($GLOBALS['TYPO3_DB']->sql_error()) > 0) { Tx_Formhandler_StaticFuncs::debugMessage('error', array($GLOBALS['TYPO3_DB']->sql_error()), 3); } } }
/** * Validates that a specified field's value is a valid date * * @param array &$check The TypoScript settings for this error check * @param string $name The field name * @param array &$gp The current GET/POST parameters * @return string The error string */ public function check(&$check, $name, &$gp) { $checkFailed = ''; if (isset($gp[$name]) && strlen(trim($gp[$name])) > 0) { # find out separator $pattern = Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'pattern'); preg_match('/^[d|m|y]*(.)[d|m|y]*/i', $pattern, $res); $sep = $res[1]; // normalisation of format $pattern = $this->normalizeDatePattern($pattern, $sep); // find out correct positioins of "d","m","y" $pos1 = strpos($pattern, 'd'); $pos2 = strpos($pattern, 'm'); $pos3 = strpos($pattern, 'y'); $dateCheck = t3lib_div::trimExplode($sep, $gp[$name]); if (sizeof($dateCheck) !== 3) { $checkFailed = $this->getCheckFailed($check); } elseif (intval($dateCheck[0]) === 0 || intval($dateCheck[1]) === 0 || intval($dateCheck[2]) === 0) { $checkFailed = $this->getCheckFailed($check); } elseif (!checkdate($dateCheck[$pos2], $dateCheck[$pos1], $dateCheck[$pos3])) { $checkFailed = $this->getCheckFailed($check); } elseif (strlen($dateCheck[$pos3]) !== 4) { $checkFailed = $this->getCheckFailed($check); } } return $checkFailed; }
/** * Validates that a specified field contains at least one of the specified words * * @param array &$check The TypoScript settings for this error check * @param string $name The field name * @param array &$gp The current GET/POST parameters * @return string The error string */ public function check(&$check, $name, &$gp) { $checkFailed = ''; $formValue = trim($gp[$name]); if (strlen($formValue) > 0) { $checkValue = Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'words'); if (!is_array($checkValue)) { $checkValue = t3lib_div::trimExplode(',', $checkValue); } $error = FALSE; $array = preg_split('//', $formValue, -1, PREG_SPLIT_NO_EMPTY); foreach ($array as $idx => $char) { if (!in_array($char, $checkValue)) { $error = TRUE; } } if ($error) { //remove userfunc settings and only store comma seperated words $check['params']['words'] = implode(',', $checkValue); unset($check['params']['words.']); $checkFailed = $this->getCheckFailed($check); } } return $checkFailed; }
/** * This function fills the default markers: * * ###PRINT_LINK### * ###PDF_LINK### * ###CSV_LINK### * * @return string Template with replaced markers */ protected function fillDefaultMarkers() { parent::fillDefaultMarkers(); if (Tx_Formhandler_Globals::$formValuesPrefix) { $params[Tx_Formhandler_Globals::$formValuesPrefix] = $this->gp; } else { $params = $this->gp; } $params['type'] = 98; $label = Tx_Formhandler_StaticFuncs::getTranslatedMessage($this->langFiles, 'print'); if (strlen($label) == 0) { $label = 'print'; } $markers['###PRINT_LINK###'] = $this->cObj->getTypolink($label, $GLOBALS['TSFE']->id, $params); unset($params['type']); if ($this->componentSettings['actions.']) { foreach ($this->componentSettings['actions.'] as $action => $options) { $sanitizedAction = str_replace('.', '', $action); $class = $options['class']; if ($class) { $class = Tx_Formhandler_StaticFuncs::prepareClassName($class); $generator = $this->componentManager->getComponent($class); $generator->init($this->gp, $options['config.']); $markers['###' . strtoupper($sanitizedAction) . '_LINK###'] = $generator->getLink($params); } } } $this->fillFEUserMarkers($markers); $this->fillFileMarkers($markers); $this->template = $this->cObj->substituteMarkerArray($this->template, $markers); }
/** * 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 translateFields($options) { $key = $options['langKey']; $field = $options['field']; if ($field) { $key = str_replace('|', $this->gp[$field], $key); } return Tx_Formhandler_StaticFuncs::getTranslatedMessage($this->langFiles, $key); }
/** * Validates that a specified field is a string and at least a specified count of characters long * * @param array &$check The TypoScript settings for this error check * @param string $name The field name * @param array &$gp The current GET/POST parameters * @return string The error string */ public function check(&$check, $name, &$gp) { $checkFailed = ''; $min = Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'value'); if (isset($gp[$name]) && mb_strlen(trim($gp[$name]), $GLOBALS['TSFE']->renderCharset) > 0 && intVal($min) > 0 && mb_strlen(trim($gp[$name]), $GLOBALS['TSFE']->renderCharset) < intval($min)) { $checkFailed = $this->getCheckFailed($check); } return $checkFailed; }
/** * Method to set GET/POST for this class and load the configuration * * @param array The GET/POST values * @param array The TypoScript configuration * @return void */ public function init($gp, $tsConfig) { $this->gp = $gp; $this->settings = $tsConfig; $redirect = Tx_Formhandler_StaticFuncs::pi_getFFvalue($this->cObj->data['pi_flexform'], 'redirect_page', 'sMISC'); if ($redirect) { $this->settings['redirectPage'] = $redirect; } }
/** * The main method called by the controller * * @return array The probably modified GET/POST parameters */ public function process() { $firstInsertInfo = array(); if (is_array($this->gp['saveDB'])) { if (isset($this->settings['table'])) { foreach ($this->gp['saveDB'] as $idx => $insertInfo) { if ($insertInfo['table'] === $this->settings['table']) { $firstInsertInfo = $insertInfo; break; } } } if (empty($firstInsertInfo)) { reset($this->gp['saveDB']); $firstInsertInfo = current($this->gp['saveDB']); } } $table = $firstInsertInfo['table']; $uid = $firstInsertInfo['uid']; $uidField = $firstInsertInfo['uidField']; if (!$uidField) { $uidField = 'uid'; } if ($table && $uid && $uidField) { $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $table, $uidField . '=' . $uid); if ($res) { $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); $authCode = $this->generateAuthCode($row); $this->gp['generated_authCode'] = $authCode; // looking for the page, which should be used for the authCode Link // first look for TS-setting 'authCodePage', second look for redirect_page-setting, third use actual page $authCodePage = ''; if (isset($this->settings['authCodePage'])) { $authCodePage = Tx_Formhandler_StaticFuncs::getSingle($this->settings, 'authCodePage'); } else { $authCodePage = Tx_Formhandler_StaticFuncs::pi_getFFvalue($this->cObj->data['pi_flexform'], 'redirect_page', 'sMISC'); } if (!$authCodePage) { $authCodePage = $GLOBALS['TSFE']->id; } //create the parameter-array for the authCode Link $paramsArray = array_merge($firstInsertInfo, array('authCode' => $authCode)); // If we have set a formValuesPrefix, add it to the parameter-array if (!empty(Tx_Formhandler_Globals::$formValuesPrefix)) { $paramsArray = array(Tx_Formhandler_Globals::$formValuesPrefix => $paramsArray); } // create the link, using typolink function, use baseUrl if set, else use t3lib_div::getIndpEnv('TYPO3_SITE_URL') $url = $this->cObj->getTypoLink_URL($authCodePage, $paramsArray); $tmpArr = parse_url($url); if (empty($tmpArr['scheme'])) { $url = t3lib_div::getIndpEnv('TYPO3_SITE_URL') . ltrim($url, '/'); } $this->gp['authCodeUrl'] = $url; } } return $this->gp; }
/** * Validates that a specified field is a string and has a length between two specified values * * @param array &$check The TypoScript settings for this error check * @param string $name The field name * @param array &$gp The current GET/POST parameters * @return string The error string */ public function check(&$check, $name, &$gp) { $checkFailed = ''; $min = intval(Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'minValue')); $max = intval(Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'maxValue')); if (isset($gp[$name]) && (mb_strlen($gp[$name], $GLOBALS['TSFE']->renderCharset) < intval($min) || mb_strlen($gp[$name], $GLOBALS['TSFE']->renderCharset) > intval($max))) { $checkFailed = $this->getCheckFailed($check); } return $checkFailed; }
/** * Validates that a specified field is an array and has an item count between two specified values * * @param array &$check The TypoScript settings for this error check * @param string $name The field name * @param array &$gp The current GET/POST parameters * @return string The error string */ public function check(&$check, $name, &$gp) { $checkFailed = ''; $min = intval(Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'minValue')); $max = intval(Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'maxValue')); if (isset($gp[$name]) && is_array($gp[$name]) && (count($gp[$name]) < intval($min) || count($gp[$name]) > intval($max))) { $checkFailed = $this->getCheckFailed($check); } return $checkFailed; }
/** * Validates that a specified field is an integer and greater than or equal a specified value * * @param array &$check The TypoScript settings for this error check * @param string $name The field name * @param array &$gp The current GET/POST parameters * @return string The error string */ public function check(&$check, $name, &$gp) { $checkFailed = ''; $min = floatval(str_replace(',', '.', Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'value'))); $valueToCheck = floatval(str_replace(',', '.', $gp[$name])); if (isset($gp[$name]) && $valueToCheck >= 0 && $min >= 0 && (!is_numeric($valueToCheck) || $valueToCheck < $min)) { $checkFailed = $this->getCheckFailed($check); } return $checkFailed; }
/** * Validates that a specified field's value matches a perl regular expression * * @param array &$check The TypoScript settings for this error check * @param string $name The field name * @param array &$gp The current GET/POST parameters * @return string The error string */ public function check(&$check, $name, &$gp) { $checkFailed = ''; if (isset($gp[$name]) && strlen(trim($gp[$name])) > 0) { $regex = Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'value'); if ($regex && !preg_match($regex, $gp[$name])) { $checkFailed = $this->getCheckFailed($check); } } return $checkFailed; }
/** * Validates that a specified field doesn't equal the value * of fieldname in param * * @param array &$check The TypoScript settings for this error check * @param string $name The field name * @param array &$gp The current GET/POST parameters * @return string The error string */ public function check(&$check, $name, &$gp) { $checkFailed = ''; if (isset($gp[$name]) && strlen(trim($gp[$name])) > 0) { $comparisonValue = $gp[Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'field')]; if (strcmp($comparisonValue, $gp[$name]) != 0) { $checkFailed = $this->getCheckFailed($check); } } return $checkFailed; }
/** * The main method called by the controller * * @return array The probably modified GET/POST parameters */ public function process() { $cacheCmd = Tx_Formhandler_StaticFuncs::getSingle($this->settings, 'cacheCmd'); if (empty($cacheCmd)) { $cacheCmd = $GLOBALS['TSFE']->id; } Tx_Formhandler_StaticFuncs::debugMessage('cacheCmd', array($cacheCmd)); $tce = t3lib_div::makeInstance('t3lib_tcemain'); $tce->clear_cacheCmd($cacheCmd); return $this->gp; }
public function process() { if (Tx_Formhandler_Globals::$session->get('originalLanguage') !== NULL) { $GLOBALS['TSFE']->lang = Tx_Formhandler_Globals::$session->get('originalLanguage'); Tx_Formhandler_Globals::$session->set('originalLanguage', NULL); Tx_Formhandler_StaticFuncs::debugMessage('Language restored to "' . $GLOBALS['TSFE']->lang . '"!', array(), 1); } else { Tx_Formhandler_StaticFuncs::debugMessage('Unable to restore language! No original language found!', array(), 2); } return $this->gp; }
/** * The constructor reading the TS setup into the according attribute * * @return void */ public function __construct() { if (TYPO3_MODE === 'FE') { $this->setup = $GLOBALS['TSFE']->tmpl->setup['plugin.'][$this->getPrefixedPackageKey() . '.']; if (!is_array($this->setup)) { Tx_Formhandler_StaticFuncs::throwException('missing_config'); } if (is_array(Tx_Formhandler_Globals::$overrideSettings)) { $this->setup = t3lib_div::array_merge_recursive_overrule($this->setup, Tx_Formhandler_Globals::$overrideSettings); } } }
/** * Validates that an uploaded file has a maximum file size * * @param array &$check The TypoScript settings for this error check * @param string $name The field name * @param array &$gp The current GET/POST parameters * @return string The error string */ public function check(&$check, $name, &$gp) { $checkFailed = ''; $maxSize = Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'maxSize'); foreach ($_FILES as $sthg => &$files) { if (strlen($files['name'][$name]) > 0 && $maxSize && $files['size'][$name] > $maxSize) { unset($files); $checkFailed = $this->getCheckFailed($check); } } return $checkFailed; }
public function fillAjaxMarkers(&$markers) { $settings = Tx_Formhandler_Globals::$session->get('settings'); $initial = Tx_Formhandler_StaticFuncs::getSingle($settings['ajax.']['config.'], 'initial'); $loadingImg = Tx_Formhandler_StaticFuncs::getSingle($settings['ajax.']['config.'], 'loading'); if (strlen($loadingImg) === 0) { $loadingImg = t3lib_extMgm::extRelPath('formhandler') . 'Resources/Images/ajax-loader.gif'; $loadingImg = '<img src="' . $loadingImg . '"/>'; } //parse validation settings if (is_array($settings['validators.'])) { foreach ($settings['validators.'] as $key => $validatorSettings) { if (is_array($validatorSettings['config.']['fieldConf.'])) { foreach ($validatorSettings['config.']['fieldConf.'] as $fieldname => $fieldSettings) { $replacedFieldname = str_replace('.', '', $fieldname); $fieldname = $replacedFieldname; if (Tx_Formhandler_Globals::$formValuesPrefix) { $fieldname = Tx_Formhandler_Globals::$formValuesPrefix . '[' . $fieldname . ']'; } $params = array('eID' => 'formhandler', 'pid' => $GLOBALS['TSFE']->id, 'randomID' => Tx_Formhandler_Globals::$randomID, 'field' => $replacedFieldname, 'value' => ''); $url = Tx_Formhandler_Globals::$cObj->getTypoLink_Url($GLOBALS['TSFE']->id, $params); $markers['###validate_' . $replacedFieldname . '###'] = ' <span class="loading" id="loading_' . $replacedFieldname . '" style="display:none">' . $loadingImg . '</span> <span id="result_' . $replacedFieldname . '">' . str_replace('###fieldname###', $replacedFieldname, $initial) . '</span> <script type="text/javascript"> $(document).ready(function() { $("*[name=\'' . $fieldname . '\']").blur(function() { var fieldVal = escape($(this).val()); if ($(this).attr("type") == "radio" || $(this).attr("type") == "checkbox") { if ($(this).attr("checked") == "") { fieldVal = ""; } } $("#loading_' . $replacedFieldname . '").show(); $("#result_' . $replacedFieldname . '").hide(); var url = "' . $url . '"; url = url.replace("value=", "value=" + fieldVal); $("#result_' . $replacedFieldname . '").load(url, function() { $("#loading_' . $replacedFieldname . '").hide(); $("#result_' . $replacedFieldname . '").show(); }); }); }); </script> '; } } } } }
/** * 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; } }
/** * The main method called by the controller * * @return array The probably modified GET/POST parameters */ public function process() { if (is_array($this->settings['combineFields.'])) { foreach ($this->settings['combineFields.'] as $newField => $options) { $newField = str_replace('.', '', $newField); if (is_array($options['fields.'])) { $this->gp[$newField] = $this->combineFields($options); Tx_Formhandler_StaticFuncs::debugMessage('combined', array($newField, $this->gp[$newField])); } } } return $this->gp; }
/** * Validates that a specified field doesn't equal a specified default value. * This default value could have been set via a PreProcessor. * * @param array &$check The TypoScript settings for this error check * @param string $name The field name * @param array &$gp The current GET/POST parameters * @return string The error string */ public function check(&$check, $name, &$gp) { $checkFailed = ''; if (isset($gp[$name]) && strlen(trim($gp[$name])) > 0) { $defaultValue = Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'defaultValue'); if (strlen($defaultValue) > 0) { if (!strcmp($defaultValue, $gp[$name])) { $checkFailed = $this->getCheckFailed($check); } } } return $checkFailed; }
/** * Main method called by the controller. * * @param array $gp The current GET/POST parameters * @param array $errors In this class the second param is used to pass information about the email mode (HTML|PLAIN) * @return string content */ public function render($gp, $errors) { //set GET/POST parameters $this->gp = array(); $this->gp = $gp; //set template $this->template = $this->subparts['template']; //set settings $this->settings = $this->parseSettings(); //set language file if (!$this->langFiles) { $this->langFiles = Tx_Formhandler_Globals::$langFiles; } $componentSettings = $this->getComponentSettings(); if ($componentSettings[$errors['mode']][$errors['suffix'] . '.']['arrayValueSeparator']) { $this->settings['arrayValueSeparator'] = $componentSettings[$errors['mode']][$errors['suffix'] . '.']['arrayValueSeparator']; $this->settings['arrayValueSeparator.'] = $componentSettings[$errors['mode']][$errors['suffix'] . '.']['arrayValueSeparator.']; } if ($errors['suffix'] != 'plain') { $this->sanitizeMarkers(); } //read master template if (!$this->masterTemplates) { $this->readMasterTemplates(); } if (!empty($this->masterTemplates)) { $this->replaceMarkersFromMaster(); } //substitute ISSET markers $this->substituteIssetSubparts(); //fill TypoScript markers if (is_array($this->settings['markers.'])) { $this->fillTypoScriptMarkers(); } //fill default markers $this->fillDefaultMarkers(); if (intval($this->settings['fillValueMarkersBeforeLangMarkers']) === 1) { //fill value_[fieldname] markers $this->fillValueMarkers(); } //fill LLL:[language_key] markers $this->fillLangMarkers(); $this->fillSelectedMarkers(); if (intval($this->settings['fillValueMarkersBeforeLangMarkers']) !== 1) { //fill value_[fieldname] markers $this->fillValueMarkers(); } //remove markers that were not substituted $content = Tx_Formhandler_StaticFuncs::removeUnfilledMarkers($this->template); return trim($content); }
/** * Validates that a specified field equals a specified word * * @param array &$check The TypoScript settings for this error check * @param string $name The field name * @param array &$gp The current GET/POST parameters * @return string The error string */ public function check(&$check, $name, &$gp) { $checkFailed = ''; $formValue = trim($gp[$name]); if (isset($gp[$name]) && strlen(trim($gp[$name])) > 0) { $checkValue = Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'word'); if (strcasecmp($formValue, $checkValue)) { //remove userfunc settings unset($check['params']['word.']); $checkFailed = $this->getCheckFailed($check); } } return $checkFailed; }
/** * Validates that a specified field's value is a valid date and between two specified dates * * @param array &$check The TypoScript settings for this error check * @param string $name The field name * @param array &$gp The current GET/POST parameters * @return string The error string */ public function check(&$check, $name, &$gp) { $checkFailed = ''; if (isset($gp[$name]) && strlen(trim($gp[$name])) > 0) { $min = Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'min'); $max = Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'max'); $pattern = Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'pattern'); preg_match('/^[d|m|y]*(.)[d|m|y]*/i', $pattern, $res); $sep = $res[1]; // normalisation of format $pattern = $this->normalizeDatePattern($pattern, $sep); // find out correct positioins of "d","m","y" $pos1 = strpos($pattern, 'd'); $pos2 = strpos($pattern, 'm'); $pos3 = strpos($pattern, 'y'); $date = $gp[$name]; $checkdate = explode($sep, $date); $check_day = $checkdate[$pos1]; $check_month = $checkdate[$pos2]; $check_year = $checkdate[$pos3]; if (strlen($min) > 0) { $min_date = t3lib_div::trimExplode($sep, $min); $min_day = $min_date[$pos1]; $min_month = $min_date[$pos2]; $min_year = $min_date[$pos3]; if ($check_year < $min_year) { $checkFailed = $this->getCheckFailed($check); } elseif ($check_year == $min_year && $check_month < $min_month) { $checkFailed = $this->getCheckFailed($check); } elseif ($check_year == $min_year && $check_month == $min_month && $check_day < $min_day) { $checkFailed = $this->getCheckFailed($check); } } if (strlen($max) > 0) { $max_date = t3lib_div::trimExplode($sep, $max); $max_day = $max_date[$pos1]; $max_month = $max_date[$pos2]; $max_year = $max_date[$pos3]; if ($check_year > $max_year) { $checkFailed = $this->getCheckFailed($check); } elseif ($check_year == $max_year && $check_month > $max_month) { $checkFailed = $this->getCheckFailed($check); } elseif ($check_year == $max_year && $check_month == $max_month && $check_day > $max_day) { $checkFailed = $this->getCheckFailed($check); } } } return $checkFailed; }
/** * Validates that a specified field is an array and has less than or exactly a specified amount of items * * @param array &$check The TypoScript settings for this error check * @param string $name The field name * @param array &$gp The current GET/POST parameters * @return string The error string */ public function check(&$check, $name, &$gp) { $checkFailed = ''; if (isset($gp[$name])) { $value = Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'value'); if (is_array($gp[$name])) { if (count($gp[$name]) > $value) { $checkFailed = $this->getCheckFailed($check); } } else { $checkFailed = $this->getCheckFailed($check); } } return $checkFailed; }
/** * Method to define whether the config is valid or not. If no, display a warning on the frontend. * The default value is TRUE. This up to the finisher to overload this method * */ public function validateConfig() { $settings = Tx_Formhandler_Globals::$settings; if (is_array($settings['finishers.'])) { $found = FALSE; foreach ($settings['finishers.'] as $finisherConfig) { if (strstr($finisherConfig['class'], 'Finisher_RestoreLanguage')) { $found = TRUE; } } if (!$found) { Tx_Formhandler_StaticFuncs::throwException('No Finisher_RestoreLanguage found in the TypoScript setup! You have to reset the language to the original value after you changed it using Finisher_SetLanguage'); } } return $found; }
/** * The main method called by the controller * * @return array The probably modified GET/POST parameters */ public function process() { //read template file $this->templateFile = Tx_Formhandler_Globals::$templateCode; //set view $view = $this->componentManager->getComponent('Tx_Formhandler_View_SubmittedOK'); //show TEMPLATE_SUBMITTEDOK $view->setTemplate($this->templateFile, 'SUBMITTEDOK' . Tx_Formhandler_Globals::$templateSuffix); if (!$view->hasTemplate()) { $view->setTemplate($this->templateFile, 'SUBMITTEDOK'); if (!$view->hasTemplate()) { Tx_Formhandler_StaticFuncs::debugMessage('no_submittedok_template', array(), 3); } } $view->setSettings(Tx_Formhandler_Globals::$session->get('settings')); $view->setComponentSettings($this->settings); return $view->render($this->gp, array()); }
/** * Performs checks if the submitted form should be treated as Spam. * * @return boolean */ protected function doCheck() { $value = $this->settings['minTime.']['value']; $unit = $this->settings['minTime.']['unit']; $minTime = Tx_Formhandler_StaticFuncs::convertToSeconds($value, $unit); $value = $this->settings['maxTime.']['value']; $unit = $this->settings['maxTime.']['unit']; $maxTime = Tx_Formhandler_StaticFuncs::convertToSeconds($value, $unit); $spam = FALSE; if (!isset($this->gp['formtime']) || !is_numeric($this->gp['formtime'])) { $spam = TRUE; } elseif ($minTime && time() - intval($this->gp['formtime']) < $minTime) { $spam = TRUE; } elseif ($maxTime && time() - intval($this->gp['formtime']) > $maxTime) { $spam = TRUE; } return $spam; }