Commit 1530c76d authored by Stefan Galinski's avatar Stefan Galinski

Merge branch 'feature_UpgradeTo9LTS' into 'master'

Feature upgrade to9 lts

See merge request typo3/lfeditor!23
parents 6ba858d2 12edc5aa
......@@ -43,6 +43,7 @@ abstract class AbstractBackendController extends AbstractController {
* Initializes any action
*
* @return void
* @throws \SGalinski\Lfeditor\Exceptions\DirectoryAccessRightsException
*/
public function initializeAction() {
parent::initializeAction();
......@@ -54,17 +55,17 @@ abstract class AbstractBackendController extends AbstractController {
$editingMode = $this->session->getDataByKey('editingMode');
$availableEditingModes = $this->configurationService->getAvailableEditingModes();
if ($this->backendUser->isAdmin()) {
if (!array_key_exists($editingMode, $availableEditingModes)) {
$firstAvailableEditMode = key($availableEditingModes);
if (!\array_key_exists($editingMode, $availableEditingModes)) {
$firstAvailableEditMode = \key($availableEditingModes);
$this->session->setDataByKey('editingMode', $firstAvailableEditMode);
}
$canChangeEditingModes = count($availableEditingModes) > 0;
$canChangeEditingModes = \count($availableEditingModes) > 0;
} else {
$canChangeEditingModes = count($availableEditingModes) > 0
$canChangeEditingModes = \count($availableEditingModes) > 0
&& $this->backendUser->user['lfeditor_change_editing_modes'] !== 0;
if (!$canChangeEditingModes || !array_key_exists($editingMode, $availableEditingModes)) {
end($availableEditingModes);
$lastAvailableEditMode = key($availableEditingModes);
if (!$canChangeEditingModes || !\array_key_exists($editingMode, $availableEditingModes)) {
\end($availableEditingModes);
$lastAvailableEditMode = \key($availableEditingModes);
$this->session->setDataByKey('editingMode', $lastAvailableEditMode);
}
}
......@@ -130,7 +131,7 @@ abstract class AbstractBackendController extends AbstractController {
$extensionKey = $this->request->getControllerExtensionKey();
$state = $this->backendUser->uc[$extensionKey . 'State']['LastActionControllerPair'];
return (!is_array($state) ? array() : $state);
return (!\is_array($state) ? [] : $state);
}
/**
......@@ -145,7 +146,7 @@ abstract class AbstractBackendController extends AbstractController {
$extensionKey = $this->request->getControllerExtensionKey();
$state = $this->backendUser->uc[$extensionKey . 'State']['LastActionControllerPairForRedirect'];
return (!is_array($state) ? array() : $state);
return (!\is_array($state) ? [] : $state);
}
/**
......@@ -153,10 +154,11 @@ abstract class AbstractBackendController extends AbstractController {
* backend user session
*
* @return void
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
*/
protected function redirectToLastCalledControllerActionPair() {
$state = $this->getLastCalledControllerActionPairForRedirect();
if (count($state) && trim($state['action']) !== '' && trim($state['controller']) !== '') {
if (\count($state) && \trim($state['action']) !== '' && \trim($state['controller']) !== '') {
$currentAction = $this->request->getControllerActionName();
$currentController = $this->request->getControllerName();
if (!($currentController === $state['controller'] && $currentAction === $state['action'])) {
......@@ -166,7 +168,9 @@ abstract class AbstractBackendController extends AbstractController {
$availableControllers = $extensionConfig['modules'][$moduleSignature]['controllers'];
$controllerExists = isset($availableControllers[$state['controller']]);
if ($controllerExists) {
$actionExists = in_array($state['action'], $availableControllers[$state['controller']]['actions']);
$actionExists = \in_array(
$state['action'], $availableControllers[$state['controller']]['actions'], TRUE
);
if ($actionExists) {
$this->forward($state['action'], $state['controller']);
}
......
......@@ -27,12 +27,11 @@ namespace SGalinski\Lfeditor\Controller;
***************************************************************/
use SGalinski\Lfeditor\Exceptions\LFException;
use SGalinski\Lfeditor\Service\BackupService;
use SGalinski\Lfeditor\Service\ConfigurationService;
use SGalinski\Lfeditor\Session\PhpSession;
use SGalinski\Tinymce\Loader;
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Messaging\AbstractMessage;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
......@@ -46,23 +45,42 @@ abstract class AbstractController extends ActionController {
protected $session;
/**
* @inject
* @var \SGalinski\Lfeditor\Service\ConfigurationService
*
* @var ConfigurationService
*/
protected $configurationService;
/**
* @inject
* @var \SGalinski\Lfeditor\Service\BackupService
* Inject the ConfigurationService
*
* @param ConfigurationService $configurationService
*/
public function injectConfigurationService(ConfigurationService $configurationService) {
$this->configurationService = $configurationService;
}
/**
*
* @var BackupService
*/
protected $backupService;
/**
* Inject the BackupService
*
* @param BackupService $backupService
*/
public function injectBackupService(BackupService $backupService) {
$this->backupService = $backupService;
}
/**
* Initializes the actions.
* - Initializes the session object.
* - Fetches configuration.
*
* @return void
* @throws \SGalinski\Lfeditor\Exceptions\DirectoryAccessRightsException
*/
public function initializeAction() {
parent::initializeAction();
......@@ -146,12 +164,12 @@ abstract class AbstractController extends ActionController {
*/
protected function checkMenuSelection($menuName, array $options) {
$selection = $this->session->getDataByKey($menuName . 'Selection');
if (!array_key_exists($selection, $options)) {
if (!\array_key_exists($selection, $options)) {
$selection = NULL;
}
if ($selection === NULL && !empty($options)) {
reset($options);
$selection = key($options);
\reset($options);
$selection = \key($options);
$this->session->setDataByKey($menuName . 'Selection', $selection);
return $selection;
}
......@@ -165,14 +183,14 @@ abstract class AbstractController extends ActionController {
* @return void
*/
public function addLFEFlashMessage(LFException $lFException) {
if ($lFException->getCode() == 0) {
if ($lFException->getCode() === 0) {
$this->addFlashMessage(
$lFException->getMessage(),
$messageTitle = LocalizationUtility::translate('failure.failure', 'lfeditor'),
$severity = AbstractMessage::ERROR,
$storeInSession = TRUE
);
} elseif ($lFException->getCode() == 1) {
} elseif ($lFException->getCode() === 1) {
$this->addFlashMessage(
$lFException->getMessage(),
$messageTitle = '',
......@@ -186,18 +204,19 @@ abstract class AbstractController extends ActionController {
* Prepares language file select options for each extension and sets combined data in view.
*
* @throws LFException
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
* @return void
*/
protected function prepareExtensionAndLangFileOptions() {
/** @var CacheManager $cacheManager */
$cacheManager = $this->objectManager->get('TYPO3\CMS\Core\Cache\CacheManager');
$cacheManager = $this->objectManager->get(CacheManager::class);
$extensions = $cacheManager->getCache('lfeditor_select_options_cache')->get('extensionAndLangFileOptions');
if (empty($extensions)) {
$extensionOptions = $this->configurationService->menuExtList();
$extensionGroupCount = 0;
foreach ($extensionOptions as $extAddress => $extLabel) {
$extension['extLabel'] = $extLabel;
$extension['languageFileOptions'] = array();
$extension['languageFileOptions'] = [];
$isExtensionGroupStart = $extAddress === '###extensionGroup###' . $extLabel;
try {
if (!$isExtensionGroupStart) {
......@@ -206,10 +225,10 @@ abstract class AbstractController extends ActionController {
continue;
}
} elseif (++$extensionGroupCount > 1) {
$extensions[$extAddress . 'EmptySpaceBefore'] = array(
$extensions[$extAddress . 'EmptySpaceBefore'] = [
'extLabel' => '',
'languageFileOptions' => array(),
);
'languageFileOptions' => [],
];
}
} catch (LFException $e) {
continue;
......@@ -217,10 +236,10 @@ abstract class AbstractController extends ActionController {
$extensions[$extAddress] = $extension;
if ($isExtensionGroupStart) {
$extensions[$extAddress . 'DelimiterAfter'] = array(
$extensions[$extAddress . 'DelimiterAfter'] = [
'extLabel' => '======',
'languageFileOptions' => array(),
);
'languageFileOptions' => [],
];
}
}
$cacheManager->getCache('lfeditor_select_options_cache')->set('extensionAndLangFileOptions', $extensions);
......@@ -252,8 +271,8 @@ abstract class AbstractController extends ActionController {
if (empty($extension['languageFileOptions'])) {
continue;
}
reset($extension['languageFileOptions']);
$languageFileSelection = key($extension['languageFileOptions']);
\reset($extension['languageFileOptions']);
$languageFileSelection = \key($extension['languageFileOptions']);
$this->session->setDataByKey('languageFileSelection', $languageFileSelection);
$this->session->setDataByKey('extensionSelection', $extAddress);
break;
......@@ -261,33 +280,6 @@ abstract class AbstractController extends ActionController {
}
}
/**
* Prepares TinyMCE for use if it's selected as insertion method.
*
* @return void
*/
protected function prepareTinyMCEIfSelected() {
$tinyMCELoaded = ExtensionManagementUtility::isLoaded('tinymce');
$this->view->assign('tinyMCELoaded', $tinyMCELoaded);
if (!$tinyMCELoaded) {
return;
}
$tinyMCESelected = $this->session->getDataByKey('tinyMCESelected');
$this->view->assign('tinyMCESelected', $tinyMCESelected);
if (!$tinyMCESelected) {
return;
}
$pathTinyMCEConfig = PATH_site . ExtensionManagementUtility::siteRelPath('lfeditor')
. 'Resources/Public/Scripts/TinyMCEConfig.js';
$tinyMCE = $this->objectManager->get('SGalinski\Tinymce\Loader');
$tinyMCE->loadConfiguration($pathTinyMCEConfig);
/** @var PageRenderer $pageRenderer */
$pageRenderer = $this->objectManager->get('TYPO3\CMS\Core\Page\PageRenderer');
$tinyMCE->loadJsViaPageRenderer($pageRenderer);
}
/**
* Clears cache used for storing select options.
* If $identifier is set, it clears only that entry in cache,
......
......@@ -46,7 +46,6 @@ class AddConstantController extends AbstractBackendController {
public function addConstantAction() {
try {
$this->view->assign('controllerName', 'AddConstant');
$this->prepareTinyMCEIfSelected();
$this->prepareExtensionAndLangFileOptions();
$this->prepareAddConstantViewMainSectionContent();
......
......@@ -45,7 +45,6 @@ class EditConstantController extends AbstractBackendController {
public function editConstantAction() {
try {
$this->view->assign('controllerName', 'EditConstant');
$this->prepareTinyMCEIfSelected();
$this->prepareExtensionAndLangFileOptions();
$this->configurationService->initFileObject(
......
......@@ -52,7 +52,6 @@ class EditFileController extends AbstractBackendController {
public function editFileAction($buttonType = 0) {
try {
$this->view->assign('controllerName', 'EditFile');
$this->prepareTinyMCEIfSelected();
$this->prepareExtensionAndLangFileOptions();
$this->configurationService->initFileObject(
......
......@@ -48,6 +48,8 @@ class GeneralController extends AbstractBackendController {
*
* @param bool $doStateRedirect
* @return void
* @throws UnsupportedRequestTypeException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
*/
public function indexAction($doStateRedirect = TRUE) {
if ($doStateRedirect) {
......@@ -65,11 +67,11 @@ class GeneralController extends AbstractBackendController {
* - after redirection from action which must not change the view.
*
* @return void
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
*/
public function generalAction() {
try {
$this->view->assign('controllerName', 'General');
$this->prepareTinyMCEIfSelected();
$this->prepareExtensionAndLangFileOptions();
if (!$this->session->getDataByKey('languageFileSelection')) {
......@@ -89,6 +91,7 @@ class GeneralController extends AbstractBackendController {
* @param string $extensionSelection
* @param string $languageFileSelection
* @throws UnsupportedRequestTypeException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
*
* @return void
*/
......@@ -105,8 +108,10 @@ class GeneralController extends AbstractBackendController {
* @param string $metaDescription
* @param string $transformFile
* @param integer $splitFile
* @throws UnsupportedRequestTypeException
* @return void
* @throws UnsupportedRequestTypeException
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
*/
public function generalSaveAction(
$authorName = NULL, $authorEmail = NULL, $metaDescription = NULL, $transformFile = NULL, $splitFile = NULL
......@@ -173,6 +178,9 @@ class GeneralController extends AbstractBackendController {
* Clears extensionAndLangFileOptions cache, and in that way refreshes list of language file options in select box.
*
* @return void
* @throws UnsupportedRequestTypeException
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
*/
public function refreshLanguageFileListAction() {
$this->clearSelectOptionsCache('extensionAndLangFileOptions');
......@@ -183,6 +191,7 @@ class GeneralController extends AbstractBackendController {
* Prepares main section content of general view.
*
* @return void
* @throws LFException
*/
protected function prepareGeneralViewMainSectionContent() {
$this->configurationService->initFileObject(
......@@ -213,28 +222,21 @@ class GeneralController extends AbstractBackendController {
*
* @param string $language
* @return void
* @throws UnsupportedRequestTypeException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
*/
public function goToEditFileAction($language) {
$this->session->setDataByKey('languageSelection', $language);
$this->redirect('editFile', 'EditFile');
}
/**
* Switches between insert modes: TinyMCE and normal.
*
* @param int $tinyMCE says is TinyMCE insert mode is selected.
* @return void
*/
public function switchInsertModeAction($tinyMCE = 0) {
$this->session->setDataByKey('tinyMCESelected', $tinyMCE !== 0);
$this->indexAction();
}
/**
* Switches between override mode and normal mode.
*
* @param string $editingMode 'extension', 'l10n', 'override'.
* @return void
* @throws UnsupportedRequestTypeException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
*/
public function switchEditingModeAction($editingMode = 'extension') {
$this->session->setDataByKey('editingMode', $editingMode);
......
......@@ -30,7 +30,9 @@ use SGalinski\Lfeditor\Exceptions\LFException;
use SGalinski\Lfeditor\Utility\Functions;
use SGalinski\Lfeditor\Utility\SgLib;
use SGalinski\Lfeditor\Utility\Typo3Lib;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Messaging\AbstractMessage;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
use TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
......@@ -70,7 +72,6 @@ class ManageBackupsController extends AbstractBackendController {
public function manageBackupsAction($fileName = '', $langFile = '', $showDiff = FALSE) {
try {
$this->view->assign('controllerName', 'ManageBackups');
$this->prepareTinyMCEIfSelected();
$extensionOptions = $this->configurationService->menuExtList();
$this->assignViewWidthMenuVariables('extension', $extensionOptions);
......@@ -154,7 +155,13 @@ class ManageBackupsController extends AbstractBackendController {
// get path to filename
$backupPath = $informations['pathBackup'];
$file = Typo3Lib::fixFilePath(PATH_site . '/' . $backupPath . '/' . $fileName);
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) {
$pathSite = PATH_site;
} else {
$pathSite = Environment::getPublicPath() . '/';
}
$file = Typo3Lib::fixFilePath($pathSite . '/' . $backupPath . '/' . $fileName);
$origFile = Typo3Lib::fixFilePath(
$this->session->getDataByKey('extensionSelection') . '/' . $langFile
);
......@@ -244,8 +251,14 @@ class ManageBackupsController extends AbstractBackendController {
$this->initializeBackupObject($langFile);
// set backup file
$metaArray = $this->backupService->getBackupObj()->getMetaInfos(3);
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) {
$pathSite = PATH_site;
} else {
$pathSite = Environment::getPublicPath() . '/';
}
$information = array(
'absPath' => PATH_site . $metaArray[$fileName]['pathBackup'],
'absPath' => $pathSite . $metaArray[$fileName]['pathBackup'],
'relFile' => $fileName,
);
$this->backupService->getBackupObj()->setVar($information);
......@@ -253,7 +266,7 @@ class ManageBackupsController extends AbstractBackendController {
// read original file
$this->configurationService->initFileObject(
$this->backupService->getBackupObj()->getVar('langFile'),
Typo3Lib::fixFilePath(PATH_site . '/' . $this->backupService->getBackupObj()->getVar('extPath'))
Typo3Lib::fixFilePath($pathSite . '/' . $this->backupService->getBackupObj()->getVar('extPath'))
);
// restore
$this->backupService->execBackupRestore();
......@@ -291,8 +304,14 @@ class ManageBackupsController extends AbstractBackendController {
* @return void
*/
protected function initializeBackupObject($langFile = '') {
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) {
$pathSite = PATH_site;
} else {
$pathSite = Environment::getPublicPath() . '/';
}
$information = array(
'extPath' => SgLib::trimPath(PATH_site, $this->session->getDataByKey('extensionSelection')),
'extPath' => SgLib::trimPath($pathSite, $this->session->getDataByKey('extensionSelection')),
'langFile' => $langFile,
);
$this->backupService->initBackupObject('base', $information);
......@@ -307,11 +326,17 @@ class ManageBackupsController extends AbstractBackendController {
protected function generateDiffContent($fileName) {
$localLangDiff = NULL;
$metaDiff = NULL;
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) {
$pathSite = PATH_site;
} else {
$pathSite = Environment::getPublicPath() . '/';
}
// set backup file
$metaArray = $this->backupService->getBackupObj()->getMetaInfos(3);
$informations = array(
'absPath' => Typo3Lib::fixFilePath(
PATH_site . '/' .
$pathSite . '/' .
$metaArray[$fileName]['pathBackup']
),
'relFile' => $fileName,
......@@ -322,7 +347,7 @@ class ManageBackupsController extends AbstractBackendController {
// read original file
$this->configurationService->initFileObject(
$this->backupService->getBackupObj()->getVar('langFile'),
Typo3Lib::fixFilePath(PATH_site . '/' . $this->backupService->getBackupObj()->getVar('extPath'))
Typo3Lib::fixFilePath($pathSite . '/' . $this->backupService->getBackupObj()->getVar('extPath'))
);
// read backup file
......
......@@ -31,6 +31,8 @@ use SGalinski\Lfeditor\Exceptions\LFException;
use SGalinski\Lfeditor\Utility\Functions;
use SGalinski\Lfeditor\Utility\SgLib;
use SGalinski\Lfeditor\Utility\Typo3Lib;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
/**
* Class BackupService
......@@ -57,9 +59,15 @@ class BackupService extends AbstractService {
// create backup and meta directory
$extConfig = $confService->getExtConfig();
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) {
$pathSite = PATH_site;
} else {
$pathSite = Environment::getPublicPath() . '/';
}
try {
SgLib::createDir($extConfig['pathBackup'], PATH_site);
SgLib::createDir(dirname($extConfig['metaFile']), PATH_site);
SgLib::createDir($extConfig['pathBackup'], $pathSite);
SgLib::createDir(dirname($extConfig['metaFile']), $pathSite);
} catch (Exception $e) {
throw new LFException('failure.failure', 0, '(' . $e->getMessage() . ')');
}
......@@ -69,7 +77,7 @@ class BackupService extends AbstractService {
$langFile = '';
if (!is_array($infos)) {
// build language file and extension path
if ($mode == 'xll') {
if ($mode == 'xlf') {
try {
$typo3RelFile = $confService->getFileObj()->getVar('typo3RelFile');
$typo3AbsFile = Typo3Lib::transTypo3File($typo3RelFile, TRUE);
......@@ -82,12 +90,12 @@ class BackupService extends AbstractService {
$extPath = SgLib::trimPath(
$langFile, SgLib::trimPath(
PATH_site,
$pathSite,
$typo3AbsFile
), '/'
);
} else {
$extPath = SgLib::trimPath(PATH_site, $confService->getFileObj()->getVar('absPath'), '/');
$extPath = SgLib::trimPath($pathSite, $confService->getFileObj()->getVar('absPath'), '/');
$langFile = $confService->getFileObj()->getVar('relFile');
}
......@@ -305,4 +313,4 @@ class BackupService extends AbstractService {
public function setBackupObj($backupObj) {
$this->backupObj = $backupObj;
}
}
}
......@@ -29,16 +29,20 @@ namespace SGalinski\Lfeditor\Service;
use Exception;
use SGalinski\Lfeditor\Exceptions\DirectoryAccessRightsException;
use SGalinski\Lfeditor\Exceptions\LFException;
use SGalinski\Lfeditor\Utility\ExtensionUtility;
use SGalinski\Lfeditor\Utility\Functions;
use SGalinski\Lfeditor\Utility\SgLib;
use SGalinski\Lfeditor\Utility\Typo3Lib;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Localization\Locales;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
use SGalinski\Lfeditor\Service\FileOverrideService;
/**
* Class ConfigurationService
......@@ -89,7 +93,7 @@ class ConfigurationService extends AbstractService {
if (!empty($this->extConfig)) {
return $this->extConfig;
}
$this->extConfig = \unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['lfeditor'], []);
$this->extConfig = ExtensionUtility::getExtensionConfiguration();
// regular expressions
if (!\preg_match('/^\/.*\/.*$/', $this->extConfig['searchRegex'])) {
......@@ -114,21 +118,25 @@ class ConfigurationService extends AbstractService {
$this->extConfig['numSiteConstsOptions']
= ['100' => 100, '200' => 200, '500' => 500, '1000' => 1000, '1500' => 1500, '2000' => 2000];
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) {
$pathSite = PATH_site;
} else {
$pathSite = Environment::getPublicPath() . '/';
}
// paths and files (dont need to exist)
$this->extConfig['pathBackup'] = Typo3Lib::fixFilePath(
PATH_site . '/typo3temp/LFEditor/Backup/'
$pathSite . '/typo3temp/LFEditor/Backup/'
) . '/';
$this->extConfig['metaFile'] = Typo3Lib::fixFilePath(
PATH_site . '/typo3temp/LFEditor/Backup/Meta.xml'
$pathSite . '/typo3temp/LFEditor/Backup/Meta.xml'
);
$this->extConfig['pathOverrideFiles'] = Typo3Lib::fixFilePath(
PATH_site . '/typo3conf/LFEditor/OverrideFiles/'
$pathSite . '/typo3conf/LFEditor/OverrideFiles/'
);
// files
$this->extConfig['pathCSS'] = 'Resources/Public/StyleSheets/Lfeditor.css';
$this->extConfig['pathTinyMCEConfig'] = PATH_site .
ExtensionManagementUtility::siteRelPath('lfeditor') . 'Resources/Public/Scripts/TinyMCEConfig.js';
// languages (default is forbidden)
if (!empty($this->extConfig['viewLanguages'])) {
......@@ -172,7 +180,8 @@ class ConfigurationService extends AbstractService {
// editing modes
$this->availabledEditingModes = array(
'extension' => LocalizationUtility::translate('select.editingMode.extension', 'lfeditor'),
'l10n' => LocalizationUtility::translate('select.editingMode.l10n', 'lfeditor'),
// The l10n mode does not work for TYPO3 9 and the var folder and we do not want to fix this, yet
//'l10n' => LocalizationUtility::translate('select.editingMode.l10n', 'lfeditor'),
// Note: override should be always available because it is the fallback mode for editors
'override' => LocalizationUtility::translate('select.editingMode.override', 'lfeditor'),
);
......@@ -186,7 +195,7 @@ class ConfigurationService extends AbstractService {
if (isset($this->extConfig['pathAdditionalConfiguration']) && $this->extConfig['pathAdditionalConfiguration']) {
$pathAdditionalConfiguration = Typo3Lib::fixFilePath($this->extConfig['pathAdditionalConfiguration']);
$this->extConfig['pathAdditionalConfiguration'] = PATH_site . $pathAdditionalConfiguration;
$this->extConfig['pathAdditionalConfiguration'] = $pathSite . $pathAdditionalConfiguration;
$additionalConfigurationDirectory = \dirname($this->extConfig['pathAdditionalConfiguration']);
if (!\is_writable($additionalConfigurationDirectory)) {
$message = 'Directory ' . $additionalConfigurationDirectory . ' is not writable.'
......@@ -214,12 +223,18 @@ class ConfigurationService extends AbstractService {
public function menuExtList() {
// search extensions
$tmpExtList = [];
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) {
$pathSite = PATH_site;
} else {
$pathSite = Environment::getPublicPath() . '/';
}
try {
// local extensions
if ($this->extConfig['viewLocalExt']) {
if (\count(
$content = Functions::searchExtensions(
PATH_site . Typo3Lib::PATH_LOCAL_EXT, $this->extConfig['viewStateExt'],
$pathSite . Typo3Lib::PATH_LOCAL_EXT, $this->extConfig['viewStateExt'],
$this->extConfig['extIgnore']
)
)
......@@ -232,7 +247,7 @@ class ConfigurationService extends AbstractService {
if ($this->extConfig['viewGlobalExt'] && \is_dir(Typo3Lib::PATH_GLOBAL_EXT)) {
if (\count(
$content = Functions::searchExtensions(
PATH_site . Typo3Lib::PATH_GLOBAL_EXT, $this->extConfig['viewStateExt'],
$pathSite . Typo3Lib::PATH_GLOBAL_EXT, $this->extConfig['viewStateExt'],
$this->extConfig['extIgnore']
)
)
......@@ -245,7 +260,7 @@ class ConfigurationService extends AbstractService {
if ($this->extConfig['viewSysExt']) {
if (\count(
$content = Functions::searchExtensions(
PATH_site . Typo3Lib::PATH_SYS_EXT, $this->extConfig['viewStateExt'],
$pathSite . Typo3Lib::PATH_SYS_EXT, $this->extConfig['viewStateExt'],
$this->extConfig['extIgnore']
)
)
......@@ -265,7 +280,7 @@ class ConfigurationService extends AbstractService {
// create list
/** @var array $extList */
$extList = Functions::prepareExtList($tmpExtList);
$extList = \array_merge([PATH_site . 'fileadmin' => 'fileadmin/', ''], $extList);
$extList = \array_merge([$pathSite . 'fileadmin' => 'fileadmin/', ''], $extList);
foreach ($extList as $extAddress => $extLabel) {
unset ($extList[$extAddress]);
......@@ -340,7 +355,7 @@ class ConfigurationService extends AbstractService {
continue;
}
$languageLabel = $language;
if ($language == 'default') {
if ($language === 'default') {
$languageLabel = 'en';
}
$languageList[$language] = $languageLabel . ' (' . $constCount . ' ' .
......@@ -409,7 +424,7 @@ class ConfigurationService extends AbstractService {
try {
if ($this->session->getDataByKey('editingMode') === 'override') {
/** @var FileOverrideService $overrideFileObj */
$overrideFileObj = $this->objectManager->get('SGalinski\Lfeditor\Service\FileOverrideService');
$overrideFileObj = $this->objectManager->get(FileOverrideService::class);
$overrideFileObj->init($originalFileObject, '', '');
$this->fileObj = $overrideFileObj;
} else {
......@@ -444,7 +459,7 @@ class ConfigurationService extends AbstractService {
}
$fileObject = $this->getFileObj();
if ($fileObject == NULL) {
if ($fileObject === NULL) {
$this->initFileObject(
$this->session->getDataByKey('languageFileSelection'),
$this->session->getDataByKey('extensionSelection')
......@@ -454,7 +469,7 @@ class ConfigurationService extends AbstractService {
// execute backup
$extConfig = $this->getExtConfig();
if ($extConfig['execBackup'] && $this->session->getDataByKey('editingMode') == 'extension') {
if ($extConfig['execBackup'] && $this->session->getDataByKey('editingMode') === 'extension') {
/** @var BackupService $backupService */
$backupService = $this->objectManager->get('SGalinski\Lfeditor\Service\BackupService');
$backupService->execBackup();
......@@ -485,7 +500,7 @@ class ConfigurationService extends AbstractService {
$originLang = $fileObject->getOriginLangData();
$emptyFiles = [];
foreach ($originLang as $lang => $origin) {
if ($origin == $absFile || !\is_file($origin)) {
if ($origin