view->assign('controllerName', 'RenameConstant'); $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->prepareRenameConstantViewMainSectionContent(); } 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 renameConstant view. * It is called on change of selection of any select menu in renameConstant 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('renameConstant'); return NULL; } else { return $this->redirect('renameConstant'); } } /** * Saves the changes made in main section of renameConstant view. * * @param string $newConstantName */ public function renameConstantSaveAction($newConstantName): ?\Psr\Http\Message\ResponseInterface { try { $oldConstantName = $this->session->getDataByKey('constantSelection'); $extConfig = $this->configurationService->getExtConfig(); if ($oldConstantName === $newConstantName) { throw new LFException('failure.langfile.noChange'); } $this->configurationService->initFileObject( $this->session->getDataByKey('languageFileSelection'), $this->session->getDataByKey('extensionSelection') ); $langData = $this->configurationService->getFileObj()->getLocalLangData(); $constExists = !empty($langData['default'][$newConstantName]) || !empty($langData[$extConfig['defaultLanguage']][$newConstantName]); if ($constExists) { throw new LFException('failure.langfile.constExists'); } $langArray = Functions::buildLangArray(); $newLang = []; foreach ($langArray as $lang) { if (isset($langData[$lang][$oldConstantName])) { $newLang[$lang][$newConstantName] = $langData[$lang][$oldConstantName]; } $newLang[$lang][$oldConstantName] = ''; } $this->configurationService->execWrite($newLang, [], TRUE); $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('renameConstant'); return NULL; } else { return $this->redirect('renameConstant'); } } /** * 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('renameConstant'); return NULL; } else { return $this->redirect('renameConstant'); } } /** * Prepares main section content of deleteConstant view. * * @throws LFException * @return void */ protected function prepareRenameConstantViewMainSectionContent() { $constantSelection = $this->session->getDataByKey('constantSelection'); if (empty($constantSelection) || $constantSelection === '###default###') { throw new LFException('failure.select.noConst', 1); } $this->view->assign('constantSelection', $constantSelection); } }