Commit e955da24 authored by flyguide's avatar flyguide

fix indentation

git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/terfe/branches/ter_fe2@64112 735d13b6-9817-0410-8766-e36946ffe9aa
parent e1587a31
<?php
/*******************************************************************
* Copyright notice
*
* (c) 2011 Kai Vogel <kai.vogel@speedprogs.de>, Speedprogs.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 2 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) 2011 Kai Vogel <kai.vogel@speedprogs.de>, Speedprogs.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 2 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!
******************************************************************/
/**
* Abstract extension provider
*/
abstract class Tx_TerFe2_Provider_AbstractProvider implements Tx_TerFe2_Provider_ProviderInterface {
/**
* Abstract extension provider
* @var Tx_Extbase_Object_ObjectManagerInterface
*/
abstract class Tx_TerFe2_Provider_AbstractProvider implements Tx_TerFe2_Provider_ProviderInterface {
/**
* @var Tx_Extbase_Object_ObjectManagerInterface
*/
protected $objectManager;
/**
* @var Tx_Extbase_Persistence_Mapper_DataMapFactory
*/
protected $dataMapFactory;
/**
* @var Tx_Extbase_Reflection_Service
*/
protected $reflectionService;
/**
* @var array Configuration array
*/
protected $configuration;
/**
* @var string
*/
protected $imageCachePath = 'typo3temp/tx_terfe2/images/';
/**
* Get or create absolute path to image cache directory
*
* @return void
*/
public function __construct() {
$this->imageCachePath = Tx_TerFe2_Utility_File::getAbsoluteDirectory($this->imageCachePath);
}
protected $objectManager;
/**
* @var Tx_Extbase_Persistence_Mapper_DataMapFactory
*/
protected $dataMapFactory;
/*
* @param Tx_Extbase_Object_ObjectManagerInterface $objectManager
* @return void
*/
public function injectObjectManager(Tx_Extbase_Object_ObjectManagerInterface $objectManager) {
$this->objectManager = $objectManager;
}
/**
* @var Tx_Extbase_Reflection_Service
*/
protected $reflectionService;
/**
* @var array Configuration array
*/
protected $configuration;
/**
* @param Tx_Extbase_Persistence_Mapper_DataMapFactory $dataMapFactory
* @return void
*/
public function injectDataMapFactory(Tx_Extbase_Persistence_Mapper_DataMapFactory $dataMapFactory) {
$this->dataMapFactory = $dataMapFactory;
}
/**
* @var string
*/
protected $imageCachePath = 'typo3temp/tx_terfe2/images/';
/**
* @param Tx_Extbase_Reflection_Service $reflectionService
* @return void
*/
public function injectReflectionService(Tx_Extbase_Reflection_Service $reflectionService) {
$this->reflectionService = $reflectionService;
}
/**
* Get or create absolute path to image cache directory
*
* @return void
*/
public function __construct() {
$this->imageCachePath = Tx_TerFe2_Utility_File::getAbsoluteDirectory($this->imageCachePath);
}
/**
* Set configuration for the DataProvider
*
* @param array $configuration TypoScript configuration
* @return void
*/
public function setConfiguration(array $configuration) {
$this->configuration = $configuration;
}
/*
* @param Tx_Extbase_Object_ObjectManagerInterface $objectManager
* @return void
*/
public function injectObjectManager(Tx_Extbase_Object_ObjectManagerInterface $objectManager) {
$this->objectManager = $objectManager;
}
/**
* Returns the url to an extension related icon
*
* @param Tx_TerFe2_Domain_Model_Version $version Version object
* @param string $fileType File type
* @return string Url to icon file
*/
public function getIconUrl(Tx_TerFe2_Domain_Model_Version $version, $fileType) {
$filename = $this->getFileName($version, $fileType);
$localName = $this->imageCachePath . basename($filename);
/**
* @param Tx_Extbase_Persistence_Mapper_DataMapFactory $dataMapFactory
* @return void
*/
public function injectDataMapFactory(Tx_Extbase_Persistence_Mapper_DataMapFactory $dataMapFactory) {
$this->dataMapFactory = $dataMapFactory;
}
// Check local cache first
if (Tx_TerFe2_Utility_File::fileExists($localName)) {
return Tx_TerFe2_Utility_File::getUrlFromAbsolutePath($localName);
}
// Get icon from concrete extension provider
$iconUrl = $this->getFileUrl($version, $fileType);
/**
* @param Tx_Extbase_Reflection_Service $reflectionService
* @return void
*/
public function injectReflectionService(Tx_Extbase_Reflection_Service $reflectionService) {
$this->reflectionService = $reflectionService;
}
// Copy icon to local cache
if (!empty($iconUrl)) {
Tx_TerFe2_Utility_File::copyFile($iconUrl, $localName);
}
/**
* Set configuration for the DataProvider
*
* @param array $configuration TypoScript configuration
* @return void
*/
public function setConfiguration(array $configuration) {
$this->configuration = $configuration;
}
/**
* Returns the url to an extension related icon
*
* @param Tx_TerFe2_Domain_Model_Version $version Version object
* @param string $fileType File type
* @return string Url to icon file
*/
public function getIconUrl(Tx_TerFe2_Domain_Model_Version $version, $fileType) {
$filename = $this->getFileName($version, $fileType);
$localName = $this->imageCachePath . basename($filename);
// Check local cache first
if (Tx_TerFe2_Utility_File::fileExists($localName)) {
return Tx_TerFe2_Utility_File::getUrlFromAbsolutePath($localName);
}
// Get icon from concrete extension provider
$iconUrl = $this->getFileUrl($version, $fileType);
/**
* Returns an array with minimum and maximum version number from range
*
* @param string $version Range of versions
* @return array Minumum and maximum version number
*/
protected function getVersionByRange($version) {
$version = Tx_Extbase_Utility_Arrays::trimExplode('-', $version);
$minimum = (!empty($version[0]) ? t3lib_div::int_from_ver($version[0]) : 0);
$maximum = (!empty($version[1]) ? t3lib_div::int_from_ver($version[1]) : 0);
return array($minimum, $maximum);
// Copy icon to local cache
if (!empty($iconUrl)) {
Tx_TerFe2_Utility_File::copyFile($iconUrl, $localName);
}
return Tx_TerFe2_Utility_File::getUrlFromAbsolutePath($localName);
}
/**
* Returns an array with minimum and maximum version number from range
*
* @param string $version Range of versions
* @return array Minumum and maximum version number
*/
protected function getVersionByRange($version) {
$version = Tx_Extbase_Utility_Arrays::trimExplode('-', $version);
$minimum = (!empty($version[0]) ? t3lib_div::int_from_ver($version[0]) : 0);
$maximum = (!empty($version[1]) ? t3lib_div::int_from_ver($version[1]) : 0);
return array($minimum, $maximum);
}
}
?>
\ No newline at end of file
<?php
/*******************************************************************
* Copyright notice
*
* (c) 2011 Kai Vogel <kai.vogel@speedprogs.de>, Speedprogs.de
/*******************************************************************
* Copyright notice
*
* (c) 2011 Kai Vogel <kai.vogel@speedprogs.de>, Speedprogs.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 2 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!
******************************************************************/
/**
* Interface for extension providers
*/
interface Tx_TerFe2_Provider_ProviderInterface extends t3lib_Singleton {
/*
* @param Tx_Extbase_Object_ObjectManagerInterface $objectManager
* @return void
*/
public function injectObjectManager(Tx_Extbase_Object_ObjectManagerInterface $objectManager);
/**
* @param Tx_Extbase_Persistence_Mapper_DataMapFactory $dataMapFactory
* @return void
*/
public function injectDataMapFactory(Tx_Extbase_Persistence_Mapper_DataMapFactory $dataMapFactory);
/**
* @param Tx_Extbase_Reflection_Service $reflectionService
* @return void
*/
public function injectReflectionService(Tx_Extbase_Reflection_Service $reflectionService);
/**
* Set configuration for the DataProvider
*
* All rights reserved
* @param array $configuration TypoScript configuration
* @return void
*/
public function setConfiguration(array $configuration);
/**
* Returns all extensions since last run
*
* 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 2 of
* the License, or (at your option) any later version.
* @param integer $lastRun Timestamp of last update
* @param integer $offset Offset to start with
* @param integer $count Extension count to load
* @return array Extension rows
*/
public function getExtensions($lastRun, $offset, $count);
/**
* Returns the url to an extension related icon
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* @param Tx_TerFe2_Domain_Model_Version $version Version object
* @param string $fileType File type
* @return string Url to icon file
*/
public function getIconUrl(Tx_TerFe2_Domain_Model_Version $version, $fileType);
/**
* Returns the url to an extension related file
*
* 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.
* @param Tx_TerFe2_Domain_Model_Version $version Version object
* @param string $fileType File type
* @return string Url to file
*/
public function getFileUrl(Tx_TerFe2_Domain_Model_Version $version, $fileType);
/**
* Returns name of an extension related file
*
* This copyright notice MUST APPEAR in all copies of the script!
******************************************************************/
* @param Tx_TerFe2_Domain_Model_Version $version Version object
* @param string $fileType File type
* @return string File name
*/
public function getFileName(Tx_TerFe2_Domain_Model_Version $version, $fileType);
/**
* Interface for extension providers
* Returns all information about an extension version
*
* @param Tx_TerFe2_Domain_Model_Version $version Version object
* @return array Version details
*/
interface Tx_TerFe2_Provider_ProviderInterface extends t3lib_Singleton {
/*
* @param Tx_Extbase_Object_ObjectManagerInterface $objectManager
* @return void
*/
public function injectObjectManager(Tx_Extbase_Object_ObjectManagerInterface $objectManager);
/**
* @param Tx_Extbase_Persistence_Mapper_DataMapFactory $dataMapFactory
* @return void
*/
public function injectDataMapFactory(Tx_Extbase_Persistence_Mapper_DataMapFactory $dataMapFactory);
/**
* @param Tx_Extbase_Reflection_Service $reflectionService
* @return void
*/
public function injectReflectionService(Tx_Extbase_Reflection_Service $reflectionService);
/**
* Set configuration for the DataProvider
*
* @param array $configuration TypoScript configuration
* @return void
*/
public function setConfiguration(array $configuration);
/**
* Returns all extensions since last run
*
* @param integer $lastRun Timestamp of last update
* @param integer $offset Offset to start with
* @param integer $count Extension count to load
* @return array Extension rows
*/
public function getExtensions($lastRun, $offset, $count);
/**
* Returns the url to an extension related icon
*
* @param Tx_TerFe2_Domain_Model_Version $version Version object
* @param string $fileType File type
* @return string Url to icon file
*/
public function getIconUrl(Tx_TerFe2_Domain_Model_Version $version, $fileType);
/**
* Returns the url to an extension related file
*
* @param Tx_TerFe2_Domain_Model_Version $version Version object
* @param string $fileType File type
* @return string Url to file
*/
public function getFileUrl(Tx_TerFe2_Domain_Model_Version $version, $fileType);
/**
* Returns name of an extension related file
*
* @param Tx_TerFe2_Domain_Model_Version $version Version object
* @param string $fileType File type
* @return string File name
*/
public function getFileName(Tx_TerFe2_Domain_Model_Version $version, $fileType);
/**
* Returns all information about an extension version
*
* @param Tx_TerFe2_Domain_Model_Version $version Version object
* @return array Version details
*/
public function getVersionDetails(Tx_TerFe2_Domain_Model_Version $version);
}
public function getVersionDetails(Tx_TerFe2_Domain_Model_Version $version);
}
?>
\ No newline at end of file
<?php
/*******************************************************************
* Copyright notice
*
* (c) 2011 Kai Vogel <kai.vogel@speedprogs.de>, Speedprogs.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 2 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) 2011 Kai Vogel <kai.vogel@speedprogs.de>, Speedprogs.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 2 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!
******************************************************************/
/**
* Manager for extension providers
*/
class Tx_TerFe2_Provider_ProviderManager implements t3lib_Singleton {
/**
* Manager for extension providers
* @var Tx_Extbase_Object_ObjectManagerInterface
*/
class Tx_TerFe2_Provider_ProviderManager implements t3lib_Singleton {
/**
* @var Tx_Extbase_Object_ObjectManagerInterface
*/
protected $objectManager;
/**
* @var array
*/
protected $providers;
protected $objectManager;
/**
* @var array
*/
protected $providers;
/*
* @param Tx_Extbase_Object_ObjectManagerInterface $objectManager
* @return void
*/
public function injectObjectManager(Tx_Extbase_Object_ObjectManagerInterface $objectManager) {
$this->objectManager = $objectManager;
}
/*
* @param Tx_Extbase_Object_ObjectManagerInterface $objectManager
* @return void
*/
public function injectObjectManager(Tx_Extbase_Object_ObjectManagerInterface $objectManager) {
$this->objectManager = $objectManager;
}
/**
* Get an instance of a concrete extension provider
*
* @param string $name Name of the provider
* @return Tx_TerFe2_Provider_ProviderInterface Extension provider
*/
public function getProvider($name) {
if (empty($name)) {
throw new Exception('No empty name allowed for an extension provider');
}
$name = strtolower(trim($name));
/**
* Get an instance of a concrete extension provider
*
* @param string $name Name of the provider
* @return Tx_TerFe2_Provider_ProviderInterface Extension provider
*/
public function getProvider($name) {
if (empty($name)) {
throw new Exception('No empty name allowed for an extension provider');
}
if (!empty($this->providers[$name])) {
return $this->providers[$name];
}
$name = strtolower(trim($name));
if (empty($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ter_fe2']['extensionProviders'][$name])) {
throw new Exception('No configuration found for an extension provider with name "' . $name . '"');
}
if (!empty($this->providers[$name])) {
return $this->providers[$name];
}
$configuration = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ter_fe2']['extensionProviders'][$name];
if (empty($configuration['class'])) {
throw new Exception('No class name found in configuration for the extension provider with name "' . $name . '"');
}
if (empty($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ter_fe2']['extensionProviders'][$name])) {
throw new Exception('No configuration found for an extension provider with name "' . $name . '"');
}
$provider = $this->objectManager->get($configuration['class']);
if (!($provider instanceof Tx_TerFe2_Provider_ProviderInterface)) {
throw new Exception('Provider "' . $name . '" does not implement the interface "Tx_TerFe2_Provider_ProviderInterface"');
}
if (!empty($configuration['configuration']) && method_exists($provider, 'setConfiguration')) {
$provider->setConfiguration($configuration['configuration']);
}
if (method_exists($provider, 'initializeProvider')) {
$provider->initializeProvider();
}
$configuration = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ter_fe2']['extensionProviders'][$name];
if (empty($configuration['class'])) {
throw new Exception('No class name found in configuration for the extension provider with name "' . $name . '"');
}
return $this->providers[$name] = $provider;
$provider = $this->objectManager->get($configuration['class']);
if (!($provider instanceof Tx_TerFe2_Provider_ProviderInterface)) {
throw new Exception('Provider "' . $name . '" does not implement the interface "Tx_TerFe2_Provider_ProviderInterface"');
}
if (!empty($configuration['configuration']) && method_exists($provider, 'setConfiguration')) {
$provider->setConfiguration($configuration['configuration']);
}
if (method_exists($provider, 'initializeProvider')) {
$provider->initializeProvider();
}
return $this->providers[$name] = $provider;
}
}
?>
\ No newline at end of file
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