TYPO3 API  SVNRelease
index.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003  *  Copyright notice
00004  *
00005  *  (c) 1999-2010 Kasper Skårhøj (kasperYYYY@typo3.com)
00006  *  (c) 2005-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 /**
00029  * Module: Extension manager
00030  *
00031  * $Id: index.php 2083 2010-03-22 00:48:31Z steffenk $
00032  *
00033  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00034  * @author  Karsten Dambekalns <karsten@typo3.org>
00035  * @author  Steffen Kamper <info@sk-typo3.de>
00036  */
00037 
00038 $GLOBALS['LANG']->includeLLFile(t3lib_extMgm::extPath('em') . 'language/locallang.xml');
00039 
00040 // from tx_ter by Robert Lemke
00041 define('TX_TER_RESULT_EXTENSIONSUCCESSFULLYUPLOADED', '10504');
00042 
00043 define('EM_INSTALL_VERSION_MIN', 1);
00044 define('EM_INSTALL_VERSION_MAX', 2);
00045 define('EM_INSTALL_VERSION_STRICT', 3);
00046 
00047 unset($MCONF);
00048 require('conf.php');
00049 
00050 $BE_USER->modAccess($MCONF, 1);
00051 
00052 
00053 /**
00054  * Module: Extension manager
00055  *
00056  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00057  * @author  Karsten Dambekalns <karsten@typo3.org>
00058  * @package TYPO3
00059  * @subpackage core
00060  */
00061 class SC_mod_tools_em_index extends t3lib_SCbase {
00062 
00063     // Internal, static:
00064     var $versionDiffFactor = 1; // This means that version difference testing for import is detected for sub-versions only, not dev-versions. Default: 1000
00065     var $systemInstall = 0; // If "1" then installs in the sysext directory is allowed. Default: 0
00066     var $requiredExt = ''; // List of required extension (from TYPO3_CONF_VARS)
00067     var $maxUploadSize = 31457280; // Max size in bytes of extension upload to repository
00068     var $kbMax = 500; // Max size in kilobytes for files to be edited.
00069     var $doPrintContent = true; // If set (default), the function printContent() will echo the content which was collected in $this->content. You can set this to FALSE in order to echo content from elsewhere, fx. when using outbut buffering
00070     var $listingLimit = 500; // List that many extension maximally at one time (fixing memory problems)
00071     var $listingLimitAuthor = 250; // List that many extension maximally at one time (fixing memory problems)
00072     var $script = ''; //URL to this script
00073 
00074 
00075     var $categories = array(); // Extension Categories (static var); see init()
00076 
00077     var $states = array(); // Extension States; see init()
00078 
00079     var $detailCols = array(
00080         0 => 2,
00081         1 => 5,
00082         2 => 6,
00083         3 => 6,
00084         4 => 4,
00085         5 => 1
00086     );
00087 
00088     var $fe_user = array(
00089         'username' => '',
00090         'password' => '',
00091     );
00092 
00093     var $privacyNotice; // Set in init()
00094     var $securityHint; // Set in init()
00095     var $editTextExtensions = 'html,htm,txt,css,tmpl,inc,php,sql,conf,cnf,pl,pm,sh,xml,ChangeLog';
00096     var $nameSpaceExceptions = 'beuser_tracking,design_components,impexp,static_file_edit,cms,freesite,quickhelp,classic_welcome,indexed_search,sys_action,sys_workflows,sys_todos,sys_messages,direct_mail,sys_stat,tt_address,tt_board,tt_calender,tt_guest,tt_links,tt_news,tt_poll,tt_rating,tt_products,setup,taskcenter,tsconfig_help,context_help,sys_note,tstemplate,lowlevel,install,belog,beuser,phpmyadmin,aboutmodules,imagelist,setup,taskcenter,sys_notepad,viewpage,adodb';
00097 
00098 
00099     // Default variables for backend modules
00100     var $MCONF = array(); // Module configuration
00101     var $MOD_MENU = array(); // Module menu items
00102     var $MOD_SETTINGS = array(); // Module session settings
00103     /**
00104      * Document Template Object
00105      *
00106      * @var noDoc
00107      */
00108     var $doc;
00109     var $content; // Accumulated content
00110 
00111     var $inst_keys = array(); // Storage of installed extensions
00112     var $gzcompress = 0; // Is set true, if system support compression.
00113 
00114     /**
00115      * Instance of EM API
00116      *
00117      * @var tx_em_API
00118      */
00119     protected $api;
00120 
00121     /**
00122      * Instance of TER connection handler
00123      *
00124      * @var tx_em_Connection_Ter
00125      */
00126     public $terConnection;
00127 
00128 
00129     /**
00130      * XML handling class for the TYPO3 Extension Manager
00131      *
00132      * @var tx_em_Tools_XmlHandler
00133      */
00134     public $xmlHandler;
00135 
00136 
00137     /**
00138      * Class for printing extension lists
00139      *
00140      * @var tx_em_Extensions_List
00141      */
00142     public $extensionList;
00143 
00144     /**
00145      * Class for extension details
00146      *
00147      * @var tx_em_Extensions_Details
00148      */
00149     public $extensionDetails;
00150 
00151     /**
00152      * Class for new ExtJs Extension Manager
00153      *
00154      * @var tx_em_ExtensionManager
00155      */
00156     public $extensionmanager;
00157 
00158     /**
00159      * Class for translation handling
00160      *
00161      * @var tx_em_Translations
00162      */
00163     public $translations;
00164 
00165     /**
00166      * Class for install extensions
00167      *
00168      * @var tx_em_Install
00169      */
00170     public $install;
00171 
00172     /**
00173      * Settings object
00174      *
00175      * @var tx_em_Settings
00176      */
00177     public $settings;
00178 
00179 
00180     var $JScode; // JavaScript code to be forwared to $this->doc->JScode
00181 
00182     // GPvars:
00183     var $CMD = array(); // CMD array
00184     var $listRemote; // If set, connects to remote repository
00185     var $lookUpStr; // Search string when listing local extensions
00186 
00187 
00188     protected $noDocHeader = 0;
00189 
00190     /*********************************
00191      *
00192      * Standard module initialization
00193      *
00194      *********************************/
00195 
00196     /**
00197      * Standard init function of a module.
00198      *
00199      * @return  void
00200      */
00201     function init() {
00202         global $BE_USER, $LANG, $BACK_PATH, $TYPO3_CONF_VARS;
00203 
00204         /**
00205          * Extension Categories (static var)
00206          * Content must be redundant with the same internal variable as in class.tx_extrep.php!
00207          */
00208         $this->categories = array(
00209             'be' => $GLOBALS['LANG']->getLL('category_BE'),
00210             'module' => $GLOBALS['LANG']->getLL('category_BE_modules'),
00211             'fe' => $GLOBALS['LANG']->getLL('category_FE'),
00212             'plugin' => $GLOBALS['LANG']->getLL('category_FE_plugins'),
00213             'misc' => $GLOBALS['LANG']->getLL('category_miscellanous'),
00214             'services' => $GLOBALS['LANG']->getLL('category_services'),
00215             'templates' => $GLOBALS['LANG']->getLL('category_templates'),
00216             'example' => $GLOBALS['LANG']->getLL('category_examples'),
00217             'doc' => $GLOBALS['LANG']->getLL('category_documentation')
00218         );
00219 
00220         /**
00221          * Extension States
00222          * Content must be redundant with the same internal variable as in class.tx_extrep.php!
00223          */
00224         $this->states = tx_em_Tools::getStates();
00225 
00226         $this->script = 'mod.php?M=tools_em';
00227         $this->privacyNotice = $GLOBALS['LANG']->getLL('privacy_notice');
00228         $securityMessage = $GLOBALS['LANG']->getLL('security_warning_extensions') .
00229                 '<br /><br />' . sprintf($GLOBALS['LANG']->getLL('security_descr'),
00230             '<a href="http://typo3.org/teams/security/" target="_blank">', '</a>'
00231         );
00232         $flashMessage = t3lib_div::makeInstance(
00233             't3lib_FlashMessage',
00234             $securityMessage,
00235             $GLOBALS['LANG']->getLL('security_header'),
00236             t3lib_FlashMessage::INFO
00237         );
00238         $this->securityHint = $flashMessage->render();
00239 
00240         $this->excludeForPackaging = $GLOBALS['TYPO3_CONF_VARS']['EXT']['excludeForPackaging'];
00241 
00242         // Setting module configuration:
00243         $this->MCONF = $GLOBALS['MCONF'];
00244 
00245         // Setting GPvars:
00246         $this->CMD = is_array(t3lib_div::_GP('CMD')) ? t3lib_div::_GP('CMD') : array();
00247         $this->lookUpStr = trim(t3lib_div::_GP('lookUp'));
00248         $this->listRemote = t3lib_div::_GP('ter_connect');
00249         $this->listRemote_search = trim(t3lib_div::_GP('ter_search'));
00250         $this->noDocHeader = intval(t3lib_div::_GP('nodoc') > 0);
00251 
00252         $this->settings = t3lib_div::makeInstance('tx_em_Settings');
00253         $this->install = t3lib_div::makeInstance('tx_em_Install', $this);
00254 
00255         if (t3lib_div::_GP('silentMode') || $this->noDocHeader) {
00256             $this->CMD['silentMode'] = 1;
00257             $this->noDocHeader = 1;
00258         }
00259 
00260         if ($this->CMD['silentMode']) {
00261             $this->install->setSilentMode(TRUE);
00262         }
00263 
00264         // Configure menu
00265         $this->menuConfig();
00266 
00267         // Setting internal static:
00268 
00269         $this->requiredExt = t3lib_div::trimExplode(',', t3lib_extMgm::getRequiredExtensionList(), TRUE);
00270 
00271         // Initialize Document Template object:
00272         $this->doc = t3lib_div::makeInstance('template');
00273         $this->doc->backPath = $BACK_PATH;
00274         $this->doc->setModuleTemplate('templates/em_index.html');
00275 
00276         // Initialize helper objects
00277         $this->api = t3lib_div::makeInstance('tx_em_API');
00278         $this->terConnection = t3lib_div::makeInstance('tx_em_Connection_Ter', $this);
00279         $this->terConnection->wsdlURL = $TYPO3_CONF_VARS['EXT']['em_wsdlURL'];
00280 
00281 
00282         $this->xmlHandler = t3lib_div::makeInstance('tx_em_Tools_XmlHandler');
00283         $this->xmlHandler->emObj = $this;
00284         $this->xmlHandler->useObsolete = $this->MOD_SETTINGS['display_obsolete'];
00285 
00286 
00287         // Initialize newListing
00288         if (isset($this->MOD_MENU['function']['extensionmanager'])) {
00289             $this->extensionmanager = t3lib_div::makeInstance('tx_em_ExtensionManager', $this);
00290         } else {
00291             $this->extensionmanager = &$this;
00292         }
00293 
00294 
00295         // Output classes
00296         $this->extensionList = t3lib_div::makeInstance('tx_em_Extensions_List', $this);
00297         $this->extensionDetails = t3lib_div::makeInstance('tx_em_Extensions_Details', $this);
00298         $this->translations = t3lib_div::makeInstance('tx_em_Translations', $this);
00299 
00300 
00301         // the id is needed for getting same styles TODO: general table styles
00302         $this->doc->bodyTagId = 'typo3-mod-tools-em-index-php';
00303 
00304         // JavaScript
00305         $this->doc->JScode = $this->doc->wrapScriptTags('
00306             script_ended = 0;
00307             function jumpToUrl(URL) {   //
00308                 window.location.href = URL;
00309             }
00310         ');
00311 
00312         // Reload left frame menu
00313         if ($this->CMD['refreshMenu']) {
00314             $this->doc->JScode .= $this->doc->wrapScriptTags('
00315                 if(top.refreshMenu) {
00316                     top.refreshMenu();
00317                 } else {
00318                     top.TYPO3ModuleMenu.refreshMenu();
00319                 }
00320             ');
00321         }
00322 
00323 
00324         // Descriptions:
00325         $this->descrTable = '_MOD_' . $this->MCONF['name'];
00326         if ($BE_USER->uc['edit_showFieldHelp']) {
00327             $LANG->loadSingleTableDescription($this->descrTable);
00328         }
00329 
00330         // Setting username/password etc. for upload-user:
00331         $this->fe_user['username'] = $this->MOD_SETTINGS['fe_u'];
00332         $this->fe_user['password'] = $this->MOD_SETTINGS['fe_p'];
00333         parent::init();
00334         $this->handleExternalFunctionValue('singleDetails');
00335     }
00336 
00337     /**
00338      * This function is a copy of the same function in t3lib_SCbase with one modification:
00339      * In contrast to t3lib_SCbase::handleExternalFunctionValue() this function merges the $this->extClassConf array
00340      * instead of overwriting it. That was necessary for including the Kickstarter as a submodule into the 'singleDetails'
00341      * selectorbox as well as in the main 'function' selectorbox.
00342      *
00343      * @param   string      Mod-setting array key
00344      * @param   string      Mod setting value, overriding the one in the key
00345      * @return  void
00346      * @see t3lib_SCbase::handleExternalFunctionValue()
00347      */
00348     function handleExternalFunctionValue($MM_key = 'function', $MS_value = NULL) {
00349         $MS_value = is_null($MS_value) ? $this->MOD_SETTINGS[$MM_key] : $MS_value;
00350         $externalItems = $this->getExternalItemConfig($this->MCONF['name'], $MM_key, $MS_value);
00351         if (is_array($externalItems)) {
00352             $this->extClassConf = array_merge($externalItems, is_array($this->extClassConf) ? $this->extClassConf : array());
00353         }
00354         if (is_array($this->extClassConf) && $this->extClassConf['path']) {
00355             $this->include_once[] = $this->extClassConf['path'];
00356         }
00357     }
00358 
00359     /**
00360      * Configuration of which mod-menu items can be used
00361      *
00362      * @return  void
00363      */
00364     function menuConfig() {
00365             // MENU-ITEMS:
00366         $this->MOD_MENU = $this->settings->MOD_MENU;
00367         $globalSettings = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['em']);
00368 
00369         if (!is_array($globalSettings)) {
00370                 // no settings saved yet, set default values
00371             $globalSettings['showOldModules'] = 1;
00372             $globalSettings['inlineToWindow'] = 1;
00373             $globalSettings['displayMyExtensions'] = 0;
00374         }
00375 
00376         if ($globalSettings['showOldModules'] == 0) {
00377             unset(
00378                 $this->MOD_MENU['function']['loaded_list'],
00379                 $this->MOD_MENU['function']['installed_list'],
00380                 $this->MOD_MENU['function']['import'],
00381                 $this->MOD_MENU['function']['translations'],
00382                 $this->MOD_MENU['function']['settings']
00383             );
00384         }
00385         $this->MOD_MENU['singleDetails'] = $this->mergeExternalItems($this->MCONF['name'], 'singleDetails', $this->MOD_MENU['singleDetails']);
00386         $this->MOD_MENU['extensionInfo'] = $this->mergeExternalItems($this->MCONF['name'], 'singleDetails', array());
00387 
00388 
00389             // page/be_user TSconfig settings and blinding of menu-items
00390         if (!$GLOBALS['BE_USER']->getTSConfigVal('mod.' . $this->MCONF['name'] . '.allowTVlisting')) {
00391             unset($this->MOD_MENU['display_details'][3]);
00392             unset($this->MOD_MENU['display_details'][4]);
00393             unset($this->MOD_MENU['display_details'][5]);
00394         }
00395 
00396             // CLEANSE SETTINGS
00397         $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
00398 
00399 
00400         if ($this->MOD_SETTINGS['function'] == 2) {
00401             // If listing from online repository, certain items are removed though:
00402             unset($this->MOD_MENU['listOrder']['type']);
00403             unset($this->MOD_MENU['display_details'][2]);
00404             unset($this->MOD_MENU['display_details'][3]);
00405             unset($this->MOD_MENU['display_details'][4]);
00406             unset($this->MOD_MENU['display_details'][5]);
00407             $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
00408         }
00409 
00410         $this->settings->saveSettings($this->MOD_SETTINGS);
00411         parent::menuConfig();
00412 
00413         $this->settings->saveSettings($this->MOD_SETTINGS);
00414     }
00415 
00416     /**
00417      * Main function for Extension Manager module.
00418      *
00419      * @return  void
00420      */
00421     function main() {
00422 
00423         $menu = '';
00424 
00425         if (empty($this->MOD_SETTINGS['mirrorListURL'])) {
00426             $this->MOD_SETTINGS['mirrorListURL'] = $GLOBALS['TYPO3_CONF_VARS']['EXT']['em_mirrorListURL'];
00427         }
00428 
00429         // Starting page:
00430         $this->content .= $this->doc->header($GLOBALS['LANG']->getLL('header'));
00431 
00432         // Command given which is executed regardless of main menu setting:
00433         if ($this->CMD['showExt']) { // Show details for a single extension
00434             $this->showExtDetails($this->CMD['showExt']);
00435         } elseif ($this->CMD['requestInstallExtensions']) { // Show details for a single extension
00436             $this->requestInstallExtensions($this->CMD['requestInstallExtensions']);
00437         } elseif ($this->CMD['importExt'] || $this->CMD['uploadExt']) { // Imports an extension from online rep.
00438             $err = $this->importExtFromRep($this->CMD['importExt'], $this->CMD['extVersion'], $this->CMD['loc'], $this->CMD['uploadExt']);
00439             if ($err) {
00440                 $this->content .= $this->doc->section('', tx_em_Tools::rfw($err));
00441             }
00442             if (!$err && $this->CMD['importExt']) {
00443                 $this->translations->installTranslationsForExtension($this->CMD['importExt'], $this->getMirrorURL());
00444             }
00445         } elseif ($this->CMD['importExtInfo']) { // Gets detailed information of an extension from online rep.
00446             $this->importExtInfo($this->CMD['importExtInfo'], $this->CMD['extVersion']);
00447         } elseif ($this->CMD['downloadExtFile']) {
00448             tx_em_Tools::sendFile($this->CMD['downloadExtFile']);
00449         } else { // No command - we show what the menu setting tells us:
00450             if (t3lib_div::inList('loaded_list,installed_list,import', $this->MOD_SETTINGS['function'])) {
00451                 $menu .= '&nbsp;' . $GLOBALS['LANG']->getLL('group_by') . '&nbsp;' . t3lib_BEfunc::getFuncMenu(0, 'SET[listOrder]', $this->MOD_SETTINGS['listOrder'], $this->MOD_MENU['listOrder']) .
00452                     '&nbsp;&nbsp;' . $GLOBALS['LANG']->getLL('show') . '&nbsp;' . t3lib_BEfunc::getFuncMenu(0, 'SET[display_details]', $this->MOD_SETTINGS['display_details'], $this->MOD_MENU['display_details']) . '<br />';
00453             }
00454             if (t3lib_div::inList('loaded_list,installed_list,updates', $this->MOD_SETTINGS['function'])) {
00455                 $menu .= '<label for="checkDisplayShy">' . $GLOBALS['LANG']->getLL('display_shy') . '</label>&nbsp;&nbsp;' . t3lib_BEfunc::getFuncCheck(0, 'SET[display_shy]', $this->MOD_SETTINGS['display_shy'], '', '', 'id="checkDisplayShy"');
00456             }
00457             if (t3lib_div::inList('import', $this->MOD_SETTINGS['function']) && strlen($this->fe_user['username'])) {
00458                 $menu .= '<label for="checkDisplayOwn">' . $GLOBALS['LANG']->getLL('only_my_ext') . '</label>&nbsp;&nbsp;' . t3lib_BEfunc::getFuncCheck(0, 'SET[display_own]', $this->MOD_SETTINGS['display_own'], '', '', 'id="checkDisplayOwn"');
00459             }
00460             if (t3lib_div::inList('loaded_list,installed_list,import', $this->MOD_SETTINGS['function'])) {
00461                 $menu .= '&nbsp;&nbsp;<label for="checkDisplayObsolete">' . $GLOBALS['LANG']->getLL('show_obsolete') . '</label>&nbsp;&nbsp;' . t3lib_BEfunc::getFuncCheck(0, 'SET[display_obsolete]', $this->MOD_SETTINGS['display_obsolete'], '', '', 'id="checkDisplayObsolete"');
00462             }
00463 
00464             $this->content .= $menu ? $this->doc->section('', '<form action="' . $this->script . '" method="post" name="pageform"><span class="nobr">' . $menu . '</span></form>') : '';
00465 
00466 
00467             $view = $this->MOD_SETTINGS['function'];
00468             if (t3lib_div::_GP('view')) {
00469                     // temporary overwrite the view with GP var. Used from ExtJS without changing the submodule
00470                 $view = t3lib_div::_GP('view');
00471             }
00472 
00473             switch ($view) {
00474                 case 'loaded_list':
00475                     // Lists loaded (installed) extensions
00476                     $headline = $GLOBALS['LANG']->getLL('loaded_exts');
00477                     $headline = t3lib_BEfunc::wrapInHelp('_MOD_tools_em', 'loaded', $headline);
00478                     $content = $this->extensionList->extensionList_loaded();
00479 
00480                     $this->content .= $this->doc->section($headline, $content, FALSE, TRUE, FALSE, TRUE);
00481                     break;
00482                 case 'installed_list':
00483                     // Lists the installed (available) extensions
00484                     $headline = sprintf($GLOBALS['LANG']->getLL('available_extensions'), $this->MOD_MENU['listOrder'][$this->MOD_SETTINGS['listOrder']]);
00485                     $headline = t3lib_BEfunc::wrapInHelp('_MOD_tools_em', 'avail', $headline);
00486                     $content = $this->extensionList->extensionList_installed();
00487 
00488                     $this->content .= $this->doc->section($headline, $content, FALSE, TRUE, FALSE, TRUE);
00489                     break;
00490                 case 'import':
00491                     // Lists the extensions available from online rep.
00492                     $this->extensionList_import();
00493                     break;
00494                 case 'settings':
00495                     // Shows the settings screen
00496                     $headline = $GLOBALS['LANG']->getLL('repository_settings');
00497                     $headline = t3lib_BEfunc::wrapInHelp('_MOD_tools_em', 'settings', $headline);
00498                     $content = $this->alterSettings();
00499 
00500                     $this->content .= $this->doc->section($headline, $content, FALSE, TRUE, FALSE, TRUE);
00501                     break;
00502                 case 'translations':
00503                     // Allows to set the translation preferences and check the status
00504                     $this->translations->translationHandling();
00505                     break;
00506                 case 'updates':
00507                     // Shows a list of extensions with updates in TER
00508                     $this->checkForUpdates();
00509                     break;
00510                 case 'extensionmanager':
00511                     $this->content .= $this->extensionmanager->render();
00512                     break;
00513                 default:
00514                     $this->extObjContent();
00515                     break;
00516             }
00517         }
00518 
00519             // closing any form?
00520         $formTags = substr_count($this->content, '<form') + substr_count($this->content, '</form');
00521         if ($formTags % 2 > 0) {
00522             $this->content .= '</form>';
00523         }
00524 
00525         if (!$this->noDocHeader) {
00526             // Setting up the buttons and markers for docheader
00527             $docHeaderButtons = $this->getButtons();
00528             $markers = array(
00529                 'CSH' => $docHeaderButtons['csh'],
00530                 'FUNC_MENU' => $this->getFuncMenu(),
00531                 'CONTENT' => $this->content
00532             );
00533 
00534             // Build the <body> for the module
00535             $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
00536         }
00537             // Renders the module page
00538         $this->content = $this->doc->render(
00539             'Extension Manager',
00540             $this->content
00541         );
00542 
00543     }
00544 
00545     /**
00546      * Print module content. Called as last thing in the global scope.
00547      *
00548      * @return  void
00549      */
00550     function printContent() {
00551         if ($this->doPrintContent) {
00552             echo $this->content;
00553         }
00554     }
00555 
00556     /**
00557      * Create the function menu
00558      *
00559      * @return  string  HTML of the function menu
00560      */
00561     public function getFuncMenu() {
00562         $funcMenu = '';
00563         if (!$this->CMD['showExt'] && !$this->CMD['requestInstallExtensions'] && !$this->CMD['importExt'] && !$this->CMD['uploadExt'] && !$this->CMD['importExtInfo']) {
00564             $funcMenu = t3lib_BEfunc::getFuncMenu(0, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']);
00565         } elseif ($this->CMD['showExt'] && (!$this->CMD['standAlone'] && !t3lib_div::_GP('standAlone'))) {
00566             $funcMenu = t3lib_BEfunc::getFuncMenu(0, 'SET[singleDetails]', $this->MOD_SETTINGS['singleDetails'], $this->MOD_MENU['singleDetails'], '', '&CMD[showExt]=' . $this->CMD['showExt']);
00567         }
00568         return $funcMenu;
00569     }
00570 
00571     /**
00572      * Create the panel of buttons for submitting the form or otherwise perform operations.
00573      *
00574      * @return  array   all available buttons as an assoc. array
00575      */
00576     public function getButtons() {
00577 
00578         $buttons = array(
00579             'csh' => '',
00580             'back' => '',
00581             'shortcut' => ''
00582         );
00583 
00584         // Shortcut
00585         if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
00586             $buttons['shortcut'] = $this->doc->makeShortcutIcon('CMD', 'function', $this->MCONF['name']);
00587         }
00588         // Back
00589         if (($this->CMD['showExt'] && (!$this->CMD['standAlone'] && !t3lib_div::_GP('standAlone'))) || ($this->CMD['importExt'] || $this->CMD['uploadExt'] && (!$this->CMD['standAlone'])) || $this->CMD['importExtInfo']) {
00590             $buttons['back'] = '<a href="' . t3lib_div::linkThisScript(array(
00591                 'CMD' => ''
00592             )) . '" class="typo3-goBack" title="' . $GLOBALS['LANG']->getLL('go_back') . '">' .
00593                     t3lib_iconWorks::getSpriteIcon('actions-view-go-back') .
00594                     '</a>';
00595         }
00596 
00597         return $buttons;
00598     }
00599 
00600 
00601     /*********************************
00602      *
00603      * Function Menu Applications
00604      *
00605      *********************************/
00606 
00607 
00608     /**
00609      * Listing remote extensions from online repository
00610      *
00611      * @return  void
00612      */
00613     function extensionList_import() {
00614         global $TYPO3_LOADED_EXT;
00615         $content = '';
00616 
00617         // Listing from online repository:
00618         if ($this->listRemote) {
00619             list($inst_list,) = $this->extensionList->getInstalledExtensions();
00620             $this->inst_keys = array_flip(array_keys($inst_list));
00621 
00622             $this->detailCols[1] += 6;
00623 
00624             // see if we have an extensionlist at all
00625             $this->extensionCount = $this->xmlHandler->countExtensions();
00626             if (!$this->extensionCount) {
00627                 $content .= $this->fetchMetaData('extensions');
00628             }
00629 
00630             if ($this->MOD_SETTINGS['listOrder'] == 'author_company') {
00631                 $this->listingLimit = $this->listingLimitAuthor;
00632             }
00633 
00634             $this->pointer = intval(t3lib_div::_GP('pointer'));
00635             $offset = $this->listingLimit * $this->pointer;
00636 
00637             if ($this->MOD_SETTINGS['display_own'] && strlen($this->fe_user['username'])) {
00638                 $this->xmlHandler->searchExtensionsXML($this->listRemote_search, $this->fe_user['username'], $this->MOD_SETTINGS['listOrder'], TRUE);
00639             } else {
00640                 $this->xmlHandler->searchExtensionsXML($this->listRemote_search, '', $this->MOD_SETTINGS['listOrder'], TRUE, FALSE, $offset, $this->listingLimit);
00641             }
00642             if (count($this->xmlHandler->extensionsXML)) {
00643                 list($list, $cat) = $this->extensionList->prepareImportExtList(TRUE);
00644 
00645                 // Available extensions
00646                 if (is_array($cat[$this->MOD_SETTINGS['listOrder']])) {
00647                     $lines = array();
00648                     $lines[] = $this->extensionList->extensionListRowHeader(' class="t3-row-header"', array('<td><img src="clear.gif" width="18" height="1" alt="" /></td>'), 1);
00649 
00650                     foreach ($cat[$this->MOD_SETTINGS['listOrder']] as $catName => $extEkeys) {
00651                         if (count($extEkeys)) {
00652                             $lines[] = '<tr><td colspan="' . (3 + $this->detailCols[$this->MOD_SETTINGS['display_details']]) . '"><br /></td></tr>';
00653                             $lines[] = '<tr><td colspan="' . (3 + $this->detailCols[$this->MOD_SETTINGS['display_details']]) . '">' . t3lib_iconWorks::getSpriteIcon('apps-filetree-folder-default') . '<strong>' . htmlspecialchars($this->listOrderTitle($this->MOD_SETTINGS['listOrder'], $catName)) . '</strong></td></tr>';
00654                             natcasesort($extEkeys);
00655                             foreach ($extEkeys as $extKey => $value) {
00656                                 $version = array_keys($list[$extKey]['versions']);
00657                                 $version = end($version);
00658                                 $ext = $list[$extKey]['versions'][$version];
00659                                 $ext['downloadcounter_all'] = $list[$extKey]['downloadcounter'];
00660                                 $ext['_ICON'] = $list[$extKey]['_ICON'];
00661                                 $loadUnloadLink = '';
00662                                 if ($inst_list[$extKey]['type'] != 'S' && (!isset($inst_list[$extKey]) || tx_em_Tools::versionDifference($version, $inst_list[$extKey]['EM_CONF']['version'], $this->versionDiffFactor))) {
00663                                     if (isset($inst_list[$extKey])) {
00664                                         // update
00665                                         if ($inst_list[$extKey]['EM_CONF']['state'] != 'excludeFromUpdates') {
00666                                             $loc = ($inst_list[$extKey]['type'] == 'G' ? 'G' : 'L');
00667                                             $aUrl = t3lib_div::linkThisScript(array(
00668                                                 'CMD[importExt]' => $extKey,
00669                                                 'CMD[extVersion]' => $version,
00670                                                 'CMD[loc]' => $loc
00671                                             ));
00672                                             $loadUnloadLink .= '<a href="' . htmlspecialchars($aUrl) . '" title="' . sprintf($GLOBALS['LANG']->getLL('do_update'), ($loc == 'G' ? $GLOBALS['LANG']->getLL('global') : $GLOBALS['LANG']->getLL('local'))) . '">' .
00673                                                     t3lib_iconWorks::getSpriteIcon('actions-system-extension-update') .
00674                                                     '</a>';
00675                                         } else {
00676                                             // extension is marked as "excludeFromUpdates"
00677                                             $loadUnloadLink .= t3lib_iconWorks::getSpriteIcon('status-dialog-warning', $GLOBALS['LANG']->getLL('excluded_from_updates'));
00678                                         }
00679                                     } else {
00680                                         // import
00681                                         $aUrl = t3lib_div::linkThisScript(array(
00682                                             'CMD[importExt]' => $extKey,
00683                                             'CMD[extVersion]' => $version,
00684                                             'CMD[loc]' => 'L'
00685                                         ));
00686                                         $loadUnloadLink .= '<a href="' . htmlspecialchars($aUrl) . '" title="' . $GLOBALS['LANG']->getLL('import_to_local_dir') . '">' . t3lib_iconWorks::getSpriteIcon('actions-system-extension-import') . '</a>';
00687                                     }
00688                                 } else {
00689                                     $loadUnloadLink = '&nbsp;';
00690                                 }
00691 
00692                                 if (isset($inst_list[$extKey])) {
00693                                     $theRowClass = t3lib_extMgm::isLoaded($extKey) ? 'em-listbg1' : 'em-listbg2';
00694                                 } else {
00695                                     $theRowClass = 'em-listbg3';
00696                                 }
00697 
00698                                 $lines[] = $this->extensionList->extensionListRow(
00699                                     $extKey, $ext, array(
00700                                     '<td class="bgColor">' . $loadUnloadLink . '</td>'
00701                                 ), $theRowClass, $inst_list, 1, t3lib_div::linkThisScript(array(
00702                                     'CMD[importExtInfo]' => rawurlencode($extKey)
00703                                 )));
00704                                 unset($list[$extKey]);
00705                             }
00706                         }
00707                     }
00708                     unset($list);
00709 
00710                     // headline and CSH
00711                     $headline = $GLOBALS['LANG']->getLL('extensions_repository_group_by') . ' ' .
00712                             $this->MOD_MENU['listOrder'][$this->MOD_SETTINGS['listOrder']];
00713                     $headline = t3lib_BEfunc::wrapInHelp('_MOD_tools_em', 'import_ter', $headline);
00714 
00715                     $onsubmit = "window.location.href='" . $this->script . "&ter_connect=1&ter_search='+escape(this.elements['lookUp'].value);return false;";
00716                     $content .= '<form action="' . $this->script . '" method="post" onsubmit="' . htmlspecialchars($onsubmit) .
00717                             '"><label for="lookUp">' . $GLOBALS['LANG']->getLL('list_or_look_up_extensions') . '</label><br />
00718                             <input type="text" id="lookUp" name="lookUp" value="' . htmlspecialchars($this->listRemote_search) .
00719                             '" /> <input type="submit" value="' . $GLOBALS['LANG']->getLL('look_up_button') . '" /></form><br /><br />';
00720 
00721                     $content .= $this->browseLinks();
00722 
00723                     $content .= '
00724 
00725                     <!-- TER Extensions list -->
00726                     <table border="0" cellpadding="2" cellspacing="1">' . implode(LF, $lines) . '</table>';
00727                     $content .= '<br />' . $this->browseLinks();
00728                     $content .= '<br /><br />' . $this->securityHint;
00729                     $content .= '<br /><br /><strong>' . $GLOBALS['LANG']->getLL('privacy_notice_header') .
00730                             '</strong><br /> ' . $this->privacyNotice;
00731 
00732                     $this->content .= $this->doc->section($headline, $content, FALSE, TRUE, FALSE, TRUE);
00733 
00734                     // Plugins which are NOT uploaded to repository but present on this server.
00735                     $content = '';
00736                     $lines = array();
00737                     if (count($this->inst_keys)) {
00738                         foreach ($this->inst_keys as $extKey => $value) {
00739                             $this->xmlHandler->searchExtensionsXMLExact($extKey, '', '', TRUE, TRUE);
00740                             if ((strlen($this->listRemote_search) && !stristr($extKey, $this->listRemote_search)) || isset($this->xmlHandler->extensionsXML[$extKey])) {
00741                                 continue;
00742                             }
00743 
00744                             $loadUnloadLink = t3lib_extMgm::isLoaded($extKey) ?
00745                                     '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array(
00746                                         'CMD[showExt]' => $extKey,
00747                                         'CMD[remove]' => 1,
00748                                         'CMD[clrCmd]' => 1,
00749                                         'SET[singleDetails]' => 'info'
00750                                     ))) . '">' . tx_em_Tools::removeButton() . '</a>' :
00751                                     '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array(
00752                                         'CMD[showExt]' => $extKey,
00753                                         'CMD[load]' => 1,
00754                                         'CMD[clrCmd]' => 1,
00755                                         'SET[singleDetails]' => 'info'
00756                                     ))) . '">' . tx_em_Tools::installButton() . '</a>';
00757                             if (in_array($extKey, $this->requiredExt)) {
00758                                 $loadUnloadLink = '<strong>' . tx_em_Tools::rfw($GLOBALS['LANG']->getLL('extension_required_short')) . '</strong>';
00759                             }
00760                             $lines[] = $this->extensionList->extensionListRow($extKey, $inst_list[$extKey], array('<td class="bgColor">' . $loadUnloadLink . '</td>'), t3lib_extMgm::isLoaded($extKey) ? 'em-listbg1' : 'em-listbg2');
00761                         }
00762                     }
00763                     if (count($lines)) {
00764                         $content .= $GLOBALS['LANG']->getLL('list_of_local_extensions') .
00765                                 '<br />' . $GLOBALS['LANG']->getLL('might_be_user_defined') . '<br /><br />';
00766                         $content .= '<table border="0" cellpadding="2" cellspacing="1">' .
00767                                 $this->extensionList->extensionListRowHeader(' class="t3-row-header"', array('<td><img src="clear.gif" width="18" height="1" alt="" /></td>')) .
00768                                 implode('', $lines) . '</table>';
00769                         $this->content .= $this->doc->spacer(20);
00770                         $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('only_on_this_server'), $content, 0, 1);
00771                     }
00772                 }
00773             } else {
00774                 // headline and CSH
00775                 $headline = $GLOBALS['LANG']->getLL('extensions_repository_group_by') . ' ' .
00776                         $this->MOD_MENU['listOrder'][$this->MOD_SETTINGS['listOrder']];
00777                 $headline = t3lib_BEfunc::wrapInHelp('_MOD_tools_em', 'import_ter', $headline);
00778 
00779                 $onsubmit = "window.location.href='" . $this->script . "&ter_connect=1&ter_search='+escape(this.elements['lookUp'].value);return false;";
00780                 $content .= '<form action="' . $this->script . '" method="post" onsubmit="' . htmlspecialchars($onsubmit) .
00781                         '"><label for="lookUp">' .
00782                         $GLOBALS['LANG']->getLL('list_or_look_up_extensions') . '</label><br />
00783                     <input type="text" id="lookUp" name="lookUp" value="' . htmlspecialchars($this->listRemote_search) .
00784                         '" /> <input type="submit" value="' . $GLOBALS['LANG']->getLL('look_up_button') . '" /></form><br /><br />';
00785 
00786                 $content .= '<p><strong>' . $GLOBALS['LANG']->getLL('no_matching_extensions') . '</strong></p>';
00787 
00788                 $content .= '<br /><br /><strong>' . $GLOBALS['LANG']->getLL('privacy_notice_header') .
00789                         '</strong><br /> ' . $this->privacyNotice;
00790                 $this->content .= $this->doc->section($headline, $content, FALSE, TRUE, 0, TRUE);
00791             }
00792         } else {
00793             // section headline and CSH
00794             $headline = $GLOBALS['LANG']->getLL('in_repository');
00795             $headline = t3lib_BEfunc::wrapInHelp('_MOD_tools_em', 'import', $headline);
00796 
00797             $onsubmit = "window.location.href='" . $this->script . "&ter_connect=1&ter_search='+escape(this.elements['lookUp'].value);return false;";
00798             $content .= '<form action="' . $this->script . '" method="post" onsubmit="' . htmlspecialchars($onsubmit) .
00799                     '"><label for="lookUp">' .
00800                     $GLOBALS['LANG']->getLL('list_or_look_up_extensions') . '</label><br />
00801                 <input type="text" id="lookUp" name="lookUp" value="" /> <input type="submit" value="' .
00802                     $GLOBALS['LANG']->getLL('look_up_button') . '" /><br /><br />';
00803 
00804             if ($this->CMD['fetchMetaData']) { // fetches mirror/extension data from online rep.
00805                 $content .= $this->fetchMetaData($this->CMD['fetchMetaData']);
00806             } else {
00807                 $onCLick = 'window.location.href="' . t3lib_div::linkThisScript(array(
00808                     'CMD[fetchMetaData]' => 'extensions'
00809                 )) . '";return false;';
00810                 $content .= $GLOBALS['LANG']->getLL('connect_to_ter') . '<br />
00811                     <input type="submit" value="' . $GLOBALS['LANG']->getLL('retrieve_update') .
00812                         '" onclick="' . htmlspecialchars($onCLick) . '" />';
00813                 if (is_file(PATH_site . 'typo3temp/extensions.xml.gz')) {
00814                     $dateFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'];
00815                     $timeFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'];
00816                     $content .= ' ' . sprintf($GLOBALS['LANG']->getLL('ext_list_last_updated') . ' ',
00817                         date(
00818                             $dateFormat . ', ' . $timeFormat,
00819                             filemtime(PATH_site . 'typo3temp/extensions.xml.gz')
00820                         ),
00821                         tx_em_Database::getExtensionCountFromRepository()
00822                     );
00823                 }
00824             }
00825             $content .= '</form><br /><br />' . $this->securityHint;
00826             $content .= '<br /><br /><strong>' . $GLOBALS['LANG']->getLL('privacy_notice_header') .
00827                     '</strong><br />' . $this->privacyNotice;
00828 
00829             $this->content .= $this->doc->section($headline, $content, FALSE, TRUE, FALSE, TRUE);
00830         }
00831 
00832         // Upload:
00833         if ($this->importAtAll()) {
00834             $content = '<form action="' . $this->script . '" enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '" method="post">
00835             <label for="upload_ext_file">' . $GLOBALS['LANG']->getLL('upload_t3x') . '</label><br />
00836                 <input type="file" size="60" id="upload_ext_file" name="upload_ext_file" /><br />' .
00837                     $GLOBALS['LANG']->getLL('upload_to_location') . '<br />
00838                 <select name="CMD[loc]">';
00839             if (tx_em_Tools::importAsType('L')) {
00840                 $content .= '<option value="L">' . $GLOBALS['LANG']->getLL('local_folder') . '</option>';
00841             }
00842             if (tx_em_Tools::importAsType('G')) {
00843                 $content .= '<option value="G">' . $GLOBALS['LANG']->getLL('global_folder') . '</option>';
00844             }
00845             if (tx_em_Tools::importAsType('S')) {
00846                 $content .= '<option value="S">' . $GLOBALS['LANG']->getLL('system_folder') . '</option>';
00847             }
00848             $content .= '</select><br />
00849     <input type="checkbox" value="1" name="CMD[uploadOverwrite]" id="checkUploadOverwrite" /> <label for="checkUploadOverwrite">' .
00850                     $GLOBALS['LANG']->getLL('overwrite_ext') . '</label><br />
00851     <input type="submit" name="CMD[uploadExt]" value="' . $GLOBALS['LANG']->getLL('upload_ext_file') . '" /></form><br />
00852             ';
00853         } else {
00854             $content = tx_em_Tools::noImportMsg();
00855         }
00856 
00857         $this->content .= $this->doc->spacer(20);
00858         $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('upload_ext_directly'), $content, 0, 1);
00859     }
00860 
00861     /**
00862      * Generates a link to the next page of extensions
00863      *
00864      * @return  void
00865      */
00866     function browseLinks() {
00867         $content = '';
00868         if ($this->pointer) {
00869             $content .= '<a href="' . t3lib_div::linkThisScript(array('pointer' => $this->pointer - 1)) .
00870                     '" class="typo3-prevPage"><img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],
00871                 'gfx/pilleft_n.gif', 'width="14" height="14"') .
00872                     ' alt="' . $GLOBALS['LANG']->getLL('previous_page') . '" /> ' .
00873                     $GLOBALS['LANG']->getLL('previous_page') . '</a>';
00874         }
00875         if ($content) {
00876             $content .= '&nbsp;&nbsp;&nbsp;';
00877         }
00878         if (intval($this->xmlHandler->matchingCount / $this->listingLimit) > $this->pointer) {
00879             $content .= '<a href="' . t3lib_div::linkThisScript(array('pointer' => $this->pointer + 1)) .
00880                     '" class="typo3-nextPage"><img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],
00881                 'gfx/pilright_n.gif', 'width="14" height="14"') .
00882                     ' alt="' . $GLOBALS['LANG']->getLL('next_page') . '" /> ' .
00883                     $GLOBALS['LANG']->getLL('next_page') . '</a>';
00884         }
00885         $upper = (($this->pointer + 1) * $this->listingLimit);
00886         if ($upper > $this->xmlHandler->matchingCount) {
00887             $upper = $this->xmlHandler->matchingCount;
00888         }
00889         if ($content) {
00890             $content .= '<br /><br />' .
00891                     sprintf($GLOBALS['LANG']->getLL('showing_extensions_from_to'),
00892                             '<strong>' . ($this->pointer * $this->listingLimit + 1) . '</strong>',
00893                             '<strong>' . $upper . '</strong>'
00894                     );
00895         }
00896         if ($content) {
00897             $content .= '<br /><br />';
00898         }
00899         return $content;
00900     }
00901 
00902     /**
00903      * Allows changing of settings
00904      *
00905      * @return  void
00906      */
00907     function alterSettings() {
00908         $content = '';
00909         // Prepare the HTML output:
00910         $content .= '
00911             <form action="' . $this->script . '" method="post" name="altersettings">
00912             <fieldset><legend>' . $GLOBALS['LANG']->getLL('user_settings') . '</legend>
00913             <table border="0" cellpadding="2" cellspacing="2">
00914                 <tr class="bgColor4">
00915                     <td><label for="set_fe_u">' . $GLOBALS['LANG']->getLL('enter_repository_username') . '</label></td>
00916                     <td><input type="text" id="set_fe_u" name="SET[fe_u]" value="' . htmlspecialchars($this->MOD_SETTINGS['fe_u']) . '" /></td>
00917                 </tr>
00918                 <tr class="bgColor4">
00919                     <td><label for="set_fe_p">' . $GLOBALS['LANG']->getLL('enter_repository_password') . '</label></td>
00920                     <td><input type="password" id="set_fe_p" name="SET[fe_p]" value="' . htmlspecialchars($this->MOD_SETTINGS['fe_p']) . '" /></td>
00921                 </tr>
00922             </table>
00923             <strong>' . $GLOBALS['LANG']->getLL('notice') . '</strong> ' .
00924                 $GLOBALS['LANG']->getLL('repository_password_info') . '
00925             </fieldset>
00926             <br />
00927             <br />
00928             <fieldset><legend>' . $GLOBALS['LANG']->getLL('mirror_selection') . '</legend>
00929             <table border="0" cellpadding="2" cellspacing="2">
00930                 <tr class="bgColor4">
00931                     <td><label for="set_mirror_list_url">' . $GLOBALS['LANG']->getLL('mirror_list_url') . '</label></td>
00932                     <td><input type="text" size="50" id="set_mirror_list_url" name="SET[mirrorListURL]" value="' . htmlspecialchars($this->MOD_SETTINGS['mirrorListURL']) . '" /></td>
00933                 </tr>
00934             </table>
00935             </fieldset>
00936             <br />
00937             <p>' . $GLOBALS['LANG']->getLL('mirror_select') . '<br /><br /></p>
00938             <fieldset><legend>' . $GLOBALS['LANG']->getLL('mirror_list') . '</legend>';
00939         if (!empty($this->MOD_SETTINGS['mirrorListURL'])) {
00940             if ($this->CMD['fetchMetaData']) { // fetches mirror/extension data from online rep.
00941                 $content .= $this->fetchMetaData($this->CMD['fetchMetaData']);
00942             } else {
00943                 $content .= '<a href="' . t3lib_div::linkThisScript(array(
00944                     'CMD[fetchMetaData]' => 'mirrors'
00945                 )) . '">' . $GLOBALS['LANG']->getLL('mirror_list_reload') . '</a>';
00946             }
00947         }
00948         $content .= '<br />
00949             <table cellspacing="4" style="text-align:left; vertical-alignment:top;">
00950             <tr>
00951                 <td>' . $GLOBALS['LANG']->getLL('mirror_use') . '</td>
00952                 <td>' . $GLOBALS['LANG']->getLL('mirror_name') . '</td>
00953                 <td>' . $GLOBALS['LANG']->getLL('mirror_url') . '</td>
00954                 <td>' . $GLOBALS['LANG']->getLL('mirror_country') . '</td>
00955                 <td>' . $GLOBALS['LANG']->getLL('mirror_sponsored_by') . '</td>
00956             </tr>
00957         ';
00958 
00959         if (!strlen($this->MOD_SETTINGS['extMirrors'])) {
00960             $this->fetchMetaData('mirrors');
00961         }
00962         $extMirrors = unserialize($this->MOD_SETTINGS['extMirrors']);
00963         $extMirrors[''] = array('title' => $GLOBALS['LANG']->getLL('mirror_use_random'));
00964         ksort($extMirrors);
00965         if (is_array($extMirrors)) {
00966             foreach ($extMirrors as $k => $v) {
00967                 if (isset($v['sponsor'])) {
00968                     $sponsor = '<a href="' . htmlspecialchars($v['sponsor']['link']) . '" target="_blank"><img src="' . $v['sponsor']['logo'] . '" title="' . htmlspecialchars($v['sponsor']['name']) . '" alt="' . htmlspecialchars($v['sponsor']['name']) . '" /></a>';
00969                 }
00970                 $selected = ($this->MOD_SETTINGS['selectedMirror'] == $k) ? 'checked="checked"' : '';
00971                 $content .= '<tr class="bgColor4">
00972             <td><input type="radio" name="SET[selectedMirror]" id="selectedMirror' . $k . '" value="' . $k . '" ' . $selected . '/></td><td><label for="selectedMirror' . $k . '">' . htmlspecialchars($v['title']) . '</label></td><td>' . htmlspecialchars($v['host'] . $v['path']) . '</td><td>' . $v['country'] . '</td><td>' . $sponsor . '</td></tr>';
00973             }
00974         }
00975         $content .= '
00976             </table>
00977             </fieldset>
00978             <fieldset>
00979             <br />
00980             <table border="0" cellpadding="2" cellspacing="2">
00981                 <tr class="bgColor4">
00982                     <td><label for="set_rep_url">' . $GLOBALS['LANG']->getLL('enter_repository_url') . '</label></td>
00983                     <td><input type="text" size="50" id="set_rep_url" name="SET[rep_url]" value="' . htmlspecialchars($this->MOD_SETTINGS['rep_url']) . '" /></td>
00984                 </tr>
00985             </table>
00986 
00987             ' . $GLOBALS['LANG']->getLL('repository_url_hint') . '<br />
00988             </fieldset>
00989             <br />
00990             <input type="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_tsfe.xml:update') . '" />
00991             </form>
00992         ';
00993 
00994         return $content;
00995     }
00996 
00997     /**
00998      * Allows to set the translation preferences and check the status
00999      *
01000      * @return  void
01001      */
01002 
01003 
01004     /*********************************
01005      *
01006      * Command Applications (triggered by GET var)
01007      *
01008      *********************************/
01009 
01010     /**
01011      * Returns detailed info about an extension in the online repository
01012      *
01013      * @param   string      Extension repository uid + optional "private key": [uid]-[key].
01014      * @param   [type]      $version: ...
01015      * @return  void
01016      */
01017     function importExtInfo($extKey, $version = '') {
01018 
01019         $content = '<form action="' . $this->script . '" method="post" name="pageform">';
01020         $addUrl = '';
01021         if ($this->noDocHeader) {
01022            $content .= '<input type="hidden" name="nodoc" value="1" />';
01023            $addUrl = '&nodoc=1';
01024        }
01025         // Fetch remote data:
01026         $this->xmlHandler->searchExtensionsXMLExact($extKey, '', '', true, true);
01027         list($fetchData,) = $this->extensionList->prepareImportExtList(true);
01028 
01029         $versions = array_keys($fetchData[$extKey]['versions']);
01030         natsort($versions);
01031         $version = ($version == '') ? end($versions) : $version;
01032 
01033         $opt = array();
01034         foreach ($versions as $ver) {
01035             $opt[] = '<option value="' . $ver . '"' . (($version == $ver) ? ' selected="selected"' : '') . '>' . $ver . '</option>';
01036         }
01037 
01038         // "Select version" box:
01039         $onClick = 'window.location.href="' . $this->script . $addUrl . '&CMD[importExtInfo]=' . $extKey . '&CMD[extVersion]="+document.pageform.extVersion.options[document.pageform.extVersion.selectedIndex].value; return false;';
01040         $select = '<select name="extVersion">' . implode('', $opt) .
01041                 '</select> <input type="submit" value="' . $GLOBALS['LANG']->getLL('ext_load_details_button') .
01042                 '" onclick="' . htmlspecialchars($onClick) . '" />';
01043 
01044         if ($this->importAtAll()) {
01045             // Check for write-protected extension
01046             list($inst_list,) = $this->extensionList->getInstalledExtensions();
01047             if ($inst_list[$extKey]['EM_CONF']['state'] != 'excludeFromUpdates') {
01048                 $onClick = '
01049                         window.location.href="' . $this->script . $addUrl . '&CMD[importExt]=' . $extKey . '"
01050                             +"&CMD[extVersion]="+document.pageform.extVersion.options[document.pageform.extVersion.selectedIndex].value
01051                             +"&CMD[loc]="+document.pageform.loc.options[document.pageform.loc.selectedIndex].value;
01052                             return false;';
01053                 $select .= ' ' . $GLOBALS['LANG']->getLL('ext_or') . '<br /><br />
01054                     <input type="submit" value="' . $GLOBALS['LANG']->getLL('ext_import_update_button') .
01055                         '" onclick="' . htmlspecialchars($onClick) . '" /> ' . $GLOBALS['LANG']->getLL('ext_import_update_to') . '
01056                     <select name="loc">' .
01057                         (tx_em_Tools::importAsType('G', $fetchData['emconf_lockType']) ?
01058                                 '<option value="G">' . $GLOBALS['LANG']->getLL('ext_import_global') . ' ' . tx_em_Tools::typePath('G') . $extKey . '/' .
01059                                         (@is_dir(tx_em_Tools::typePath('G') . $extKey) ?
01060                                                 ' ' . $GLOBALS['LANG']->getLL('ext_import_overwrite') :
01061                                                 ' ' . $GLOBALS['LANG']->getLL('ext_import_folder_empty')
01062                                         ) . '</option>' : ''
01063                         ) .
01064                         (tx_em_Tools::importAsType('L', $fetchData['emconf_lockType']) ?
01065                                 '<option value="L">' . $GLOBALS['LANG']->getLL('ext_import_local') . ' ' . tx_em_Tools::typePath('L') . $extKey . '/' .
01066                                         (@is_dir(tx_em_Tools::typePath('L') . $extKey) ?
01067                                                 ' ' . $GLOBALS['LANG']->getLL('ext_import_overwrite') :
01068                                                 ' ' . $GLOBALS['LANG']->getLL('ext_import_folder_empty')
01069                                         ) . '</option>' : ''
01070                         ) .
01071                         (tx_em_Tools::importAsType('S', $fetchData['emconf_lockType']) ?
01072                                 '<option value="S">' . $GLOBALS['LANG']->getLL('ext_import_system') . ' ' . tx_em_Tools::typePath('S') . $extKey . '/' .
01073                                         (@is_dir(tx_em_Tools::typePath('S') . $extKey) ?
01074                                                 ' ' . $GLOBALS['LANG']->getLL('ext_import_overwrite') :
01075                                                 ' ' . $GLOBALS['LANG']->getLL('ext_import_folder_empty')
01076                                         ) . '</option>' : ''
01077                         ) .
01078                         '</select>
01079                     </form>';
01080             } else {
01081                 $select .= '<br /><br />' . $GLOBALS['LANG']->getLL('ext_import_excluded_from_updates');
01082             }
01083         } else {
01084             $select .= '<br /><br />' . tx_em_Tools::noImportMsg();
01085         }
01086         $content .= $select;
01087         $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('ext_import_select_command'), $content, 0, 1);
01088 
01089         // Details:
01090         $eInfo = $fetchData[$extKey]['versions'][$version];
01091         $content = '<strong>' . $fetchData[$extKey]['_ICON'] . ' &nbsp;' . $eInfo['EM_CONF']['title'] . ' (' . $extKey . ', ' . $version . ')</strong><br /><br />';
01092         $content .= $this->extensionDetails->extInformationarray($extKey, $eInfo, 1);
01093         $this->content .= $this->doc->spacer(10);
01094         $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('ext_import_remote_ext_details'), $content, 0, 1);
01095     }
01096 
01097     /**
01098      * Fetches metadata and stores it to the corresponding place. This includes the mirror list,
01099      * extension XML files.
01100      *
01101      * @param   string      Type of data to fetch: (mirrors)
01102      * @param   boolean     If true the method doesn't produce any output
01103      * @return  void
01104      */
01105     function fetchMetaData($metaType) {
01106         global $TYPO3_CONF_VARS;
01107 
01108         $content = '';
01109         switch ($metaType) {
01110             case 'mirrors':
01111                 $mfile = t3lib_div::tempnam('mirrors');
01112                 $mirrorsFile = t3lib_div::getURL($this->MOD_SETTINGS['mirrorListURL'], 0, array(TYPO3_user_agent));
01113                 if ($mirrorsFile===false) {
01114                     t3lib_div::unlink_tempfile($mfile);
01115                     $content = '<p>' .
01116                             sprintf($GLOBALS['LANG']->getLL('ext_import_list_not_updated'),
01117                                 $this->MOD_SETTINGS['mirrorListURL']
01118                             ) . ' ' .
01119                             $GLOBALS['LANG']->getLL('translation_problems') . '</p>';
01120                 } else {
01121                     t3lib_div::writeFile($mfile, $mirrorsFile);
01122                     $mirrors = implode('', gzfile($mfile));
01123                     t3lib_div::unlink_tempfile($mfile);
01124 
01125                     $mirrors = $this->xmlHandler->parseMirrorsXML($mirrors);
01126                     if (is_array($mirrors) && count($mirrors)) {
01127                         t3lib_BEfunc::getModuleData($this->MOD_MENU, array('extMirrors' => serialize($mirrors)), $this->MCONF['name'], '', 'extMirrors');
01128                         $this->MOD_SETTINGS['extMirrors'] = serialize($mirrors);
01129                         $content = '<p>' .
01130                                 sprintf($GLOBALS['LANG']->getLL('ext_import_list_updated'),
01131                                     count($mirrors)
01132                                 ) . '</p>';
01133                     }
01134                     else {
01135                         $content = '<p>' . $mirrors . '<br />' . $GLOBALS['LANG']->getLL('ext_import_list_empty') . '</p>';
01136                     }
01137                 }
01138                 break;
01139             case 'extensions':
01140                 $this->fetchMetaData('mirrors'); // if we fetch the extensions anyway, we can as well keep this up-to-date
01141 
01142                 $mirror = $this->getMirrorURL();
01143                 $extfile = $mirror . 'extensions.xml.gz';
01144                 $extmd5 = t3lib_div::getURL($mirror . 'extensions.md5', 0, array(TYPO3_user_agent));
01145                 if (is_file(PATH_site . 'typo3temp/extensions.xml.gz')) {
01146                     $localmd5 = md5_file(PATH_site . 'typo3temp/extensions.xml.gz');
01147                 }
01148 
01149                 // count cached extensions. If cache is empty re-fill it
01150                 $cacheCount = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('extkey', 'cache_extensions');
01151 
01152                 if ($extmd5 === false) {
01153                     $content .= '<p>' .
01154                             sprintf($GLOBALS['LANG']->getLL('ext_import_md5_not_updated'),
01155                                     $mirror . 'extensions.md5'
01156                             ) .
01157                             $GLOBALS['LANG']->getLL('translation_problems') . '</p>';
01158                 } elseif ($extmd5 == $localmd5 && $cacheCount) {
01159                     $flashMessage = t3lib_div::makeInstance(
01160                         't3lib_FlashMessage',
01161                         $GLOBALS['LANG']->getLL('ext_import_list_unchanged'),
01162                         $GLOBALS['LANG']->getLL('ext_import_list_unchanged_header'),
01163                         t3lib_FlashMessage::INFO
01164                     );
01165                     $content .= $flashMessage->render();
01166                 } else {
01167                     $extXML = t3lib_div::getURL($extfile, 0, array(TYPO3_user_agent));
01168                     if ($extXML === false) {
01169                         $content .= '<p>' .
01170                                 sprintf($GLOBALS['LANG']->getLL('ext_import_list_unchanged'),
01171                                     $extfile
01172                                 ) . ' ' .
01173                                 $GLOBALS['LANG']->getLL('translation_problems') . '</p>';
01174                     } else {
01175                         t3lib_div::writeFile(PATH_site . 'typo3temp/extensions.xml.gz', $extXML);
01176                         $content .= $this->xmlHandler->parseExtensionsXML(PATH_site . 'typo3temp/extensions.xml.gz');
01177                     }
01178                 }
01179                 break;
01180         }
01181 
01182         return $content;
01183     }
01184 
01185     /**
01186      * Returns the base URL for the slected or a random mirror.
01187      *
01188      * @return  string      The URL for the selected or a random mirror
01189      */
01190     function getMirrorURL() {
01191         if (strlen($this->MOD_SETTINGS['rep_url'])) {
01192             return $this->MOD_SETTINGS['rep_url'];
01193         }
01194 
01195         $mirrors = unserialize($this->MOD_SETTINGS['extMirrors']);
01196         if (!is_array($mirrors)) {
01197             $this->fetchMetaData('mirrors');
01198             $mirrors = unserialize($this->MOD_SETTINGS['extMirrors']);
01199             if (!is_array($mirrors)) {
01200                 return false;
01201             }
01202         }
01203         if ($this->MOD_SETTINGS['selectedMirror'] == '') {
01204             $rand = array_rand($mirrors);
01205             $url = 'http://' . $mirrors[$rand]['host'] . $mirrors[$rand]['path'];
01206         }
01207         else {
01208             $url = 'http://' . $mirrors[$this->MOD_SETTINGS['selectedMirror']]['host'] . $mirrors[$this->MOD_SETTINGS['selectedMirror']]['path'];
01209         }
01210 
01211         return $url;
01212     }
01213 
01214 
01215     /**
01216      * Installs (activates) an extension
01217      *
01218      * For $mode use the three constants EM_INSTALL_VERSION_MIN, EM_INSTALL_VERSION_MAX, EM_INSTALL_VERSION_STRICT
01219      *
01220      * If an extension is loaded or imported already and the version requirement is matched, it will not be
01221      * fetched from the repository. This means, if you use EM_INSTALL_VERSION_MIN, you will not always get the latest
01222      * version of an extension!
01223      *
01224      * @param   string      $extKey The extension key to install
01225      * @param   string      $version    A version number that should be installed
01226      * @param   int     $mode   If a version is requested, this determines if it is the min, max or strict version requested
01227      * @return  [type]      ...
01228      * @todo Make the method able to handle needed interaction somehow (unmatched dependencies)
01229      */
01230     function installExtension($extKey, $version = null, $mode = EM_INSTALL_VERSION_MIN) {
01231         list($inst_list,) = $this->extensionList->getInstalledExtensions();
01232 
01233         // check if it is already installed and loaded with sufficient version
01234         if (isset($inst_list[$extKey])) {
01235             $currentVersion = $inst_list[$extKey]['EM_CONF']['version'];
01236 
01237             if (t3lib_extMgm::isLoaded($extKey)) {
01238                 if ($version===null) {
01239                     return array(true, $GLOBALS['LANG']->getLL('ext_import_ext_already_installed_loaded'));
01240                 } else {
01241                     switch ($mode) {
01242                         case EM_INSTALL_VERSION_STRICT:
01243                             if ($currentVersion == $version) {
01244                                 return array(true, $GLOBALS['LANG']->getLL('ext_import_ext_already_installed_loaded'));
01245                             }
01246                             break;
01247                         case EM_INSTALL_VERSION_MIN:
01248                             if (version_compare($currentVersion, $version, '>=')) {
01249                                 return array(true, $GLOBALS['LANG']->getLL('ext_import_ext_already_installed_loaded'));
01250                             }
01251                             break;
01252                         case EM_INSTALL_VERSION_MAX:
01253                             if (version_compare($currentVersion, $version, '<=')) {
01254                                 return array(true, $GLOBALS['LANG']->getLL('ext_import_ext_already_installed_loaded'));
01255                             }
01256                             break;
01257                     }
01258                 }
01259             } else {
01260                 if (!t3lib_extMgm::isLocalconfWritable()) {
01261                     return array(false, $GLOBALS['LANG']->getLL('ext_import_p_localconf'));
01262                 }
01263                 $newExtList = -1;
01264                 switch ($mode) {
01265                     case EM_INSTALL_VERSION_STRICT:
01266                         if ($currentVersion == $version) {
01267                             $newExtList = $this->extensionList->addExtToList($extKey, $inst_list);
01268                         }
01269                         break;
01270                     case EM_INSTALL_VERSION_MIN:
01271                         if (version_compare($currentVersion, $version, '>=')) {
01272                             $newExtList = $this->extensionList->addExtToList($extKey, $inst_list);
01273                         }
01274                         break;
01275                     case EM_INSTALL_VERSION_MAX:
01276                         if (version_compare($currentVersion, $version, '<=')) {
01277                             $newExtList = $this->extensionList->addExtToList($extKey, $inst_list);
01278                         }
01279                         break;
01280                 }
01281                 if ($newExtList != -1) {
01282                     $this->install->writeNewExtensionList($newExtList);
01283                     tx_em_Tools::refreshGlobalExtList();
01284                     $this->install->forceDBupdates($extKey, $inst_list[$extKey]);
01285                     return array(true, $GLOBALS['LANG']->getLL('ext_import_ext_loaded'));
01286                 }
01287             }
01288         }
01289 
01290         // at this point we know we need to import (a matching version of) the extension from TER2
01291 
01292         // see if we have an extension list at all
01293         if (!$this->xmlHandler->countExtensions()) {
01294             $this->fetchMetaData('extensions');
01295         }
01296         $this->xmlHandler->searchExtensionsXMLExact($extKey, '', '', true);
01297 
01298         // check if extension can be fetched
01299         if (isset($this->xmlHandler->extensionsXML[$extKey])) {
01300             $versions = array_keys($this->xmlHandler->extensionsXML[$extKey]['versions']);
01301             $latestVersion = end($versions);
01302             switch ($mode) {
01303                 case EM_INSTALL_VERSION_STRICT:
01304                     if (!isset($this->xmlHandler->extensionsXML[$extKey]['versions'][$version])) {
01305                         return array(false, $GLOBALS['LANG']->getLL('ext_import_ext_n_a'));
01306                     }
01307                     break;
01308                 case EM_INSTALL_VERSION_MIN:
01309                     if (version_compare($latestVersion, $version, '>=')) {
01310                         $version = $latestVersion;
01311                     } else {
01312                         return array(false, $GLOBALS['LANG']->getLL('ext_import_ext_n_a'));
01313                     }
01314                     break;
01315                 case EM_INSTALL_VERSION_MAX:
01316                     while (($v = array_pop($versions)) && version_compare($v, $version, '>=')) {
01317                         // Loop until a version is found
01318                     }
01319 
01320                     if ($v !== null && version_compare($v, $version, '<=')) {
01321                         $version = $v;
01322                     } else {
01323                         return array(false, $GLOBALS['LANG']->getLL('ext_import_ext_n_a'));
01324                     }
01325                     break;
01326             }
01327             $this->importExtFromRep($extKey, $version, 'L');
01328             $newExtList = $this->extensionList->addExtToList($extKey, $inst_list);
01329             if ($newExtList != -1) {
01330                 $this->install->writeNewExtensionList($newExtList);
01331                 tx_em_Tools::refreshGlobalExtList();
01332                 $this->install->forceDBupdates($extKey, $inst_list[$extKey]);
01333                 $this->translations->installTranslationsForExtension($extKey, $this->getMirrorURL());
01334                 return array(true, $GLOBALS['LANG']->getLL('ext_import_ext_imported'));
01335             } else {
01336                 return array(false, $GLOBALS['LANG']->getLL('ext_import_ext_not_loaded'));
01337             }
01338         } else {
01339             return array(false, $GLOBALS['LANG']->getLL('ext_import_ext_n_a_rep'));
01340         }
01341     }
01342 
01343 
01344     /**
01345      * Imports an extensions from the online repository
01346      * NOTICE: in version 4.0 this changed from "importExtFromRep_old($extRepUid,$loc,$uploadFlag=0,$directInput='',$recentTranslations=0,$incManual=0,$dontDelete=0)"
01347      *
01348      * @param   string      Extension key
01349      * @param   string      Version
01350      * @param   string      Install scope: "L" or "G" or "S"
01351      * @param   boolean     If true, extension is uploaded as file
01352      * @param   boolean     If true, extension directory+files will not be deleted before writing the new ones. That way custom files stored in the extension folder will be kept.
01353      * @param   array       Direct input array (like from kickstarter)
01354      * @return  string      Return false on success, returns error message if error.
01355      */
01356     function importExtFromRep($extKey, $version, $loc, $uploadFlag = 0, $dontDelete = 0, $directInput = '') {
01357 
01358         $uploadSucceed = false;
01359         $uploadedTempFile = '';
01360         if (is_array($directInput)) {
01361             $fetchData = array($directInput, '');
01362             $loc = ($loc==='G' || $loc==='S') ? $loc : 'L';
01363         } elseif ($uploadFlag) {
01364             if (($uploadedTempFile = $this->CMD['alreadyUploaded']) || $_FILES['upload_ext_file']['tmp_name']) {
01365 
01366                 // Read uploaded file:
01367                 if (!$uploadedTempFile) {
01368                     if (!is_uploaded_file($_FILES['upload_ext_file']['tmp_name'])) {
01369                         t3lib_div::sysLog('Possible file upload attack: ' . $_FILES['upload_ext_file']['tmp_name'], 'Extension Manager', 3);
01370 
01371                         $flashMessage = t3lib_div::makeInstance(
01372                             't3lib_FlashMessage',
01373                             $GLOBALS['LANG']->getLL('ext_import_file_not_uploaded'),
01374                             '',
01375                             t3lib_FlashMessage::ERROR
01376                         );
01377                         return $flashMessage->render();
01378                     }
01379 
01380                     $uploadedTempFile = t3lib_div::upload_to_tempfile($_FILES['upload_ext_file']['tmp_name']);
01381                 }
01382                 $fileContent = t3lib_div::getUrl($uploadedTempFile);
01383 
01384                 if (!$fileContent) {
01385                     $flashMessage = t3lib_div::makeInstance(
01386                         't3lib_FlashMessage',
01387                         $GLOBALS['LANG']->getLL('ext_import_file_empty'),
01388                         '',
01389                         t3lib_FlashMessage::ERROR
01390                     );
01391                     return $flashMessage->render();
01392                 }
01393 
01394                 // Decode file data:
01395                 $fetchData = $this->terConnection->decodeExchangeData($fileContent);
01396 
01397                 if (is_array($fetchData)) {
01398                     $extKey = $fetchData[0]['extKey'];
01399                     if ($extKey) {
01400                         if (!$this->CMD['uploadOverwrite']) {
01401                             $loc = ($loc==='G' || $loc==='S') ? $loc : 'L';
01402                             $comingExtPath = tx_em_Tools::typePath($loc) . $extKey . '/';
01403                             if (@is_dir($comingExtPath)) {
01404                                 $flashMessage = t3lib_div::makeInstance(
01405                                     't3lib_FlashMessage',
01406                                         sprintf($GLOBALS['LANG']->getLL('ext_import_ext_present_no_overwrite'), $comingExtPath) .
01407                                                 '<br />' . $GLOBALS['LANG']->getLL('ext_import_ext_present_nothing_done'),
01408                                     '',
01409                                     t3lib_FlashMessage::ERROR
01410                                 );
01411                                 return $flashMessage->render();
01412                             } // ... else go on, install...
01413                         } // ... else go on, install...
01414                     } else {
01415                         $flashMessage = t3lib_div::makeInstance(
01416                             't3lib_FlashMessage',
01417                             $GLOBALS['LANG']->getLL('ext_import_no_key'),
01418                             '',
01419                             t3lib_FlashMessage::ERROR
01420                         );
01421                         return $flashMessage->render();
01422                     }
01423                 } else {
01424                     $flashMessage = t3lib_div::makeInstance(
01425                         't3lib_FlashMessage',
01426                         sprintf($GLOBALS['LANG']->getLL('ext_import_wrong_file_format'), $fetchData),
01427                         '',
01428                         t3lib_FlashMessage::ERROR
01429                     );
01430                     return $flashMessage->render();
01431                 }
01432             } else {
01433                 $flashMessage = t3lib_div::makeInstance(
01434                     't3lib_FlashMessage',
01435                     $GLOBALS['LANG']->getLL('ext_import_no_file'),
01436                     '',
01437                     t3lib_FlashMessage::ERROR
01438                 );
01439                 return $flashMessage->render();
01440             }
01441         } else {
01442             $this->xmlHandler->searchExtensionsXMLExact($extKey, '', '', true, true);
01443 
01444             // Fetch extension from TER:
01445             if (!strlen($version)) {
01446                 $versions = array_keys($this->xmlHandler->extensionsXML[$extKey]['versions']);
01447                 $version = end($versions);
01448             }
01449             $fetchData = $this->terConnection->fetchExtension($extKey, $version, $this->xmlHandler->extensionsXML[$extKey]['versions'][$version]['t3xfilemd5'], $this->getMirrorURL());
01450         }
01451 
01452         // At this point the extension data should be present; so we want to write it to disc:
01453         $content = $this->install->installExtension($fetchData, $loc, $version, $uploadedTempFile, $dontDelete);
01454 
01455         $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('ext_import_results'), $content, 0, 1);
01456 
01457         if ($uploadSucceed && $uploadedTempFile) {
01458             t3lib_div::unlink_tempfile($uploadedTempFile);
01459         }
01460 
01461         return false;
01462     }
01463 
01464     /**
01465      * Display extensions details.
01466      *
01467      * @param   string      Extension key
01468      * @return  void        Writes content to $this->content
01469      */
01470     function showExtDetails($extKey) {
01471         global $TYPO3_LOADED_EXT;
01472 
01473         list($list,) = $this->extensionList->getInstalledExtensions();
01474         $absPath = tx_em_Tools::getExtPath($extKey, $list[$extKey]['type']);
01475 
01476         // Check updateModule:
01477         if (isset($list[$extKey]) && @is_file($absPath . 'class.ext_update.php')) {
01478             require_once($absPath . 'class.ext_update.php');
01479             $updateObj = new ext_update;
01480             if (!$updateObj->access()) {
01481                 unset($this->MOD_MENU['singleDetails']['updateModule']);
01482             }
01483         } else {
01484             unset($this->MOD_MENU['singleDetails']['updateModule']);
01485         }
01486 
01487         if ($this->CMD['doDelete']) {
01488             $this->MOD_MENU['singleDetails'] = array();
01489         }
01490 
01491         // Function menu here:
01492         if (!$this->CMD['standAlone'] && !t3lib_div::_GP('standAlone')) {
01493             $content = $GLOBALS['LANG']->getLL('ext_details_ext') . '&nbsp;<strong>' .
01494                     $this->extensionTitleIconHeader($extKey, $list[$extKey]) . '</strong> (' . htmlspecialchars($extKey) . ')';
01495             $this->content .= $this->doc->section('', $content);
01496         }
01497 
01498         // Show extension details:
01499         if ($list[$extKey]) {
01500 
01501             // Checking if a command for install/uninstall is executed:
01502             if (($this->CMD['remove'] || $this->CMD['load']) && !in_array($extKey, $this->requiredExt)) {
01503 
01504                 // Install / Uninstall extension here:
01505                 if (t3lib_extMgm::isLocalconfWritable()) {
01506                     // Check dependencies:
01507                     $depStatus = $this->install->checkDependencies($extKey, $list[$extKey]['EM_CONF'], $list);
01508 
01509                     if (!$this->CMD['remove'] && !$depStatus['returnCode']) {
01510                         $this->content .= $depStatus['html'];
01511                         $newExtList = -1;
01512                     } elseif ($this->CMD['remove']) {
01513                         $newExtList = $this->extensionList->removeExtFromList($extKey, $list);
01514                     } else {
01515                         $newExtList = $this->extensionList->addExtToList($extKey, $list);
01516                     }
01517 
01518                     // Successful installation:
01519                     if ($newExtList != -1) {
01520                         $updates = '';
01521                         if ($this->CMD['load']) {
01522                             if ($_SERVER['REQUEST_METHOD'] == 'POST') {
01523                                 $script = t3lib_div::linkThisScript(array(
01524                                     'CMD[showExt]' => $extKey,
01525                                     'CMD[load]' => 1,
01526                                     'CMD[clrCmd]' => $this->CMD['clrCmd'],
01527                                     'SET[singleDetails]' => 'info'
01528                                 ));
01529                             } else {
01530                                 $script = '';
01531                             }
01532                             $standaloneUpdates = '';
01533                             if ($this->CMD['standAlone']) {
01534                                 $standaloneUpdates .= '<input type="hidden" name="standAlone" value="1" />';
01535                             }
01536                             if ($this->CMD['silendMode']) {
01537                                 $standaloneUpdates .= '<input type="hidden" name="silendMode" value="1" />';
01538                             }
01539                             $depsolver = t3lib_div::_POST('depsolver');
01540                             if (is_array($depsolver['ignore'])) {
01541                                 foreach ($depsolver['ignore'] as $depK => $depV) {
01542                                     $dependencyUpdates .= '<input type="hidden" name="depsolver[ignore][' . $depK . ']" value="1" />';
01543                                 }
01544                             }
01545                             $updatesForm = $this->install->updatesForm(
01546                                 $extKey,
01547                                 $list[$extKey],
01548                                 1,
01549                                 $script,
01550                                 $dependencyUpdates . $standaloneUpdates . '<input type="hidden" name="_do_install" value="1" /><input type="hidden" name="_clrCmd" value="' . $this->CMD['clrCmd'] . '" />',
01551                                 TRUE
01552                             );
01553                             if ($updatesForm) {
01554                                 $updates = $GLOBALS['LANG']->getLL('ext_details_new_tables_fields') . '<br />' .
01555                                         $GLOBALS['LANG']->getLL('ext_details_new_tables_fields_select') . $updatesForm;
01556                                 $labelDBUpdate = $GLOBALS['LANG']->csConvObj->conv_case(
01557                                     $GLOBALS['LANG']->charSet,
01558                                     $GLOBALS['LANG']->getLL('ext_details_db_needs_update'),
01559                                     'toUpper'
01560                                 );
01561                                 $this->content .= $this->doc->section(
01562                                     sprintf($GLOBALS['LANG']->getLL('ext_details_installing') . ' ',
01563                                         $this->extensionTitleIconHeader($extKey, $list[$extKey])
01564                                     ) . ' ' .
01565                                             $labelDBUpdate,
01566                                     $updates, 1, 1, 1, 1
01567                                 );
01568                             }
01569                         } elseif ($this->CMD['remove']) {
01570                             $updates .= $this->install->checkClearCache($list[$extKey]);
01571                             if ($updates) {
01572                                 $updates = '
01573                                 <form action="' . $this->script . '" method="post">' . $updates . '
01574                                 <br /><input type="submit" name="write" value="' .
01575                                         $GLOBALS['LANG']->getLL('ext_details_remove_ext') . '" />
01576                                 <input type="hidden" name="_do_install" value="1" />
01577                                 <input type="hidden" name="_clrCmd" value="' . $this->CMD['clrCmd'] . '" />
01578                                 <input type="hidden" name="CMD[showExt]" value="' . $this->CMD['showExt'] . '" />
01579                                 <input type="hidden" name="CMD[remove]" value="' . $this->CMD['remove'] . '" />
01580                                 <input type="hidden" name="standAlone" value="' . $this->CMD['standAlone'] . '" />
01581                                 <input type="hidden" name="silentMode" value="' . $this->CMD['silentMode'] . '" />
01582                                 ' . ($this->noDocHeader ? '<input type="hidden" name="nodoc" value="1" />' : '') . '
01583                                 </form>';
01584                                 $labelDBUpdate = $GLOBALS['LANG']->csConvObj->conv_case(
01585                                     $GLOBALS['LANG']->charSet,
01586                                     $GLOBALS['LANG']->getLL('ext_details_db_needs_update'),
01587                                     'toUpper'
01588                                 );
01589                                 $this->content .= $this->doc->section(
01590                                     sprintf($GLOBALS['LANG']->getLL('ext_details_removing') . ' ',
01591                                         $this->extensionTitleIconHeader($extKey, $list[$extKey])
01592                                     ) . ' ' .
01593                                             $labelDBUpdate,
01594                                     $updates, 1, 1, 1, 1
01595                                 );
01596                             }
01597                         }
01598                         if (!$updates || t3lib_div::_GP('_do_install') || ($this->noDocHeader && $this->CMD['remove'])) {
01599                             $this->install->writeNewExtensionList($newExtList);
01600                             $action = $this->CMD['load'] ? 'installed' : 'removed';
01601                             $GLOBALS['BE_USER']->writelog(5, 1, 0, 0, 'Extension list has been changed, extension %s has been %s', array($extKey, $action));
01602 
01603                             if (!t3lib_div::_GP('silentMode') && !$this->CMD['standAlone']) {
01604                                 $messageLabel = 'ext_details_ext_' . $action . '_with_key';
01605                                 $flashMessage = t3lib_div::makeInstance(
01606                                     't3lib_FlashMessage',
01607                                     sprintf($GLOBALS['LANG']->getLL($messageLabel), $extKey),
01608                                     '',
01609                                     t3lib_FlashMessage::OK,
01610                                     TRUE
01611                                 );
01612                                 t3lib_FlashMessageQueue::addMessage($flashMessage);
01613                             }
01614                             if ($this->CMD['clrCmd'] || t3lib_div::_GP('_clrCmd')) {
01615                                 if ($this->CMD['load'] && @is_file($absPath . 'ext_conf_template.txt')) {
01616                                     $vA = array('CMD' => array('showExt' => $extKey));
01617                                 } else {
01618                                     $vA = array('CMD' => '');
01619                                 }
01620                             } else {
01621                                 $vA = array('CMD' => array('showExt' => $extKey));
01622                             }
01623 
01624                             if ($this->CMD['standAlone'] || t3lib_div::_GP('standAlone')) {
01625                                 $this->content .= sprintf($GLOBALS['LANG']->getLL('ext_details_ext_installed_removed'),
01626                                     ($this->CMD['load'] ?
01627                                             $GLOBALS['LANG']->getLL('ext_details_installed') :
01628                                             $GLOBALS['LANG']->getLL('ext_details_removed')
01629                                     )
01630                                 ) .
01631                                         '<br /><br />' . $this->getSubmitAndOpenerCloseLink();
01632                             } else {
01633                                 // Determine if new modules were installed:
01634                                 $techInfo = $this->install->makeDetailedExtensionAnalysis($extKey, $list[$extKey]);
01635                                 if (($this->CMD['load'] || $this->CMD['remove']) && is_array($techInfo['flags']) && in_array('Module', $techInfo['flags'], true)) {
01636                                     $vA['CMD']['refreshMenu'] = 1;
01637                                 }
01638                                 t3lib_utility_Http::redirect(t3lib_div::linkThisScript($vA));
01639                                 exit;
01640                             }
01641                         }
01642                     }
01643                 } else {
01644                     $writeAccessError = $GLOBALS['LANG']->csConvObj->conv_case(
01645                         $GLOBALS['LANG']->charSet,
01646                         $GLOBALS['LANG']->getLL('ext_details_write_access_error'),
01647                         'toUpper'
01648                     );
01649                     $this->content .= $this->doc->section(
01650                         sprintf($GLOBALS['LANG']->getLL('ext_details_installing') . ' ',
01651                             $this->extensionTitleIconHeader($extKey, $list[$extKey])
01652                         ) . ' ' .
01653                                 $writeAccessError,
01654                         $GLOBALS['LANG']->getLL('ext_details_write_error_localconf'),
01655                         1, 1, 2, 1
01656                     );
01657                 }
01658 
01659             } elseif ($this->CMD['downloadFile'] && !in_array($extKey, $this->requiredExt)) {
01660 
01661                 // Link for downloading extension has been clicked - deliver content stream:
01662                 $dlFile = $this->CMD['downloadFile'];
01663                 if (t3lib_div::isAllowedAbsPath($dlFile) && t3lib_div::isFirstPartOfStr($dlFile, PATH_site) && t3lib_div::isFirstPartOfStr($dlFile, $absPath) && @is_file($dlFile)) {
01664                     $mimeType = 'application/octet-stream';
01665                     Header('Content-Type: ' . $mimeType);
01666                     Header('Content-Disposition: attachment; filename=' . basename($dlFile));
01667                     echo t3lib_div::getUrl($dlFile);
01668                     exit;
01669                 } else {
01670                     throw new RuntimeException(
01671                         'TYPO3 Fatal Error: ' . $GLOBALS['LANG']->getLL('ext_details_error_downloading'),
01672                         1270853980
01673                     );
01674                 }
01675 
01676             } elseif ($this->CMD['editFile'] && !in_array($extKey, $this->requiredExt)) {
01677 
01678                 // Editing extension file:
01679                 $editFile = rawurldecode($this->CMD['editFile']);
01680                 if (t3lib_div::isAllowedAbsPath($editFile) && t3lib_div::isFirstPartOfStr($editFile, $absPath)) {
01681 
01682                     $fI = t3lib_div::split_fileref($editFile);
01683                     if (@is_file($editFile) && t3lib_div::inList($this->editTextExtensions, ($fI['fileext'] ? $fI['fileext'] : $fI['filebody']))) {
01684                         if (filesize($editFile) < ($this->kbMax * 1024)) {
01685                             $outCode = '<form action="' . $this->script . ' method="post" name="editfileform">';
01686                             $info = '';
01687                             $submittedContent = t3lib_div::_POST('edit');
01688                             $saveFlag = 0;
01689 
01690                             if (isset($submittedContent['file']) && !$GLOBALS['TYPO3_CONF_VARS']['EXT']['noEdit']) { // Check referer here?
01691                                 $oldFileContent = t3lib_div::getUrl($editFile);
01692                                 if ($oldFileContent != $submittedContent['file']) {
01693                                     $oldMD5 = md5(str_replace(CR, '', $oldFileContent));
01694                                     $info .= sprintf(
01695                                         $GLOBALS['LANG']->getLL('ext_details_md5_previous'),
01696                                             '<strong>' . $oldMD5 . '</strong>'
01697                                     ) . '<br />';
01698                                     t3lib_div::writeFile($editFile, $submittedContent['file']);
01699                                     $saveFlag = 1;
01700                                 } else {
01701                                     $info .= $GLOBALS['LANG']->getLL('ext_details_no_changes') . '<br />';
01702                                 }
01703                             }
01704 
01705                             $fileContent = t3lib_div::getUrl($editFile);
01706 
01707                             $outCode .= sprintf(
01708                                 $GLOBALS['LANG']->getLL('ext_details_file'),
01709                                     '<strong>' . substr($editFile, strlen($absPath)) . '</strong> (' .
01710                                             t3lib_div::formatSize(filesize($editFile)) . ')<br />'
01711                             );
01712                             $fileMD5 = md5(str_replace(CR, '', $fileContent));
01713                             $info .= sprintf(
01714                                 $GLOBALS['LANG']->getLL('ext_details_md5_current'),
01715                                     '<strong>' . $fileMD5 . '</strong>'
01716                             ) . '<br />';
01717                             if ($saveFlag) {
01718                                 $saveMD5 = md5(str_replace(CR, '', $submittedContent['file']));
01719                                 $info .= sprintf(
01720                                     $GLOBALS['LANG']->getLL('ext_details_md5_submitted'),
01721                                         '<strong>' . $saveMD5 . '</strong>'
01722                                 ) . '<br />';
01723                                 if ($fileMD5 != $saveMD5) {
01724                                     $info .= tx_em_Tools::rfw(
01725                                         '<br /><strong>' . $GLOBALS['LANG']->getLL('ext_details_saving_failed_changes_lost') . '</strong>'
01726                                     ) . '<br />';
01727                                 }
01728                                 else {
01729                                     $info .= tx_em_Tools::rfw(
01730                                         '<br /><strong>' . $GLOBALS['LANG']->getLL('ext_details_file_saved') . '</strong>'
01731                                     ) . '<br />';
01732                                 }
01733                             }
01734 
01735                             $outCode .= '<textarea name="edit[file]" rows="35" wrap="off"' . $this->doc->formWidthText(48, 'width:98%;height:70%', 'off') . ' class="fixed-font enable-tab">' . t3lib_div::formatForTextarea($fileContent) . '</textarea>';
01736                             $outCode .= '<input type="hidden" name="edit[filename]" value="' . $editFile . '" />';
01737                             $outCode .= '<input type="hidden" name="CMD[editFile]" value="' . htmlspecialchars($editFile) . '" />';
01738                             $outCode .= '<input type="hidden" name="CMD[showExt]" value="' . $extKey . '" />';
01739                             $outCode .= $info;
01740 
01741                             if (!$GLOBALS['TYPO3_CONF_VARS']['EXT']['noEdit']) {
01742                                 $outCode .= '<br /><input type="submit" name="save_file" value="' .
01743                                         $GLOBALS['LANG']->getLL('ext_details_file_save_button') . '" />';
01744                             }
01745                             else {
01746                                 $outCode .= tx_em_Tools::rfw(
01747                                     '<br />' . $GLOBALS['LANG']->getLL('ext_details_saving_disabled') . ' '
01748                                 );
01749                             }
01750 
01751                             $onClick = 'window.location.href="' . t3lib_div::linkThisScript(array(
01752                                 'CMD[showExt]' => $extKey
01753                             )) . '";return false;';
01754                             $outCode .= '<input type="submit" name="cancel" value="' .
01755                                     $GLOBALS['LANG']->getLL('ext_details_cancel_button') . '" onclick="' .
01756                                     htmlspecialchars($onClick) . '" /></form>';
01757 
01758                             $theOutput .= $this->doc->spacer(15);
01759                             $theOutput .= $this->doc->section($GLOBALS['LANG']->getLL('ext_details_edit_file'), '', 0, 1);
01760                             $theOutput .= $this->doc->sectionEnd() . $outCode;
01761                             $this->content .= $theOutput;
01762                         } else {
01763                             $theOutput .= $this->doc->spacer(15);
01764                             $theOutput .= $this->doc->section(
01765                                 sprintf(
01766                                     $GLOBALS['LANG']->getLL('ext_details_filesize_exceeded_kb'),
01767                                     $this->kbMax
01768                                 ),
01769                                 sprintf(
01770                                     $GLOBALS['LANG']->getLL('ext_details_file_too_large'),
01771                                     $this->kbMax
01772                                 )
01773                             );
01774                         }
01775                     }
01776                 } else {
01777                     die (sprintf($GLOBALS['LANG']->getLL('ext_details_fatal_edit_error'),
01778                         htmlspecialchars($editFile)
01779                     )
01780                     );
01781                 }
01782             } else {
01783 
01784                 // MAIN:
01785                 switch ((string) $this->MOD_SETTINGS['singleDetails']) {
01786                     case 'info':
01787                         // Loaded / Not loaded:
01788                         if (!in_array($extKey, $this->requiredExt)) {
01789                             if ($TYPO3_LOADED_EXT[$extKey]) {
01790                                 $content = '<strong>' . $GLOBALS['LANG']->getLL('ext_details_loaded_and_running') . '</strong><br />' .
01791                                         '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array(
01792                                     'CMD[showExt]' => $extKey,
01793                                     'CMD[remove]' => 1
01794                                 ))) .
01795                                         '">' . $GLOBALS['LANG']->getLL('ext_details_remove_button') . ' ' . tx_em_Tools::removeButton() . '</a>';
01796                             } else {
01797                                 $content = $GLOBALS['LANG']->getLL('ext_details_not_loaded') . '<br />' .
01798                                         '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array(
01799                                     'CMD[showExt]' => $extKey,
01800                                     'CMD[load]' => 1
01801                                 ))) .
01802                                         '">' . $GLOBALS['LANG']->getLL('ext_details_install_button') . ' ' . tx_em_Tools::installButton() . '</a>';
01803                             }
01804                         } else {
01805                             $content = $GLOBALS['LANG']->getLL('ext_details_always_loaded');
01806                         }
01807                         $this->content .= $this->doc->spacer(10);
01808                         $this->content .= $this->doc->section(
01809                             $GLOBALS['LANG']->getLL('ext_details_current_status'), $content, 0, 1
01810                         );
01811 
01812                         if (t3lib_extMgm::isLoaded($extKey)) {
01813                             $updates = $this->install->updatesForm($extKey, $list[$extKey]);
01814                             if ($updates) {
01815                                 $this->content .= $this->doc->spacer(10);
01816                                 $this->content .= $this->doc->section(
01817                                     $GLOBALS['LANG']->getLL('ext_details_update_needed'),
01818                                         $updates . '<br /><br />' . $GLOBALS['LANG']->getLL('ext_details_notice_static_data'),
01819                                     0, 1
01820                                 );
01821                             }
01822                         }
01823 
01824                         // Config:
01825                         if (@is_file($absPath . 'ext_conf_template.txt')) {
01826                             $this->content .= $this->doc->spacer(10);
01827                             $this->content .= $this->doc->section(
01828                                 $GLOBALS['LANG']->getLL('ext_details_configuration'),
01829                                     $GLOBALS['LANG']->getLL('ext_details_notice_clear_cache') . '<br /><br />',
01830                                 0, 1
01831                             );
01832 
01833                             $this->content .= $this->install->tsStyleConfigForm($extKey, $list[$extKey]);
01834                         }
01835 
01836                         // Show details:
01837                         $headline = $GLOBALS['LANG']->getLL('ext_details_details');
01838                         $headline = t3lib_BEfunc::wrapInHelp('_MOD_tools_em', 'info', $headline);
01839                         $content = $this->extensionDetails->extInformationarray($extKey, $list[$extKey]);
01840 
01841 
01842                         $this->content .= $this->doc->spacer(10);
01843                         $this->content .= $this->doc->section($headline, $content, FALSE, TRUE, FALSE, TRUE);
01844                         break;
01845                     case 'upload':
01846                         $em = t3lib_div::_POST('em');
01847                         if ($em['action'] == 'doUpload') {
01848                             $em['extKey'] = $extKey;
01849                             $em['extInfo'] = $list[$extKey];
01850                             $content = $this->extensionDetails->uploadExtensionToTER($em);
01851                             $content .= $this->doc->spacer(10);
01852                             // Must reload this, because EM_CONF information has been updated!
01853                             list($list,) = $this->extensionList->getInstalledExtensions();
01854                         } else {
01855                             // headline and CSH
01856                             $headline = $GLOBALS['LANG']->getLL('ext_details_upload_to_ter');
01857                             $headline = t3lib_BEfunc::wrapInHelp('_MOD_tools_em', 'upload', $headline);
01858 
01859                             // Upload:
01860                             if (substr($extKey, 0, 5) != 'user_') {
01861                                 $content = $this->getRepositoryUploadForm($extKey, $list[$extKey]);
01862                                 $eC = 0;
01863                             } else {
01864                                 $content = $GLOBALS['LANG']->getLL('ext_details_no_unique_ext');
01865                                 $eC = 2;
01866                             }
01867                             if (!$this->fe_user['username']) {
01868                                 $flashMessage = t3lib_div::makeInstance(
01869                                     't3lib_FlashMessage',
01870                                     sprintf($GLOBALS['LANG']->getLL('ext_details_no_username'),
01871                                             '<a href="' . t3lib_div::linkThisScript(array(
01872                                                 'SET[function]' => 3
01873                                             )) . '">', '</a>'
01874                                     ),
01875                                     '',
01876                                     t3lib_FlashMessage::INFO
01877                                 );
01878                                 $content .= '<br />' . $flashMessage->render();
01879 
01880                             }
01881                         }
01882                         $this->content .= $this->doc->section($headline, $content, 0, 1, $eC, TRUE);
01883                         break;
01884                     case 'backup':
01885                         if ($this->CMD['doDelete']) {
01886                             $content = $this->install->extDelete($extKey, $list[$extKey], $this->CMD);
01887                             $this->content .= $this->doc->section(
01888                                 $GLOBALS['LANG']->getLL('ext_details_delete'),
01889                                 $GLOBALS['LANG']->getLL('ext_details_delete'),
01890                                 $content, 0, 1
01891                             );
01892                         } else {
01893                             // headline and CSH
01894                             $headline = $GLOBALS['LANG']->getLL('ext_details_backup');
01895                             $headline = t3lib_BEfunc::wrapInHelp('_MOD_tools_em', 'backup_delete', $headline);
01896 
01897                             $content = $this->extBackup($extKey, $list[$extKey]);
01898                             $this->content .= $this->doc->section($headline, $content, 0, 1, 0, 1);
01899 
01900                             $content = $this->install->extDelete($extKey, $list[$extKey], $this->CMD);
01901                             $this->content .= $this->doc->section(
01902                                 $GLOBALS['LANG']->getLL('ext_details_delete'),
01903                                 $content, 0, 1
01904                             );
01905 
01906                             $content = $this->extUpdateEMCONF($extKey, $list[$extKey]);
01907                             $this->content .= $this->doc->section(
01908                                 $GLOBALS['LANG']->getLL('ext_details_update_em_conf'),
01909                                 $content, 0, 1
01910                             );
01911                         }
01912                         break;
01913                     case 'dump':
01914                         $this->extDumpTables($extKey, $list[$extKey]);
01915                         break;
01916                     case 'edit':
01917                         // headline and CSH
01918                         $headline = $GLOBALS['LANG']->getLL('ext_details_ext_files');
01919                         $headline = t3lib_BEfunc::wrapInHelp('_MOD_tools_em', 'editfiles', $headline);
01920 
01921                         $content = $this->getFileListOfExtension($extKey, $list[$extKey]);
01922 
01923                         $this->content .= $this->doc->section($headline, $content, FALSE, TRUE, FALSE, TRUE);
01924                         break;
01925                     case 'updateModule':
01926                         $this->content .= $this->doc->section(
01927                             $GLOBALS['LANG']->getLL('ext_details_update'),
01928                             is_object($updateObj) ?
01929                                     $updateObj->main() :
01930                                     $GLOBALS['LANG']->getLL('ext_details_no_update_object'),
01931                             0, 1
01932                         );
01933                         break;
01934                     default:
01935                         $this->extObjContent();
01936                         break;
01937                 }
01938             }
01939         }
01940     }
01941 
01942     /**
01943      * Outputs a screen from where you can install multiple extensions in one go
01944      * This can be called from external modules with "...index.php?CMD[requestInstallExtensions]=
01945      *
01946      * @param   string      Comma list of extension keys to install. Renders a screen with checkboxes for all extensions not already imported or installed
01947      * @return  void
01948      */
01949     function requestInstallExtensions($extList) {
01950 
01951         // Return URL:
01952         $returnUrl = t3lib_div::sanitizeLocalUrl(t3lib_div::_GP('returnUrl'));
01953         $installOrImportExtension = t3lib_div::_POST('installOrImportExtension');
01954 
01955         // Extension List:
01956         $extArray = explode(',', $extList);
01957         $outputRow = array();
01958         $outputRow[] = '
01959             <tr class="t3-row-header tableheader">
01960                 <td>' . $GLOBALS['LANG']->getLL('reqInstExt_install_import') . '</td>
01961                 <td>' . $GLOBALS['LANG']->getLL('reqInstExt_ext_key') . '</td>
01962             </tr>
01963         ';
01964 
01965         foreach ($extArray as $extKey) {
01966 
01967             // Check for the request:
01968             if ($installOrImportExtension[$extKey]) {
01969                 $this->installExtension($extKey);
01970             }
01971 
01972             // Display:
01973             if (!t3lib_extMgm::isLoaded($extKey)) {
01974                 $outputRow[] = '
01975                 <tr class="bgColor4">
01976                     <td><input type="checkbox" name="' . htmlspecialchars('installOrImportExtension[' . $extKey . ']') . '" value="1" checked="checked" id="check_' . $extKey . '" /></td>
01977                     <td><label for="check_' . $extKey . '">' . htmlspecialchars($extKey) . '</label></td>
01978                 </tr>
01979                 ';
01980             }
01981         }
01982 
01983         if (count($outputRow) > 1 || !$returnUrl) {
01984             $content = '
01985                 <!-- ending page form ... -->
01986             <form action="' . htmlspecialchars(t3lib_div::getIndpEnv('REQUEST_URI')) . '" method="post">
01987                 <table border="0" cellpadding="1" cellspacing="1">' . implode('', $outputRow) . '</table>
01988             <input type="submit" name="_" value="' . $GLOBALS['LANG']->getLL('reqInstExt_import_install_selected') . '" />
01989             </form>';
01990 
01991             if ($returnUrl) {
01992                 $content .= '
01993                 <br />
01994                 <br />
01995                 <a href="' . htmlspecialchars($returnUrl) . '">' . $GLOBALS['LANG']->getLL('reqInstExt_return') . '</a>
01996                 ';
01997             }
01998 
01999             $this->content .= $this->doc->section(
02000                 $GLOBALS['LANG']->getLL('reqInstExt_imp_inst_ext'), $content, 0, 1
02001             );
02002         } else {
02003             t3lib_utility_Http::redirect($returnUrl);
02004         }
02005     }
02006 
02007 
02008     /***********************************
02009      *
02010      * Application Sub-functions (HTML parts)
02011      *
02012      **********************************/
02013 
02014 
02015     /**
02016      * Creates view for dumping static tables and table/fields structures...
02017      *
02018      * @param   string      Extension key
02019      * @param   array       Extension information array
02020      * @return  void
02021      */
02022     function extDumpTables($extKey, $extInfo) {
02023 
02024         // Get dbInfo which holds the structure known from the tables.sql file
02025         $techInfo = $this->install->makeDetailedExtensionAnalysis($extKey, $extInfo);
02026         $absPath = tx_em_Tools::getExtPath($extKey, $extInfo['type']);
02027 
02028         // Static tables:
02029         if (is_array($techInfo['static'])) {
02030             if ($this->CMD['writeSTATICdump']) { // Writing static dump:
02031                 $writeFile = $absPath . 'ext_tables_static+adt.sql';
02032                 if (@is_file($writeFile)) {
02033                     $dump_static = tx_em_Database::dumpStaticTables(implode(',', $techInfo['static']));
02034                     t3lib_div::writeFile($writeFile, $dump_static);
02035                     $this->content .= $this->doc->section(
02036                         $GLOBALS['LANG']->getLL('extDumpTables_tables_fields'),
02037                         sprintf($GLOBALS['LANG']->getLL('extDumpTables_bytes_written_to'),
02038                             t3lib_div::formatSize(strlen($dump_static)),
02039                             substr($writeFile, strlen(PATH_site))
02040                         ),
02041                         0, 1
02042                     );
02043                 }
02044             } else { // Showing info about what tables to dump - and giving the link to execute it.
02045                 $msg = $GLOBALS['LANG']->getLL('extDumpTables_dumping_content') . '<br />';
02046                 $msg .= '<br />' . implode('<br />', $techInfo['static']) . '<br />';
02047 
02048                 // ... then feed that to this function which will make new CREATE statements of the same fields but based on the current database content.
02049                 $this->content .= $this->doc->section(
02050                     $GLOBALS['LANG']->getLL('extDumpTables_static_tables'),
02051                         $msg . '<hr /><strong><a href="' . htmlspecialchars(t3lib_div::linkThisScript(array(
02052                             'CMD[showExt]' => $extKey,
02053                             'CMD[writeSTATICdump]' => 1
02054                         ))) . '">' . $GLOBALS['LANG']->getLL('extDumpTables_write_static') . '</a></strong>',
02055                     0, 1
02056                 );
02057                 $this->content .= $this->doc->spacer(20);
02058             }
02059         }
02060 
02061         // Table and field definitions:
02062         if (is_array($techInfo['dump_tf'])) {
02063             $dump_tf_array = tx_em_Database::getTableAndFieldStructure($techInfo['dump_tf']);
02064             $dump_tf = tx_em_Database::dumpTableAndFieldStructure($dump_tf_array);
02065             if ($this->CMD['writeTFdump']) {
02066                 $writeFile = $absPath . 'ext_tables.sql';
02067                 if (@is_file($writeFile)) {
02068                     t3lib_div::writeFile($writeFile, $dump_tf);
02069                     $this->content .= $this->doc->section(
02070                         $GLOBALS['LANG']->getLL('extDumpTables_tables_fields'),
02071                         sprintf($GLOBALS['LANG']->getLL('extDumpTables_bytes_written_to'),
02072                             t3lib_div::formatSize(strlen($dump_tf)),
02073                             substr($writeFile, strlen(PATH_site))
02074                         ),
02075                         0, 1
02076                     );
02077                 }
02078             } else {
02079                 $msg = $GLOBALS['LANG']->getLL('extDumpTables_dumping_db_structure') . '<br />';
02080                 if (is_array($techInfo['tables'])) {
02081                     $msg .= '<br /><strong>' . $GLOBALS['LANG']->getLL('extDumpTables_tables') . '</strong><br />' .
02082                             implode('<br />', $techInfo['tables']) . '<br />';
02083                 }
02084                 if (is_array($techInfo['fields'])) {
02085                     $msg .= '<br /><strong>' . $GLOBALS['LANG']->getLL('extDumpTables_solo_fields') . '</strong><br />' .
02086                             implode('<br />', $techInfo['fields']) . '<br />';
02087                 }
02088 
02089                 // ... then feed that to this function which will make new CREATE statements of the same fields but based on the current database content.
02090                 $this->content .= $this->doc->section(
02091                     $GLOBALS['LANG']->getLL('extDumpTables_tables_fields'),
02092                         $msg . '<hr /><strong><a href="' . htmlspecialchars(t3lib_div::linkThisScript(array(
02093                             'CMD[showExt]' => $extKey,
02094                             'CMD[writeTFdump]' => 1
02095                         ))) .
02096                                 '">' . $GLOBALS['LANG']->getLL('extDumpTables_write_dump') . '</a></strong><hr />
02097                         <pre>' . htmlspecialchars($dump_tf) . '</pre>',
02098                     0, 1
02099                 );
02100 
02101 
02102                 $details = '                            ' . $GLOBALS['LANG']->getLL('extDumpTables_based_on') . '<br />
02103                 <ul>
02104                 <li>' . $GLOBALS['LANG']->getLL('extDumpTables_based_on_one') . '</li>
02105                 <li>' . $GLOBALS['LANG']->getLL('extDumpTables_based_on_two') . '</li>
02106                 </ul>
02107                 ' . $GLOBALS['LANG']->getLL('extDumpTables_bottomline') . '<br />';
02108                 $this->content .= $this->doc->section('', $details);
02109             }
02110         }
02111     }
02112 
02113     /**
02114      * Returns file-listing of an extension
02115      *
02116      * @param   string      Extension key
02117      * @param   array       Extension information array
02118      * @return  string      HTML table.
02119      */
02120     function getFileListOfExtension($extKey, $conf) {
02121         $content = '';
02122         $extPath = tx_em_Tools::getExtPath($extKey, $conf['type']);
02123 
02124         if ($extPath) {
02125             // Read files:
02126             $fileArr = array();
02127             $fileArr = t3lib_div::getAllFilesAndFoldersInPath($fileArr, $extPath, '', 0, 99, $this->excludeForPackaging);
02128 
02129             // Start table:
02130             $lines = array();
02131             $totalSize = 0;
02132 
02133             // Header:
02134             $lines[] = '
02135                 <tr class="t3-row-header">
02136                     <td>' . $GLOBALS['LANG']->getLL('extFileList_file') . '</td>
02137                     <td>' . $GLOBALS['LANG']->getLL('extFileList_size') . '</td>
02138                     <td>' . $GLOBALS['LANG']->getLL('extFileList_edit') . '</td>
02139                 </tr>';
02140 
02141             foreach ($fileArr as $file) {
02142                 $fI = t3lib_div::split_fileref($file);
02143                 $lines[] = '
02144                 <tr class="bgColor4">
02145                     <td><a href="' . htmlspecialchars(t3lib_div::linkThisScript(array(
02146                     'CMD[showExt]' => $extKey,
02147                     'CMD[downloadFile]' => rawurlencode($file)
02148                 ))) . '" title="' . $GLOBALS['LANG']->getLL('extFileList_download') . '">' .
02149                         substr($file, strlen($extPath)) . '</a></td>
02150                     <td>' . t3lib_div::formatSize(filesize($file)) . '</td>
02151                     <td>' . (!in_array($extKey, $this->requiredExt) &&
02152                         t3lib_div::inList($this->editTextExtensions,
02153                             ($fI['fileext'] ? $fI['fileext'] : $fI['filebody'])) ?
02154                         '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array(
02155                             'CMD[showExt]' => $extKey,
02156                             'CMD[editFile]' => rawurlencode($file)
02157                         ))) . '">' .
02158                                 $GLOBALS['LANG']->getLL('extFileList_edit_file') . '</a>' : ''
02159                 ) . '</td>
02160                 </tr>';
02161                 $totalSize += filesize($file);
02162             }
02163 
02164             $lines[] = '
02165                 <tr class="bgColor6">
02166                     <td><strong>' . $GLOBALS['LANG']->getLL('extFileList_total') . '</strong></td>
02167                     <td><strong>' . t3lib_div::formatSize($totalSize) . '</strong></td>
02168                     <td>&nbsp;</td>
02169                 </tr>';
02170 
02171             $content = '
02172             Path: ' . $extPath . '<br /><br />
02173             <table border="0" cellpadding="1" cellspacing="2">' . implode('', $lines) . '</table>';
02174         }
02175 
02176         return $content;
02177     }
02178 
02179 
02180     /**
02181      * Update extension EM_CONF...
02182      *
02183      * @param   string      Extension key
02184      * @param   array       Extension information array
02185      * @return  string      HTML content.
02186      */
02187     function extUpdateEMCONF($extKey, $extInfo) {
02188         $absPath = tx_em_Tools::getExtPath($extKey, $extInfo['type']);
02189         $content = '';
02190 
02191         if ($this->CMD['doUpdateEMCONF']) {
02192             return $this->extensionDetails->updateLocalEM_CONF($extKey, $extInfo);
02193         } else {
02194             $sure = $GLOBALS['LANG']->getLL('extUpdateEMCONF_sure');
02195             $updateEMConf = $GLOBALS['LANG']->getLL('extUpdateEMCONF_file');
02196             $onClick = "if (confirm('$sure')) {window.location.href='" . t3lib_div::linkThisScript(array(
02197                 'CMD[showExt]' => $extKey,
02198                 'CMD[doUpdateEMCONF]' => 1
02199             )) . "';}";
02200             $content .= $GLOBALS['LANG']->getLL('extUpdateEMCONF_info_changes') . '<br />'
02201                 . $GLOBALS['LANG']->getLL('extUpdateEMCONF_info_reset') . '<br /><br />';
02202             $content .= '<a class="t3-link" href="#" onclick="' . htmlspecialchars($onClick) .
02203                     ' return false;"><strong>' . $updateEMConf . '</strong> ' .
02204                     sprintf($GLOBALS['LANG']->getLL('extDelete_from_location'),
02205                         $this->typeLabels[$extInfo['type']],
02206                         substr($absPath, strlen(PATH_site))
02207                     ) . '</a>';
02208             return $content;
02209         }
02210     }
02211 
02212     /**
02213      * Download extension as file / make backup
02214      *
02215      * @param   string      Extension key
02216      * @param   array       Extension information array
02217      * @return  string      HTML content
02218      */
02219     function extBackup($extKey, $extInfo) {
02220         $uArr = $this->extensionDetails->makeUploadarray($extKey, $extInfo);
02221         if (is_array($uArr)) {
02222             $backUpData = $this->terConnection->makeUploadDataFromarray($uArr);
02223             $filename = 'T3X_' . $extKey . '-' . str_replace('.', '_', $extInfo['EM_CONF']['version']) . '-z-' . date('YmdHi') . '.t3x';
02224             if (intval($this->CMD['doBackup']) == 1) {
02225                 ob_end_clean();
02226                 header('Content-Type: application/octet-stream');
02227                 header('Content-Disposition: attachment; filename=' . $filename);
02228                 echo $backUpData;
02229                 exit;
02230             } elseif ($this->CMD['dumpTables']) {
02231                 $filename = 'T3X_' . $extKey;
02232                 $cTables = count(explode(',', $this->CMD['dumpTables']));
02233                 if ($cTables > 1) {
02234                     $filename .= '-' . $cTables . 'tables';
02235                 } else {
02236                     $filename .= '-' . $this->CMD['dumpTables'];
02237                 }
02238                 $filename .= '+adt.sql';
02239 
02240                 header('Content-Type: application/octet-stream');
02241                 header('Content-Disposition: attachment; filename=' . $filename);
02242                 echo tx_em_Database::dumpStaticTables($this->CMD['dumpTables']);
02243                 exit;
02244             } else {
02245                 $techInfo = $this->install->makeDetailedExtensionAnalysis($extKey, $extInfo);
02246                 $lines = array();
02247                 $lines[] = '<tr class="t3-row-header"><td colspan="2">' .
02248                         $GLOBALS['LANG']->getLL('extBackup_select') . '</td></tr>';
02249                 $lines[] = '<tr class="bgColor4"><td><strong>' .
02250                         $GLOBALS['LANG']->getLL('extBackup_files') . '</strong></td><td>' .
02251                         '<a class="t3-link" href="' . htmlspecialchars(t3lib_div::linkThisScript(array(
02252                     'CMD[doBackup]' => 1,
02253                     'CMD[showExt]' => $extKey
02254                 ))) .
02255                         '">' . sprintf($GLOBALS['LANG']->getLL('extBackup_download'),
02256                     $extKey
02257                 ) . '</a><br />
02258                     (' . $filename . ', <br />' .
02259                         t3lib_div::formatSize(strlen($backUpData)) . ', <br />' .
02260                         $GLOBALS['LANG']->getLL('extBackup_md5') . ' ' . md5($backUpData) . ')
02261                     <br /></td></tr>';
02262 
02263                 if (is_array($techInfo['tables'])) {
02264                     $lines[] = '<tr class="bgColor4"><td><strong>' . $GLOBALS['LANG']->getLL('extBackup_data_tables') .
02265                             '</strong></td><td>' . tx_em_Database::dumpDataTablesLine($techInfo['tables'], $extKey) . '</td></tr>';
02266                 }
02267                 if (is_array($techInfo['static'])) {
02268                     $lines[] = '<tr class="bgColor4"><td><strong>' . $GLOBALS['LANG']->getLL('extBackup_static_tables') .
02269                             '</strong></td><td>' . tx_em_Database::dumpDataTablesLine($techInfo['static'], $extKey) . '</td></tr>';
02270                 }
02271 
02272                 $content = '<table border="0" cellpadding="2" cellspacing="2">' . implode('', $lines) . '</table>';
02273                 return $content;
02274             }
02275         } else {
02276             throw new RuntimeException(
02277                 'TYPO3 Fatal Error: ' . $GLOBALS['LANG']->getLL('extBackup_unexpected_error'),
02278                 1270853981
02279             );
02280         }
02281     }
02282 
02283 
02284 
02285     /**
02286      * Prints the upload form for extensions
02287      *
02288      * @param   string      Extension key
02289      * @param   array       Extension information array
02290      * @return  string      HTML content.
02291      */
02292     function getRepositoryUploadForm($extKey, $extInfo) {
02293         $content = '<form action="' . $this->script . '" method="post" name="repuploadform">
02294             <input type="hidden" name="CMD[showExt]" value="' . $extKey . '" />
02295             <input type="hidden" name="em[action]" value="doUpload" />
02296             <table border="0" cellpadding="2" cellspacing="1">
02297                 <tr class="bgColor4">
02298                     <td>' . $GLOBALS['LANG']->getLL('repositoryUploadForm_username') . '</td>
02299                     <td><input' . $this->doc->formWidth(20) . ' type="text" name="em[user][fe_u]" value="' . $this->fe_user['username'] . '" /></td>
02300                 </tr>
02301                 <tr class="bgColor4">
02302                     <td>' . $GLOBALS['LANG']->getLL('repositoryUploadForm_password') . '</td>
02303                     <td><input' . $this->doc->formWidth(20) . ' type="password" name="em[user][fe_p]" value="' . $this->fe_user['password'] . '" /></td>
02304                 </tr>
02305                 <tr class="bgColor4">
02306                     <td>' . $GLOBALS['LANG']->getLL('repositoryUploadForm_changelog') . '</td>
02307                     <td><textarea' . $this->doc->formWidth(30, 1) . ' rows="5" name="em[upload][comment]"></textarea></td>
02308                 </tr>
02309                 <tr class="bgColor4">
02310                     <td>' . $GLOBALS['LANG']->getLL('repositoryUploadForm_command') . '</td>
02311                     <td nowrap="nowrap">
02312                         <input type="radio" name="em[upload][mode]" id="new_dev" value="new_dev" checked="checked" />
02313                             <label for="new_dev">' . sprintf($GLOBALS['LANG']->getLL('repositoryUploadForm_new_bugfix'),
02314                 'x.x.<strong>' . tx_em_Tools::rfw('x+1') . '</strong>'
02315         ) . '</label><br />
02316                         <input type="radio" name="em[upload][mode]" id="new_sub" value="new_sub" />
02317                             <label for="new_sub">' . sprintf($GLOBALS['LANG']->getLL('repositoryUploadForm_new_sub_version'),
02318                 'x.<strong>' . tx_em_Tools::rfw('x+1') . '</strong>.0'
02319         ) . '</label><br />
02320                         <input type="radio" name="em[upload][mode]" id="new_main" value="new_main" />
02321                             <label for="new_main">' . sprintf($GLOBALS['LANG']->getLL('repositoryUploadForm_new_main_version'),
02322                 '<strong>' . tx_em_Tools::rfw('x+1') . '</strong>.0.0'
02323         ) . '</label><br />
02324                     </td>
02325                 </tr>
02326                 <tr class="bgColor4">
02327                     <td>&nbsp;</td>
02328                     <td><input type="submit" name="submit" value="' . $GLOBALS['LANG']->getLL('repositoryUploadForm_upload') . '" />
02329                     </td>
02330                 </tr>
02331             </table>
02332             </form>';
02333 
02334         return $content;
02335     }
02336 
02337 
02338     /************************************
02339      *
02340      * Output helper functions
02341      *
02342      ************************************/
02343 
02344 
02345     /**
02346      * Returns a header for an extensions including icon if any
02347      *
02348      * @param   string      Extension key
02349      * @param   array       Extension information array
02350      * @param   string      align-attribute value (for <img> tag)
02351      * @return  string      HTML; Extension title and image.
02352      */
02353     function extensionTitleIconHeader($extKey, $extInfo, $align = 'top') {
02354         $imgInfo = @getImageSize(tx_em_Tools::getExtPath($extKey, $extInfo['type']) . '/ext_icon.gif');
02355         $out = '';
02356         if (is_array($imgInfo)) {
02357             $out .= '<img src="' . $GLOBALS['BACK_PATH'] . tx_em_Tools::typeRelPath($extInfo['type']) . $extKey . '/ext_icon.gif" ' . $imgInfo[3] . ' align="' . $align . '" alt="" />';
02358         }
02359         $out .= $extInfo['EM_CONF']['title'] ? htmlspecialchars(t3lib_div::fixed_lgd_cs($extInfo['EM_CONF']['title'], 40)) : '<em>' . htmlspecialchars($extKey) . '</em>';
02360         return $out;
02361     }
02362 
02363 
02364 
02365 
02366 
02367 
02368 
02369 
02370     /************************************
02371      *
02372      * Various helper functions
02373      *
02374      ************************************/
02375 
02376     /**
02377      * Returns subtitles for the extension listings
02378      *
02379      * @param   string      List order type
02380      * @param   string      Key value
02381      * @return  string      output.
02382      */
02383     function listOrderTitle($listOrder, $key) {
02384         switch ($listOrder) {
02385             case 'cat':
02386                 return isset($this->categories[$key]) ? $this->categories[$key] : '[' . $key . ']';
02387                 break;
02388             case 'author_company':
02389                 return $key;
02390                 break;
02391             case 'state':
02392                 return $this->states[$key];
02393                 break;
02394             case 'type':
02395                 return $this->typeDescr[$key];
02396                 break;
02397         }
02398     }
02399 
02400 
02401     /**
02402      * Returns true if global OR local installation of extensions is allowed/possible.
02403      *
02404      * @return  boolean     Returns true if global OR local installation of extensions is allowed/possible.
02405      */
02406     function importAtAll() {
02407         return ($GLOBALS['TYPO3_CONF_VARS']['EXT']['allowGlobalInstall'] || $GLOBALS['TYPO3_CONF_VARS']['EXT']['allowLocalInstall']);
02408     }
02409 
02410 
02411     /**
02412      * Searches for ->lookUpStr in extension and returns true if found (or if no search string is set)
02413      *
02414      * @param   string      Extension key
02415      * @param   array       Extension content
02416      * @return  boolean     If true, display extension in list
02417      */
02418     function searchExtension($extKey, $row) {
02419         if ($this->lookUpStr) {
02420             return (
02421                     stristr($extKey, $this->lookUpStr) ||
02422                             stristr($row['EM_CONF']['title'], $this->lookUpStr) ||
02423                             stristr($row['EM_CONF']['description'], $this->lookUpStr) ||
02424                             stristr($row['EM_CONF']['author'], $this->lookUpStr) ||
02425                             stristr($row['EM_CONF']['author_company'], $this->lookUpStr)
02426             );
02427         } else {
02428             return true;
02429         }
02430     }
02431 
02432 
02433     /**
02434      *  Checks if there are newer versions of installed extensions in the TER
02435      *  integrated from the extension "ter_update_check" for TYPO3 4.2 by Christian Welzel
02436      *
02437      * @return  nothing
02438      */
02439     function checkForUpdates() {
02440         global $LANG;
02441         $content = '';
02442 
02443         if (is_file(PATH_site . 'typo3temp/extensions.xml.gz')) {
02444             $content = $this->extensionList->showExtensionsToUpdate()
02445                     . t3lib_BEfunc::getFuncCheck(0, 'SET[display_installed]', $this->MOD_SETTINGS['display_installed'], '', '', 'id="checkDisplayInstalled"')
02446                     . '&nbsp;<label for="checkDisplayInstalled">' . $LANG->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:display_nle') . '</label><br />'
02447                     . t3lib_BEfunc::getFuncCheck(0, 'SET[display_files]', $this->MOD_SETTINGS['display_files'], '', '', 'id="checkDisplayFiles"')
02448                     . '&nbsp;<label for="checkDisplayFiles">' . $LANG->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:display_files') . '</label>';
02449             $this->content .= $this->doc->section($LANG->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:header_upd_ext'), $content, 0, 1);
02450 
02451             $dateFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'];
02452             $timeFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'];
02453             $content = sprintf($GLOBALS['LANG']->getLL('note_last_update_new'),
02454                 date(
02455                     $dateFormat . ', ' . $timeFormat,
02456                     filemtime(PATH_site . 'typo3temp/extensions.xml.gz')
02457                 )
02458             ) . '<br />';
02459         }
02460 
02461         $content .= sprintf($GLOBALS['LANG']->getLL('note_last_update2_new'),
02462                 '<a href="' . t3lib_div::linkThisScript(array(
02463                     'SET[function]' => 2
02464                 )) . '">', '</a>');
02465         $this->content .= $this->doc->section($LANG->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:header_vers_ret'), $content, 0, 1);
02466     }
02467 
02468 
02469     function showRepositoryUpdateForm() {
02470         $content = '<div class="em-repupdate"><strong>Repository:</strong>';
02471 
02472         // print registered repositories
02473         /* @var $settings em_settings */
02474         $settings = t3lib_div::makeInstance('tx_em_Settings');
02475         $registeredRepos = $settings->getRegisteredRepositories();
02476         $content .= '<select>';
02477         foreach ($registeredRepos as $repository) {
02478             $content .= '<option>' . $repository->getTitle() . '</option>';
02479         }
02480         $content .= '</select>';
02481 
02482         $selectedRepo = $settings->getSelectedRepository();
02483         /* @var $repoUtility em_repository_utility */
02484         $repoUtility = t3lib_div::makeInstance('tx_em_Repository_Utility');
02485         $repoUtility->setRepository($selectedRepo);
02486 
02487         $onCLick = 'window.location.href="' . t3lib_div::linkThisScript(array(
02488             'CMD[fetchMetaData]' => 'extensions'
02489         )) . '";return false;';
02490         $content .= '
02491             <input type="button" value="' . $GLOBALS['LANG']->getLL('retrieve_update') .
02492                 '" onclick="' . htmlspecialchars($onCLick) . '" />';
02493         if (is_file($repoUtility->getLocalExtListFile())) {
02494             $dateFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'];
02495             $timeFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'];
02496 
02497             $count = tx_em_Database::getExtensionCountFromRepository($repoUtility->getRepositoryUID());
02498             $content .= '<span style="margin-left:10px;padding-right: 50px;" class="typo3-message message-notice">' .
02499                     sprintf($GLOBALS['LANG']->getLL('ext_list_last_updated'),
02500                         date(
02501                             $dateFormat . ', ' . $timeFormat,
02502                             filemtime($repoUtility->getLocalExtListFile())
02503                         ), $count) . '</span>';
02504         } else {
02505             $content .= '<span style="margin-left:10px;padding-right: 50px;" class="typo3-message message-error">There are no extensions available, please update!</span>';
02506         }
02507         $content .= '<br>&nbsp;<br>';
02508 
02509         if ($this->CMD['fetchMetaData'] && $this->CMD['fetchMetaData'] == 'extensions') { // fetches mirror/extension data from online rep.
02510             $content .= $repoUtility->updateExtList(TRUE)->render();
02511         }
02512 
02513         $content .= '</div>';
02514         return $content;
02515     }
02516 
02517 
02518     // Function wrappers for compatibility
02519 
02520     /**
02521      * Reports back if installation in a certain scope is possible.
02522      *
02523      * @param   string      Scope: G, L, S
02524      * @param   string      Extension lock-type (eg. "L" or "G")
02525      * @return  boolean     True if installation is allowed.
02526      */
02527     public static function importAsType($type, $lockType = '') {
02528         return tx_em_Tools::importAsType($type, $lockType);
02529     }
02530 
02531     /**
02532      * Returns the list of available (installed) extensions
02533      *
02534      * @return  array       Array with two arrays, list array (all extensions with info) and category index
02535      * @wrapper for compatibility
02536      */
02537     public function getInstalledExtensions() {
02538         return $this->extensionList->getInstalledExtensions();
02539     }
02540 
02541 
02542     /**
02543      * @return string
02544      */
02545     protected function getSubmitAndOpenerCloseLink() {
02546         if (!$this->CMD['standAlone'] && !$this->noDocHeader && ($this->CMD['standAlone'] || t3lib_div::_GP('standAlone'))) {
02547             $link = '<a href="javascript:opener.top.list.iframe.document.forms[0].submit();window.close();">' .
02548                 $GLOBALS['LANG']->getLL('ext_import_close_check') . '</a>';
02549             return $link;
02550         } else {
02551             return '<a id="closewindow" href="javascript:if (parent.TYPO3.EM) {parent.TYPO3.EM.Tools.closeImportWindow();} else {window.close();}">' . $GLOBALS['LANG']->getLL('ext_import_close') . '</a>';
02552         }
02553     }
02554 
02555 
02556     /* Compatibility wrappers */
02557 
02558 
02559 /**
02560      * Returns the absolute path where the extension $extKey is installed (based on 'type' (SGL))
02561      *
02562      * @param   string      Extension key
02563      * @param   string      Install scope type: L, G, S
02564      * @return  string      Returns the absolute path to the install scope given by input $type variable. It is checked if the path is a directory. Slash is appended.
02565      */
02566     public function getExtPath($extKey, $type, $returnWithoutExtKey = FALSE) {
02567         return tx_em_Tools::getExtPath($extKey, $type, $returnWithoutExtKey);
02568     }
02569 }
02570 
02571 
02572 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['em/index.php']) {
02573     include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['em/index.php']);
02574 }
02575 
02576 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/sysext/em/classes/index.php'])) {
02577     include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/sysext/em/classes/index.php']);
02578 }
02579 
02580 
02581 // Make instance:
02582 $SOBE = t3lib_div::makeInstance('SC_mod_tools_em_index');
02583 $SOBE->init();
02584 foreach ($SOBE->include_once as $INC_FILE) {
02585     include_once($INC_FILE);
02586 }
02587 $SOBE->checkExtObj();
02588 
02589 $SOBE->main();
02590 $SOBE->printContent();
02591 
02592 ?>