Commit 973b19e3 authored by Kevin Ditscheid's avatar Kevin Ditscheid

[TASK] Resolve PATH_site constant deprecations

parent c93a87cc
......@@ -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;
......@@ -153,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
);
......@@ -243,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);
......@@ -252,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();
......@@ -290,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);
......@@ -306,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,
......@@ -321,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() . ')');
}
......@@ -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;
}
}
}
......@@ -35,9 +35,11 @@ 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;
......@@ -116,15 +118,21 @@ 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
......@@ -186,7 +194,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 +222,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 +246,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 +259,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 +279,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]);
......
......@@ -30,7 +30,9 @@ use Exception;
use SGalinski\Lfeditor\Exceptions\LFException;
use SGalinski\Lfeditor\Utility\SgLib;
use SGalinski\Lfeditor\Utility\Typo3Lib;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
/**
* backup class
......@@ -305,7 +307,13 @@ class FileBackupService extends FileService {
// get file
$backupPath = $metaArray[$filename]['pathBackup'];
$file = GeneralUtility::fixWindowsFilePath(PATH_site . '/' . $backupPath . '/' . $filename);
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) {
$pathSite = PATH_site;
} else {
$pathSite = Environment::getPublicPath() . '/';
}
$file = GeneralUtility::fixWindowsFilePath($pathSite . $backupPath . '/' . $filename);
// build new meta information file
unset($metaArray[$filename]);
......@@ -369,6 +377,12 @@ class FileBackupService extends FileService {
throw new LFException('failure.backup.notRead');
}
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) {
$pathSite = PATH_site;
} else {
$pathSite = Environment::getPublicPath() . '/';
}
// read array
$localLang = $originLang = array();
foreach ($phpArray['data'] as $langKey => $informations) {
......@@ -376,7 +390,7 @@ class FileBackupService extends FileService {
try {
$originLang[$langKey] = Typo3Lib::transTypo3File($informations['meta']['origin'], TRUE);
} catch (Exception $e) {
$originLang[$langKey] = PATH_site . $informations['meta']['origin'];
$originLang[$langKey] = $pathSite . $informations['meta']['origin'];
}
// read data
......@@ -406,13 +420,19 @@ class FileBackupService extends FileService {
// set meta
$phpArray['meta'] = $this->meta;
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) {
$pathSite = PATH_site;
} else {
$pathSite = Environment::getPublicPath() . '/';
}
// set array
foreach ($this->originLang as $lang => $origin) {
// set origin
try {
$phpArray['data'][$lang]['meta']['origin'] = Typo3Lib::transTypo3File($origin, FALSE);
} catch (Exception $e) {
$phpArray['data'][$lang]['meta']['origin'] = substr($origin, strlen(PATH_site));
$phpArray['data'][$lang]['meta']['origin'] = substr($origin, strlen($pathSite));
}
// set data
......@@ -453,7 +473,7 @@ class FileBackupService extends FileService {
// get new meta information
$metaArray = $this->getMetaInfos(3);
$metaArray[$this->relFile]['createdAt'] = time();
$metaArray[$this->relFile]['pathBackup'] = str_replace(PATH_site, '', $this->absPath);
$metaArray[$this->relFile]['pathBackup'] = str_replace($pathSite, '', $this->absPath);
$this->setMetaInfos($metaArray, 3);
// write meta information file
......
......@@ -30,8 +30,10 @@ use SGalinski\Lfeditor\Exceptions\LFException;
use SGalinski\Lfeditor\Utility\ExtensionUtility;
use SGalinski\Lfeditor\Utility\SgLib;
use SGalinski\Lfeditor\Utility\Typo3Lib;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
/**
* base workspace class (xlf)
......@@ -188,7 +190,13 @@ class FileBaseXLFService extends FileBaseService {
protected function getLocalizedFile($content, $langKey) {
$file = '';
if ($this->session->getDataByKey('editingMode') !== 'extension') {
$file = PATH_site . $this->getLocalizedFileName($this->absFile, $langKey);
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) {
$pathSite = PATH_site;
} else {
$pathSite = Environment::getPublicPath() . '/';
}
$file = $pathSite . $this->getLocalizedFileName($this->absFile, $langKey);
}
if (!\is_file($file)) {
$file = \dirname($this->absFile) . '/' . $this->nameLocalizedFile($langKey);
......
......@@ -32,7 +32,9 @@ use SGalinski\Lfeditor\Exceptions\LFException;
use SGalinski\Lfeditor\Utility\CdataSupportingSimpleXMLElement;
use SGalinski\Lfeditor\Utility\SgLib;
use SGalinski\Lfeditor\Utility\Typo3Lib;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
/**
* base workspace class (xml)
......@@ -91,10 +93,16 @@ class FileBaseXMLService extends FileBaseService {
* @return string localized file (absolute)
*/
protected function getLocalizedFile($content, $langKey) {
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) {
$pathSite = PATH_site;
} else {
$pathSite = Environment::getPublicPath() . '/';
}
if ($this->session->getDataByKey('editingMode') === 'l10n') {
$file = $this->getLocalizedFileName($this->absFile, $langKey);
if (\is_file(PATH_site . $file)) {
return Typo3Lib::fixFilePath(PATH_site . $file);
if (\is_file($pathSite . $file)) {
return Typo3Lib::fixFilePath($pathSite . $file);
}
}
......@@ -104,7 +112,7 @@ class FileBaseXMLService extends FileBaseService {
if (!$file = $this->getLocalizedFileName($this->absFile, $langKey, TRUE)) {
return $content;
}
$file = PATH_site . $file;
$file = $pathSite . $file;
if (!\is_file($file)) {
return $content;
}
......
......@@ -29,6 +29,8 @@ namespace SGalinski\Lfeditor\Service;
use SGalinski\Lfeditor\Exceptions\LFException;
use SGalinski\Lfeditor\Utility\SgLib;
use SGalinski\Lfeditor\Utility\Typo3Lib;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
/**
* FileOverrideService
......@@ -53,8 +55,15 @@ class FileOverrideService extends FileBaseXMLService {
} catch (\Exception $e) {
$typo3ExtRelativeFilePath = '';
}
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) {
$pathSite = PATH_site;
} else {
$pathSite = Environment::getPublicPath() . '/';
}
$overrideFileAbsolutePath = Typo3Lib::fixFilePath(
PATH_site . '/' .
$pathSite . '/' .
$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride'][$typo3ExtRelativeFilePath][0]
);
......@@ -145,8 +154,14 @@ class FileOverrideService extends FileBaseXMLService {
return;
}
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) {
$pathSite = PATH_site;
} else {
$pathSite = Environment::getPublicPath() . '/';
}
try {
SgLib::createDir($this->absPath, PATH_site);
SgLib::createDir($this->absPath, $pathSite);
} catch (\Exception $exception) {
throw new LFException('failure.failure', 0, '(' . $exception->getMessage() . ')');
}
......@@ -155,7 +170,7 @@ class FileOverrideService extends FileBaseXMLService {
// Set only new values in GlobalConfiguration if something changed
$typo3ExtRelativeFilePath = Typo3Lib::transTypo3File($this->originalFileObject->getAbsFile(), FALSE);
$relativeOverrideFilePath = SgLib::trimPath(PATH_site, $this->absFile);
$relativeOverrideFilePath = SgLib::trimPath($pathSite, $this->absFile);
$locallangXMLOverride = &$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride'];
if ($locallangXMLOverride[$typo3ExtRelativeFilePath][0] === $relativeOverrideFilePath) {
return;
......
......@@ -28,7 +28,9 @@ namespace SGalinski\Lfeditor\Utility;
use Exception;
use SGalinski\Lfeditor\Service\FileBasePHPService;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
/**
......@@ -260,7 +262,13 @@ class Functions {
$infos[$langKey]['origin'] = Typo3Lib::transTypo3File($origin, FALSE);
}
} catch (Exception $e) {
$infos[$langKey]['origin'] = SgLib::trimPath(PATH_site, $origin);
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) {
$pathSite = PATH_site;
} else {
$pathSite = Environment::getPublicPath() . '/';
}
$infos[$langKey]['origin'] = SgLib::trimPath($pathSite, $origin);
}
}
......
......@@ -29,7 +29,9 @@ namespace SGalinski\Lfeditor\Utility;
use Exception;
use RuntimeException;
use TYPO3\CMS\Core\Configuration\ConfigurationManager;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
/**
* includes special typo3 methods
......@@ -82,6 +84,12 @@ class Typo3Lib {
$extType['global'] = self::PATH_GLOBAL_EXT;
$extType['system'] = self::PATH_SYS_EXT;
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) {
$pathSite = PATH_site;
} else {
$pathSite = Environment::getPublicPath() . '/';
}
// relative to absolute
if ($mode) {
if (strpos($file, 'EXT:') === FALSE) {
......@@ -91,7 +99,7 @@ class Typo3Lib {
$cleanFile = SgLib::trimPath('EXT:', $file);
/** @var string[] $extType */
foreach ($extType as $type) {
$path = self::fixFilePath(PATH_site . '/' . $type . '/' . $cleanFile);
$path = self::fixFilePath($pathSite . '/' . $type . '/' . $cleanFile);
if (is_dir(\dirname($path))) {
return $path;
}
......@@ -107,7 +115,7 @@ class Typo3Lib {
continue;
}
return 'EXT:' . SgLib::trimPath($type, SgLib::trimPath(PATH_site, $file));
return 'EXT:' . SgLib::trimPath($type, SgLib::trimPath($pathSite, $file));
}
throw new RuntimeException('cant convert absolute file "' . $file . '"');
......
......@@ -10,11 +10,17 @@ if (!\is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfiguration
}
$extConf = \SGalinski\Lfeditor\Utility\ExtensionUtility::getExtensionConfiguration();
if (version_compare(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) {
$pathSite = PATH_site;
} else {
$pathSite = \TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/';
}
if (
$extConf['pathAdditionalConfiguration'] !== 'typo3conf/AdditionalConfiguration.php' &&
\is_file(PATH_site . $extConf['pathAdditionalConfiguration'])
\is_file($pathSite . $extConf['pathAdditionalConfiguration'])
) {
// Include the additional LFEditor configuration file if not set to AdditionalConfiguration.php
include_once PATH_site . $extConf['pathAdditionalConfiguration'];
include_once $pathSite . $extConf['pathAdditionalConfiguration'];
}
unset($extConf);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment