TYPO3 API  SVNRelease
class.tx_em_extensions_list.php
Go to the documentation of this file.
00001 <?php
00002 /* **************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) webservices.nl
00006 *  (c) 2006-2010 Karsten Dambekalns <karsten@typo3.org>
00007 *  All rights reserved
00008 *
00009 *  This script is part of the TYPO3 project. The TYPO3 project is
00010 *  free software; you can redistribute it and/or modify
00011 *  it under the terms of the GNU General Public License as published by
00012 *  the Free Software Foundation; either version 2 of the License, or
00013 *  (at your option) any later version.
00014 *
00015 *  The GNU General Public License can be found at
00016 *  http://www.gnu.org/copyleft/gpl.html.
00017 *  A copy is found in the textfile GPL.txt and important notices to the license
00018 *  from the author is found in LICENSE.txt distributed with these scripts.
00019 *
00020 *
00021 *  This script is distributed in the hope that it will be useful,
00022 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00023 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00024 *  GNU General Public License for more details.
00025 *
00026 *  This copyright notice MUST APPEAR in all copies of the script!
00027 ***************************************************************/
00028 /* $Id: class.tx_em_extensions_list.php 2084 2010-03-22 01:46:37Z steffenk $ */
00029 
00030 /**
00031  * This class handles extension listings
00032  *
00033  */
00034 class tx_em_Extensions_List {
00035 
00036 
00037     protected $parentObject;
00038 
00039     /** @var tx_em_Tools_XmlHandler */
00040     protected $xmlHandler;
00041 
00042     protected $categories;
00043     protected $types;
00044     protected $states;
00045 
00046     /**
00047      * Constructor
00048      *
00049      * @param object $parentObject
00050      * @return void
00051      */
00052     public function __construct($parentObject = NULL) {
00053         $this->parentObject = $parentObject;
00054         $this->install = t3lib_div::makeInstance('tx_em_Install', $this);
00055         $this->xmlHandler = t3lib_div::makeInstance('tx_em_Tools_XmlHandler');
00056 
00057         $this->categories = array(
00058             'be' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:category_BE'),
00059             'module' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:category_BE_modules'),
00060             'fe' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:category_FE'),
00061             'plugin' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:category_FE_plugins'),
00062             'misc' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:category_miscellanous'),
00063             'services' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:category_services'),
00064             'templates' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:category_templates'),
00065             'example' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:category_examples'),
00066             'doc' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:category_documentation')
00067         );
00068         $this->types = array(
00069             'S' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:type_system'),
00070             'G' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:type_global'),
00071             'L' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:type_local'),
00072         );
00073         $this->states = tx_em_Tools::getStates();
00074     }
00075 
00076 
00077     /**
00078      * Returns the list of available (installed) extensions
00079      *
00080      * @param   boolean     if set, function will return a flat list only
00081      * @return  array       Array with two arrays, list array (all extensions with info) and category index
00082      * @see getInstExtList()
00083      */
00084     function getInstalledExtensions($flatList = FALSE) {
00085         $list = array();
00086 
00087         if ($flatList) {
00088             $path = PATH_typo3 . 'sysext/';
00089             $this->getFlatInstExtList($path, $list, 'S');
00090 
00091             $path = PATH_typo3 . 'ext/';
00092             $this->getFlatInstExtList($path, $list, 'G');
00093 
00094             $path = PATH_typo3conf . 'ext/';
00095             $this->getFlatInstExtList($path, $list, 'L');
00096 
00097             return $list;
00098         } else {
00099             $cat = tx_em_Tools::getDefaultCategory();
00100 
00101             $path = PATH_typo3 . 'sysext/';
00102             $this->getInstExtList($path, $list, $cat, 'S');
00103 
00104             $path = PATH_typo3 . 'ext/';
00105             $this->getInstExtList($path, $list, $cat, 'G');
00106 
00107             $path = PATH_typo3conf . 'ext/';
00108             $this->getInstExtList($path, $list, $cat, 'L');
00109 
00110             return array($list, $cat);
00111         }
00112     }
00113 
00114     /**
00115      * Gathers all extensions in $path
00116      *
00117      * @param   string      Absolute path to local, global or system extensions
00118      * @param   array       Array with information for each extension key found. Notice: passed by reference
00119      * @param   array       Categories index: Contains extension titles grouped by various criteria.
00120      * @param   string      Path-type: L, G or S
00121      * @return  void        "Returns" content by reference
00122      * @see getInstalledExtensions()
00123      */
00124     function getInstExtList($path, &$list, &$cat, $type) {
00125 
00126         if (@is_dir($path)) {
00127             $extList = t3lib_div::get_dirs($path);
00128             if (is_array($extList)) {
00129                 foreach ($extList as $extKey) {
00130                     if (@is_file($path . $extKey . '/ext_emconf.php')) {
00131                         $emConf = tx_em_Tools::includeEMCONF($path . $extKey . '/ext_emconf.php', $extKey);
00132                         if (is_array($emConf)) {
00133                             if (is_array($list[$extKey])) {
00134                                 $list[$extKey] = array('doubleInstall' => $list[$extKey]['doubleInstall']);
00135                             }
00136                             $list[$extKey]['extkey'] = $extKey;
00137                             $list[$extKey]['doubleInstall'] .= $type;
00138                             $list[$extKey]['type'] = $type;
00139                             $list[$extKey]['installed'] = t3lib_extMgm::isLoaded($extKey);
00140                             $list[$extKey]['EM_CONF'] = $emConf;
00141                             $list[$extKey]['files'] = t3lib_div::getFilesInDir($path . $extKey, '', 0, '', $this->excludeForPackaging);
00142 
00143                             tx_em_Tools::setCat($cat, $list[$extKey], $extKey);
00144                         }
00145                     }
00146                 }
00147             }
00148         }
00149     }
00150 
00151     /**
00152      * Gathers all extensions in $path
00153      *
00154      * @param   string      Absolute path to local, global or system extensions
00155      * @param   array       Array with information for each extension key found. Notice: passed by reference
00156      * @param   array       Categories index: Contains extension titles grouped by various criteria.
00157      * @param   string      Path-type: L, G or S
00158      * @return  void        "Returns" content by reference
00159      * @access private
00160      * @see getInstalledExtensions()
00161      */
00162     function getFlatInstExtList($path, &$list, $type) {
00163 
00164 
00165         if (@is_dir($path)) {
00166             $extList = t3lib_div::get_dirs($path);
00167             if (is_array($extList)) {
00168                 foreach ($extList as $extKey) {
00169                     $this->singleExtInfo($extKey, $path, $list, $type);
00170                 }
00171             }
00172         }
00173     }
00174 
00175     /**
00176      * Gets a single extension info
00177      *
00178      * @param  $extKey
00179      * @param  $path
00180      * @param  $list
00181      * @param string $type
00182      * @return void
00183      */
00184     public function singleExtInfo($extKey, $path, &$list, $type = '') {
00185         if (@is_file($path . $extKey . '/ext_emconf.php')) {
00186             $relPath = '../' . substr($path, strlen(PATH_site));
00187             $directLink = 'mod.php?M=tools_em';
00188             $emConf = tx_em_Tools::includeEMCONF($path . $extKey . '/ext_emconf.php', $extKey);
00189             $manual = $path . $extKey . '/doc/manual.sxw';
00190             $manualRelPath = $relPath . $extKey . '/doc/manual.sxw';
00191 
00192             if ($type === '') {
00193                 $type = tx_em_Tools::getExtTypeFromPath($path);
00194             }
00195 
00196             if (is_array($emConf)) {
00197                 $key = count($list);
00198                 $loaded = t3lib_extMgm::isLoaded($extKey);
00199 
00200 
00201 
00202                 $exist = $this->findIndex($extKey, $list);
00203                 if ($exist !== FALSE) {
00204                     $key = $exist;
00205                     $list[$key] = array(
00206                         'doubleInstall' => $list[$key]['doubleInstall'],
00207                         'doubleInstallShort' => $list[$key]['doubleInstallShort'],
00208                     );
00209 
00210                 }
00211                 $list[$key]['extkey'] = $extKey;
00212                 $list[$key]['path'] = $path . $extKey;
00213                 $list[$key]['nodePath'] = substr($path . $extKey, strlen(PATH_site));
00214                 $list[$key]['doubleInstall'] = $list[$key]['doubleInstall'] ? $list[$key]['doubleInstall'] . '/' . $this->types[$type] : $this->types[$type];
00215                 $list[$key]['doubleInstallShort'] .= $type;
00216 
00217                 $list[$key] = t3lib_div::array_merge_recursive_overrule($list[$key], $emConf);
00218 
00219                 if (@is_file($path . $extKey . '/class.ext_update.php')) {
00220                     $list[$key]['updateModule'] = TRUE;
00221                 } else {
00222                     $list[$key]['updateModule'] = FALSE;
00223                 }
00224                 $list[$key]['type'] = $this->types[$type];
00225                 $list[$key]['typeShort'] = $type;
00226                 $list[$key]['installed'] = $loaded ? 1 : 0;
00227 
00228 
00229                 $state = htmlspecialchars($emConf['state']);
00230                 $list[$key]['state'] = $this->states[$state];
00231                 $list[$key]['stateCls'] = 'state-' . $state;
00232                 $list[$key]['title'] = htmlspecialchars($list[$key]['title']);
00233                 $list[$key]['description'] = htmlspecialchars($list[$key]['description']);
00234                 $list[$key]['author'] = htmlspecialchars($list[$key]['author']);
00235                 $list[$key]['author_email'] = htmlspecialchars($list[$key]['author_email']);
00236                 $list[$key]['files'] = t3lib_div::getFilesInDir($path . $extKey, '', 0, '', $this->excludeForPackaging);
00237                 $list[$key]['reviewstate'] = $this->xmlHandler->getReviewState($extKey, $list[$key]['version']);
00238 
00239                 $list[$key]['download'] = '<a href="' . htmlspecialchars(
00240                     $directLink .'&CMD[doBackup]=1&SET[singleDetails]=backup&CMD[showExt]=' . $extKey
00241                 ) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:download') . '">' .
00242                     t3lib_iconWorks::getSpriteIcon('actions-system-extension-download') . '</a>';
00243 
00244                 $list[$key]['doc'] = '';
00245                 if ($list[$key]['docPath']) {
00246                     $manual = $path . $extKey . '/' . $list[$key]['docPath'] . '/manual.sxw';
00247                     $manualRelPath = $relPath . $extKey . '/' .  $list[$key]['docPath'] . '/manual.sxw';
00248                 }
00249 
00250                 if (@is_file($manual)) {
00251                     $list[$key]['doc'] = '<a href="' . htmlspecialchars($manualRelPath) . '" target="_blank">'
00252                         . t3lib_iconWorks::getSpriteIcon('actions-system-extension-documentation') . '</a>';
00253                 }
00254                 $list[$key]['icon'] = @is_file($path . $extKey . '/ext_icon.gif') ? '<img src="' . $relPath . $extKey . '/ext_icon.gif" alt="" height="16" />' : '<img src="clear.gif" alt="" width="16" height="16" />';
00255 
00256                 $list[$key]['categoryShort'] = $list[$key]['category'];
00257                 $list[$key]['category'] = isset($this->categories[$list[$key]['category']]) ? $this->categories[$list[$key]['category']] : $list[$key]['category'];
00258                 $list[$key]['required'] = t3lib_div::inList(t3lib_extMgm::getRequiredExtensionList(), $extKey);
00259 
00260                 $constraints = $this->humanizeConstraints($list[$key]['constraints']);
00261                 $list[$key]['depends'] = $constraints['depends'];
00262                 $list[$key]['conflicts'] = $constraints['conflicts'];
00263                 $list[$key]['suggests'] = $constraints['suggests'];
00264 
00265 
00266                 unset($list[$key]['_md5_values_when_last_written']);
00267             }
00268         }
00269     }
00270 
00271     /**
00272      * Make constraints readable
00273      *
00274      * @param  array $constraints
00275      * @return array
00276      */
00277     public function humanizeConstraints($constraints) {
00278         $depends = $conflicts = $suggests = array();
00279         $result = array(
00280             'depends' => '',
00281             'conflicts' => '',
00282             'suggests' => ''
00283         );
00284 
00285         if (is_array($constraints) && count($constraints)) {
00286             if (is_array($constraints['depends']) && count($constraints['depends'])) {
00287                 foreach ($constraints['depends'] as $key => $value) {
00288                     if ($value) {
00289                         $tmp = t3lib_div::trimExplode('-', $value, TRUE);
00290                         if (trim($tmp[1]) && trim($tmp[1]) !== '0.0.0') {
00291                             $value = $tmp[0] . ' - ' . $tmp[1];
00292                         } else {
00293                             $value = $tmp[0];
00294                         }
00295                     }
00296                     $depends[] = $key . ($value ? ' (' . $value . ')' : '');
00297                 }
00298             }
00299             if (is_array($constraints['conflicts']) && count($constraints['conflicts'])) {
00300                 foreach ($constraints['conflicts'] as $key => $value) {
00301                     if ($value) {
00302                         $tmp = t3lib_div::trimExplode('-', $value, TRUE);
00303                         if (trim($tmp[1]) && trim($tmp[1]) !== '0.0.0') {
00304                             $value = $tmp[0] . ' - ' . $tmp[1];
00305                         } else {
00306                             $value = $tmp[0];
00307                         }
00308                     }
00309                     $conflicts[] = $key . ($value ? ' (' . $value . ')' : '');
00310                 }
00311             }
00312             if (is_array($constraints['suggests']) && count($constraints['suggests'])) {
00313                 foreach ($constraints['suggests'] as $key => $value) {
00314                     if ($value) {
00315                         $tmp = t3lib_div::trimExplode('-', $value, TRUE);
00316                         if (trim($tmp[1]) && trim($tmp[1]) !== '0.0.0') {
00317                             $value = $tmp[0] . ' - ' . $tmp[1];
00318                         } else {
00319                             $value = $tmp[0];
00320                         }
00321                     }
00322                     $suggests[] = $key . ($value ? ' (' . $value . ')' : '');
00323                 }
00324             }
00325             if (count($depends)) {
00326                 $result['depends'] = htmlspecialchars(implode(', ', $depends));
00327             }
00328             if (count($conflicts)) {
00329                 $result['conflicts'] = htmlspecialchars(implode(', ', $conflicts));
00330             }
00331             if (count($suggests)) {
00332                 $result['suggests'] = htmlspecialchars(implode(', ', $suggests));
00333             }
00334         }
00335         return $result;
00336     }
00337 
00338     /**
00339      * Listing of loaded (installed) extensions
00340      *
00341      * @return  void
00342      */
00343     function extensionList_loaded() {
00344         global $TYPO3_LOADED_EXT;
00345 
00346         list($list, $cat) = $this->getInstalledExtensions();
00347 
00348         // Loaded extensions
00349         $content = '';
00350         $lines = array();
00351 
00352         // Available extensions
00353         if (is_array($cat[$this->parentObject->MOD_SETTINGS['listOrder']])) {
00354             $content = '';
00355             $lines = array();
00356             $lines[] = $this->extensionListRowHeader(' class="t3-row-header"', array('<td><img src="clear.gif" width="1" height="1" alt="" /></td>'));
00357 
00358             foreach ($cat[$this->parentObject->MOD_SETTINGS['listOrder']] as $catName => $extEkeys) {
00359 
00360                 natcasesort($extEkeys);
00361                 $extensions = array();
00362                 foreach ($extEkeys as $extKey => $data) {
00363                     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])) {
00364                         if (in_array($extKey, $this->parentObject->requiredExt)) {
00365                             $loadUnloadLink = '<strong>' . tx_em_Tools::rfw($GLOBALS['LANG']->getLL('extension_required_short')) . '</strong>';
00366                         } else {
00367                             $loadUnloadLink = '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array(
00368                                 'CMD[showExt]' => $extKey,
00369                                 'CMD[remove]' => 1
00370                             ))) . '">' . tx_em_Tools::removeButton() . '</a>';
00371                         }
00372 
00373                         $extensions[] = $this->extensionListRow($extKey, $list[$extKey], array('<td class="bgColor">' . $loadUnloadLink . '</td>'));
00374 
00375                     }
00376                 }
00377                 if (count($extensions)) {
00378                     $lines[] = '<tr><td colspan="' . (3 + $this->parentObject->detailCols[$this->parentObject->MOD_SETTINGS['display_details']]) . '"><br /></td></tr>';
00379                     $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>';
00380                     $lines[] = implode(LF, $extensions);
00381                 }
00382             }
00383         }
00384 
00385         $content .= '<form action="' . $this->parentObject->script . '" method="post" name="lookupform">';
00386         $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 />';
00387 
00388         $content .= '</form>
00389 
00390             <!-- Loaded Extensions List -->
00391             <table cellspacing="1" class="t3-em-extension-list t3-em-extension-list-loaded">' . implode('', $lines) . '</table>';
00392 
00393         return $content;
00394     }
00395 
00396     /**
00397      * Listing of available (installed) extensions
00398      *
00399      * @return  void
00400      */
00401     function extensionList_installed() {
00402 
00403         list($list, $cat) = $this->getInstalledExtensions();
00404 
00405         // Available extensions
00406         if (is_array($cat[$this->parentObject->MOD_SETTINGS['listOrder']])) {
00407             $content = '';
00408             $lines = array();
00409             $lines[] = $this->extensionListRowHeader(' class="t3-row-header"', array('<td><img src="clear.gif" width="18" height="1" alt="" /></td>'));
00410 
00411             $allKeys = array();
00412             foreach ($cat[$this->parentObject->MOD_SETTINGS['listOrder']] as $catName => $extEkeys) {
00413                 if (!$this->parentObject->MOD_SETTINGS['display_obsolete'] && $catName == 'obsolete') {
00414                     continue;
00415                 }
00416 
00417                 $allKeys[] = '';
00418                 $allKeys[] = 'TYPE: ' . $catName;
00419 
00420                 natcasesort($extEkeys);
00421                 $extensions = array();
00422                 foreach ($extEkeys as $extKey => $value) {
00423                     $allKeys[] = $extKey;
00424                     if ((!$list[$extKey]['EM_CONF']['shy'] || $this->parentObject->MOD_SETTINGS['display_shy']) &&
00425                             ($list[$extKey]['EM_CONF']['state'] != 'obsolete' || $this->parentObject->MOD_SETTINGS['display_obsolete'])
00426                             && $this->parentObject->searchExtension($extKey, $list[$extKey])) {
00427                         $loadUnloadLink = t3lib_extMgm::isLoaded($extKey) ?
00428                                 '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array(
00429                                     'CMD[showExt]' => $extKey,
00430                                     'CMD[remove]' => 1,
00431                                     'CMD[clrCmd]' => 1,
00432                                     'SET[singleDetails]' => 'info'
00433                                 ))) . '">' . tx_em_Tools::removeButton() . '</a>' :
00434                                 '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array(
00435                                     'CMD[showExt]' => $extKey,
00436                                     'CMD[load]' => 1,
00437                                     'CMD[clrCmd]' => 1,
00438                                     'SET[singleDetails]' => 'info'
00439                                 ))) . '">' . tx_em_Tools::installButton() . '</a>';
00440                         if (in_array($extKey, $this->parentObject->requiredExt)) {
00441                             $loadUnloadLink = '<strong>' . tx_em_Tools::rfw($GLOBALS['LANG']->getLL('extension_required_short')) . '</strong>';
00442                         }
00443                         $theRowClass = t3lib_extMgm::isLoaded($extKey) ? 'em-listbg1' : 'em-listbg2';
00444                         $extensions[] = $this->extensionListRow($extKey, $list[$extKey], array('<td class="bgColor">' . $loadUnloadLink . '</td>'), $theRowClass);
00445                     }
00446                 }
00447                 if (count($extensions)) {
00448                     $lines[] = '<tr><td colspan="' . (3 + $this->parentObject->detailCols[$this->parentObject->MOD_SETTINGS['display_details']]) . '"><br /></td></tr>';
00449                     $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>';
00450                     $lines[] = implode(LF, $extensions);
00451                 }
00452             }
00453 
00454             $content .= '
00455 
00456 
00457 <!--
00458 EXTENSION KEYS:
00459 
00460 ' . trim(implode(LF, $allKeys)) . '
00461 
00462 -->
00463 
00464 ';
00465 
00466             $content .= sprintf($GLOBALS['LANG']->getLL('how_to_install'), tx_em_Tools::installButton()) . ' <br />' .
00467                     sprintf($GLOBALS['LANG']->getLL('how_to_uninstall'), tx_em_Tools::removeButton()) . ' <br /><br />';
00468             $content .= '<form action="' . $this->parentObject->script . '" method="post" name="lookupform">';
00469             $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 />';
00470             $content .= $this->securityHint . '<br /><br />';
00471 
00472             $content .= '<table cellspacing="1" class="t3-em-extension-list t3-em-extension-list-installed">' . implode('', $lines) . '</table>';
00473 
00474             return $content;
00475         }
00476     }
00477 
00478 
00479     /**
00480      * Prints the header row for the various listings
00481      *
00482      * @param   string      Attributes for the <tr> tag
00483      * @param   array       Preset cells in the beginning of the row. Typically a blank cell with a clear-gif
00484      * @param   boolean     If set, the list is coming from remote server.
00485      * @return  string      HTML <tr> table row
00486      */
00487     function extensionListRowHeader($trAttrib, $cells, $import = 0) {
00488         $cells[] = '<td></td>';
00489         $cells[] = '<td>' . $GLOBALS['LANG']->getLL('extInfoArray_title') . '</td>';
00490 
00491         if (!$this->parentObject->MOD_SETTINGS['display_details']) {
00492             $cells[] = '<td>' . $GLOBALS['LANG']->getLL('extInfoArray_description') . '</td>';
00493             $cells[] = '<td>' . $GLOBALS['LANG']->getLL('extInfoArray_author') . '</td>';
00494         } elseif ($this->parentObject->MOD_SETTINGS['display_details'] == 2) {
00495             $cells[] = '<td>' . $GLOBALS['LANG']->getLL('extInfoArray_priority') . '</td>';
00496             $cells[] = '<td>' . $GLOBALS['LANG']->getLL('listRowHeader_modifies_tables_short') . '</td>';
00497             $cells[] = '<td>' . $GLOBALS['LANG']->getLL('listRowHeader_modules') . '</td>';
00498             $cells[] = '<td>' . $GLOBALS['LANG']->getLL('listRowHeader_clear_cache_short') . '</td>';
00499             $cells[] = '<td>' . $GLOBALS['LANG']->getLL('extInfoArray_internal') . '</td>';
00500             $cells[] = '<td>' . $GLOBALS['LANG']->getLL('extInfoArray_shy') . '</td>';
00501         } elseif ($this->parentObject->MOD_SETTINGS['display_details'] == 3) {
00502             $cells[] = '<td>' . $GLOBALS['LANG']->getLL('listRowHeader_tables_fields') . '</td>';
00503             $cells[] = '<td>' . $GLOBALS['LANG']->getLL('listRowHeader_ts_files') . '</td>';
00504             $cells[] = '<td>' . $GLOBALS['LANG']->getLL('listRowHeader_affects') . '</td>';
00505             $cells[] = '<td>' . $GLOBALS['LANG']->getLL('listRowHeader_modules') . '</td>';
00506             $cells[] = '<td>' . $GLOBALS['LANG']->getLL('listRowHeader_config') . '</td>';
00507             $cells[] = '<td>' . $GLOBALS['LANG']->getLL('extInfoArray_code_warnings') . '</td>';
00508         } elseif ($this->parentObject->MOD_SETTINGS['display_details'] == 4) {
00509             $cells[] = '<td>' . $GLOBALS['LANG']->getLL('listRowHeader_locallang') . '</td>';
00510             $cells[] = '<td>' . $GLOBALS['LANG']->getLL('listRowHeader_classes') . '</td>';
00511             $cells[] = '<td>' . $GLOBALS['LANG']->getLL('extInfoArray_code_warnings') . '</td>';
00512             $cells[] = '<td>' . $GLOBALS['LANG']->getLL('extInfoArray_annoyances') . '</td>';
00513         } elseif ($this->parentObject->MOD_SETTINGS['display_details'] == 5) {
00514             $cells[] = '<td>' . $GLOBALS['LANG']->getLL('listRowHeader_changed_files') . '</td>';
00515         } else {
00516             $cells[] = '<td>' . $GLOBALS['LANG']->getLL('listRowHeader_ext_key') . '</td>';
00517             $cells[] = '<td>' . $GLOBALS['LANG']->getLL('extInfoArray_version') . '</td>';
00518             if (!$import) {
00519                 $cells[] = '<td>' . $GLOBALS['LANG']->getLL('listRowHeader_download_short') . '</td>';
00520                 $cells[] = '<td>' . $GLOBALS['LANG']->getLL('listRowHeader_documentation_short') . '</td>';
00521                 $cells[] = '<td>' . $GLOBALS['LANG']->getLL('listRowHeader_type') . '</td>';
00522             } else {
00523                 $cells[] = '<td' . tx_em_Tools::labelInfo($GLOBALS['LANG']->getLL('listRowHeader_title_upload_date')) . '>' .
00524                         $GLOBALS['LANG']->getLL('listRowHeader_upload_date') . '</td>';
00525                 $cells[] = '<td>' . $GLOBALS['LANG']->getLL('extInfoArray_author') . '</td>';
00526                 $cells[] = '<td' . tx_em_Tools::labelInfo($GLOBALS['LANG']->getLL('listRowHeader_title_current_version')) . '>' .
00527                         $GLOBALS['LANG']->getLL('listRowHeader_current_version') . '</td>';
00528                 $cells[] = '<td' . tx_em_Tools::labelInfo($GLOBALS['LANG']->getLL('listRowHeader_title_current_type')) . '>' .
00529                         $GLOBALS['LANG']->getLL('listRowHeader_current_type') . '</td>';
00530                 $cells[] = '<td' . tx_em_Tools::labelInfo($GLOBALS['LANG']->getLL('listRowHeader_title_number_of_downloads')) . '>' .
00531                         $GLOBALS['LANG']->getLL('listRowHeader_download_short') . '</td>';
00532             }
00533             $cells[] = '<td>' . $GLOBALS['LANG']->getLL('extInfoArray_state') . '</td>';
00534         }
00535         return '
00536             <tr' . $trAttrib . '>
00537                 ' . implode('
00538                 ', $cells) . '
00539             </tr>';
00540     }
00541 
00542 
00543     /**
00544      * Prints a row with data for the various extension listings
00545      *
00546      * @param   string      Extension key
00547      * @param   array       Extension information array
00548      * @param   array       Preset table cells, eg. install/uninstall icons.
00549      * @param   string      <tr> tag class
00550      * @param   array       Array with installed extension keys (as keys)
00551      * @param   boolean     If set, the list is coming from remote server.
00552      * @param   string      Alternative link URL
00553      * @return  string      HTML <tr> content
00554      */
00555     function extensionListRow($extKey, $extInfo, $cells, $bgColorClass = '', $inst_list = array(), $import = 0, $altLinkUrl = '') {
00556         $stateColors = tx_em_Tools::getStateColors();
00557 
00558         // Icon:
00559         $imgInfo = @getImageSize(tx_em_Tools::getExtPath($extKey, $extInfo['type']) . '/ext_icon.gif');
00560         if (is_array($imgInfo)) {
00561             $cells[] = '<td><img src="' . $GLOBALS['BACK_PATH'] . tx_em_Tools::typeRelPath($extInfo['type']) . $extKey . '/ext_icon.gif' . '" ' . $imgInfo[3] . ' alt="" /></td>';
00562         } elseif ($extInfo['_ICON']) {
00563             $cells[] = '<td>' . $extInfo['_ICON'] . '</td>';
00564         } else {
00565             $cells[] = '<td><img src="clear.gif" width="1" height="1" alt="" /></td>';
00566         }
00567 
00568         // Extension title:
00569         $cells[] = '<td nowrap="nowrap"><a href="' . htmlspecialchars($altLinkUrl ? $altLinkUrl : t3lib_div::linkThisScript(array(
00570             'CMD[showExt]' => $extKey,
00571             'SET[singleDetails]' => 'info'
00572         ))) . '" title="' . htmlspecialchars($extInfo['EM_CONF']['description']) . '">'
00573                 . t3lib_div::fixed_lgd_cs($extInfo['EM_CONF']['title'] ? htmlspecialchars($extInfo['EM_CONF']['title']) : '<em>' . $extKey . '</em>', 40) . '</a></td>';
00574 
00575         // Based on the display mode you will see more or less details:
00576         if (!$this->parentObject->MOD_SETTINGS['display_details']) {
00577             $cells[] = '<td>' . htmlspecialchars(t3lib_div::fixed_lgd_cs($extInfo['EM_CONF']['description'], 400)) . '<br /><img src="clear.gif" width="300" height="1" alt="" /></td>';
00578             $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>';
00579         } elseif ($this->parentObject->MOD_SETTINGS['display_details'] == 2) {
00580             $cells[] = '<td nowrap="nowrap">' . $extInfo['EM_CONF']['priority'] . '</td>';
00581             $cells[] = '<td nowrap="nowrap">' . implode('<br />', t3lib_div::trimExplode(',', $extInfo['EM_CONF']['modify_tables'], 1)) . '</td>';
00582             $cells[] = '<td nowrap="nowrap">' . $extInfo['EM_CONF']['module'] . '</td>';
00583             $cells[] = '<td nowrap="nowrap">' . ($extInfo['EM_CONF']['clearCacheOnLoad'] ? $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:yes') : '') . '</td>';
00584             $cells[] = '<td nowrap="nowrap">' . ($extInfo['EM_CONF']['internal'] ? $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:yes') : '') . '</td>';
00585             $cells[] = '<td nowrap="nowrap">' . ($extInfo['EM_CONF']['shy'] ? $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:yes') : '') . '</td>';
00586         } elseif ($this->parentObject->MOD_SETTINGS['display_details'] == 3) {
00587             $techInfo = $this->install->makeDetailedExtensionAnalysis($extKey, $extInfo);
00588 
00589             $cells[] = '<td>' . $this->parentObject->extensionDetails->extInformationArray_dbReq($techInfo) .
00590                     '</td>';
00591             $cells[] = '<td nowrap="nowrap">' . (is_array($techInfo['TSfiles']) ? implode('<br />', $techInfo['TSfiles']) : '') . '</td>';
00592             $cells[] = '<td nowrap="nowrap">' . (is_array($techInfo['flags']) ? implode('<br />', $techInfo['flags']) : '') . '</td>';
00593             $cells[] = '<td nowrap="nowrap">' . (is_array($techInfo['moduleNames']) ? implode('<br />', $techInfo['moduleNames']) : '') . '</td>';
00594             $cells[] = '<td nowrap="nowrap">' . ($techInfo['conf'] ? $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:yes') : '') . '</td>';
00595             $cells[] = '<td>' .
00596                     tx_em_Tools::rfw((t3lib_extMgm::isLoaded($extKey) && $techInfo['tables_error'] ?
00597                             '<strong>' . $GLOBALS['LANG']->getLL('extInfoArray_table_error') . '</strong><br />' .
00598                                     $GLOBALS['LANG']->getLL('extInfoArray_missing_fields') : '') .
00599                             (t3lib_extMgm::isLoaded($extKey) && $techInfo['static_error'] ?
00600                                     '<strong>' . $GLOBALS['LANG']->getLL('extInfoArray_static_table_error') . '</strong><br />' .
00601                                             $GLOBALS['LANG']->getLL('extInfoArray_static_tables_missing_empty') : '')) .
00602                     '</td>';
00603         } elseif ($this->parentObject->MOD_SETTINGS['display_details'] == 4) {
00604             $techInfo = $this->install->makeDetailedExtensionAnalysis($extKey, $extInfo, 1);
00605 
00606             $cells[] = '<td>' . (is_array($techInfo['locallang']) ? implode('<br />', $techInfo['locallang']) : '') . '</td>';
00607             $cells[] = '<td>' . (is_array($techInfo['classes']) ? implode('<br />', $techInfo['classes']) : '') . '</td>';
00608             $cells[] = '<td>' . (is_array($techInfo['errors']) ? tx_em_Tools::rfw(implode('<hr />', $techInfo['errors'])) : '') . '</td>';
00609             $cells[] = '<td>' . (is_array($techInfo['NSerrors']) ?
00610                     (!t3lib_div::inList($this->parentObject->nameSpaceExceptions, $extKey) ?
00611                             t3lib_utility_Debug::viewarray($techInfo['NSerrors']) :
00612                             tx_em_Tools::dfw($GLOBALS['LANG']->getLL('extInfoArray_exception'))) : '') . '</td>';
00613         } elseif ($this->parentObject->MOD_SETTINGS['display_details'] == 5) {
00614             $currentMd5Array = $this->parentObject->extensionDetails->serverExtensionMD5array($extKey, $extInfo);
00615             $affectedFiles = '';
00616             $msgLines = array();
00617             $msgLines[] = $GLOBALS['LANG']->getLL('listRow_files') . ' ' . count($currentMd5Array);
00618             if (strcmp($extInfo['EM_CONF']['_md5_values_when_last_written'], serialize($currentMd5Array))) {
00619                 $msgLines[] = tx_em_Tools::rfw('<br /><strong>' . $GLOBALS['LANG']->getLL('extInfoArray_difference_detected') . '</strong>');
00620                 $affectedFiles = tx_em_Tools::findMD5ArrayDiff($currentMd5Array, unserialize($extInfo['EM_CONF']['_md5_values_when_last_written']));
00621                 if (count($affectedFiles)) {
00622                     $msgLines[] = '<br /><strong>' . $GLOBALS['LANG']->getLL('extInfoArray_modified_files') . '</strong><br />' .
00623                             tx_em_Tools::rfw(implode('<br />', $affectedFiles));
00624                 }
00625             }
00626             $cells[] = '<td>' . implode('<br />', $msgLines) . '</td>';
00627         } else {
00628             // Default view:
00629             $verDiff = $inst_list[$extKey] && tx_em_Tools::versionDifference($extInfo['EM_CONF']['version'], $inst_list[$extKey]['EM_CONF']['version'], $this->parentObject->versionDiffFactor);
00630 
00631             $cells[] = '<td nowrap="nowrap"><em>' . $extKey . '</em></td>';
00632             $cells[] = '<td nowrap="nowrap">' . ($verDiff ? '<strong>' . tx_em_Tools::rfw(htmlspecialchars($extInfo['EM_CONF']['version'])) . '</strong>' : $extInfo['EM_CONF']['version']) . '</td>';
00633             if (!$import) { // Listing extension on LOCAL server:
00634                 // Extension Download:
00635                 $cells[] = '<td nowrap="nowrap"><a href="' . htmlspecialchars(t3lib_div::linkThisScript(array(
00636                     'CMD[doBackup]' => 1,
00637                     'SET[singleDetails]' => 'backup',
00638                     'CMD[showExt]' => $extKey
00639                 ))) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:download') . '">' .
00640                         t3lib_iconWorks::getSpriteIcon('actions-system-extension-download') .
00641                         '</a></td>';
00642 
00643                 // Manual download
00644                 $manual = tx_em_Tools::typePath($extInfo['type']) . $extKey . '/doc/manual.sxw';
00645                 $manualRelPath = t3lib_div::resolveBackPath($this->parentObject->doc->backPath . tx_em_Tools::typeRelPath($extInfo['type'])) . $extKey . '/doc/manual.sxw';
00646                 if ($extInfo['EM_CONF']['docPath']) {
00647                     $manual = tx_em_Tools::typePath($extInfo['type']) . $extKey . '/' . $extInfo['EM_CONF']['docPath'] . '/manual.sxw';
00648                     $manualRelPath = t3lib_div::resolveBackPath($this->parentObject->doc->backPath . tx_em_Tools::typeRelPath($extInfo['type'])) . $extKey . '/' . $extInfo['EM_CONF']['docPath'] . '/manual.sxw';
00649                 }
00650                 $cells[] = '<td nowrap="nowrap">' .
00651                         (tx_em_Tools::typePath($extInfo['type']) && @is_file($manual) ?
00652                                 '<a href="' . htmlspecialchars($manualRelPath) . '" target="_blank" title="' . $GLOBALS['LANG']->getLL('listRow_local_manual') . '">' .
00653                                         t3lib_iconWorks::getSpriteIcon('actions-system-extension-documentation') . '</a>' : '') .
00654                         '</td>';
00655 
00656                 // Double installation (inclusion of an extension in more than one of system, global or local scopes)
00657                 $doubleInstall = '';
00658                 if (strlen($extInfo['doubleInstall']) > 1) {
00659                     // Separate the "SL" et al. string into an array and replace L by Local, G by Global etc.
00660                     $doubleInstallations = str_replace(
00661                         array('S', 'G', 'L'),
00662                         array(
00663                             $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:sysext'),
00664                             $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:globalext'),
00665                             $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:localext')
00666                         ),
00667                         str_split($extInfo['doubleInstall'])
00668                     );
00669                     // Last extension is the one actually used
00670                     $usedExtension = array_pop($doubleInstallations);
00671                     // Next extension is overridden
00672                     $overriddenExtensions = array_pop($doubleInstallations);
00673                     // If the array is not yet empty, the extension is actually installed 3 times (SGL)
00674                     if (count($doubleInstallations) > 0) {
00675                         $lastExtension = array_pop($doubleInstallations);
00676                         $overriddenExtensions .= ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:and') . ' ' . $lastExtension;
00677                     }
00678                     $doubleInstallTitle = sprintf(
00679                         $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:double_inclusion'),
00680                         $usedExtension,
00681                         $overriddenExtensions
00682                     );
00683                     $doubleInstall = ' <strong><abbr title="' . $doubleInstallTitle . '">' . tx_em_Tools::rfw($extInfo['doubleInstall']) . '</abbr></strong>';
00684                 }
00685                 $cells[] = '<td nowrap="nowrap">' . $this->types[$extInfo['type']] . $doubleInstall . '</td>';
00686             } else { // Listing extensions from REMOTE repository:
00687                 $inst_curVer = $inst_list[$extKey]['EM_CONF']['version'];
00688                 if (isset($inst_list[$extKey])) {
00689                     if ($verDiff) {
00690                         $inst_curVer = '<strong>' . tx_em_Tools::rfw($inst_curVer) . '</strong>';
00691                     }
00692                 }
00693                 $cells[] = '<td nowrap="nowrap">' . t3lib_befunc::date($extInfo['EM_CONF']['lastuploaddate']) . '</td>';
00694                 $cells[] = '<td nowrap="nowrap">' . htmlspecialchars(t3lib_div::fixed_lgd_cs($extInfo['EM_CONF']['author'], $GLOBALS['BE_USER']->uc[titleLen])) . '</td>';
00695                 $cells[] = '<td nowrap="nowrap">' . $inst_curVer . '</td>';
00696                 $cells[] = '<td nowrap="nowrap">' . $this->api->typeLabels[$inst_list[$extKey]['type']] . (strlen($inst_list[$extKey]['doubleInstall']) > 1 ? '<strong> ' . tx_em_Tools::rfw($inst_list[$extKey]['doubleInstall']) . '</strong>' : '') . '</td>';
00697                 $cells[] = '<td nowrap="nowrap">' . ($extInfo['downloadcounter_all'] ? $extInfo['downloadcounter_all'] : '&nbsp;&nbsp;') . '/' . ($extInfo['downloadcounter'] ? $extInfo['downloadcounter'] : '&nbsp;') . '</td>';
00698             }
00699             $cells[] = '<td nowrap="nowrap" class="extstate" style="background-color:' . $stateColors[$extInfo['EM_CONF']['state']] . ';">' . $this->states[$extInfo['EM_CONF']['state']] . '</td>';
00700         }
00701 
00702         // show a different background through a different class for insecure (-1) extensions,
00703         // for unreviewed (0) and reviewed extensions (1), just use the regular class
00704         if ($this->xmlHandler->getReviewState($extKey, $extInfo['EM_CONF']['version']) < 0) {
00705             $bgclass = ' class="unsupported-ext"';
00706         } else {
00707             $bgclass = ' class="' . ($bgColorClass ? $bgColorClass : 'em-listbg1') . '"';
00708         }
00709 
00710         return '
00711             <tr' . $bgclass . '>
00712                 ' . implode('
00713                 ', $cells) . '
00714             </tr>';
00715     }
00716 
00717 
00718     /**
00719      *  Displays a list of extensions where a newer version is available
00720      *  in the TER than the one that is installed right now
00721      *  integrated from the extension "ter_update_check" for TYPO3 4.2 by Christian Welzel
00722      *
00723      * @return string
00724      */
00725     function showExtensionsToUpdate() {
00726         global $LANG;
00727         $extList = $this->getInstalledExtensions();
00728 
00729         $content = '<table cellspacing="1" class="t3-em-extension-list t3-em-extension-list-to-update">' .
00730                 '<tr class="t3-row-header">' .
00731                 '<td></td>' .
00732                 '<td>' . $LANG->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:tab_mod_name') . '</td>' .
00733                 '<td>' . $LANG->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:tab_mod_key') . '</td>' .
00734                 '<td>' . $LANG->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:tab_mod_loc_ver') . '</td>' .
00735                 '<td>' . $LANG->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:tab_mod_rem_ver') . '</td>' .
00736                 '<td>' . $LANG->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:tab_mod_location') . '</td>' .
00737                 '<td>' . $LANG->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:tab_mod_comment') . '</td>' .
00738                 '</tr>';
00739 
00740         foreach ($extList[0] as $name => $data) {
00741             $this->xmlHandler->searchExtensionsXMLExact($name, '', '', TRUE, TRUE);
00742             if (!is_array($this->xmlHandler->extensionsXML[$name])) {
00743                 continue;
00744             }
00745 
00746             $v = $this->xmlHandler->extensionsXML[$name]['versions'];
00747             $versions = array_keys($v);
00748             natsort($versions);
00749             $lastversion = end($versions);
00750 
00751             if ((t3lib_extMgm::isLoaded($name) || $this->parentObject->MOD_SETTINGS['display_installed']) &&
00752                     ($data['EM_CONF']['shy'] == 0 || $this->parentObject->MOD_SETTINGS['display_shy']) &&
00753                     tx_em_Tools::versionDifference($lastversion, $data['EM_CONF']['version'], 1)) {
00754 
00755                 $imgInfo = @getImageSize(tx_em_Tools::getExtPath($name, $data['type']) . '/ext_icon.gif');
00756                 if (is_array($imgInfo)) {
00757                     $icon = '<img src="' . $GLOBALS['BACK_PATH'] . tx_em_Tools::typeRelPath($data['type']) . $name . '/ext_icon.gif' . '" ' . $imgInfo[3] . ' alt="" />';
00758                 } elseif ($data['_ICON']) { //TODO: see if this can be removed, seems to be wrong in this context
00759                     $icon = $data['_ICON'];
00760                 } else {
00761                     $icon = '<img src="clear.gif" width="1" height="1" alt="" />';
00762                 }
00763                 $comment = '<table cellpadding="0" cellspacing="0" width="100%">';
00764                 foreach ($versions as $vk) {
00765                     $va = & $v[$vk];
00766                     if (t3lib_div::int_from_ver($vk) <= t3lib_div::int_from_ver($data['EM_CONF']['version'])) {
00767                         continue;
00768                     }
00769                     $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>';
00770                 }
00771                 $comment .= '</table>';
00772 
00773                 $serverMD5Array = $this->parentObject->extensionDetails->serverExtensionMD5array($name, $data);
00774                 if (is_array($serverMD5Array)) {
00775                     ksort($serverMD5Array);
00776                 }
00777                 $currentMD5Array = unserialize($data['EM_CONF']['_md5_values_when_last_written']);
00778                 if (is_array($currentMD5Array)) {
00779                     @ksort($currentMD5Array);
00780                 }
00781                 $warn = '';
00782                 if (strcmp(serialize($currentMD5Array), serialize($serverMD5Array))) {
00783                     $warn = '<tr class="bgColor4" style="color:red"><td colspan="7">' . tx_em_Tools::rfw('<br /><strong>' . $name . ': ' . $LANG->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:msg_warn_diff') . '</strong>') . '</td></tr>' . LF;
00784                     if ($this->parentObject->MOD_SETTINGS['display_files'] == 1) {
00785                         $affectedFiles = tx_em_Tools::findMD5ArrayDiff($serverMD5Array, $currentMD5Array);
00786                         if (count($affectedFiles)) {
00787                             $warn .= '<tr class="bgColor4"><td colspan="7"><strong>' . $LANG->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:msg_modified') . '</strong><br />' . tx_em_Tools::rfw(implode('<br />', $affectedFiles)) . '</td></tr>' . LF;
00788                         }
00789                     }
00790                 }
00791 
00792                 $content .= '<tr class="bgColor4"><td valign="top">' . $icon . '</td>' .
00793                         '<td valign="top">' . ($data['EM_CONF']['state'] == 'excludeFromUpdates'
00794                             ? '<span style="color:#cf7307">' . $data['EM_CONF']['title'] . ' ' . $LANG->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:write_protected') . '</span>'
00795                             : '<a href="' . t3lib_div::linkThisScript(array(
00796                                 'CMD[importExtInfo]' => $name
00797                                 )) . '">' . $data[EM_CONF][title] . '</a>') . '</td>' .
00798                         '<td valign="top">' . $name . '</td>' .
00799                         '<td valign="top" align="right">' . $data[EM_CONF][version] . '</td>' .
00800                         '<td valign="top" align="right">' . $lastversion . '</td>' .
00801                         '<td valign="top" nowrap="nowrap">' . $this->api->typeLabels[$data['type']] . (strlen($data['doubleInstall']) > 1 ? '<strong> ' . tx_em_Tools::rfw($data['doubleInstall']) . '</strong>' : '') . '</td>' .
00802                         '<td valign="top">' . $comment . '</td></tr>' . LF .
00803                         $warn .
00804                         '<tr class="bgColor4"><td colspan="7"><hr style="margin:0px" /></td></tr>' . LF;
00805             }
00806         }
00807 
00808         return $content . '</table><br />';
00809     }
00810 
00811     /**
00812      * Maps remote extensions information into $cat/$list arrays for listing
00813      *
00814      * @param   boolean     If set the info in the internal extensionsXML array will be unset before returning the result.
00815      * @return  array       List array and category index as key 0 / 1 in an array.
00816      */
00817     function prepareImportExtList($unsetProc = false) {
00818         $list = array();
00819         $cat = tx_em_Tools::getDefaultCategory();
00820         $filepath = $this->parentObject->getMirrorURL();
00821 
00822         foreach ($this->parentObject->xmlHandler->extensionsXML as $extKey => $data) {
00823             $GLOBALS['LANG']->csConvObj->convarray($data, 'utf-8', $GLOBALS['LANG']->charSet); // is there a better place for conversion?
00824             $list[$extKey]['type'] = '_';
00825             $version = array_keys($data['versions']);
00826             $extPath = t3lib_div::strtolower($extKey);
00827             $list[$extKey]['_ICON'] = '<img alt="" src="' . $filepath . $extPath{0} . '/' . $extPath{1} . '/' . $extPath . '_' . end($version) . '.gif" />';
00828             $list[$extKey]['downloadcounter'] = $data['downloadcounter'];
00829 
00830             foreach (array_keys($data['versions']) as $version) {
00831                 $list[$extKey]['versions'][$version]['downloadcounter'] = $data['versions'][$version]['downloadcounter'];
00832 
00833                 $list[$extKey]['versions'][$version]['EM_CONF'] = array(
00834                     'version' => $version,
00835                     'title' => $data['versions'][$version]['title'],
00836                     'description' => $data['versions'][$version]['description'],
00837                     'category' => $data['versions'][$version]['category'],
00838                     'constraints' => $data['versions'][$version]['dependencies'],
00839                     'state' => $data['versions'][$version]['state'],
00840                     'reviewstate' => $data['versions'][$version]['reviewstate'],
00841                     'lastuploaddate' => $data['versions'][$version]['lastuploaddate'],
00842                     'author' => $data['versions'][$version]['authorname'],
00843                     'author_email' => $data['versions'][$version]['authoremail'],
00844                     'author_company' => $data['versions'][$version]['authorcompany'],
00845                 );
00846             }
00847             tx_em_Tools::setCat($cat, $list[$extKey]['versions'][$version], $extKey);
00848             if ($unsetProc) {
00849                 unset($this->parentObject->xmlHandler->extensionsXML[$extKey]);
00850             }
00851         }
00852 
00853         return array($list, $cat);
00854     }
00855 
00856 
00857     /**
00858      * Adds extension to extension list and returns new list. If -1 is returned, an error happend.
00859      * Checks dependencies etc.
00860      *
00861      * @param   string      Extension key
00862      * @param   array       Extension information array - information about installed extensions
00863      * @return  string      New list of installed extensions or -1 if error
00864      * @see showExtDetails()
00865      */
00866     function addExtToList($extKey, $instExtInfo) {
00867         global $TYPO3_LOADED_EXT;
00868 
00869         // ext_emconf.php information:
00870         $conf = $instExtInfo[$extKey]['EM_CONF'];
00871 
00872         // Get list of installed extensions and add this one.
00873         $listArr = array_keys($TYPO3_LOADED_EXT);
00874         if ($conf['priority'] == 'top') {
00875             array_unshift($listArr, $extKey);
00876         } else {
00877             $listArr[] = $extKey;
00878         }
00879 
00880         // Manage other circumstances:
00881         $listArr = tx_em_Tools::managesPriorities($listArr, $instExtInfo);
00882         $listArr = $this->removeRequiredExtFromListArr($listArr);
00883 
00884         // Implode unique list of extensions to load and return:
00885         $list = implode(',', array_unique($listArr));
00886 
00887         return $list;
00888     }
00889 
00890     /**
00891      * Remove extension key from the list of currently installed extensions and return list. If -1 is returned, an error happend.
00892      * Checks dependencies etc.
00893      *
00894      * @param   string      Extension key
00895      * @param   array       Extension information array - information about installed extensions
00896      * @return  string      New list of installed extensions or -1 if error
00897      * @see showExtDetails()
00898      */
00899     function removeExtFromList($extKey, $instExtInfo) {
00900         global $TYPO3_LOADED_EXT;
00901 
00902         // Initialize:
00903         $depList = array();
00904         $listArr = array_keys($TYPO3_LOADED_EXT);
00905 
00906         // 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!
00907         foreach ($listArr as $k => $ext) {
00908             if ($instExtInfo[$ext]['EM_CONF']['dependencies']) {
00909                 $dep = t3lib_div::trimExplode(',', $instExtInfo[$ext]['EM_CONF']['dependencies'], 1);
00910                 if (in_array($extKey, $dep)) {
00911                     $depList[] = $ext;
00912                 }
00913             }
00914             if (!strcmp($ext, $extKey)) {
00915                 unset($listArr[$k]);
00916             }
00917         }
00918 
00919         // Returns either error or the new list
00920         if (count($depList)) {
00921             $msg = sprintf($GLOBALS['LANG']->getLL('removeExtFromList_dependency'),
00922                 implode(', ', $depList)
00923             );
00924             $this->parentObject->content .= $this->parentObject->doc->section($GLOBALS['LANG']->getLL('removeExtFromList_dependency_error'), $msg, 0, 1, 2);
00925             return -1;
00926         } else {
00927             $listArr = $this->removeRequiredExtFromListArr($listArr);
00928             $list = implode(',', array_unique($listArr));
00929             return $list;
00930         }
00931     }
00932 
00933     /**
00934      * 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
00935      *
00936      * @param   array       Array of extension keys as values
00937      * @return  array       Modified array
00938      * @see removeExtFromList(), addExtToList()
00939      */
00940     function removeRequiredExtFromListArr($listArr) {
00941         $requiredExtensions = t3lib_div::trimExplode(',', t3lib_extMgm::getRequiredExtensionList(), 1);
00942         foreach ($listArr as $k => $ext) {
00943             if (in_array($ext, $requiredExtensions) || !strcmp($ext, '_CACHEFILE')) {
00944                 unset($listArr[$k]);
00945             }
00946         }
00947         return $listArr;
00948     }
00949 
00950     /**
00951      * Returns array index of extKey entry
00952      *
00953      * @param  string  $extKey
00954      * @param  array  $list
00955      * @return intval|bool index of array or FALSE if not found
00956      */
00957     protected function findIndex($extKey, $list) {
00958         foreach ($list as $key => $value) {
00959             if ($value['extkey'] === $extKey) {
00960                 return $key;
00961             }
00962         }
00963         return FALSE;
00964     }
00965 }
00966 
00967 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/sysext/em/classes/extensions/class.tx_em_extensions_list.php'])) {
00968     include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/sysext/em/classes/extensions/class.tx_em_extensions_list.php']);
00969 }
00970 
00971 ?>