Commit a5c34a9b authored by speedprogs_de's avatar speedprogs_de

rewrite step 1: cleaned extension structure and optimized extension providers

git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/terfe/branches/ter_fe2@51487 735d13b6-9817-0410-8766-e36946ffe9aa
parent 4b437fcf
......@@ -53,6 +53,12 @@
*/
protected $forgeLink;
/**
* Owner username
* @var string
*/
protected $username;
/**
* versions
* @var Tx_Extbase_Persistence_ObjectStorage<Tx_TerFe2_Domain_Model_Version>
......@@ -153,6 +159,27 @@
}
/**
* Setter for username
*
* @param string $username Owner username
* @return void
*/
public function setUsername($username) {
$this->username = $username;
}
/**
* Getter for username
*
* @return string Owner username
*/
public function getUsername() {
return $this->username;
}
/**
* Getter for versions
*
......
<?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!
******************************************************************/
/**
* Extension manager cache entry
*/
class Tx_TerFe2_Domain_Model_ExtensionManagerCacheEntry extends Tx_Extbase_DomainObject_AbstractEntity {
// No attributes, getters and setters. Only required to get RAW result from respository
}
?>
\ No newline at end of file
......@@ -179,6 +179,12 @@
*/
protected $cglComplianceNote;
/**
* Review state
* @var integer
*/
protected $reviewState;
/**
* Relation to manual object of ter_doc extension
* @var string
......@@ -740,6 +746,27 @@
}
/**
* Setter for reviewState
*
* @param string $reviewState Review state
* @return void
*/
public function setReviewState($reviewState) {
$this->reviewState = $reviewState;
}
/**
* Getter for reviewState
*
* @return string Review state
*/
public function getReviewState() {
return $this->reviewState;
}
/**
* Setter for manual
*
......
......@@ -30,7 +30,7 @@
/**
* Returns random objects from db
*
*
* @param integer $limit Limit of the results
* @return Tx_Extbase_Persistence_QueryResult Query result
*/
......
<?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!
******************************************************************/
/**
* Repository for Tx_TerFe2_Domain_Model_ExtensionManagerCacheEntry
*/
class Tx_TerFe2_Domain_Repository_ExtensionManagerCacheEntryRepository extends Tx_TerFe2_Domain_Repository_AbstractRepository {
/**
* Get all updated extensions
*
* @param integer $lastUpdateDate Date of the last update
* @param integer $offset Offset to start with
* @param integer $count Extension count to load
* @return Tx_Extbase_Persistence_QueryResult Query result
*/
public function findLastUpdated($lastUpdateDate, $offset = 0, $count = 0) {
$query = $this->createQuery();
$query->getQuerySettings()->setRespectStoragePage(FALSE);
$query->getQuerySettings()->setRespectSysLanguage(FALSE);
$query->getQuerySettings()->setReturnRawQueryResult(TRUE);
$query->matching($query->greaterThan('lastuploaddate', (int) $lastUpdateDate));
if (!empty($offset)) {
$query->setOffset((int) $offset);
}
if (!empty($count)) {
$query->setLimit((int) $count);
}
return $query->execute();
}
}
?>
\ No newline at end of file
......@@ -60,7 +60,7 @@
/**
* Returns top rated extensions
*
*
* @param integer $topRatedCount Count of extensions
* @param boolean $rawResult Return raw data
* @return array An array of extensions
......@@ -110,7 +110,7 @@
/**
* Returns all extensions by an author
*
*
* @param Tx_TerFe2_Domain_Model_Author $author The Author to search for
* @return array An array of extensions
*/
......
<?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!
******************************************************************/
/**
* Abstract extension provider
*/
abstract class Tx_TerFe2_ExtensionProvider_AbstractProvider implements Tx_TerFe2_ExtensionProvider_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/pics/';
/**
* Get or create absolute path to image cache directory
*
* @return void
*/
public function __construct() {
$this->imageCachePath = Tx_TerFe2_Utility_Files::getAbsoluteDirectory($this->imageCachePath);
}
/*
* @param Tx_Extbase_Object_ObjectManagerInterface $objectManager
* @return void
*/
public function injectObjectManager(Tx_Extbase_Object_ObjectManagerInterface $objectManager) {
$this->objectManager = $objectManager;
}
/**
* @param Tx_Extbase_Persistence_Mapper_DataMapFactory $dataMapFactory
* @return void
*/
public function injectDataMapFactory(Tx_Extbase_Persistence_Mapper_DataMapFactory $dataMapFactory) {
$this->dataMapFactory = $dataMapFactory;
}
/**
* @param Tx_Extbase_Reflection_Service $reflectionService
* @return void
*/
public function injectReflectionService(Tx_Extbase_Reflection_Service $reflectionService) {
$this->reflectionService = $reflectionService;
}
/**
* 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);
// Check local cache first
if (Tx_TerFe2_Utility_Files::fileExists($this->imageCachePath . $filename)) {
return t3lib_div::locationHeaderUrl($this->imageCachePath . $filename);
}
// Get icon from concrete extension provider
$iconUrl = $this->getFileUrl($filename);
// Copy icon to local cache
Tx_TerFe2_Utility_Files::copyFile($iconUrl, $this->imageCachePath . $filename);
return $iconUrl;
}
/**
* 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
*
* 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_ExtensionProvider_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);
}
?>
\ 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!
******************************************************************/
/**
* Manager for extension providers
*/
class Tx_TerFe2_ExtensionProvider_ProviderManager implements t3lib_Singleton {
/**
* @var Tx_Extbase_Object_ObjectManagerInterface
*/
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;
}
/**
* Get an instance of a concrete extension provider
*
* @param string $name Name of the provider
* @return Tx_TerFe2_ExtensionProvider_ExtensionProviderInterface Extension provider
*/
public function getProvider($name) {
$name = strtolower(trim($name));
if (!empty($this->providers[$name])) {
return $this->providers[$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 . '"');
}
$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 . '"');
}
$provider = $this->objectManager->get($configuration['class']);
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
<?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!
******************************************************************/
/**
* Abstract persistence handler
*/
abstract class Tx_TerFe2_Persistence_AbstractPersistence implements Tx_TerFe2_Persistence_PersistenceInterface {
/**
* @var string
*/
protected $name = 'Tx_TerFe2';
/**
* @var array
*/
protected $content = array();
/**
* @var boolean
*/
protected $isLoaded = FALSE;
/**
* @var boolean
*/
protected $saveImmediately = TRUE;
/**
* Set name
*
* @param string $name Name to set
* @return void
*/
public function setName($name) {
$this->name = $name;
}
/**
* Set saveImmediately
*
* @param boolean $saveImmediately Save immediately
* @return void
*/
public function setSaveImmediately($saveImmediately) {
$this->saveImmediately = (bool) $saveImmediately;