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