view->assign('controllerName', 'AddConstant'); $this->prepareExtensionAndLangFileOptions(); $this->prepareAddConstantViewMainSectionContent(); } catch (LFException $e) { $this->addLFEFlashMessage($e); } $this->commonViewRenderingActionSettings(); if (version_compare(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '11.0.0', '<')) { $this->view->assign('V11', FALSE); return NULL; } else { $this->view->assign('V11', TRUE); return $this->createBackendResponse(); } } /** * This action saves in session currently selected options from selection menus in addConstant view. * It is called on change of selection of any select menu in addConstant view. * * @param string $extensionSelection * @param string $languageFileSelection * @param string $extKey * @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException */ public function changeSelectionAction($extensionSelection = NULL, $languageFileSelection = NULL, $extKey = ''): ?\Psr\Http\Message\ResponseInterface { $this->saveSelectionsInSession( $extensionSelection, $languageFileSelection, NULL, NULL, NULL, NULL, NULL, NULL, $extKey ); if (version_compare(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '11.0.0', '<')) { $this->redirect('addConstant'); return NULL; } else { return $this->redirect('addConstant'); } } /** * Saves the changes made in main section of addConstant view. * * @param string $nameOfConstant * @param array $addConstTextArea * @return \Psr\Http\Message\ResponseInterface|null * @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException * @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException */ public function addConstantSaveAction($nameOfConstant, array $addConstTextArea): ?\Psr\Http\Message\ResponseInterface { try { if (empty($nameOfConstant)) { throw new LFException('failure.select.noConstDefined'); } $extConfig = $this->configurationService->getExtConfig(); $this->configurationService->initFileObject( $this->session->getDataByKey('languageFileSelection'), $this->session->getDataByKey('extensionSelection') ); $langData = $this->configurationService->getFileObj()->getLocalLangData(); $constExists = !empty($langData['default'][$nameOfConstant]) || !empty($langData[$extConfig['defaultLanguage']][$nameOfConstant]); if ($constExists) { throw new LFException('failure.langfile.constExists'); } $newConstLanguages = []; foreach ($addConstTextArea as $lang => $value) { $newConstLanguages[$lang][$nameOfConstant] = $value; } $this->configurationService->execWrite($newConstLanguages); $this->session->setDataByKey('constantSelection', $nameOfConstant); $this->addFlashMessage( LocalizationUtility::translate('lang.file.write.success', 'lfeditor'), '', $severity = AbstractMessage::OK, $storeInSession = TRUE ); } catch (LFException $e) { $this->addLFEFlashMessage($e); } if (version_compare(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '11.0.0', '<')) { $this->redirect('addConstant'); return NULL; } else { return $this->redirect('addConstant'); } } /** * Clears extensionAndLangFileOptions cache, and in that way refreshes list of language file options in select box. * */ public function refreshLanguageFileListAction(): ?\Psr\Http\Message\ResponseInterface { $this->clearSelectOptionsCache('extensionAndLangFileOptions'); if (version_compare(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '11.0.0', '<')) { $this->redirect('addConstant'); return NULL; } else { return $this->redirect('addConstant'); } } /** * Prepares main section content of addConstant view. * * @throws LFException * @return void */ protected function prepareAddConstantViewMainSectionContent() { $extConfig = $this->configurationService->getExtConfig(); $langArray = $this->configurationService->getLangArray($this->backendUser); $this->view->assign('languages', $langArray); $this->view->assign('numTextAreaRows', $extConfig['numTextAreaRows']); } }