2 /***************************************************************
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
29 * Utility for dealing with extension list related functions
31 * @author Susanne Moog <typo3@susannemoog.de>
32 * @package Extension Manager
35 class Tx_Extensionmanager_Utility_List
implements t3lib_Singleton
{
38 * @var Tx_Extbase_Object_ObjectManager
40 public $objectManager;
43 * @param Tx_Extbase_Object_ObjectManagerInterface $objectManager
46 public function injectObjectManager(Tx_Extbase_Object_ObjectManagerInterface
$objectManager) {
47 $this->objectManager
= $objectManager;
51 * @var Tx_Extensionmanager_Utility_EmConf
53 public $emConfUtility;
56 * Inject emConfUtility
58 * @param Tx_Extensionmanager_Utility_EmConf $emConfUtility
61 public function injectEmConfUtility(Tx_Extensionmanager_Utility_EmConf
$emConfUtility) {
62 $this->emConfUtility
= $emConfUtility;
66 * @var Tx_Extensionmanager_Domain_Repository_ExtensionRepository
68 public $extensionRepository;
71 * @var Tx_Extensionmanager_Utility_Install
73 protected $installUtility;
76 * @param Tx_Extensionmanager_Utility_Install $installUtility
79 public function injectInstallUtility(Tx_Extensionmanager_Utility_Install
$installUtility) {
80 $this->installUtility
= $installUtility;
84 * Inject emConfUtility
86 * @param Tx_Extensionmanager_Domain_Repository_ExtensionRepository $extensionRepository
89 public function injectExtensionRepository(Tx_Extensionmanager_Domain_Repository_ExtensionRepository
$extensionRepository) {
90 $this->extensionRepository
= $extensionRepository;
93 * Returns the list of available (installed) extensions
95 * @return array Array with two sub-arrays, list array (all extensions with info) and category index
96 * @see getInstExtList()
98 public function getAvailableExtensions() {
99 $extensions = array();
100 $paths = Tx_Extensionmanager_Domain_Model_Extension
::returnInstallPaths();
101 foreach ($paths as $installationType => $path) {
104 $extList = t3lib_div
::get_dirs($path);
105 if (is_array($extList)) {
106 foreach ($extList as $extKey) {
107 $extensions[$extKey] = array(
108 'siteRelPath' => str_replace(PATH_site
, '', $path . $extKey),
109 'type' => $installationType,
111 'ext_icon' => t3lib_extMgm
::getExtensionIcon( $path . $extKey . '/'),
116 } catch (Exception
$e) {
117 t3lib_div
::sysLog($e->getMessage(), 'extensionmanager');
124 * Reduce the available extensions list to only loaded extensions
126 * @param array $availableExtensions
129 public function getAvailableAndInstalledExtensions(array $availableExtensions) {
130 foreach ($GLOBALS['TYPO3_LOADED_EXT'] as $extKey => $properties) {
131 if (array_key_exists($extKey, $availableExtensions)) {
132 $availableExtensions[$extKey]['installed'] = TRUE;
135 return $availableExtensions;
139 * Adds the information from the emconf array to the extension information
141 * @param array $extensions
144 public function enrichExtensionsWithEmConfAndTerInformation(array $extensions) {
145 foreach ($extensions as $extensionKey => $properties) {
146 $emconf = $this->emConfUtility
->includeEmConf($properties);
148 $extensions[$extensionKey] = array_merge($emconf, $properties);
149 $terObject = $this->extensionRepository
->findOneByExtensionKeyAndVersion(
151 $extensions[$extensionKey]['version']
153 if ($terObject instanceof Tx_Extensionmanager_Domain_Model_Extension
) {
154 $extensions[$extensionKey]['terObject'] = $terObject;
155 $extensions[$extensionKey]['updateAvailable'] = $this->installUtility
->isUpdateAvailable($terObject);
159 unset($extensions[$extensionKey]);
166 * Gets all available and installed extension with additional information
167 * from em_conf and TER (if available)
171 public function getAvailableAndInstalledExtensionsWithAdditionalInformation() {
172 $availableExtensions = $this->getAvailableExtensions();
173 $availableAndInstalledExtensions = $this->getAvailableAndInstalledExtensions($availableExtensions);
174 return $this->enrichExtensionsWithEmConfAndTerInformation($availableAndInstalledExtensions);