2 /* **************************************************************
6 * (c) 2006-2010 Karsten Dambekalns <karsten@typo3.org>
9 * This script is part of the TYPO3 project. The TYPO3 project is
10 * free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * The GNU General Public License can be found at
16 * http://www.gnu.org/copyleft/gpl.html.
17 * A copy is found in the textfile GPL.txt and important notices to the license
18 * from the author is found in LICENSE.txt distributed with these scripts.
21 * This script is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * This copyright notice MUST APPEAR in all copies of the script!
27 ***************************************************************/
28 /* $Id: class.tx_em_extensions_list.php 2084 2010-03-22 01:46:37Z steffenk $ */
31 * This class handles extension listings
34 class tx_em_Extensions_List
{
37 protected $parentObject;
39 protected $categories;
45 * @param object $parentObject
48 public function __construct($parentObject = NULL) {
49 $this->parentObject
= $parentObject;
50 $this->install
= t3lib_div
::makeInstance('tx_em_Install', $this);
52 $this->categories
= array(
53 'be' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:category_BE'),
54 'module' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:category_BE_modules'),
55 'fe' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:category_FE'),
56 'plugin' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:category_FE_plugins'),
57 'misc' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:category_miscellanous'),
58 'services' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:category_services'),
59 'templates' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:category_templates'),
60 'example' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:category_examples'),
61 'doc' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:category_documentation')
64 'S' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:type_system'),
65 'G' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:type_global'),
66 'L' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:type_local'),
72 * Returns the list of available (installed) extensions
74 * @return array Array with two arrays, list array (all extensions with info) and category index
75 * @see getInstExtList()
77 function getInstalledExtensions($new = FALSE) {
81 $cat = $this->parentObject
->defaultCategories
;
83 $path = PATH_typo3
. 'sysext/';
84 $this->getInstExtList($path, $list, $cat, 'S');
86 $path = PATH_typo3
. 'ext/';
87 $this->getInstExtList($path, $list, $cat, 'G');
89 $path = PATH_typo3conf
. 'ext/';
90 $this->getInstExtList($path, $list, $cat, 'L');
92 return array($list, $cat);
94 $path = PATH_typo3
. 'sysext/';
95 $this->getFlatInstExtList($path, $list, 'S');
97 $path = PATH_typo3
. 'ext/';
98 $this->getFlatInstExtList($path, $list, 'G');
100 $path = PATH_typo3conf
. 'ext/';
101 $this->getFlatInstExtList($path, $list, 'L');
108 * Gathers all extensions in $path
110 * @param string Absolute path to local, global or system extensions
111 * @param array Array with information for each extension key found. Notice: passed by reference
112 * @param array Categories index: Contains extension titles grouped by various criteria.
113 * @param string Path-type: L, G or S
114 * @return void "Returns" content by reference
115 * @see getInstalledExtensions()
117 function getInstExtList($path, &$list, &$cat, $type) {
119 if (@is_dir
($path)) {
120 $extList = t3lib_div
::get_dirs($path);
121 if (is_array($extList)) {
122 foreach ($extList as $extKey) {
123 if (@is_file
($path . $extKey . '/ext_emconf.php')) {
124 $emConf = tx_em_Tools
::includeEMCONF($path . $extKey . '/ext_emconf.php', $extKey);
125 if (is_array($emConf)) {
126 if (is_array($list[$extKey])) {
127 $list[$extKey] = array('doubleInstall' => $list[$extKey]['doubleInstall']);
129 $list[$extKey]['extkey'] = $extKey;
130 $list[$extKey]['doubleInstall'] .= $type;
131 $list[$extKey]['type'] = $type;
132 $list[$extKey]['installed'] = t3lib_extMgm
::isLoaded($extKey);
133 $list[$extKey]['EM_CONF'] = $emConf;
134 $list[$extKey]['files'] = t3lib_div
::getFilesInDir($path . $extKey, '', 0, '', $this->excludeForPackaging
);
136 tx_em_Tools
::setCat($cat, $list[$extKey], $extKey);
145 * Gathers all extensions in $path
147 * @param string Absolute path to local, global or system extensions
148 * @param array Array with information for each extension key found. Notice: passed by reference
149 * @param array Categories index: Contains extension titles grouped by various criteria.
150 * @param string Path-type: L, G or S
151 * @return void "Returns" content by reference
153 * @see getInstalledExtensions()
155 function getFlatInstExtList($path, &$list, $type) {
158 if (@is_dir
($path)) {
159 $extList = t3lib_div
::get_dirs($path);
160 if (is_array($extList)) {
161 foreach ($extList as $extKey) {
162 $this->singleExtInfo($extKey, $path, $list, $type);
169 * Gets a single extension info
174 * @param string $type
177 public function singleExtInfo($extKey, $path, &$list, $type = '') {
178 if (@is_file
($path . $extKey . '/ext_emconf.php')) {
179 $relPath = '../../../../' . substr($path, strlen(PATH_site
));
180 $emConf = tx_em_Tools
::includeEMCONF($path . $extKey . '/ext_emconf.php', $extKey);
181 $manual = $path . $extKey . '/doc/manual.sxw';
183 $type = tx_em_Tools
::getExtTypeFromPath($path);
185 if (is_array($emConf)) {
187 $loaded = t3lib_extMgm
::isLoaded($extKey);
188 if (is_array($list[$key])) {
189 $list[$key] = array('doubleInstall' => $list[$key]['doubleInstall']);
191 $list[$key]['extkey'] = $extKey;
192 $list[$key]['path'] = $path . $extKey;
193 $list[$key]['nodePath'] = substr($path . $extKey, strlen(PATH_site
));
194 $list[$key]['doubleInstall'] .= $this->types
[$type];
196 $list[$key]['type'] = $this->types
[$type];
197 $list[$key]['typeShort'] = $type;
198 $list[$key]['installed'] = $loaded ?
1 : 0;
199 // FIXME: raises PHP warning
200 // "Core: Error handler (BE): PHP Warning: htmlspecialchars() expects parameter 1 to be string, array given in [...]/typo3/mod/tools/em/classes/class.tx_em_extensions_list.php line 185
201 $list[$key] = t3lib_div
::array_merge_recursive_overrule($list[$key], $emConf);
202 $list[$key]['title'] = htmlspecialchars($list[$key]['title']);
203 $list[$key]['description'] = htmlspecialchars($list[$key]['description']);
204 $list[$key]['files'] = t3lib_div
::getFilesInDir($path . $extKey, '', 0, '', $this->excludeForPackaging
);
205 $list[$key]['install'] = $loaded ?
'<a href="' . htmlspecialchars(t3lib_div
::linkThisScript(array(
206 'CMD[showExt]' => $extKey,
209 'SET[singleDetails]' => 'info'
210 ))) . '">' . tx_em_Tools
::removeButton() . '</a>' :
211 '<a href="' . htmlspecialchars(t3lib_div
::linkThisScript(array(
212 'CMD[showExt]' => $extKey,
215 'SET[singleDetails]' => 'info'
216 ))) . '">' . tx_em_Tools
::installButton() . '</a>';
218 $list[$key]['install'] = $loaded ? tx_em_Tools
::removeButton() : tx_em_Tools
::installButton();
220 $list[$key]['download'] = '<a href="' . htmlspecialchars(t3lib_div
::linkThisScript(array(
221 'CMD[doBackup]' => 1,
222 'SET[singleDetails]' => 'backup',
223 'CMD[showExt]' => $extKey
225 t3lib_iconWorks
::getSpriteIcon('actions-system-extension-download') . ' title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:download') . '" alt=""></a>';
227 $list[$key]['doc'] = '';
228 if (@is_file
($manual)) {
229 $list[$key]['doc'] = '<a href="' . htmlspecialchars($relPath . $extKey . '/doc/manual.sxw') . '" target="_blank">
230 <img src="res/icons/oodoc.gif" width="13" height="16" title="' . $GLOBALS['LANG']->getLL('listRow_local_manual') . '" alt="" /></a>';
232 $list[$key]['icon'] = @is_file
($path . $extKey . '/ext_icon.gif') ?
'<img src="' . $relPath . $extKey . '/ext_icon.gif" alt="" width="16" height="16" />' : '<img src="clear.gif" alt="" width="16" height="16" />';
234 $list[$key]['categoryShort'] = $list[$key]['category'];
235 $list[$key]['category'] = $this->categories
[$list[$key]['category']];
237 unset($list[$key]['_md5_values_when_last_written']);
244 * Listing of loaded (installed) extensions
248 function extensionList_loaded() {
249 global $TYPO3_LOADED_EXT;
251 list($list, $cat) = $this->getInstalledExtensions();
257 // Available extensions
258 if (is_array($cat[$this->parentObject
->MOD_SETTINGS
['listOrder']])) {
261 $lines[] = $this->extensionListRowHeader(' class="t3-row-header"', array('<td><img src="clear.gif" width="1" height="1" alt="" /></td>'));
263 foreach ($cat[$this->parentObject
->MOD_SETTINGS
['listOrder']] as $catName => $extEkeys) {
265 natcasesort($extEkeys);
266 $extensions = array();
267 foreach ($extEkeys as $extKey => $data) {
268 if (array_key_exists($extKey, $TYPO3_LOADED_EXT) && ($this->parentObject
->MOD_SETTINGS
['display_shy'] ||
!$list[$extKey]['EM_CONF']['shy']) && $this->parentObject
->searchExtension($extKey, $list[$extKey])) {
269 if (in_array($extKey, $this->parentObject
->requiredExt
)) {
270 $loadUnloadLink = '<strong>' . $GLOBALS['TBE_TEMPLATE']->rfw($GLOBALS['LANG']->getLL('extension_required_short')) . '</strong>';
272 $loadUnloadLink = '<a href="' . htmlspecialchars(t3lib_div
::linkThisScript(array(
273 'CMD[showExt]' => $extKey,
275 ))) . '">' . tx_em_Tools
::removeButton() . '</a>';
278 $extensions[] = $this->extensionListRow($extKey, $list[$extKey], array('<td class="bgColor">' . $loadUnloadLink . '</td>'));
282 if (count($extensions)) {
283 $lines[] = '<tr><td colspan="' . (3 +
$this->parentObject
->detailCols
[$this->parentObject
->MOD_SETTINGS
['display_details']]) . '"><br /></td></tr>';
284 $lines[] = '<tr><td colspan="' . (3 +
$this->parentObject
->detailCols
[$this->parentObject
->MOD_SETTINGS
['display_details']]) . '">' . t3lib_iconWorks
::getSpriteIcon('apps-filetree-folder-default') . '<strong>' . htmlspecialchars($this->parentObject
->listOrderTitle($this->parentObject
->MOD_SETTINGS
['listOrder'], $catName)) . '</strong></td></tr>';
285 $lines[] = implode(LF
, $extensions);
290 $content .= '<form action="' . $this->parentObject
->script
. '" method="post" name="lookupform">';
291 $content .= '<label for="lookUp">' . $GLOBALS['LANG']->getLL('look_up') . '</label> <input type="text" id="lookUp" name="lookUp" value="' . htmlspecialchars($this->lookUpStr
) . '" /><input type="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:search') . '" /><br /><br />';
295 <!-- Loaded Extensions List -->
296 <table border="0" cellpadding="2" cellspacing="1">' . implode('', $lines) . '</table>';
302 * Listing of available (installed) extensions
306 function extensionList_installed() {
308 list($list, $cat) = $this->getInstalledExtensions();
310 // Available extensions
311 if (is_array($cat[$this->parentObject
->MOD_SETTINGS
['listOrder']])) {
314 $lines[] = $this->extensionListRowHeader(' class="t3-row-header"', array('<td><img src="clear.gif" width="18" height="1" alt="" /></td>'));
317 foreach ($cat[$this->parentObject
->MOD_SETTINGS
['listOrder']] as $catName => $extEkeys) {
318 if (!$this->parentObject
->MOD_SETTINGS
['display_obsolete'] && $catName == 'obsolete') {
323 $allKeys[] = 'TYPE: ' . $catName;
325 natcasesort($extEkeys);
326 $extensions = array();
327 foreach ($extEkeys as $extKey => $value) {
328 $allKeys[] = $extKey;
329 if ((!$list[$extKey]['EM_CONF']['shy'] ||
$this->parentObject
->MOD_SETTINGS
['display_shy']) &&
330 ($list[$extKey]['EM_CONF']['state'] != 'obsolete' ||
$this->parentObject
->MOD_SETTINGS
['display_obsolete'])
331 && $this->parentObject
->searchExtension($extKey, $list[$extKey])) {
332 $loadUnloadLink = t3lib_extMgm
::isLoaded($extKey) ?
333 '<a href="' . htmlspecialchars(t3lib_div
::linkThisScript(array(
334 'CMD[showExt]' => $extKey,
337 'SET[singleDetails]' => 'info'
338 ))) . '">' . tx_em_Tools
::removeButton() . '</a>' :
339 '<a href="' . htmlspecialchars(t3lib_div
::linkThisScript(array(
340 'CMD[showExt]' => $extKey,
343 'SET[singleDetails]' => 'info'
344 ))) . '">' . tx_em_Tools
::installButton() . '</a>';
345 if (in_array($extKey, $this->parentObject
->requiredExt
)) {
346 $loadUnloadLink = '<strong>' . $GLOBALS['TBE_TEMPLATE']->rfw($GLOBALS['LANG']->getLL('extension_required_short')) . '</strong>';
348 $theRowClass = t3lib_extMgm
::isLoaded($extKey) ?
'em-listbg1' : 'em-listbg2';
349 $extensions[] = $this->extensionListRow($extKey, $list[$extKey], array('<td class="bgColor">' . $loadUnloadLink . '</td>'), $theRowClass);
352 if (count($extensions)) {
353 $lines[] = '<tr><td colspan="' . (3 +
$this->parentObject
->detailCols
[$this->parentObject
->MOD_SETTINGS
['display_details']]) . '"><br /></td></tr>';
354 $lines[] = '<tr><td colspan="' . (3 +
$this->parentObject
->detailCols
[$this->parentObject
->MOD_SETTINGS
['display_details']]) . '">' . t3lib_iconWorks
::getSpriteIcon('apps-filetree-folder-default') . '<strong>' . htmlspecialchars($this->parentObject
->listOrderTitle($this->parentObject
->MOD_SETTINGS
['listOrder'], $catName)) . '</strong></td></tr>';
355 $lines[] = implode(LF
, $extensions);
365 ' . trim(implode(LF
, $allKeys)) . '
371 $content .= sprintf($GLOBALS['LANG']->getLL('how_to_install'), tx_em_Tools
::installButton()) . ' <br />' .
372 sprintf($GLOBALS['LANG']->getLL('how_to_uninstall'), tx_em_Tools
::removeButton()) . ' <br /><br />';
373 $content .= '<form action="' . $this->parentObject
->script
. '" method="post" name="lookupform">';
374 $content .= '<label for="lookUp">' . $GLOBALS['LANG']->getLL('look_up') . '</label> <input type="text" id="lookUp" name="lookUp" value="' . htmlspecialchars($this->parentObject
->lookUpStr
) . '" /><input type="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:search') . '" /></form><br /><br />';
375 $content .= $this->securityHint
. '<br /><br />';
377 $content .= '<table border="0" cellpadding="2" cellspacing="1">' . implode('', $lines) . '</table>';
385 * Prints the header row for the various listings
387 * @param string Attributes for the <tr> tag
388 * @param array Preset cells in the beginning of the row. Typically a blank cell with a clear-gif
389 * @param boolean If set, the list is coming from remote server.
390 * @return string HTML <tr> table row
392 function extensionListRowHeader($trAttrib, $cells, $import = 0) {
393 $cells[] = '<td></td>';
394 $cells[] = '<td>' . $GLOBALS['LANG']->getLL('extInfoArray_title') . '</td>';
396 if (!$this->parentObject
->MOD_SETTINGS
['display_details']) {
397 $cells[] = '<td>' . $GLOBALS['LANG']->getLL('extInfoArray_description') . '</td>';
398 $cells[] = '<td>' . $GLOBALS['LANG']->getLL('extInfoArray_author') . '</td>';
399 } elseif ($this->parentObject
->MOD_SETTINGS
['display_details'] == 2) {
400 $cells[] = '<td>' . $GLOBALS['LANG']->getLL('extInfoArray_priority') . '</td>';
401 $cells[] = '<td>' . $GLOBALS['LANG']->getLL('listRowHeader_modifies_tables_short') . '</td>';
402 $cells[] = '<td>' . $GLOBALS['LANG']->getLL('listRowHeader_modules') . '</td>';
403 $cells[] = '<td>' . $GLOBALS['LANG']->getLL('listRowHeader_clear_cache_short') . '</td>';
404 $cells[] = '<td>' . $GLOBALS['LANG']->getLL('extInfoArray_internal') . '</td>';
405 $cells[] = '<td>' . $GLOBALS['LANG']->getLL('extInfoArray_shy') . '</td>';
406 } elseif ($this->parentObject
->MOD_SETTINGS
['display_details'] == 3) {
407 $cells[] = '<td>' . $GLOBALS['LANG']->getLL('listRowHeader_tables_fields') . '</td>';
408 $cells[] = '<td>' . $GLOBALS['LANG']->getLL('listRowHeader_ts_files') . '</td>';
409 $cells[] = '<td>' . $GLOBALS['LANG']->getLL('listRowHeader_affects') . '</td>';
410 $cells[] = '<td>' . $GLOBALS['LANG']->getLL('listRowHeader_modules') . '</td>';
411 $cells[] = '<td>' . $GLOBALS['LANG']->getLL('listRowHeader_config') . '</td>';
412 $cells[] = '<td>' . $GLOBALS['LANG']->getLL('extInfoArray_code_warnings') . '</td>';
413 } elseif ($this->parentObject
->MOD_SETTINGS
['display_details'] == 4) {
414 $cells[] = '<td>' . $GLOBALS['LANG']->getLL('listRowHeader_locallang') . '</td>';
415 $cells[] = '<td>' . $GLOBALS['LANG']->getLL('listRowHeader_classes') . '</td>';
416 $cells[] = '<td>' . $GLOBALS['LANG']->getLL('extInfoArray_code_warnings') . '</td>';
417 $cells[] = '<td>' . $GLOBALS['LANG']->getLL('extInfoArray_annoyances') . '</td>';
418 } elseif ($this->parentObject
->MOD_SETTINGS
['display_details'] == 5) {
419 $cells[] = '<td>' . $GLOBALS['LANG']->getLL('listRowHeader_changed_files') . '</td>';
421 $cells[] = '<td>' . $GLOBALS['LANG']->getLL('listRowHeader_ext_key') . '</td>';
422 $cells[] = '<td>' . $GLOBALS['LANG']->getLL('extInfoArray_version') . '</td>';
424 $cells[] = '<td>' . $GLOBALS['LANG']->getLL('listRowHeader_download_short') . '</td>';
425 $cells[] = '<td>' . $GLOBALS['LANG']->getLL('listRowHeader_documentation_short') . '</td>';
426 $cells[] = '<td>' . $GLOBALS['LANG']->getLL('listRowHeader_type') . '</td>';
428 $cells[] = '<td' . tx_em_Tools
::labelInfo($GLOBALS['LANG']->getLL('listRowHeader_title_upload_date')) . '>' .
429 $GLOBALS['LANG']->getLL('listRowHeader_upload_date') . '</td>';
430 $cells[] = '<td>' . $GLOBALS['LANG']->getLL('extInfoArray_author') . '</td>';
431 $cells[] = '<td' . tx_em_Tools
::labelInfo($GLOBALS['LANG']->getLL('listRowHeader_title_current_version')) . '>' .
432 $GLOBALS['LANG']->getLL('listRowHeader_current_version') . '</td>';
433 $cells[] = '<td' . tx_em_Tools
::labelInfo($GLOBALS['LANG']->getLL('listRowHeader_title_current_type')) . '>' .
434 $GLOBALS['LANG']->getLL('listRowHeader_current_type') . '</td>';
435 $cells[] = '<td' . tx_em_Tools
::labelInfo($GLOBALS['LANG']->getLL('listRowHeader_title_number_of_downloads')) . '>' .
436 $GLOBALS['LANG']->getLL('listRowHeader_download_short') . '</td>';
438 $cells[] = '<td>' . $GLOBALS['LANG']->getLL('extInfoArray_state') . '</td>';
441 <tr' . $trAttrib . '>
449 * Prints a row with data for the various extension listings
451 * @param string Extension key
452 * @param array Extension information array
453 * @param array Preset table cells, eg. install/uninstall icons.
454 * @param string <tr> tag class
455 * @param array Array with installed extension keys (as keys)
456 * @param boolean If set, the list is coming from remote server.
457 * @param string Alternative link URL
458 * @return string HTML <tr> content
460 function extensionListRow($extKey, $extInfo, $cells, $bgColorClass = '', $inst_list = array(), $import = 0, $altLinkUrl = '') {
462 $imgInfo = @getImageSize
(tx_em_Tools
::getExtPath($extKey, $extInfo['type']) . '/ext_icon.gif');
463 if (is_array($imgInfo)) {
464 $cells[] = '<td><img src="' . $GLOBALS['BACK_PATH'] . $this->parentObject
->typeRelPaths
[$extInfo['type']] . $extKey . '/ext_icon.gif' . '" ' . $imgInfo[3] . ' alt="" /></td>';
465 } elseif ($extInfo['_ICON']) {
466 $cells[] = '<td>' . $extInfo['_ICON'] . '</td>';
468 $cells[] = '<td><img src="clear.gif" width="1" height="1" alt="" /></td>';
472 $cells[] = '<td nowrap="nowrap"><a href="' . htmlspecialchars($altLinkUrl ?
$altLinkUrl : t3lib_div
::linkThisScript(array(
473 'CMD[showExt]' => $extKey,
474 'SET[singleDetails]' => 'info'
475 ))) . '" title="' . htmlspecialchars($extInfo['EM_CONF']['description']) . '">'
476 . t3lib_div
::fixed_lgd_cs($extInfo['EM_CONF']['title'] ?
htmlspecialchars($extInfo['EM_CONF']['title']) : '<em>' . $extKey . '</em>', 40) . '</a></td>';
478 // Based on the display mode you will see more or less details:
479 if (!$this->parentObject
->MOD_SETTINGS
['display_details']) {
480 $cells[] = '<td>' . htmlspecialchars(t3lib_div
::fixed_lgd_cs($extInfo['EM_CONF']['description'], 400)) . '<br /><img src="clear.gif" width="300" height="1" alt="" /></td>';
481 $cells[] = '<td nowrap="nowrap">' . ($extInfo['EM_CONF']['author_email'] ?
'<a href="mailto:' . htmlspecialchars($extInfo['EM_CONF']['author_email']) . '">' : '') . htmlspecialchars($extInfo['EM_CONF']['author']) . (htmlspecialchars($extInfo['EM_CONF']['author_email']) ?
'</a>' : '') . ($extInfo['EM_CONF']['author_company'] ?
'<br />' . htmlspecialchars($extInfo['EM_CONF']['author_company']) : '') . '</td>';
482 } elseif ($this->parentObject
->MOD_SETTINGS
['display_details'] == 2) {
483 $cells[] = '<td nowrap="nowrap">' . $extInfo['EM_CONF']['priority'] . '</td>';
484 $cells[] = '<td nowrap="nowrap">' . implode('<br />', t3lib_div
::trimExplode(',', $extInfo['EM_CONF']['modify_tables'], 1)) . '</td>';
485 $cells[] = '<td nowrap="nowrap">' . $extInfo['EM_CONF']['module'] . '</td>';
486 $cells[] = '<td nowrap="nowrap">' . ($extInfo['EM_CONF']['clearCacheOnLoad'] ?
$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:yes') : '') . '</td>';
487 $cells[] = '<td nowrap="nowrap">' . ($extInfo['EM_CONF']['internal'] ?
$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:yes') : '') . '</td>';
488 $cells[] = '<td nowrap="nowrap">' . ($extInfo['EM_CONF']['shy'] ?
$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:yes') : '') . '</td>';
489 } elseif ($this->parentObject
->MOD_SETTINGS
['display_details'] == 3) {
490 $techInfo = $this->install
->makeDetailedExtensionAnalysis($extKey, $extInfo);
492 $cells[] = '<td>' . $this->parentObject
->extensionDetails
->extInformationArray_dbReq($techInfo) .
494 $cells[] = '<td nowrap="nowrap">' . (is_array($techInfo['TSfiles']) ?
implode('<br />', $techInfo['TSfiles']) : '') . '</td>';
495 $cells[] = '<td nowrap="nowrap">' . (is_array($techInfo['flags']) ?
implode('<br />', $techInfo['flags']) : '') . '</td>';
496 $cells[] = '<td nowrap="nowrap">' . (is_array($techInfo['moduleNames']) ?
implode('<br />', $techInfo['moduleNames']) : '') . '</td>';
497 $cells[] = '<td nowrap="nowrap">' . ($techInfo['conf'] ?
$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:yes') : '') . '</td>';
499 $GLOBALS['TBE_TEMPLATE']->rfw((t3lib_extMgm
::isLoaded($extKey) && $techInfo['tables_error'] ?
500 '<strong>' . $GLOBALS['LANG']->getLL('extInfoArray_table_error') . '</strong><br />' .
501 $GLOBALS['LANG']->getLL('extInfoArray_missing_fields') : '') .
502 (t3lib_extMgm
::isLoaded($extKey) && $techInfo['static_error'] ?
503 '<strong>' . $GLOBALS['LANG']->getLL('extInfoArray_static_table_error') . '</strong><br />' .
504 $GLOBALS['LANG']->getLL('extInfoArray_static_tables_missing_empty') : '')) .
506 } elseif ($this->parentObject
->MOD_SETTINGS
['display_details'] == 4) {
507 $techInfo = $this->install
->makeDetailedExtensionAnalysis($extKey, $extInfo, 1);
509 $cells[] = '<td>' . (is_array($techInfo['locallang']) ?
implode('<br />', $techInfo['locallang']) : '') . '</td>';
510 $cells[] = '<td>' . (is_array($techInfo['classes']) ?
implode('<br />', $techInfo['classes']) : '') . '</td>';
511 $cells[] = '<td>' . (is_array($techInfo['errors']) ?
$GLOBALS['TBE_TEMPLATE']->rfw(implode('<hr />', $techInfo['errors'])) : '') . '</td>';
512 $cells[] = '<td>' . (is_array($techInfo['NSerrors']) ?
513 (!t3lib_div
::inList($this->parentObject
->nameSpaceExceptions
, $extKey) ?
514 t3lib_utility_Debug
::viewarray($techInfo['NSerrors']) :
515 $GLOBALS['TBE_TEMPLATE']->dfw($GLOBALS['LANG']->getLL('extInfoArray_exception'))) : '') . '</td>';
516 } elseif ($this->parentObject
->MOD_SETTINGS
['display_details'] == 5) {
517 $currentMd5Array = $this->parentObject
->extensionDetails
->serverExtensionMD5array($extKey, $extInfo);
520 $msgLines[] = $GLOBALS['LANG']->getLL('listRow_files') . ' ' . count($currentMd5Array);
521 if (strcmp($extInfo['EM_CONF']['_md5_values_when_last_written'], serialize($currentMd5Array))) {
522 $msgLines[] = $GLOBALS['TBE_TEMPLATE']->rfw('<br /><strong>' . $GLOBALS['LANG']->getLL('extInfoArray_difference_detected') . '</strong>');
523 $affectedFiles = tx_em_Tools
::findMD5ArrayDiff($currentMd5Array, unserialize($extInfo['EM_CONF']['_md5_values_when_last_written']));
524 if (count($affectedFiles)) {
525 $msgLines[] = '<br /><strong>' . $GLOBALS['LANG']->getLL('extInfoArray_modified_files') . '</strong><br />' .
526 $GLOBALS['TBE_TEMPLATE']->rfw(implode('<br />', $affectedFiles));
529 $cells[] = '<td>' . implode('<br />', $msgLines) . '</td>';
532 $verDiff = $inst_list[$extKey] && tx_em_Tools
::versionDifference($extInfo['EM_CONF']['version'], $inst_list[$extKey]['EM_CONF']['version'], $this->parentObject
->versionDiffFactor
);
534 $cells[] = '<td nowrap="nowrap"><em>' . $extKey . '</em></td>';
535 $cells[] = '<td nowrap="nowrap">' . ($verDiff ?
'<strong>' . $GLOBALS['TBE_TEMPLATE']->rfw(htmlspecialchars($extInfo['EM_CONF']['version'])) . '</strong>' : $extInfo['EM_CONF']['version']) . '</td>';
536 if (!$import) { // Listing extension on LOCAL server:
537 // Extension Download:
538 $cells[] = '<td nowrap="nowrap"><a href="' . htmlspecialchars(t3lib_div
::linkThisScript(array(
539 'CMD[doBackup]' => 1,
540 'SET[singleDetails]' => 'backup',
541 'CMD[showExt]' => $extKey
542 ))) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:download') . '">' .
543 t3lib_iconWorks
::getSpriteIcon('actions-system-extension-download') .
547 $fileP = PATH_site
. $this->parentObject
->typePaths
[$extInfo['type']] . $extKey . '/doc/manual.sxw';
548 $cells[] = '<td nowrap="nowrap">' .
549 ($this->parentObject
->typePaths
[$extInfo['type']] && @is_file
($fileP) ?
550 '<a href="' . htmlspecialchars(t3lib_div
::resolveBackPath($this->parentObject
->doc
->backPath
. '../' . $this->parentObject
->typePaths
[$extInfo['type']] . $extKey . '/doc/manual.sxw')) . '" target="_blank" title="' . $GLOBALS['LANG']->getLL('listRow_local_manual') . '">' .
551 t3lib_iconWorks
::getSpriteIcon('actions-system-extension-documentation') . '</a>' : '') .
554 // Double installation (inclusion of an extension in more than one of system, global or local scopes)
556 if (strlen($extInfo['doubleInstall']) > 1) {
557 // Separate the "SL" et al. string into an array and replace L by Local, G by Global etc.
558 $doubleInstallations = str_replace(
559 array('S', 'G', 'L'),
561 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:sysext'),
562 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:globalext'),
563 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:localext')
565 str_split($extInfo['doubleInstall'])
567 // Last extension is the one actually used
568 $usedExtension = array_pop($doubleInstallations);
569 // Next extension is overridden
570 $overriddenExtensions = array_pop($doubleInstallations);
571 // If the array is not yet empty, the extension is actually installed 3 times (SGL)
572 if (count($doubleInstallations) > 0) {
573 $lastExtension = array_pop($doubleInstallations);
574 $overriddenExtensions .= ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:and') . ' ' . $lastExtension;
576 $doubleInstallTitle = sprintf(
577 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:double_inclusion'),
579 $overriddenExtensions
581 $doubleInstall = ' <strong><abbr title="' . $doubleInstallTitle . '">' . $GLOBALS['TBE_TEMPLATE']->rfw($extInfo['doubleInstall']) . '</abbr></strong>';
583 $cells[] = '<td nowrap="nowrap">' . $this->parentObject
->typeLabels
[$extInfo['type']] . $doubleInstall . '</td>';
584 } else { // Listing extensions from REMOTE repository:
585 $inst_curVer = $inst_list[$extKey]['EM_CONF']['version'];
586 if (isset($inst_list[$extKey])) {
588 $inst_curVer = '<strong>' . $GLOBALS['TBE_TEMPLATE']->rfw($inst_curVer) . '</strong>';
591 $cells[] = '<td nowrap="nowrap">' . t3lib_befunc
::date($extInfo['EM_CONF']['lastuploaddate']) . '</td>';
592 $cells[] = '<td nowrap="nowrap">' . htmlspecialchars(t3lib_div
::fixed_lgd_cs($extInfo['EM_CONF']['author'], $GLOBALS['BE_USER']->uc
[titleLen
])) . '</td>';
593 $cells[] = '<td nowrap="nowrap">' . $inst_curVer . '</td>';
594 $cells[] = '<td nowrap="nowrap">' . $this->parentObject
->typeLabels
[$inst_list[$extKey]['type']] . (strlen($inst_list[$extKey]['doubleInstall']) > 1 ?
'<strong> ' . $GLOBALS['TBE_TEMPLATE']->rfw($inst_list[$extKey]['doubleInstall']) . '</strong>' : '') . '</td>';
595 $cells[] = '<td nowrap="nowrap">' . ($extInfo['downloadcounter_all'] ?
$extInfo['downloadcounter_all'] : ' ') . '/' . ($extInfo['downloadcounter'] ?
$extInfo['downloadcounter'] : ' ') . '</td>';
597 $cells[] = '<td nowrap="nowrap" class="extstate" style="background-color:' . $this->parentObject
->stateColors
[$extInfo['EM_CONF']['state']] . ';">' . $this->parentObject
->states
[$extInfo['EM_CONF']['state']] . '</td>';
600 // show a different background through a different class for insecure (-1) extensions,
601 // for unreviewed (0) and reviewed extensions (1), just use the regular class
602 if ($this->parentObject
->xmlhandler
->getReviewState($extKey, $extInfo['EM_CONF']['version']) < 0) {
603 $bgclass = ' class="unsupported-ext"';
605 $bgclass = ' class="' . ($bgColorClass ?
$bgColorClass : 'em-listbg1') . '"';
617 * Displays a list of extensions where a newer version is available
618 * in the TER than the one that is installed right now
619 * integrated from the extension "ter_update_check" for TYPO3 4.2 by Christian Welzel
623 function showExtensionsToUpdate() {
625 $extList = $this->getInstalledExtensions();
627 $content = '<table border="0" cellpadding="2" cellspacing="1">' .
628 '<tr class="t3-row-header">' .
630 '<td>' . $LANG->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:tab_mod_name') . '</td>' .
631 '<td>' . $LANG->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:tab_mod_key') . '</td>' .
632 '<td>' . $LANG->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:tab_mod_loc_ver') . '</td>' .
633 '<td>' . $LANG->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:tab_mod_rem_ver') . '</td>' .
634 '<td>' . $LANG->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:tab_mod_location') . '</td>' .
635 '<td>' . $LANG->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:tab_mod_comment') . '</td>' .
638 foreach ($extList[0] as $name => $data) {
639 $this->parentObject
->xmlhandler
->searchExtensionsXMLExact($name, '', '', TRUE, TRUE);
640 if (!is_array($this->parentObject
->xmlhandler
->extensionsXML
[$name])) {
644 $v = $this->parentObject
->xmlhandler
->extensionsXML
[$name]['versions'];
645 $versions = array_keys($v);
647 $lastversion = end($versions);
649 if ((t3lib_extMgm
::isLoaded($name) ||
$this->parentObject
->MOD_SETTINGS
['display_installed']) &&
650 ($data['EM_CONF']['shy'] == 0 ||
$this->parentObject
->MOD_SETTINGS
['display_shy']) &&
651 tx_em_Tools
::versionDifference($lastversion, $data['EM_CONF']['version'], 1)) {
653 $imgInfo = @getImageSize
(tx_em_Tools
::getExtPath($name, $data['type']) . '/ext_icon.gif');
654 if (is_array($imgInfo)) {
655 $icon = '<img src="' . $GLOBALS['BACK_PATH'] . $this->parentObject
->typeRelPaths
[$data['type']] . $name . '/ext_icon.gif' . '" ' . $imgInfo[3] . ' alt="" />';
656 } elseif ($data['_ICON']) { //TODO: see if this can be removed, seems to be wrong in this context
657 $icon = $data['_ICON'];
659 $icon = '<img src="clear.gif" width="1" height="1" alt="" />';
661 $comment = '<table cellpadding="0" cellspacing="0" width="100%">';
662 foreach ($versions as $vk) {
664 if (t3lib_div
::int_from_ver($vk) <= t3lib_div
::int_from_ver($data['EM_CONF']['version'])) {
667 $comment .= '<tr><td valign="top" style="padding-right:2px;border-bottom:1px dotted gray">' . $vk . '</td>' . '<td valign="top" style="border-bottom:1px dotted gray">' . nl2br($va[uploadcomment
]) . '</td></tr>';
669 $comment .= '</table>';
671 $serverMD5Array = $this->parentObject
->extensionDetails
->serverExtensionMD5array($name, $data);
672 if (is_array($serverMD5Array)) {
673 ksort($serverMD5Array);
675 $currentMD5Array = unserialize($data['EM_CONF']['_md5_values_when_last_written']);
676 if (is_array($currentMD5Array)) {
677 @ksort
($currentMD5Array);
680 if (strcmp(serialize($currentMD5Array), serialize($serverMD5Array))) {
681 $warn = '<tr class="bgColor4" style="color:red"><td colspan="7">' . $GLOBALS['TBE_TEMPLATE']->rfw('<br /><strong>' . $name . ': ' . $LANG->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:msg_warn_diff') . '</strong>') . '</td></tr>' . LF
;
682 if ($this->parentObject
->MOD_SETTINGS
['display_files'] == 1) {
683 $affectedFiles = tx_em_Tools
::findMD5ArrayDiff($serverMD5Array, $currentMD5Array);
684 if (count($affectedFiles)) {
685 $warn .= '<tr class="bgColor4"><td colspan="7"><strong>' . $LANG->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:msg_modified') . '</strong><br />' . $GLOBALS['TBE_TEMPLATE']->rfw(implode('<br />', $affectedFiles)) . '</td></tr>' . LF
;
689 //TODO: $extInfo is unknown in this context
690 $content .= '<tr class="bgColor4"><td valign="top">' . $icon . '</td>' .
691 '<td valign="top">' . ($data['EM_CONF']['state'] == 'excludeFromUpdates' ?
'<span style="color:#cf7307">' . $data['EM_CONF']['title'] . ' ' . $LANG->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:write_protected') . '</span>' : '<a href="?CMD[importExtInfo]=' . $name . '">' . $data[EM_CONF
][title
] . '</a>') . '</td>' .
692 '<td valign="top">' . $name . '</td>' .
693 '<td valign="top" align="right">' . $data[EM_CONF
][version
] . '</td>' .
694 '<td valign="top" align="right">' . $lastversion . '</td>' .
695 '<td valign="top" nowrap="nowrap">' . $this->parentObject
->typeLabels
[$data['type']] . (strlen($data['doubleInstall']) > 1 ?
'<strong> ' . $GLOBALS['TBE_TEMPLATE']->rfw($extInfo['doubleInstall']) . '</strong>' : '') . '</td>' .
696 '<td valign="top">' . $comment . '</td></tr>' . LF
.
698 '<tr class="bgColor4"><td colspan="7"><hr style="margin:0px" /></td></tr>' . LF
;
702 return $content . '</table><br />';
706 * Maps remote extensions information into $cat/$list arrays for listing
708 * @param boolean If set the info in the internal extensionsXML array will be unset before returning the result.
709 * @return array List array and category index as key 0 / 1 in an array.
711 function prepareImportExtList($unsetProc = false) {
713 $cat = $this->parentObject
->defaultCategories
;
714 $filepath = $this->parentObject
->getMirrorURL();
716 foreach ($this->parentObject
->xmlhandler
->extensionsXML
as $extKey => $data) {
717 $GLOBALS['LANG']->csConvObj
->convarray($data, 'utf-8', $GLOBALS['LANG']->charSet
); // is there a better place for conversion?
718 $list[$extKey]['type'] = '_';
719 $version = array_keys($data['versions']);
720 $extPath = t3lib_div
::strtolower($extKey);
721 $list[$extKey]['_ICON'] = '<img alt="" src="' . $filepath . $extPath{0} . '/' . $extPath{1} . '/' . $extPath . '_' . end($version) . '.gif" />';
722 $list[$extKey]['downloadcounter'] = $data['downloadcounter'];
724 foreach (array_keys($data['versions']) as $version) {
725 $list[$extKey]['versions'][$version]['downloadcounter'] = $data['versions'][$version]['downloadcounter'];
727 $list[$extKey]['versions'][$version]['EM_CONF'] = array(
728 'version' => $version,
729 'title' => $data['versions'][$version]['title'],
730 'description' => $data['versions'][$version]['description'],
731 'category' => $data['versions'][$version]['category'],
732 'constraints' => $data['versions'][$version]['dependencies'],
733 'state' => $data['versions'][$version]['state'],
734 'reviewstate' => $data['versions'][$version]['reviewstate'],
735 'lastuploaddate' => $data['versions'][$version]['lastuploaddate'],
736 'author' => $data['versions'][$version]['authorname'],
737 'author_email' => $data['versions'][$version]['authoremail'],
738 'author_company' => $data['versions'][$version]['authorcompany'],
741 tx_em_Tools
::setCat($cat, $list[$extKey]['versions'][$version], $extKey);
743 unset($this->parentObject
->xmlhandler
->extensionsXML
[$extKey]);
747 return array($list, $cat);
752 * Adds extension to extension list and returns new list. If -1 is returned, an error happend.
753 * Checks dependencies etc.
755 * @param string Extension key
756 * @param array Extension information array - information about installed extensions
757 * @return string New list of installed extensions or -1 if error
758 * @see showExtDetails()
760 function addExtToList($extKey, $instExtInfo) {
761 global $TYPO3_LOADED_EXT;
763 // ext_emconf.php information:
764 $conf = $instExtInfo[$extKey]['EM_CONF'];
766 // Get list of installed extensions and add this one.
767 $listArr = array_keys($TYPO3_LOADED_EXT);
768 if ($conf['priority'] == 'top') {
769 array_unshift($listArr, $extKey);
771 $listArr[] = $extKey;
774 // Manage other circumstances:
775 $listArr = tx_em_Tools
::managesPriorities($listArr, $instExtInfo);
776 $listArr = $this->removeRequiredExtFromListArr($listArr);
778 // Implode unique list of extensions to load and return:
779 $list = implode(',', array_unique($listArr));
784 * Remove extension key from the list of currently installed extensions and return list. If -1 is returned, an error happend.
785 * Checks dependencies etc.
787 * @param string Extension key
788 * @param array Extension information array - information about installed extensions
789 * @return string New list of installed extensions or -1 if error
790 * @see showExtDetails()
792 function removeExtFromList($extKey, $instExtInfo) {
793 global $TYPO3_LOADED_EXT;
797 $listArr = array_keys($TYPO3_LOADED_EXT);
799 // Traverse all installed extensions to check if any of them have this extension as dependency since if that is the case it will not work out!
800 foreach ($listArr as $k => $ext) {
801 if ($instExtInfo[$ext]['EM_CONF']['dependencies']) {
802 $dep = t3lib_div
::trimExplode(',', $instExtInfo[$ext]['EM_CONF']['dependencies'], 1);
803 if (in_array($extKey, $dep)) {
807 if (!strcmp($ext, $extKey)) {
812 // Returns either error or the new list
813 if (count($depList)) {
814 $msg = sprintf($GLOBALS['LANG']->getLL('removeExtFromList_dependency'),
815 implode(', ', $depList)
817 $this->content
.= $this->doc
->section($GLOBALS['LANG']->getLL('removeExtFromList_dependency_error'), $msg, 0, 1, 2);
820 $listArr = $this->removeRequiredExtFromListArr($listArr);
821 $list = implode(',', array_unique($listArr));
827 * This removes any required extensions from the $listArr - they should NOT be added to the common extension list, because they are found already in "requiredExt" list
829 * @param array Array of extension keys as values
830 * @return array Modified array
831 * @see removeExtFromList(), addExtToList()
833 function removeRequiredExtFromListArr($listArr) {
834 foreach ($listArr as $k => $ext) {
835 if (in_array($ext, $this->parentObject
->requiredExt
) ||
!strcmp($ext, '_CACHEFILE')) {