/** * Performs search and replace settings defined in TypoScript. * * Example: * * <code> * plugin.Tx_Formhandler.settings.files.search = ä,ö,ü * plugin.Tx_Formhandler.settings.files.replace = ae,oe,ue * </code> * * @param string The file name * @return string The replaced file name * **/ public function doFileNameReplace($fileName) { $settings = $this->globals->getSettings(); //Default: Replace spaces with underscores $search = [' ', '%20']; $replace = ['_']; $separator = ','; $usePregReplace = $this->getSingle($settings['files.'], 'usePregReplace'); if (intval($usePregReplace) === 1) { $search = ['/ /', '/%20/']; } //The settings "search" and "replace" are comma separated lists if ($settings['files.']['search']) { $search = $this->getSingle($settings['files.'], 'search'); if ($settings['files.']['search.']['separator']) { $separator = $this->getSingle($settings['files.']['search.'], 'separator'); } $search = explode($separator, $search); } if ($settings['files.']['replace']) { $replace = $this->getSingle($settings['files.'], 'replace'); if ($settings['files.']['replace.']['separator']) { $separator = $this->getSingle($settings['files.']['replace.'], 'separator'); } $replace = explode($separator, $replace); } $usePregReplace = $this->getSingle($settings['files.'], 'usePregReplace'); if (intval($usePregReplace) === 1) { $fileName = preg_replace($search, $replace, $fileName); } else { $fileName = str_replace($search, $replace, $fileName); } return $fileName; }
/** * Initializes the formhandler globals and the expiry timestamp */ public function __construct() { $this->objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager'); $this->authCodeRepository = $this->objectManager->get('Tx\\Authcode\\Domain\\Repository\\AuthCodeRepository'); $this->authCodeRecordRepository = $this->objectManager->get('Tx\\Authcode\\Domain\\Repository\\AuthCodeRecordRepository'); $this->formhandlerUtils = GeneralUtility::makeInstance(FormhandlerGeneralUtility::class); $this->globals = GeneralUtility::makeInstance(FormhandlerGlobals::class); $this->tsfeUser = $GLOBALS['TSFE']->fe_user; $settings = $this->globals->getSettings(); if (array_key_exists('authCodeDBExpiryTime', $settings)) { $this->authCodeRepository->setAuthCodeExpiryTime($settings['authCodeDBExpiryTime']); } if (array_key_exists('authCodeDBAutoDeleteExpired', $settings)) { $this->authCodeRepository->setAutoDeleteExpiredAuthCodes($settings['authCodeDBAutoDeleteExpired']); } }