view->assign('controllerName', 'EditConstant'); $this->prepareExtensionAndLangFileOptions(); $this->configurationService->initFileObject( $this->session->getDataByKey('languageFileSelection'), $this->session->getDataByKey('extensionSelection') ); $langData = $this->configurationService->getFileObj()->getLocalLangData(); $constantOptions = $this->configurationService->menuConstList( $langData, LocalizationUtility::translate('select.nothing', 'lfeditor') ); $this->assignViewWidthMenuVariables('constant', $constantOptions); $this->prepareEditConstantViewMainSectionContent($langData); } 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 editConstant view. * It is called on change of selection of any select menu in editConstant view. * * @param string $extensionSelection * @param string $languageFileSelection * @param string $constantSelection * @param string $extKey * @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException */ public function changeSelectionAction( $extensionSelection = NULL, $languageFileSelection = NULL, $constantSelection = NULL, $extKey = '' ): ?\Psr\Http\Message\ResponseInterface { $this->saveSelectionsInSession( $extensionSelection, $languageFileSelection, NULL, $constantSelection, NULL, NULL, NULL, NULL, $extKey ); if (version_compare(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '11.0.0', '<')) { $this->redirect('editConstant'); return NULL; } else { return $this->redirect('editConstant'); } } /** * Saves the changes made in main section of editConstant view. * * @param array $editConstTextArea * @return \Psr\Http\Message\ResponseInterface|null * @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException * @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException */ public function editConstantSaveAction(array $editConstTextArea): ?\Psr\Http\Message\ResponseInterface { try { $this->configurationService->execWrite($editConstTextArea); $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('editConstant'); return NULL; } else { return $this->redirect('editConstant'); } } /** * Clears extensionAndLangFileOptions cache, and in that way refreshes list of language file options in select box. * * @return \Psr\Http\Message\ResponseInterface|null * @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException * @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException */ public function refreshLanguageFileListAction(): ?\Psr\Http\Message\ResponseInterface { $this->clearSelectOptionsCache('extensionAndLangFileOptions'); if (version_compare(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '11.0.0', '<')) { $this->redirect('editConstant'); return NULL; } else { return $this->redirect('editConstant'); } } /** * Prepares main section content of editConstant view. * * @param array $langData * @throws LFException * @return void */ protected function prepareEditConstantViewMainSectionContent(array $langData = NULL) { $extConfig = $this->configurationService->getExtConfig(); $langArray = $this->configurationService->getLangArray($this->backendUser); $constantSelection = $this->session->getDataByKey('constantSelection'); if (empty($constantSelection) || $constantSelection == '###default###') { throw new LFException('failure.select.noConst', 1); } $languages = []; foreach ($langArray as $lang) { if (array_key_exists($lang, $langData) && array_key_exists($constantSelection, $langData[$lang])) { $languages[$lang] = $langData[$lang][$constantSelection]; } else { $languages[$lang] = ''; } } $this->view->assign('constantSelection', $constantSelection); $this->view->assign('languages', $languages); $this->view->assign('numTextAreaRows', $extConfig['numTextAreaRows']); $this->view->assign('defaultLanguage', $extConfig['defaultLanguage']); } /** * Sets chosen constant and redirects to editConstant view. * * @param string $constantKey * @return void */ protected function prepareEditConstantAction($constantKey) { $this->session->setDataByKey('constantSelection', $constantKey); $this->redirect('editConstant', 'EditConstant'); } }