Commit e6479c24 authored by Andreas Wolf's avatar Andreas Wolf Committed by Thomas Löffler
Browse files

[CLEANUP] Reformat sources according to PSR-2

Change-Id: I1e052aac90bd198b2d0e061b497b6a0ef7b747e3
Reviewed-on: https://review.typo3.org/50611

Reviewed-by: Thomas Löffler's avatarThomas Löffler <loeffler@spooner-web.de>
Tested-by: Thomas Löffler's avatarThomas Löffler <loeffler@spooner-web.de>
parent 630e3d3b
<?php <?php
/******************************************************************* /*******************************************************************
* Copyright notice * Copyright notice
* *
* (c) 2011 Kai Vogel <kai.vogel@speedprogs.de>, Speedprogs.de * (c) 2011 Kai Vogel <kai.vogel@speedprogs.de>, Speedprogs.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 * it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of * published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version. * the License, or (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!
******************************************************************/ ******************************************************************/
/** /**
* Cache for extension files * Cache for extension files
*/ */
class Tx_TerFe2_Cache_FileCache implements t3lib_Singleton { class Tx_TerFe2_Cache_FileCache implements t3lib_Singleton
{
/**
* @var string /**
*/ * @var string
protected $cacheDirectory; */
protected $cacheDirectory;
/**
* Set cache directory path /**
* * Set cache directory path
* @param string $cacheDirectory Path to cache directory *
* @return void * @param string $cacheDirectory Path to cache directory
*/ * @return void
public function setCacheDirectory($cacheDirectory) { */
if (empty($cacheDirectory)) { public function setCacheDirectory($cacheDirectory)
throw new Exception('An empty cache directory is not allowed'); {
} if (empty($cacheDirectory)) {
$this->cacheDirectory = Tx_TerFe2_Utility_File::getAbsoluteDirectory($cacheDirectory); throw new Exception('An empty cache directory is not allowed');
} }
$this->cacheDirectory = Tx_TerFe2_Utility_File::getAbsoluteDirectory($cacheDirectory);
}
/**
* Get cache directory path
* /**
* @return string Path of the cache directory * Get cache directory path
*/ *
public function getCacheDirectory() { * @return string Path of the cache directory
return $this->cacheDirectory; */
} public function getCacheDirectory()
{
return $this->cacheDirectory;
/** }
* Get filename
*
* @param string $filename Name of the file /**
* @return string Local filename * Get filename
*/ *
public function getFile($filename) { * @param string $filename Name of the file
$filename = $this->getFilePath($filename); * @return string Local filename
if (Tx_TerFe2_Utility_File::fileExists($filename)) { */
return $filename; public function getFile($filename)
} {
return ''; $filename = $this->getFilePath($filename);
} if (Tx_TerFe2_Utility_File::fileExists($filename)) {
return $filename;
}
/** return '';
* Returns an extension related filename }
*
* @param string $extensionKey Extension key
* @param string $filename Name of the file /**
* @return string Local filename * Returns an extension related filename
*/ *
public function getExtensionFile($extensionKey, $filename) { * @param string $extensionKey Extension key
$filename = $this->getExtensionFilename($extensionKey, $filename); * @param string $filename Name of the file
return $this->getFile($filename); * @return string Local filename
} */
public function getExtensionFile($extensionKey, $filename)
{
/** $filename = $this->getExtensionFilename($extensionKey, $filename);
* Copy a file to local cache return $this->getFile($filename);
* }
* @param string $fileUrl Url to the file
* @param string $filename Name of the file
* @return string Local filename /**
*/ * Copy a file to local cache
public function addFile($fileUrl, $filename) { *
if (empty($fileUrl)) { * @param string $fileUrl Url to the file
return ''; * @param string $filename Name of the file
} * @return string Local filename
$filename = $this->getFilePath($filename); */
if (Tx_TerFe2_Utility_File::copyFile($fileUrl, $filename)) { public function addFile($fileUrl, $filename)
return $filename; {
} if (empty($fileUrl)) {
return ''; return '';
} }
$filename = $this->getFilePath($filename);
if (Tx_TerFe2_Utility_File::copyFile($fileUrl, $filename)) {
/** return $filename;
* Copy an extension file to local cache }
* return '';
* @param string $extensionKey Extension key }
* @param string $fileUrl Url to the file
* @param string $filename Name of the file
* @return string Local filename /**
*/ * Copy an extension file to local cache
public function addExtensionFile($extensionKey, $fileUrl, $filename) { *
$filename = $this->getExtensionFilename($extensionKey, $filename); * @param string $extensionKey Extension key
return $this->addFile($fileUrl, $filename); * @param string $fileUrl Url to the file
} * @param string $filename Name of the file
* @return string Local filename
*/
/** public function addExtensionFile($extensionKey, $fileUrl, $filename)
* Remove a file from local cache {
* $filename = $this->getExtensionFilename($extensionKey, $filename);
* @param string $filename Name of the file return $this->addFile($fileUrl, $filename);
* @return boolean TRUE if success }
*/
public function removeFile($filename) {
$filename = $this->getFilePath($filename); /**
if (!Tx_TerFe2_Utility_File::fileExists($fileUrl)) { * Remove a file from local cache
return FALSE; *
} * @param string $filename Name of the file
return unlink($filename); * @return boolean TRUE if success
} */
public function removeFile($filename)
{
/** $filename = $this->getFilePath($filename);
* Remove an extension file from local cache if (!Tx_TerFe2_Utility_File::fileExists($fileUrl)) {
* return FALSE;
* @param string $extensionKey Extension key }
* @param string $filename Name of the file return unlink($filename);
* @return string Local filename }
*/
public function removeExtensionFile($extensionKey, $filename) {
$filename = $this->getExtensionFilename($extensionKey, $filename); /**
return $this->removeFile($filename); * Remove an extension file from local cache
} *
* @param string $extensionKey Extension key
* @param string $filename Name of the file
/** * @return string Local filename
* Returns the filename of a file */
* public function removeExtensionFile($extensionKey, $filename)
* @param string $filename Name of the file {
* @return string Absolute path to file $filename = $this->getExtensionFilename($extensionKey, $filename);
*/ return $this->removeFile($filename);
protected function getFilePath($filename) { }
if (empty($filename)) {
return '';
} /**
$cacheDirectory = $this->getCacheDirectory(); * Returns the filename of a file
if (empty($cacheDirectory)) { *
throw new Exception('No cache directory defined'); * @param string $filename Name of the file
} * @return string Absolute path to file
return $cacheDirectory . $filename; */
} protected function getFilePath($filename)
{
if (empty($filename)) {
/** return '';
* Returns the filename of an extension file }
* $cacheDirectory = $this->getCacheDirectory();
* @param string $extensionKey Extension key if (empty($cacheDirectory)) {
* @param string $filename Name of the file throw new Exception('No cache directory defined');
* @return string Extension filename }
*/ return $cacheDirectory . $filename;
protected function getExtensionFilename($extensionKey, $filename) { }
if (empty($extensionKey) || empty($filename)) {
return '';
} /**
return strtolower($extensionKey) . '/' . basename($filename); * Returns the filename of an extension file
} *
* @param string $extensionKey Extension key
} * @param string $filename Name of the file
* @return string Extension filename
*/
protected function getExtensionFilename($extensionKey, $filename)
{
if (empty($extensionKey) || empty($filename)) {
return '';
}
return strtolower($extensionKey) . '/' . basename($filename);
}
}
?> ?>
\ No newline at end of file
<?php <?php
/******************************************************************* /*******************************************************************
* Copyright notice * Copyright notice
* *
* (c) 2011 Kai Vogel <kai.vogel@speedprogs.de>, Speedprogs.de * (c) 2011 Kai Vogel <kai.vogel@speedprogs.de>, Speedprogs.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 * it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of * published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version. * the License, or (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!
******************************************************************/ ******************************************************************/
/** /**
* Abstract controller * Abstract controller
*/ */
abstract class Tx_TerFe2_Controller_AbstractController extends Tx_Extbase_MVC_Controller_ActionController { abstract class Tx_TerFe2_Controller_AbstractController extends Tx_Extbase_MVC_Controller_ActionController
{
/**
* @var Tx_TerFe2_Security_Role /**
*/ * @var Tx_TerFe2_Security_Role
protected $securityRole; */
protected $securityRole;
/**
* @param Tx_TerFe2_Security_Role $securityRole /**
*/ * @param Tx_TerFe2_Security_Role $securityRole
public function injectSecurityRole(Tx_TerFe2_Security_Role $securityRole) { */
$this->securityRole = $securityRole; public function injectSecurityRole(Tx_TerFe2_Security_Role $securityRole)
} {
$this->securityRole = $securityRole;
/** }
* Pre-parse TypoScript setup
* /**
* @return void * Pre-parse TypoScript setup
*/ *
public function initializeAction() { * @return void
// Pre-parse settings */
$this->settings = Tx_TerFe2_Utility_TypoScript::parse($this->settings); public function initializeAction()
{
// Initialize the controller // Pre-parse settings
$this->initializeController(); $this->settings = Tx_TerFe2_Utility_TypoScript::parse($this->settings);
}
// Initialize the controller
$this->initializeController();
/** }
* Override in concrete controller to initialize it
*
* @return void /**
*/ * Override in concrete controller to initialize it
protected function initializeController() { *
* @return void
} */
protected function initializeController()
{
/**
* Translate a label }
*
* @param string $label Label to translate
* @param array $arguments Optional arguments array /**
* @return string Translated label * Translate a label
*/ *
protected function translate($label, array $arguments = array()) { * @param string $label Label to translate
$extensionKey = $this->request->getControllerExtensionKey(); * @param array $arguments Optional arguments array
return Tx_Extbase_Utility_Localization::translate($label, $extensionKey, $arguments); * @return string Translated label
} */
protected function translate($label, array $arguments = array())
{
/** $extensionKey = $this->request->getControllerExtensionKey();
* Send flash message and redirect to given action return Tx_Extbase_Utility_Localization::translate($label, $extensionKey, $arguments);
* }
* @param string $message Identifier of the message to send
* @param string $action Name of the action
* @param string $title Title for the flash message /**
* @param int $severity Severity for the flash message * Send flash message and redirect to given action
* @param string $controller Unqualified object name of the controller *
* @param string $extension Name of the extension containing the controller * @param string $message Identifier of the message to send
* @param array $arguments Arguments to pass to the target action * @param string $action Name of the action
* @return void * @param string $title Title for the flash message
*/ * @param int $severity Severity for the flash message
protected function redirectWithMessage($message, $action, $title = '', $severity = t3lib_FlashMessage::OK, * @param string $controller Unqualified object name of the controller
$controller = NULL, $extension = NULL, array $arguments = NULL) { * @param string $extension Name of the extension containing the controller
$this->flashMessageContainer->add($message, $title, $severity); * @param array $arguments Arguments to pass to the target action
$this->clearPageCache($GLOBALS['TSFE']->id); * @return void
$this->redirect($action, $controller, $extension, $arguments); */
} protected function redirectWithMessage($message, $action, $title = '', $severity = t3lib_FlashMessage::OK,
$controller = NULL, $extension = NULL, array $arguments = NULL)
{
/** $this->flashMessageContainer->add($message, $title, $severity);
* Send flash message and forward to given action $this->clearPageCache($GLOBALS['TSFE']->id);
* $this->redirect($action, $controller, $extension, $arguments);
* @param string $message Identifier of the message to send }
* @param string $action Name of the action
* @param string $controller Unqualified object name of the controller
* @param string $extension Name of the extension containing the controller /**
* @param array $arguments Arguments to pass to the target action * Send flash message and forward to given action
* @return void *
*/ * @param string $message Identifier of the message to send
protected function forwardWithMessage($message, $action, $controller = NULL, $extension = NULL, array $arguments = NULL) { * @param string $action Name of the action
$this->flashMessageContainer->add($message); * @param string $controller Unqualified object name of the controller
$this->clearPageCache($GLOBALS['TSFE']->id); * @param string $extension Name of the extension containing the controller
$this->forward($action, $controller, $extension, $arguments); * @param array $arguments Arguments to pass to the target action
} * @return void
*/
protected function forwardWithMessage($message, $action, $controller = NULL, $extension = NULL, array $arguments = NULL)
/** {
* Send flash message and redirect to given action $this->flashMessageContainer->add($message);
* $this->clearPageCache($GLOBALS['TSFE']->id);
* @param string $message Identifier of the message to send $this->forward($action, $controller, $extension, $arguments);
* @param string $action Name of the action }
* @param string $controller Unqualified object name of the controller
* @param string $extension Name of the extension containing the controller
* @param array $arguments Arguments to pass to the target action /**
* @return void * Send flash message and redirect to given action
*/ *
protected function redirectWithError($message, $action, $controller = NULL, $extension = NULL, array $arguments = NULL) { * @param string $message Identifier of the message to send
$this->flashMessageContainer->add($message, '', t3lib_FlashMessage::ERROR); * @param string $action Name of the action
$this->clearPageCache($GLOBALS['TSFE']->id); * @param string $controller Unqualified object name of the controller
$this->redirect($action, $controller, $extension, $arguments); * @param string $extension Name of the extension containing the controller
} * @param array $arguments Arguments to pass to the target action
* @return void
*/
/** protected function redirectWithError($message, $action, $controller = NULL, $extension = NULL, array $arguments = NULL)
* Send flash message and forward to given action {
* $this->flashMessageContainer->add($message, '', t3lib_FlashMessage::ERROR);
* @param string $message Identifier of the message to send $this->clearPageCache($GLOBALS['TSFE']->id);
* @param string $action Name of the action $this->redirect($action, $controller, $extension, $arguments);
* @param string $controller Unqualified object name of the controller }
* @param string $extension Name of the extension containing the controller
* @param array $arguments Arguments to pass to the target action
* @return void /**
*/ * Send flash message and forward to given action
protected function forwardWithError($message, $action, $controller = NULL, $extension = NULL, array $arguments = NULL) { *
$this->flashMessageContainer->add($message, '', t3lib_FlashMessage::ERROR); * @param string $message Identifier of the message to send
$this->clearPageCache($GLOBALS['TSFE']->id); * @param string $action Name of the action
$this->forward($action, $controller, $extension, $arguments); * @param string $controller Unqualified object name of the controller
} * @param string $extension Name of the extension containing the controller
* @param array $arguments Arguments to pass to the target action
* @return void
/** */