Commit a1f35d6f authored by Stefan Galinski's avatar Stefan Galinski 🎮
Browse files

[BUGFIX] General code cleanup and fix warnings (e.g. PHP 5.3 support)

parent 0dfdc922
......@@ -280,7 +280,7 @@ abstract class AbstractController extends ActionController {
}
$pathTinyMCEConfig = PATH_site . ExtensionManagementUtility::siteRelPath('lfeditor')
. 'Resources/Public/Scripts/TinyMCEConfig.js';
$tinyMCE = $this->objectManager->get(Loader::class);
$tinyMCE = $this->objectManager->get('SGalinski\Tinymce\Loader');
$tinyMCE->loadConfiguration($pathTinyMCEConfig);
/** @var PageRenderer $pageRenderer */
......
......@@ -28,7 +28,6 @@ namespace SGalinski\Lfeditor\Controller;
use SGalinski\Lfeditor\Exceptions\LFException;
use TYPO3\CMS\Core\Messaging\AbstractMessage;
use TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
/**
......
......@@ -103,7 +103,8 @@ class EditFileController extends AbstractBackendController {
*/
public function changeSelectionAction(
$extensionSelection = NULL, $languageFileSelection = NULL, $languageSelection = NULL,
$referenceLanguageSelection = NULL, $constantTypeSelection = NULL, $bottomReferenceLanguageSelection = NULL, $numSiteConstsSelection = NULL
$referenceLanguageSelection = NULL, $constantTypeSelection = NULL, $bottomReferenceLanguageSelection = NULL,
$numSiteConstsSelection = NULL
) {
$this->saveSelectionsInSession(
$extensionSelection, $languageFileSelection, $referenceLanguageSelection, NULL, $languageSelection,
......
......@@ -30,6 +30,9 @@ use SGalinski\Lfeditor\Session\PhpSession;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Class AbstractService
*/
abstract class AbstractService implements SingletonInterface {
/**
* @var \TYPO3\CMS\Extbase\Object\ObjectManager
......@@ -40,9 +43,13 @@ abstract class AbstractService implements SingletonInterface {
*/
protected $session;
/**
* Constructor
*/
public function __construct() {
$this->objectManager = GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Object\ObjectManager');
}
/**
* Initializes the session object.
*
......
......@@ -32,6 +32,9 @@ use SGalinski\Lfeditor\Utility\Functions;
use SGalinski\Lfeditor\Utility\SgLib;
use SGalinski\Lfeditor\Utility\Typo3Lib;
/**
* Class BackupService
*/
class BackupService extends AbstractService {
/**
* @var \SGalinski\Lfeditor\Service\FileBackupService
......@@ -79,9 +82,9 @@ class BackupService extends AbstractService {
$extPath = SgLib::trimPath(
$langFile, SgLib::trimPath(
PATH_site,
$typo3AbsFile
), '/'
PATH_site,
$typo3AbsFile
), '/'
);
} else {
$extPath = SgLib::trimPath(PATH_site, $confService->getFileObj()->getVar('absPath'), '/');
......
......@@ -39,6 +39,9 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
/**
* Class ConfigurationService
*/
class ConfigurationService extends AbstractService {
/**
* @var array extension configuration
......@@ -57,7 +60,7 @@ class ConfigurationService extends AbstractService {
protected $langArray = array();
/**
* @var \SGalinski\Lfeditor\Service\FileService
* @var \SGalinski\Lfeditor\Service\FileBaseService
*/
protected $fileObj;
......@@ -284,7 +287,8 @@ class ConfigurationService extends AbstractService {
* @throws LFException
*/
public function menuLangList(
$langData, $default = '', BackendUserAuthentication $backendUser = NULL, $translatedLanguagesOnly = FALSE) {
$langData, $default = '', BackendUserAuthentication $backendUser = NULL, $translatedLanguagesOnly = FALSE
) {
// build languages
$languageArray = $this->getLangArray($backendUser);
$languageList = array();
......@@ -559,7 +563,7 @@ class ConfigurationService extends AbstractService {
$newFile = SgLib::setFileExtension($type, $file);
if ($this->convObj->getVar('workspace') == 'base') {
if ($this->convObj->checkLocalizedFile(basename($file), $langKey)) {
$newFile = dirname($file) . '/' . $this->fileObj->nameLocalizedFile($langKey);
$newFile = dirname($file) . '/' . $this->fileObj->nameLocalizedFile($langKey);
}
}
$this->fileObj->setOriginLangData(Typo3Lib::fixFilePath($newFile), $langKey);
......
......@@ -331,8 +331,10 @@ class FileBackupService extends FileService {
try {
SgLib::deleteFiles(array($file));
} catch (Exception $e) {
throw new LFException('failure.backup.notDeleted', 0,
'(' . $e->getMessage(), ')');
throw new LFException(
'failure.backup.notDeleted', 0,
'(' . $e->getMessage(), ')'
);
}
}
......
......@@ -153,7 +153,7 @@ abstract class FileBaseService extends FileService {
protected function prepareLanguageFilesForFirstUsage() {
$adaptedContent = $this->checkFileForFirstImport($this->absFile);
if ($adaptedContent) {
$files = [];
$files = array();
$files[$this->absFile] = $adaptedContent;
$languages = SgLib::getSystemLanguages();
......@@ -182,6 +182,10 @@ abstract class FileBaseService extends FileService {
* @return bool|string
*/
protected function checkFileForFirstImport($file) {
if (!file_exists($file)) {
return FALSE;
}
$fileContent = file_get_contents($file);
if (strpos($fileContent, '<generator>LFEditor</generator>') === FALSE) {
$fileContent = str_replace('<![CDATA[', '&lt;![CDATA[', $fileContent);
......
......@@ -269,7 +269,9 @@ class FileBaseXLFService extends FileBaseService {
$value = SgLib::htmlSpecialCharsIgnoringCdata($value);
$body .= "\t\t" . '<trans-unit id="' . htmlspecialchars(
$constant
) . '"' . $approved . $this->addPreserveSpaceAttribute($value, $enValue, $targetLanguage) . '>' . "\n";
) . '"' . $approved . $this->addPreserveSpaceAttribute(
$value, $enValue, $targetLanguage
) . '>' . "\n";
if ($targetLanguage !== 'default') {
$body .= "\t\t\t" . '<source>' . $enValue . '</source>' . "\n";
......@@ -348,7 +350,8 @@ class FileBaseXLFService extends FileBaseService {
}
// If default language content and $lang language content are not edited, skip this file.
if ($editedLanguages !== NULL &&
!in_array('default', $editedLanguages) && !in_array($lang, $editedLanguages)) {
!in_array('default', $editedLanguages) && !in_array($lang, $editedLanguages)
) {
continue;
}
......
......@@ -173,7 +173,8 @@ class FileBaseXMLService extends FileBaseService {
* @return void
*/
protected function arrayToXml(
array $phpArray, CdataSupportingSimpleXMLElement $xmlElement, array $parentTagMap = array(), $parentTagName = NULL
array $phpArray, CdataSupportingSimpleXMLElement $xmlElement, array $parentTagMap = array(),
$parentTagName = NULL
) {
foreach ($phpArray as $key => $value) {
if (strcasecmp($key, '@attributes') === 0) {
......
......@@ -30,6 +30,9 @@ use SGalinski\Lfeditor\Exceptions\LFException;
use SGalinski\Lfeditor\Utility\SgLib;
use SGalinski\Lfeditor\Utility\Typo3Lib;
/**
* FileOverrideService
*/
class FileOverrideService extends FileBaseXMLService {
/**
* Object which represents original (overridden) language file.
......
......@@ -285,15 +285,15 @@ abstract class FileService extends AbstractService {
*
* Array structure:
* array (
* '/var/www/file.xlf' => 'My content',
* ...
* '/var/www/file.xlf' => 'My content',
* ...
* )
*
* @param array $files
* @throws LFException
* @return void
*/
public function writeFilesWithContent(array $files = []) {
public function writeFilesWithContent(array $files = array()) {
// check write permissions of all files
foreach ($files as $file => $content) {
if (!SgLib::checkWritePerms($file)) {
......
......@@ -2,29 +2,29 @@
namespace SGalinski\Lfeditor\Utility;
/***************************************************************
* Copyright notice
*
* (c) sgalinski Internet Services (http://www.sgalinski.de)
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/***************************************************************
* Copyright notice
*
* (c) sgalinski Internet Services (http://www.sgalinski.de)
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Class which adds CDATA support to SimpleXMLElement.
......
......@@ -266,7 +266,7 @@ class Functions {
// Sort by numTranslated DESC
foreach ($infos as $key => $row) {
$numTranslated[$key] = $row['numTranslated'];
$numTranslated[$key] = $row['numTranslated'];
}
array_multisort($numTranslated, SORT_DESC, $infos);
......
......@@ -132,7 +132,7 @@ class Typo3Lib {
// get charset object
/** @var $csConvObj CharsetConverter */
$csConvObj = & $GLOBALS['LANG']->csConvObj;
$csConvObj = &$GLOBALS['LANG']->csConvObj;
// loop all possible languages
foreach ($localLang as $langKey => $convContent) {
......
......@@ -49,7 +49,7 @@ Following functions are implemented in this module:
'CGLcompliance_note' => '',
'constraints' => array(
'depends' => array(
'php' => '5.5.0-5.6.99',
'php' => '5.3.0-5.6.99',
'typo3' => '6.2.15-7.99.99',
),
'conflicts' => array(
......
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