Commit d54b61d3 authored by Damjan's avatar Damjan
Browse files

[TASK] Compatibility with PHP 5.3.

Changing '[]' to 'array()'
parent 821c0262
......@@ -68,10 +68,10 @@ abstract class AbstractBackendController extends AbstractController {
}
$extensionKey = $this->request->getControllerExtensionKey();
$pair = [
$pair = array(
'action' => $this->request->getControllerActionName(),
'controller' => $this->request->getControllerName(),
];
);
$this->backendUser->uc[$extensionKey . 'State']['LastActionControllerPair'] = $pair;
if ($saveWithRedirectPair) {
......@@ -92,8 +92,8 @@ abstract class AbstractBackendController extends AbstractController {
}
$extensionKey = $this->request->getControllerExtensionKey();
$this->backendUser->uc[$extensionKey . 'State']['LastActionControllerPair'] = [];
$this->backendUser->uc[$extensionKey . 'State']['LastActionControllerPairForRedirect'] = [];
$this->backendUser->uc[$extensionKey . 'State']['LastActionControllerPair'] = array();
$this->backendUser->uc[$extensionKey . 'State']['LastActionControllerPairForRedirect'] = array();
$this->backendUser->writeUC($this->backendUser->uc);
if ($this->view instanceof ViewInterface) {
......@@ -108,12 +108,12 @@ abstract class AbstractBackendController extends AbstractController {
*/
protected function getLastCalledControllerActionPair() {
if (!$this->backendUser) {
return [];
return array();
}
$extensionKey = $this->request->getControllerExtensionKey();
$state = $this->backendUser->uc[$extensionKey . 'State']['LastActionControllerPair'];
return (!is_array($state) ? [] : $state);
return (!is_array($state) ? array() : $state);
}
/**
......@@ -123,12 +123,12 @@ abstract class AbstractBackendController extends AbstractController {
*/
protected function getLastCalledControllerActionPairForRedirect() {
if (!$this->backendUser) {
return [];
return array();
}
$extensionKey = $this->request->getControllerExtensionKey();
$state = $this->backendUser->uc[$extensionKey . 'State']['LastActionControllerPairForRedirect'];
return (!is_array($state) ? [] : $state);
return (!is_array($state) ? array() : $state);
}
/**
......
......@@ -95,7 +95,7 @@ class AddConstantController extends AbstractBackendController {
throw new LFException('failure.langfile.constExists');
}
$newConstLanguages = [];
$newConstLanguages = array();
foreach ($addConstTextArea as $lang => $value) {
$newConstLanguages[$lang][$nameOfConstant] = $value;
}
......@@ -121,11 +121,11 @@ class AddConstantController extends AbstractBackendController {
* @return void
*/
protected function prepareAddConstantViewMainSectionContent() {
$numTextAreaRows = $this->configurationService->getExtConfig()['numTextAreaRows'];
$extConfig = $this->configurationService->getExtConfig();
$langArray = $this->configurationService->getLangArray($this->backendUser);
$this->view->assign('languages', $langArray);
$this->view->assign('numTextAreaRows', $numTextAreaRows);
$this->view->assign('numTextAreaRows', $extConfig['numTextAreaRows']);
}
}
......
......@@ -100,15 +100,15 @@ class DeleteConstantController extends AbstractBackendController {
try {
$constantSelection = $this->session->getDataByKey('constantSelection');
$languages = Functions::buildLangArray();
$langArray = array_merge(['default'], $languages);
$langArray = array_merge(array('default'), $languages);
// build modArray
$newLang = [];
$newLang = array();
foreach ($langArray as $lang) {
$newLang[$lang][$constantSelection] = '';
}
$this->configurationService->execWrite($newLang, [], TRUE);
$this->configurationService->execWrite($newLang, array(), TRUE);
$this->addFlashMessage(
LocalizationUtility::translate('lang.file.write.success', 'lfeditor'),
......
......@@ -119,7 +119,7 @@ class EditConstantController extends AbstractBackendController {
* @return void
*/
protected function prepareEditConstantViewMainSectionContent(array $langData = NULL) {
$numTextAreaRows = $this->configurationService->getExtConfig()['numTextAreaRows'];
$extConfig = $this->configurationService->getExtConfig();
$langArray = $this->configurationService->getLangArray($this->backendUser);
$constantSelection = $this->session->getDataByKey('constantSelection');
......@@ -127,7 +127,7 @@ class EditConstantController extends AbstractBackendController {
throw new LFException('failure.select.noConst', 1);
}
$languages = [];
$languages = array();
foreach ($langArray as $lang) {
if ($langData[$lang]) {
$languages[$lang] = $langData[$lang][$constantSelection];
......@@ -139,7 +139,7 @@ class EditConstantController extends AbstractBackendController {
$this->view->assign('constantSelection', $constantSelection);
$this->view->assign('languages', $languages);
$this->view->assign('numTextAreaRows', $numTextAreaRows);
$this->view->assign('numTextAreaRows', $extConfig['numTextAreaRows']);
}
/**
......
......@@ -99,7 +99,7 @@ class EditFileController extends AbstractBackendController {
$extensionSelection, $languageFileSelection, $referenceLanguageSelection, NULL, $languageSelection,
$constantTypeSelection
);
$this->redirect('editFile', NULL, NULL, ['buttonType' => 0]);
$this->redirect('editFile', NULL, NULL, array('buttonType' => 0));
}
/**
......@@ -122,17 +122,17 @@ class EditFileController extends AbstractBackendController {
protected function prepareEditFileViewMainSectionContent(array $langData, $buttonType) {
$sessID = 'tx_lfeditor_sessionVariables'; // TODO: Use $this->session
$numTextAreaRows = $this->configurationService->getExtConfig()['numTextAreaRows'];
$numConstantsPerPage = $this->configurationService->getExtConfig()['numSiteConsts'];
$extConfig = $this->configurationService->getExtConfig();
$numConstantsPerPage = $extConfig['numSiteConsts'];
$langList = $this->session->getDataByKey('languageSelection');
$patternList = $this->session->getDataByKey('referenceLanguageSelection');
$constTypeList = $this->session->getDataByKey('constantTypeSelection');
$parallelEdit = $patternList != '###default###' && $patternList != $langList;
$langEdit = is_array($langData[$langList]) ? $langData[$langList] : [];
$langPattern = is_array($langData[$patternList]) ? $langData[$patternList] : [];
$langDefault = is_array($langData['default']) ? $langData['default'] : [];
$langEdit = is_array($langData[$langList]) ? $langData[$langList] : array();
$langPattern = is_array($langData[$patternList]) ? $langData[$patternList] : array();
$langDefault = is_array($langData['default']) ? $langData['default'] : array();
$langDataSessionContinued = $buttonType != 3;
if ($buttonType === 0) {
......@@ -183,7 +183,7 @@ class EditFileController extends AbstractBackendController {
// prepare constant list for this page
$numberLastPageConstants = 0;
$constValues = [];
$constValues = array();
do {
// check number of session constants
if ($sessionLangDataConstantsIterator >= $numConsts) {
......@@ -218,7 +218,7 @@ class EditFileController extends AbstractBackendController {
$this->session->setDataByKey('sessionLangDataConstantsIterator', $sessionLangDataConstantsIterator);
$this->session->setDataByKey('numberLastPageConstants', $numberLastPageConstants);
$this->view->assign('numTextAreaRows', $numTextAreaRows);
$this->view->assign('numTextAreaRows', $extConfig['numTextAreaRows']);
$this->view->assign('parallelEdit', $parallelEdit);
$this->view->assign('displayBackButton', $sessionLangDataConstantsIterator > $numConstantsPerPage);
$this->view->assign('displayNextButton', $sessionLangDataConstantsIterator < $numConsts);
......@@ -285,7 +285,7 @@ class EditFileController extends AbstractBackendController {
} catch (LFException $e) {
$this->addLFEFlashMessage($e);
}
$this->redirect('editFile', NULL, NULL, ['buttonType' => $buttonType]);
$this->redirect('editFile', NULL, NULL, array('buttonType' => $buttonType));
}
}
......
......@@ -106,17 +106,17 @@ class GeneralController extends AbstractBackendController {
$authorName = NULL, $authorEmail = NULL, $metaDescription = NULL, $transformFile = NULL, $splitFile = NULL
) {
try {
$metaArray = [
$metaArray = array(
'authorName' => $authorName,
'authorEmail' => $authorEmail,
'description' => $metaDescription
];
$this->configurationService->execWrite([], $metaArray);
);
$this->configurationService->execWrite(array(), $metaArray);
if(!$this->session->getDataByKey('overrideMode')) {
// split or merge
if (($splitFile == 1 || $splitFile == 2)) {
$langModes = [];
$langModes = array();
// set vars
if ($splitFile != 1 && $splitFile != 2) {
$splitFile = 0;
......@@ -173,7 +173,7 @@ class GeneralController extends AbstractBackendController {
$this->session->getDataByKey('languageFileSelection'),
$this->session->getDataByKey('extensionSelection')
);
$numTextAreaRows = $this->configurationService->getExtConfig()['numTextAreaRows'];
$extConfig = $this->configurationService->getExtConfig();
$langArray = $this->configurationService->getLangArray($this->backendUser);
$infoArray = Functions::genGeneralInfoArray(
$referenceLanguageSelection,
......@@ -186,7 +186,7 @@ class GeneralController extends AbstractBackendController {
$this->view->assign('infos', $infoArray);
$this->view->assign('refLangNumTranslated', $infoArray[$referenceLanguageSelection]['numTranslated']);
$this->view->assign('numTextAreaRows', $numTextAreaRows);
$this->view->assign('numTextAreaRows', $extConfig['numTextAreaRows']);
$this->view->assign('metaDescription', $description);
$this->view->assign('langFileExtension', $langFileExtension);
$this->view->assign('preselectMerge', $preselectMerge);
......
......@@ -134,13 +134,13 @@ class ManageBackupsController extends AbstractBackendController {
* @return array
*/
protected function makeBackupsList() {
$backups = [];
$backups = array();
$metaArray = $this->backupService->getBackupObj()->getMetaInfos(2);
if (is_array($metaArray)) {
$keys = array_keys($metaArray);
foreach ($keys as $langFile) {
foreach ($metaArray[$langFile] as $fileName => $informations) {
$backup = [];
$backup = array();
// get path to filename
$backupPath = $informations['pathBackup'];
......@@ -176,7 +176,7 @@ class ManageBackupsController extends AbstractBackendController {
public function deleteAllBackupAction() {
try {
$this->initializeBackupObject();
$delFiles = [];
$delFiles = array();
$metaArray = $this->backupService->getBackupObj()->getMetaInfos(2);
foreach ($metaArray as $langFile => $metaPiece) {
$files = array_keys($metaPiece);
......@@ -207,7 +207,7 @@ class ManageBackupsController extends AbstractBackendController {
public function deleteBackupAction($fileName, $langFile) {
try {
$this->initializeBackupObject($langFile);
$delFiles = [];
$delFiles = array();
$delFiles[$fileName] = '';
$this->backupService->execBackupDelete($delFiles);
$this->addFlashMessage(
......@@ -234,10 +234,10 @@ class ManageBackupsController extends AbstractBackendController {
$this->initializeBackupObject($langFile);
// set backup file
$metaArray = $this->backupService->getBackupObj()->getMetaInfos(3);
$information = [
$information = array(
'absPath' => PATH_site . $metaArray[$fileName]['pathBackup'],
'relFile' => $fileName,
];
);
$this->backupService->getBackupObj()->setVar($information);
$this->backupService->getBackupObj()->readFile();
// read original file
......@@ -268,7 +268,7 @@ class ManageBackupsController extends AbstractBackendController {
*/
public function showDifferenceBackupAction($fileName, $langFile) {
$this->redirect(
'manageBackups', NULL, NULL, ['fileName' => $fileName, 'langFile' => $langFile, 'showDiff' => TRUE]
'manageBackups', NULL, NULL, array('fileName' => $fileName, 'langFile' => $langFile, 'showDiff' => TRUE)
);
}
......@@ -281,10 +281,10 @@ class ManageBackupsController extends AbstractBackendController {
* @return void
*/
protected function initializeBackupObject($langFile = '') {
$information = [
$information = array(
'extPath' => SgLib::trimPath(PATH_site, $this->session->getDataByKey('extensionSelection')),
'langFile' => $langFile,
];
);
$this->backupService->initBackupObject('base', $information);
}
......@@ -299,13 +299,13 @@ class ManageBackupsController extends AbstractBackendController {
$metaDiff = NULL;
// set backup file
$metaArray = $this->backupService->getBackupObj()->getMetaInfos(3);
$informations = [
$informations = array(
'absPath' => Typo3Lib::fixFilePath(
PATH_site . '/' .
$metaArray[$fileName]['pathBackup']
),
'relFile' => $fileName,
];
);
$this->backupService->getBackupObj()->setVar($informations);
// exec diff
......@@ -359,15 +359,15 @@ class ManageBackupsController extends AbstractBackendController {
protected function outputManageBackupsDiff(
$diff, $metaDiff, $origLang, $backupLang, $origOriginLang, $backupOriginLang, $origMeta, $backupMeta
) {
$differences = [];
$differences = array();
// meta entry
if (count($metaDiff)) {
$difference = [];
$difference = array();
$difference['legend'] = LocalizationUtility::translate('function.backupMgr.diff.meta', 'lfeditor');
$difference['constants'] = [];
$difference['constants'] = array();
foreach ($metaDiff as $label => $value) {
$constant = [];
$constant = array();
$constant['value'] = $value;
$constant['label'] = $label;
if (!isset($backupMeta[$label])) {
......@@ -384,7 +384,7 @@ class ManageBackupsController extends AbstractBackendController {
// loop each language entry
foreach ($diff as $langKey => $data) {
$difference = [];
$difference = array();
if (!count($data) && ($origOriginLang[$langKey] == $backupOriginLang[$langKey])) {
continue;
}
......@@ -394,9 +394,9 @@ class ManageBackupsController extends AbstractBackendController {
$languageFile = $backupOriginLang[$langKey];
}
$difference['legend'] = $langKey . ' (' . $languageFile . ')';
$difference['constants'] = [];
$difference['constants'] = array();
foreach ($data as $label => $value) {
$constant = [];
$constant = array();
$constant['value'] = $value;
$constant['label'] = $label;
......
......@@ -107,8 +107,8 @@ class RenameConstantController extends AbstractBackendController {
throw new LFException('failure.langfile.constExists');
}
$langArray = array_merge(['default'], Functions::buildLangArray());
$newLang = [];
$langArray = array_merge(array('default'), Functions::buildLangArray());
$newLang = array();
foreach ($langArray as $lang) {
if (isset($langData[$lang][$oldConstantName])) {
$newLang[$lang][$newConstantName] = $langData[$lang][$oldConstantName];
......@@ -116,7 +116,7 @@ class RenameConstantController extends AbstractBackendController {
$newLang[$lang][$oldConstantName] = '';
}
$this->configurationService->execWrite($newLang, [], TRUE);
$this->configurationService->execWrite($newLang, array(), TRUE);
$this->addFlashMessage(
LocalizationUtility::translate('lang.file.write.success', 'lfeditor'),
......
......@@ -77,7 +77,7 @@ class SearchConstantController extends AbstractBackendController {
* @return void
*/
public function searchConstantSearchAction($caseSensitive, $searchStr) {
$searchResultArray = [];
$searchResultArray = array();
try {
$this->configurationService->initFileObject(
$this->session->getDataByKey('languageFileSelection'),
......@@ -115,7 +115,7 @@ class SearchConstantController extends AbstractBackendController {
$this->session->setDataByKey('searchString', $searchStr);
$this->session->setDataByKey('searchCaseSensitive', $caseSensitive);
$this->redirect('searchConstant', NULL, NULL, ['searchDone' => TRUE]);
$this->redirect('searchConstant', NULL, NULL, array('searchDone' => TRUE));
}
/**
......@@ -125,11 +125,11 @@ class SearchConstantController extends AbstractBackendController {
* @return void
*/
protected function prepareSearchConstantViewMainSectionContent($searchDone) {
$searchResultArray = [];
$searchResultArray = array();
if ($searchDone) {
$searchResultArray = $this->session->getDataByKey('searchResultArray');
} else {
$this->session->setDataByKey('searchResultArray', []);
$this->session->setDataByKey('searchResultArray', array());
}
$searchString = $this->session->getDataByKey('searchString');
$searchCaseSensitive = $this->session->getDataByKey('searchCaseSensitive');
......
......@@ -120,9 +120,10 @@ class ViewTreeController extends AbstractBackendController {
$refLangSelection = $this->session->getDataByKey('referenceLanguageSelection');
$languageSelection = $this->session->getDataByKey('languageSelection');
$tree = Functions::genTreeInfoArray($langData[$languageSelection], $langData[$refLangSelection], $explodeToken);
$treeHide = $this->configurationService->getExtConfig()['treeHide'];
$extConfig = $this->configurationService->getExtConfig();
$treeHide = $extConfig['treeHide'];
$fluidTree = [];
$fluidTree = array();
$levelIndex = 0;
$this->addLevelElementsToFluidTree($tree, $levelIndex, NULL, $fluidTree, $treeHide);
......@@ -157,7 +158,7 @@ class ViewTreeController extends AbstractBackendController {
$index = 0;
foreach ($sourceTree[$level] as $constKey => $treeNode) {
if ($level === 0 || $treeNode['parent'] === $parentKey) {
$fluidTreeElem = [];
$fluidTreeElem = array();
$fluidTreeElem['label'] = $treeNode['name'];
$fluidTreeElem['parent'] = $fluidTree; //$treeNode['parent'];//; //
$fluidTreeElem['type'] = $treeNode['type'];
......@@ -192,8 +193,8 @@ class ViewTreeController extends AbstractBackendController {
* @return array
*/
protected function prepareTreeIcons($level, $treeHide, array $fluidTreeElem, $hasChildren) {
$icons = [];
$leftMargins = [];
$icons = array();
$leftMargins = array();
$marginLeftSpaceCounter = 0;
for ($iconLevel = $level, $currentFluidTreeElem = $fluidTreeElem;
$currentFluidTreeElem;
......@@ -218,7 +219,7 @@ class ViewTreeController extends AbstractBackendController {
continue;
}
}
$icons[] = ['name' => $iconName];
$icons[] = array('name' => $iconName);
}
$leftMargins[] = $marginLeftSpaceCounter;
for ($iterator = 0, $iconsSize = count($icons); $iterator < $iconsSize; $iterator++) {
......
......@@ -53,11 +53,10 @@ class BackupService extends AbstractService {
$confService = $this->objectManager->get('SGalinski\Lfeditor\Service\ConfigurationService');
// create backup and meta directory
$backupPath = $confService->getExtConfig()['pathBackup'];
$metaFile = $confService->getExtConfig()['metaFile'];
$extConfig = $confService->getExtConfig();
try {
SgLib::createDir($backupPath, PATH_site);
SgLib::createDir(dirname($metaFile), PATH_site);
SgLib::createDir($extConfig['pathBackup'], PATH_site);
SgLib::createDir(dirname($extConfig['metaFile']), PATH_site);
} catch (Exception $e) {
throw new LFException('failure.failure', 0, '(' . $e->getMessage() . ')');
}
......@@ -103,7 +102,7 @@ class BackupService extends AbstractService {
// create and initialize the backup object
try {
$this->backupObj = $this->objectManager->get('SGalinski\Lfeditor\Service\FileBackupService');
$this->backupObj->init('', $backupPath, $metaFile);
$this->backupObj->init('', $extConfig['pathBackup'], $extConfig['metaFile']);
$this->backupObj->setVar($informations);
} catch (LFException $e) {
throw $e;
......@@ -140,8 +139,8 @@ class BackupService extends AbstractService {
$confService = $this->objectManager->get('SGalinski\Lfeditor\Service\ConfigurationService');
// get vars
$localLang = [];
$meta = [];
$localLang = array();
$meta = array();
$origLang = $confService->getFileObj()->getLocalLangData();
$origMeta = $confService->getFileObj()->getMetaData();
$backupMeta = $this->backupObj->getMetaData();
......@@ -193,7 +192,7 @@ class BackupService extends AbstractService {
}
// restore origins of languages
$deleteFiles = [];
$deleteFiles = array();
foreach ($backupOriginLang as $langKey => $file) {
$curFile = $confService->getFileObj()->getOriginLangData($langKey);
if ($curFile != $file && $curFile != $confService->getFileObj()->getVar('absFile')) {
......@@ -248,14 +247,15 @@ class BackupService extends AbstractService {
}
// exec automatic deletion of backup files, if anzBackup greater zero
if ($confService->getExtConfig()['anzBackup'] <= 0) {
$extConfig = $confService->getExtConfig();
if ($extConfig['anzBackup'] <= 0) {
return TRUE;
}
// get difference information
$metaArray = $this->backupObj->getMetaInfos(3);
$rows = count($metaArray);
$dif = $rows - $confService->getExtConfig()['anzBackup'];
$dif = $rows - $extConfig['anzBackup'];
if ($dif <= 0) {
return TRUE;
......
......@@ -43,7 +43,7 @@ class ConfigurationService extends AbstractService {
* @var array extension configuration
* @see prepareConfig()
*/
protected $extConfig = [];
protected $extConfig = array();
/**
* @var string
......@@ -53,7 +53,7 @@ class ConfigurationService extends AbstractService {
/**
* @var array
*/
protected $langArray = [];
protected $langArray = array();
/**
* @var \SGalinski\Lfeditor\Service\FileService
......@@ -115,7 +115,7 @@ class ConfigurationService extends AbstractService {
$langs = GeneralUtility::trimExplode(',', $this->extConfig['viewLanguages'], TRUE);
unset($this->extConfig['viewLanguages']);
$availableLanguages = [];
$availableLanguages = array();
if (GeneralUtility::compat_version('6.0')) {
/** @var Locales $locales */
$locales = GeneralUtility::makeInstance('TYPO3\CMS\Core\Localization\Locales');
......@@ -156,7 +156,7 @@ class ConfigurationService extends AbstractService {
*/
public function menuExtList() {
// search extensions
$tmpExtList = [];
$tmpExtList = array();
try {
// local extensions
if ($this->extConfig['viewLocalExt']) {
......@@ -208,7 +208,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(array(PATH_site . 'fileadmin' => 'fileadmin/', ''), $extList);
foreach ($extList as $extAddress => $extLabel) {
unset ($extList[$extAddress]);
......@@ -245,7 +245,7 @@ class ConfigurationService extends AbstractService {
);
}
$fileArray = [];
$fileArray = array();
if (count($files)) {
foreach ($files as $file) {
$filename = substr($file, strlen($extensionAddress) + 1);
......@@ -271,9 +271,9 @@ class ConfigurationService extends AbstractService {
if (empty($this->langArray)) {
$languages = Functions::buildLangArray($this->extConfig['viewLanguages']);
$languages = $this->narrowToUserLanguages($languages, $backendUser);
$this->langArray = array_merge(['default'], $languages);
$this->langArray = array_merge(array('default'), $languages);
}
$langList = [];
$langList = array();
foreach ($this->langArray as $lang) {
$constCount = 0;
if (is_array($langData[$lang])) {
......@@ -285,7 +285,7 @@ class ConfigurationService extends AbstractService {
// add default value
if (!empty($default)) {
$langList = array_merge(['###default###' => $default], $langList);
$langList = array_merge(array('###default###' => $default), $langList);
}
return $langList;
}
......@@ -299,7 +299,7 @@ class ConfigurationService extends AbstractService {
*/
public function menuConstList($langData, $default) {
// generate constant list
$constList = [];
$constList = array();
$languages = Functions::buildLangArray();
foreach ($languages as $language) {
if (!is_array($langData[$language]) || !count($langData[$language])) {
......@@ -315,7 +315,7 @@ class ConfigurationService extends AbstractService {
// sorting and default entry
asort($constList);
$constList = array_merge(['###default###' => $default], $constList);
$constList = array_merge(array('###default###' => $default), $constList);
return $constList;
}
......@@ -370,7 +370,7 @@ class ConfigurationService extends AbstractService {
* @param boolean $forceDel set to true if you want delete default constants
* @return void
*/
public function execWrite($modArray, $modMetaArray = [], $forceDel = FALSE) {
public function execWrite($modArray, $modMetaArray = array(), $forceDel = FALSE) {
// checks
if (!is_array($modArray)) {