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
/*******************************************************************
/*******************************************************************
* Copyright notice
*
* (c) 2011 Kai Vogel <kai.vogel@speedprogs.de>, Speedprogs.de
......@@ -23,10 +23,11 @@
* This copyright notice MUST APPEAR in all copies of the script!
******************************************************************/
/**
/**
* Cache for extension files
*/
class Tx_TerFe2_Cache_FileCache implements t3lib_Singleton {
class Tx_TerFe2_Cache_FileCache implements t3lib_Singleton
{
/**
* @var string
......@@ -40,7 +41,8 @@
* @param string $cacheDirectory Path to cache directory
* @return void
*/
public function setCacheDirectory($cacheDirectory) {
public function setCacheDirectory($cacheDirectory)
{
if (empty($cacheDirectory)) {
throw new Exception('An empty cache directory is not allowed');
}
......@@ -53,7 +55,8 @@
*
* @return string Path of the cache directory
*/
public function getCacheDirectory() {
public function getCacheDirectory()
{
return $this->cacheDirectory;
}
......@@ -64,7 +67,8 @@
* @param string $filename Name of the file
* @return string Local filename
*/
public function getFile($filename) {
public function getFile($filename)
{
$filename = $this->getFilePath($filename);
if (Tx_TerFe2_Utility_File::fileExists($filename)) {
return $filename;
......@@ -80,7 +84,8 @@
* @param string $filename Name of the file
* @return string Local filename
*/
public function getExtensionFile($extensionKey, $filename) {
public function getExtensionFile($extensionKey, $filename)
{
$filename = $this->getExtensionFilename($extensionKey, $filename);
return $this->getFile($filename);
}
......@@ -93,7 +98,8 @@
* @param string $filename Name of the file
* @return string Local filename
*/
public function addFile($fileUrl, $filename) {
public function addFile($fileUrl, $filename)
{
if (empty($fileUrl)) {
return '';
}
......@@ -113,7 +119,8 @@
* @param string $filename Name of the file
* @return string Local filename
*/
public function addExtensionFile($extensionKey, $fileUrl, $filename) {
public function addExtensionFile($extensionKey, $fileUrl, $filename)
{
$filename = $this->getExtensionFilename($extensionKey, $filename);
return $this->addFile($fileUrl, $filename);
}
......@@ -125,7 +132,8 @@
* @param string $filename Name of the file
* @return boolean TRUE if success
*/
public function removeFile($filename) {
public function removeFile($filename)
{
$filename = $this->getFilePath($filename);
if (!Tx_TerFe2_Utility_File::fileExists($fileUrl)) {
return FALSE;
......@@ -141,7 +149,8 @@
* @param string $filename Name of the file
* @return string Local filename
*/
public function removeExtensionFile($extensionKey, $filename) {
public function removeExtensionFile($extensionKey, $filename)
{
$filename = $this->getExtensionFilename($extensionKey, $filename);
return $this->removeFile($filename);
}
......@@ -153,7 +162,8 @@
* @param string $filename Name of the file
* @return string Absolute path to file
*/
protected function getFilePath($filename) {
protected function getFilePath($filename)
{
if (empty($filename)) {
return '';
}
......@@ -172,12 +182,14 @@
* @param string $filename Name of the file
* @return string Extension filename
*/
protected function getExtensionFilename($extensionKey, $filename) {
protected function getExtensionFilename($extensionKey, $filename)
{
if (empty($extensionKey) || empty($filename)) {
return '';
}
return strtolower($extensionKey) . '/' . basename($filename);
}
}
}
?>
\ No newline at end of file
<?php
/*******************************************************************
/*******************************************************************
* Copyright notice
*
* (c) 2011 Kai Vogel <kai.vogel@speedprogs.de>, Speedprogs.de
......@@ -23,10 +23,11 @@
* This copyright notice MUST APPEAR in all copies of the script!
******************************************************************/
/**
/**
* 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
......@@ -36,7 +37,8 @@
/**
* @param Tx_TerFe2_Security_Role $securityRole
*/
public function injectSecurityRole(Tx_TerFe2_Security_Role $securityRole) {
public function injectSecurityRole(Tx_TerFe2_Security_Role $securityRole)
{
$this->securityRole = $securityRole;
}
......@@ -45,7 +47,8 @@
*
* @return void
*/
public function initializeAction() {
public function initializeAction()
{
// Pre-parse settings
$this->settings = Tx_TerFe2_Utility_TypoScript::parse($this->settings);
......@@ -59,7 +62,8 @@
*
* @return void
*/
protected function initializeController() {
protected function initializeController()
{
}
......@@ -71,7 +75,8 @@
* @param array $arguments Optional arguments array
* @return string Translated label
*/
protected function translate($label, array $arguments = array()) {
protected function translate($label, array $arguments = array())
{
$extensionKey = $this->request->getControllerExtensionKey();
return Tx_Extbase_Utility_Localization::translate($label, $extensionKey, $arguments);
}
......@@ -90,7 +95,8 @@
* @return void
*/
protected function redirectWithMessage($message, $action, $title = '', $severity = t3lib_FlashMessage::OK,
$controller = NULL, $extension = NULL, array $arguments = NULL) {
$controller = NULL, $extension = NULL, array $arguments = NULL)
{
$this->flashMessageContainer->add($message, $title, $severity);
$this->clearPageCache($GLOBALS['TSFE']->id);
$this->redirect($action, $controller, $extension, $arguments);
......@@ -107,7 +113,8 @@
* @param array $arguments Arguments to pass to the target action
* @return void
*/
protected function forwardWithMessage($message, $action, $controller = NULL, $extension = NULL, array $arguments = NULL) {
protected function forwardWithMessage($message, $action, $controller = NULL, $extension = NULL, array $arguments = NULL)
{
$this->flashMessageContainer->add($message);
$this->clearPageCache($GLOBALS['TSFE']->id);
$this->forward($action, $controller, $extension, $arguments);
......@@ -124,7 +131,8 @@
* @param array $arguments Arguments to pass to the target action
* @return void
*/
protected function redirectWithError($message, $action, $controller = NULL, $extension = NULL, array $arguments = NULL) {
protected function redirectWithError($message, $action, $controller = NULL, $extension = NULL, array $arguments = NULL)
{
$this->flashMessageContainer->add($message, '', t3lib_FlashMessage::ERROR);
$this->clearPageCache($GLOBALS['TSFE']->id);
$this->redirect($action, $controller, $extension, $arguments);
......@@ -141,7 +149,8 @@
* @param array $arguments Arguments to pass to the target action
* @return void
*/
protected function forwardWithError($message, $action, $controller = NULL, $extension = NULL, array $arguments = NULL) {
protected function forwardWithError($message, $action, $controller = NULL, $extension = NULL, array $arguments = NULL)
{
$this->flashMessageContainer->add($message, '', t3lib_FlashMessage::ERROR);
$this->clearPageCache($GLOBALS['TSFE']->id);
$this->forward($action, $controller, $extension, $arguments);
......@@ -154,7 +163,8 @@
* @param string $pages List of page ids
* @return void
*/
protected function clearPageCache($pages) {
protected function clearPageCache($pages)
{
if (!empty($pages)) {
$pages = t3lib_div::intExplode(',', $pages, TRUE);
Tx_Extbase_Utility_Cache::clearPageCache($pages);
......@@ -170,9 +180,11 @@
* @param string $uri The URI
* @return void
*/
protected function addBaseUriIfNecessary($uri) {
protected function addBaseUriIfNecessary($uri)
{
return t3lib_div::locationHeaderUrl($uri);
}
}
}
?>
\ No newline at end of file
<?php
/*******************************************************************
/*******************************************************************
* Copyright notice
*
* (c) 2011 Kai Vogel <kai.vogel@speedprogs.de>, Speedprogs.de
......@@ -23,10 +23,11 @@
* This copyright notice MUST APPEAR in all copies of the script!
******************************************************************/
/**
/**
* Abstract controller
*/
abstract class Tx_TerFe2_Controller_AbstractTerBasedController extends Tx_TerFe2_Controller_AbstractController {
abstract class Tx_TerFe2_Controller_AbstractTerBasedController extends Tx_TerFe2_Controller_AbstractController
{
/**
* @var array
......@@ -54,7 +55,8 @@
*
* @return void
*/
public function initializeAction() {
public function initializeAction()
{
parent::initializeAction();
$this->frontendUser = (!empty($GLOBALS['TSFE']->fe_user->user) ? $GLOBALS['TSFE']->fe_user->user : array());
$this->terSettings = (!empty($this->settings['terConnection']) ? $this->settings['terConnection'] : array());
......@@ -68,7 +70,8 @@
*
* @return void
*/
public function initializeView() {
public function initializeView()
{
$this->view->assign('loggedIn', FALSE);
if (!empty($this->frontendUser)) {
$this->view->assign('loggedIn', TRUE);
......@@ -83,7 +86,8 @@
*
* @return array Frontend user account data
*/
protected function getTerAccount() {
protected function getTerAccount()
{
$username = $this->frontendUser['username'];
$password = $this->frontendUser['password'];
if (!empty($this->terSettings['username']) && !empty($this->terSettings['password'])) {
......@@ -102,7 +106,8 @@
*
* @return Tx_TerFe2_Service_Ter The TER connection
*/
protected function getTerConnection() {
protected function getTerConnection()
{
// Check the wsdl uri
if (empty($this->terSettings['wsdl'])) {
throw new Exception('No wsdl set to connect to TER server');
......@@ -113,5 +118,6 @@
return $this->objectManager->get('Tx_TerFe2_Service_Ter', $wsdl, $this->terAccount['username'], $this->terAccount['password']);
}
}
}
?>
\ No newline at end of file
<?php
/*******************************************************************
/*******************************************************************
* Copyright notice
*
* (c) 2011 Kai Vogel <kai.vogel@speedprogs.de>, Speedprogs.de
......@@ -23,10 +23,11 @@
* This copyright notice MUST APPEAR in all copies of the script!
******************************************************************/
/**
/**
* Controller for the author object
*/
class Tx_TerFe2_Controller_AuthorController extends Tx_TerFe2_Controller_AbstractController {
class Tx_TerFe2_Controller_AuthorController extends Tx_TerFe2_Controller_AbstractController
{
/**
* @var Tx_TerFe2_Domain_Repository_AuthorRepository
......@@ -44,7 +45,8 @@
*
* @return void
*/
protected function initializeController() {
protected function initializeController()
{
$this->authorRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_AuthorRepository');
$this->extensionRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_ExtensionRepository');
}
......@@ -55,7 +57,8 @@
*
* @return void
*/
public function listAction() {
public function listAction()
{
$this->view->assign('authors', $this->authorRepository->findAll());
}
......@@ -66,7 +69,8 @@
* @param Tx_TerFe2_Domain_Model_Author $author The author to display
* @return void
*/
public function showAction(Tx_TerFe2_Domain_Model_Author $author) {
public function showAction(Tx_TerFe2_Domain_Model_Author $author)
{
$this->view->assign('author', $author);
$authorExtensions = $this->extensionRepository->findByAuthor($author);
$this->view->assign('authorExtensions', $authorExtensions);
......@@ -80,7 +84,8 @@
* @return void
* @dontvalidate $author
*/
public function editAction(Tx_TerFe2_Domain_Model_Author $author) {
public function editAction(Tx_TerFe2_Domain_Model_Author $author)
{
$this->view->assign('author', $author);
}
......@@ -91,10 +96,12 @@
* @param Tx_TerFe2_Domain_Model_Author $author Author to update
* @return void
*/
public function updateAction(Tx_TerFe2_Domain_Model_Author $author) {
public function updateAction(Tx_TerFe2_Domain_Model_Author $author)
{
$this->authorRepository->update($author);
$this->redirectWithMessage($this->translate('msg.author_updated'), 'list');
}
}
}
?>
\ No newline at end of file
<?php
/*******************************************************************
/*******************************************************************
* Copyright notice
*
* (c) 2011 Kai Vogel <kai.vogel@speedprogs.de>, Speedprogs.de
......@@ -23,10 +23,11 @@
* This copyright notice MUST APPEAR in all copies of the script!
******************************************************************/
/**
/**
* Controller for the category object
*/
class Tx_TerFe2_Controller_CategoryController extends Tx_TerFe2_Controller_AbstractController {
class Tx_TerFe2_Controller_CategoryController extends Tx_TerFe2_Controller_AbstractController
{
/**
* @var Tx_TerFe2_Domain_Repository_CategoryRepository
......@@ -44,7 +45,8 @@
*
* @return void
*/
protected function initializeController() {
protected function initializeController()
{
$this->categoryRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_CategoryRepository');
$this->extensionRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_ExtensionRepository');
}
......@@ -55,7 +57,8 @@
*
* @return void
*/
public function listAction() {
public function listAction()
{
$this->view->assign('categories', $this->categoryRepository->findAll());
}
......@@ -66,7 +69,8 @@
* @param Tx_TerFe2_Domain_Model_Category $category The category to display
* @return void
*/
public function showAction(Tx_TerFe2_Domain_Model_Category $category) {
public function showAction(Tx_TerFe2_Domain_Model_Category $category)
{
$this->view->assign('category', $category);
$categoryExtensions = $this->extensionRepository->findByCategory($category);
$this->view->assign('categoryExtensions', $categoryExtensions);
......@@ -80,7 +84,8 @@
* @return void
* @dontvalidate $newCategory
*/
public function newAction(Tx_TerFe2_Domain_Model_Category $newCategory = NULL) {
public function newAction(Tx_TerFe2_Domain_Model_Category $newCategory = NULL)
{
$this->view->assign('newCategory', $newCategory);
}
......@@ -91,7 +96,8 @@
* @param Tx_TerFe2_Domain_Model_Category $newCategory New category object
* @return void
*/
public function createAction(Tx_TerFe2_Domain_Model_Category $newCategory) {
public function createAction(Tx_TerFe2_Domain_Model_Category $newCategory)
{
$this->categoryRepository->add($newCategory);
$this->redirectWithMessage($this->translate('msg.category_created'), 'list');
}
......@@ -104,7 +110,8 @@
* @return void
* @dontvalidate $category
*/
public function editAction(Tx_TerFe2_Domain_Model_Category $category) {
public function editAction(Tx_TerFe2_Domain_Model_Category $category)
{
$this->view->assign('category', $category);
}
......@@ -115,7 +122,8 @@
* @param Tx_TerFe2_Domain_Model_Category $category Category to update
* @return void
*/
public function updateAction(Tx_TerFe2_Domain_Model_Category $category) {
public function updateAction(Tx_TerFe2_Domain_Model_Category $category)
{
$this->categoryRepository->update($category);
$this->redirectWithMessage($this->translate('msg.category_updated'), 'list');
}
......@@ -127,10 +135,12 @@
* @param Tx_TerFe2_Domain_Model_Category $category The category to delete
* @return void
*/
public function deleteAction(Tx_TerFe2_Domain_Model_Category $category) {
public function deleteAction(Tx_TerFe2_Domain_Model_Category $category)
{
$this->categoryRepository->remove($category);
$this->redirectWithMessage($this->translate('msg.category_deleted'), 'list');
}
}
}
?>
\ No newline at end of file
<?php
/*******************************************************************
/*******************************************************************
* Copyright notice
*
* (c) 2011 Kai Vogel <kai.vogel@speedprogs.de>, Speedprogs.de
......@@ -23,10 +23,11 @@
* This copyright notice MUST APPEAR in all copies of the script!
******************************************************************/
/**
/**
* Controller for the extension object
*/
class Tx_TerFe2_Controller_ExtensionController extends Tx_TerFe2_Controller_AbstractController {
class Tx_TerFe2_Controller_ExtensionController extends Tx_TerFe2_Controller_AbstractController
{
/**
* @var Tx_TerFe2_Domain_Repository_ExtensionRepository
......@@ -83,7 +84,8 @@
*
* @return void
*/
protected function initializeController() {
protected function initializeController()
{
$this->extensionRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_ExtensionRepository');
$this->categoryRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_CategoryRepository');
$this->tagRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_TagRepository');
......@@ -107,7 +109,8 @@
* @return void
* @dontvalidate $search
*/
public function indexAction() {
public function indexAction()
{
$this->searchAction();
}
......@@ -120,7 +123,8 @@
* @return void
* @dontvalidate $search
*/
public function searchAction(array $search = array(), $restoreSearch = FALSE) {
public function searchAction(array $search = array(), $restoreSearch = FALSE)
{
// Get extension list
if (!empty($this->settings['show']['extensionSearch'])) {
$this->view->assign('extensions', $this->getExtensions($search, $restoreSearch));
......@@ -156,7 +160,8 @@
*
* @return void
*/
public function listAction() {
public function listAction()
{
$this->view->assign('extensions', $this->extensionRepository->findAll());
}
......@@ -168,10 +173,11 @@
*
* @return void
*/
public function listLatestAction() {
public function listLatestAction()
{
$latestCount = (!empty($this->settings['latestCount']) ? $this->settings['latestCount'] : 20);
$extensions = $this->extensionRepository->findLatest($latestCount);
if($extensions->count() > 0) {
if ($extensions->count() > 0) {
$this->updateSysLastChanged($extensions[0]->getLastVersion()->getUploadDate());
}
$this->view->assign('extensions', $extensions);
......@@ -187,7 +193,8 @@
* @dontvalidate $extension
* @dontvalidate $extensionKey
*/
public function showAction(Tx_TerFe2_Domain_Model_Extension $extension = NULL, $extensionKey = NULL) {
public function showAction(Tx_TerFe2_Domain_Model_Extension $extension = NULL, $extensionKey = NULL)
{
if (!empty($extensionKey)) {
if (!is_string($extensionKey)) {
throw new Exception('No valid extension key given');
......@@ -283,7 +290,8 @@
* @return void
* @dontvalidate $newExtension
*/
public function newAction(Tx_TerFe2_Domain_Model_Extension $newExtension = NULL) {
public function newAction(Tx_TerFe2_Domain_Model_Extension $newExtension = NULL)
{
$this->view->assign('newExtension', $newExtension);
$this->view->assign('categories', $this->categoryRepository->findAll());
$this->view->assign('tags', $this->tagRepository->findAll());
......@@ -296,7 +304,8 @@
* @param Tx_TerFe2_Domain_Model_Extension $newExtension New extension object
* @return void
*/
public function createAction(Tx_TerFe2_Domain_Model_Extension $newExtension) {
public function createAction(Tx_TerFe2_Domain_Model_Extension $newExtension)
{
$this->extensionRepository->add($newExtension);
$this->redirectWithMessage($this->translate('msg.extension_created'), 'index');
}
......@@ -309,10 +318,12 @@
* @dontvalidate $extension
* @return void
*/
public function editAction(Tx_TerFe2_Domain_Model_Extension $extension) {
public function editAction(Tx_TerFe2_Domain_Model_Extension $extension)
{
$extensionOwner = $this->ownerRepository->findByUid($GLOBALS['TSFE']->fe_user->user['uid']);
if ($this->securityRole->isAdmin()
|| $extension->getFrontendUser() == $extensionOwner->getUsername()) {
|| $extension->getFrontendUser() == $extensionOwner->getUsername()
) {
$this->view->assign('isLoggedIn', 1);
$this->view->assign('extension', $extension);
}
......@@ -327,7 +338,8 @@
* @param string $save
* @return void
*/
public function updateAction(Tx_TerFe2_Domain_Model_Extension $extension, $tag = '', $save = '') {
public function updateAction(Tx_TerFe2_Domain_Model_Extension $extension, $tag = '', $save = '')
{
/** @var Tx_T3oAjaxlogin_Domain_Model_User $currentUser */
$currentUser = $this->ownerRepository->findByUid($GLOBALS['TSFE']->fe_user->user['uid']);
if ($extension->getFrontendUser() !== $currentUser->getUsername()) {
......@@ -392,7 +404,8 @@
*
* @return void
*/
public function removeTagAction(Tx_TerFe2_Domain_Model_Extension $extension, Tx_TerFe2_Domain_Model_Tag $tag) {
public function removeTagAction(Tx_TerFe2_Domain_Model_Extension $extension, Tx_TerFe2_Domain_Model_Tag $tag)
{
if ($extension->getTags()->contains($tag)) {
$extension->removeTag($tag);
}
......@@ -414,7 +427,8 @@
* @param Tx_TerFe2_Domain_Model_Extension $extension The extension to delete
* @return void
*/