Added improvement #11855: security related links in EM are not marked as links.
[Packages/TYPO3.CMS.git] / typo3 / mod / tools / em / class.em_index.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
6 * (c) 2005-2009 Karsten Dambekalns <karsten@typo3.org>
7 * All rights reserved
8 *
9 * This script is part of the TYPO3 project. The TYPO3 project is
10 * free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * The GNU General Public License can be found at
16 * http://www.gnu.org/copyleft/gpl.html.
17 * A copy is found in the textfile GPL.txt and important notices to the license
18 * from the author is found in LICENSE.txt distributed with these scripts.
19 *
20 *
21 * This script is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * This copyright notice MUST APPEAR in all copies of the script!
27 ***************************************************************/
28 /**
29 * Module: Extension manager
30 *
31 * $Id$
32 *
33 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
34 * @author Karsten Dambekalns <karsten@typo3.org>
35 */
36 /**
37 * [CLASS/FUNCTION INDEX of SCRIPT]
38 *
39 *
40 *
41 * 194: class SC_mod_tools_em_index extends t3lib_SCbase
42 *
43 * SECTION: Standard module initialization
44 * 337: function init()
45 * 417: function handleExternalFunctionValue($MM_key='function', $MS_value=NULL)
46 * 431: function menuConfig()
47 * 508: function main()
48 * 584: function printContent()
49 *
50 * SECTION: Function Menu Applications
51 * 609: function extensionList_loaded()
52 * 664: function extensionList_installed()
53 * 736: function extensionList_import()
54 * 903: function alterSettings()
55 *
56 * SECTION: Command Applications (triggered by GET var)
57 * 1005: function importExtInfo($extKey, $version='')
58 * 1062: function fetchMetaData($metaType)
59 * 1125: function getMirrorURL()
60 * 1158: function installExtension($extKey, $version=null, $mode=EM_INSTALL_VERSION_MIN)
61 * 1279: function importExtFromRep($extKey,$version,$loc,$uploadFlag=0,$dontDelete=0,$directInput='')
62 * 1425: function showExtDetails($extKey)
63 *
64 * SECTION: Application Sub-functions (HTML parts)
65 * 1737: function updatesForm($extKey,$extInfo,$notSilent=0,$script='',$addFields='')
66 * 1768: function extDumpTables($extKey,$extInfo)
67 * 1835: function getFileListOfExtension($extKey,$conf)
68 * 1889: function extDelete($extKey,$extInfo)
69 * 1920: function extUpdateEMCONF($extKey,$extInfo)
70 * 1940: function extBackup($extKey,$extInfo)
71 * 1987: function extBackup_dumpDataTablesLine($tablesArray,$extKey)
72 * 2015: function extInformationArray($extKey,$extInfo,$remote=0)
73 * 2097: function extInformationArray_dbReq($techInfo,$tableHeader=0)
74 * 2110: function extInformationArray_dbInst($dbInst,$current)
75 * 2129: function getRepositoryUploadForm($extKey,$extInfo)
76 *
77 * SECTION: Extension list rendering
78 * 2190: function extensionListRowHeader($trAttrib,$cells,$import=0)
79 * 2251: function extensionListRow($extKey,$extInfo,$cells,$bgColorClass='',$inst_list=array(),$import=0,$altLinkUrl='')
80 *
81 * SECTION: Output helper functions
82 * 2367: function wrapEmail($str,$email)
83 * 2380: function helpCol($key)
84 * 2396: function labelInfo($str)
85 * 2408: function extensionTitleIconHeader($extKey,$extInfo,$align='top')
86 * 2423: function removeButton()
87 * 2432: function installButton()
88 * 2441: function noImportMsg()
89 * 2454: function depToString($dep,$type='depends')
90 * 2473: function stringToDep($dep)
91 *
92 * SECTION: Read information about all available extensions
93 * 2503: function getInstalledExtensions()
94 * 2530: function getInstExtList($path,&$list,&$cat,$type)
95 * 2561: function fixEMCONF($emConf)
96 * 2600: function splitVersionRange($ver)
97 * 2616: function prepareImportExtList()
98 * 2660: function setCat(&$cat,$listArrayPart,$extKey)
99 *
100 * SECTION: Extension analyzing (detailed information)
101 * 2710: function makeDetailedExtensionAnalysis($extKey,$extInfo,$validity=0)
102 * 2892: function getClassIndexLocallangFiles($absPath,$table_class_prefix,$extKey)
103 * 2962: function modConfFileAnalysis($confFilePath)
104 * 2990: function serverExtensionMD5Array($extKey,$conf)
105 * 3015: function findMD5ArrayDiff($current,$past)
106 *
107 * SECTION: File system operations
108 * 3047: function createDirsInPath($dirs,$extDirPath)
109 * 3065: function removeExtDirectory($removePath,$removeContentOnly=0)
110 * 3128: function clearAndMakeExtensionDir($importedData,$type,$dontDelete=0)
111 * 3182: function removeCacheFiles()
112 * 3192: function extractDirsFromFileList($files)
113 * 3218: function getExtPath($extKey,$type)
114 *
115 * SECTION: Writing to "conf.php" and "localconf.php" files
116 * 3252: function writeTYPO3_MOD_PATH($confFilePath,$type,$mP)
117 * 3289: function writeNewExtensionList($newExtList)
118 * 3312: function writeTsStyleConfig($extKey,$arr)
119 * 3334: function updateLocalEM_CONF($extKey,$extInfo)
120 *
121 * SECTION: Compiling upload information, emconf-file etc.
122 * 3376: function construct_ext_emconf_file($extKey,$EM_CONF)
123 * 3407: function arrayToCode($array, $level=0)
124 * 3433: function makeUploadArray($extKey,$conf)
125 * 3502: function getSerializedLocalLang($file,$content)
126 *
127 * SECTION: Managing dependencies, conflicts, priorities, load order of extension keys
128 * 3538: function addExtToList($extKey,$instExtInfo)
129 * 3569: function checkDependencies($extKey, $conf, $instExtInfo)
130 * 3709: function removeExtFromList($extKey,$instExtInfo)
131 * 3746: function removeRequiredExtFromListArr($listArr)
132 * 3761: function managesPriorities($listArr,$instExtInfo)
133 *
134 * SECTION: System Update functions (based on extension requirements)
135 * 3813: function checkClearCache($extInfo)
136 * 3840: function checkUploadFolder($extKey,$extInfo)
137 * 3925: function checkDBupdates($extKey,$extInfo,$infoOnly=0)
138 * 4022: function forceDBupdates($extKey, $extInfo)
139 * 4080: function tsStyleConfigForm($extKey,$extInfo,$output=0,$script='',$addFields='')
140 *
141 * SECTION: Dumping database (MySQL compliant)
142 * 4175: function dumpTableAndFieldStructure($arr)
143 * 4200: function dumpStaticTables($tableList)
144 * 4229: function dumpHeader()
145 * 4246: function dumpTableHeader($table,$fieldKeyInfo,$dropTableIfExists=0)
146 * 4288: function dumpTableContent($table,$fieldStructure)
147 * 4323: function getTableAndFieldStructure($parts)
148 *
149 * SECTION: TER Communication functions
150 * 4373: function uploadExtensionToTER($em)
151 *
152 * SECTION: Various helper functions
153 * 4411: function listOrderTitle($listOrder,$key)
154 * 4436: function makeVersion($v,$mode)
155 * 4448: function renderVersion($v,$raise='')
156 * 4485: function ulFolder($extKey)
157 * 4494: function importAtAll()
158 * 4505: function importAsType($type,$lockType='')
159 * 4527: function deleteAsType($type)
160 * 4548: function versionDifference($v1,$v2,$div=1)
161 * 4560: function first_in_array($str,$array,$caseInsensitive=FALSE)
162 * 4578: function includeEMCONF($path,$_EXTKEY)
163 * 4593: function searchExtension($extKey,$row)
164 *
165 * TOTAL FUNCTIONS: 90
166 * (This index is automatically created/updated by the extension "extdeveval")
167 *
168 */
169
170 // Include classes needed:
171 require_once('class.em_xmlhandler.php');
172 require_once('class.em_terconnection.php');
173 require_once('class.em_unzip.php');
174
175 $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_mod_tools_em.xml');
176
177 // from tx_ter by Robert Lemke
178 define('TX_TER_RESULT_EXTENSIONSUCCESSFULLYUPLOADED', '10504');
179
180 define('EM_INSTALL_VERSION_MIN', 1);
181 define('EM_INSTALL_VERSION_MAX', 2);
182 define('EM_INSTALL_VERSION_STRICT', 3);
183
184 /**
185 * Module: Extension manager
186 *
187 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
188 * @author Karsten Dambekalns <karsten@typo3.org>
189 * @package TYPO3
190 * @subpackage core
191 */
192 class SC_mod_tools_em_index extends t3lib_SCbase {
193
194 // Internal, static:
195 var $versionDiffFactor = 1; // This means that version difference testing for import is detected for sub-versions only, not dev-versions. Default: 1000
196 var $systemInstall = 0; // If "1" then installs in the sysext directory is allowed. Default: 0
197 var $requiredExt = ''; // List of required extension (from TYPO3_CONF_VARS)
198 var $maxUploadSize = 31457280; // Max size in bytes of extension upload to repository
199 var $kbMax = 500; // Max size in kilobytes for files to be edited.
200 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
201 var $listingLimit = 500; // List that many extension maximally at one time (fixing memory problems)
202 var $listingLimitAuthor = 250; // List that many extension maximally at one time (fixing memory problems)
203
204 /**
205 * Internal variable loaded with extension categories (for display/listing). Should reflect $categories above
206 * Dynamic var.
207 */
208 var $defaultCategories = Array(
209 'cat' => Array (
210 'be' => array(),
211 'module' => array(),
212 'fe' => array(),
213 'plugin' => array(),
214 'misc' => array(),
215 'services' => array(),
216 'templates' => array(),
217 'example' => array(),
218 'doc' => array()
219 )
220 );
221
222 var $categories = array(); // Extension Categories (static var); see init()
223
224 var $states = array(); // Extension States; see init()
225
226 /**
227 * Colors for extension states
228 */
229 var $stateColors = Array (
230 'alpha' => '#d12438',
231 'beta' => '#97b17e',
232 'stable' => '#3bb65c',
233 'experimental' => '#007eba',
234 'test' => '#979797',
235 'obsolete' => '#000000',
236 'excludeFromUpdates' => '#cf7307'
237 );
238
239 /**
240 * "TYPE" information; labels, paths, description etc. See init()
241 */
242 var $typeLabels = array();
243 var $typeDescr = array();
244 var $typePaths = Array(); // Also static, set in init()
245 var $typeBackPaths = Array(); // Also static, set in init()
246
247 var $typeRelPaths = Array (
248 'S' => 'sysext/',
249 'G' => 'ext/',
250 'L' => '../typo3conf/ext/',
251 );
252
253 var $detailCols = Array (
254 0 => 2,
255 1 => 5,
256 2 => 6,
257 3 => 6,
258 4 => 4,
259 5 => 1
260 );
261
262 var $fe_user = array(
263 'username' => '',
264 'password' => '',
265 );
266
267 var $privacyNotice; // Set in init()
268 var $securityHint; // Set in init()
269 var $editTextExtensions = 'html,htm,txt,css,tmpl,inc,php,sql,conf,cnf,pl,pm,sh,xml,ChangeLog';
270 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';
271
272
273
274
275
276 // Default variables for backend modules
277 var $MCONF = array(); // Module configuration
278 var $MOD_MENU = array(); // Module menu items
279 var $MOD_SETTINGS = array(); // Module session settings
280 /**
281 * Document Template Object
282 *
283 * @var noDoc
284 */
285 var $doc;
286 var $content; // Accumulated content
287
288 var $inst_keys = array(); // Storage of installed extensions
289 var $gzcompress = 0; // Is set true, if system support compression.
290
291 /**
292 * instance of TER connection handler
293 *
294 * @var SC_mod_tools_em_terconnection
295 */
296 var $terConnection;
297
298 /**
299 * XML handling class for the TYPO3 Extension Manager
300 *
301 * @var SC_mod_tools_em_xmlhandler
302 */
303 var $xmlhandler;
304 var $JScode; // JavaScript code to be forwared to $this->doc->JScode
305
306 // GPvars:
307 var $CMD = array(); // CMD array
308 var $listRemote; // If set, connects to remote repository
309 var $lookUpStr; // Search string when listing local extensions
310
311
312
313
314 /*********************************
315 *
316 * Standard module initialization
317 *
318 *********************************/
319
320 /**
321 * Standard init function of a module.
322 *
323 * @return void
324 */
325 function init() {
326 global $BE_USER,$LANG,$BACK_PATH,$TYPO3_CONF_VARS;
327
328 /**
329 * Extension Categories (static var)
330 * Content must be redundant with the same internal variable as in class.tx_extrep.php!
331 */
332 $this->categories = array(
333 'be' => $GLOBALS['LANG']->getLL('category_BE'),
334 'module' => $GLOBALS['LANG']->getLL('category_BE_modules'),
335 'fe' => $GLOBALS['LANG']->getLL('category_FE'),
336 'plugin' => $GLOBALS['LANG']->getLL('category_FE_plugins'),
337 'misc' => $GLOBALS['LANG']->getLL('category_miscellanous'),
338 'services' => $GLOBALS['LANG']->getLL('category_services'),
339 'templates' => $GLOBALS['LANG']->getLL('category_templates'),
340 'example' => $GLOBALS['LANG']->getLL('category_examples'),
341 'doc' => $GLOBALS['LANG']->getLL('category_documentation')
342 );
343
344 /**
345 * Extension States
346 * Content must be redundant with the same internal variable as in class.tx_extrep.php!
347 */
348 $this->states = array(
349 'alpha' => $GLOBALS['LANG']->getLL('state_alpha'),
350 'beta' => $GLOBALS['LANG']->getLL('state_beta'),
351 'stable' => $GLOBALS['LANG']->getLL('state_stable'),
352 'experimental' => $GLOBALS['LANG']->getLL('state_experimental'),
353 'test' => $GLOBALS['LANG']->getLL('state_test'),
354 'obsolete' => $GLOBALS['LANG']->getLL('state_obsolete'),
355 'excludeFromUpdates' => $GLOBALS['LANG']->getLL('state_exclude_from_updates')
356 );
357
358 /**
359 * "TYPE" information; labels, paths, description etc.
360 */
361 $this->typeLabels = array(
362 'S' => $GLOBALS['LANG']->getLL('type_system'),
363 'G' => $GLOBALS['LANG']->getLL('type_global'),
364 'L' => $GLOBALS['LANG']->getLL('type_local'),
365 );
366 $this->typeDescr = array(
367 'S' => $GLOBALS['LANG']->getLL('descr_system'),
368 'G' => $GLOBALS['LANG']->getLL('descr_global'),
369 'L' => $GLOBALS['LANG']->getLL('descr_local'),
370 );
371
372 // Setting paths of install scopes:
373 $this->typePaths = Array (
374 'S' => TYPO3_mainDir.'sysext/',
375 'G' => TYPO3_mainDir.'ext/',
376 'L' => 'typo3conf/ext/'
377 );
378 $this->typeBackPaths = Array (
379 'S' => '../../../',
380 'G' => '../../../',
381 'L' => '../../../../'.TYPO3_mainDir
382 );
383
384 $this->privacyNotice = $GLOBALS['LANG']->getLL('privacy_notice');
385 $this->securityHint = '<div class="typo3-message message-information">
386 <strong>' . $GLOBALS['LANG']->getLL('security_header') . '</strong><br />' .
387 sprintf($GLOBALS['LANG']->getLL('security_descr'),
388 '<a href="http://typo3.org/teams/security/" target="_blank">', '</a>'
389 );
390 $this->securityHint .= '</div>';
391
392 $this->excludeForPackaging = $GLOBALS['TYPO3_CONF_VARS']['EXT']['excludeForPackaging'];
393
394 // Setting module configuration:
395 $this->MCONF = $GLOBALS['MCONF'];
396
397 // Setting GPvars:
398 $this->CMD = is_array(t3lib_div::_GP('CMD')) ? t3lib_div::_GP('CMD') : array();
399 $this->lookUpStr = trim(t3lib_div::_GP('_lookUp'));
400 $this->listRemote = t3lib_div::_GP('ter_connect');
401 $this->listRemote_search = trim(t3lib_div::_GP('ter_search'));
402
403
404 // Configure menu
405 $this->menuConfig();
406
407 // Setting internal static:
408 if ($TYPO3_CONF_VARS['EXT']['allowSystemInstall']) $this->systemInstall = 1;
409 $this->requiredExt = t3lib_div::trimExplode(',',$TYPO3_CONF_VARS['EXT']['requiredExt'],1);
410
411
412 // Initialize helper object
413 $this->terConnection = t3lib_div::makeInstance('SC_mod_tools_em_terconnection');
414 $this->terConnection->emObj = $this;
415 $this->terConnection->wsdlURL = $TYPO3_CONF_VARS['EXT']['em_wsdlURL'];
416 $this->xmlhandler = t3lib_div::makeInstance('SC_mod_tools_em_xmlhandler');
417 $this->xmlhandler->emObj = $this;
418 $this->xmlhandler->useUnchecked = $this->MOD_SETTINGS['display_unchecked'];
419 $this->xmlhandler->useObsolete = $this->MOD_SETTINGS['display_obsolete'];
420
421 // Initialize Document Template object:
422 $this->doc = t3lib_div::makeInstance('template');
423 $this->doc->backPath = $BACK_PATH;
424 $this->doc->setModuleTemplate('templates/em_index.html');
425
426 // JavaScript
427 $this->doc->JScode = $this->doc->wrapScriptTags('
428 script_ended = 0;
429 function jumpToUrl(URL) { //
430 window.location.href = URL;
431 }
432 ');
433
434 // Reload left frame menu
435 if ($this->CMD['refreshMenu']) {
436 $this->doc->JScode .= $this->doc->wrapScriptTags('
437 if(top.refreshMenu) {
438 top.refreshMenu();
439 } else {
440 top.TYPO3ModuleMenu.refreshMenu();
441 }
442 ');
443 }
444
445
446 // Descriptions:
447 $this->descrTable = '_MOD_'.$this->MCONF['name'];
448 if ($BE_USER->uc['edit_showFieldHelp']) {
449 $LANG->loadSingleTableDescription($this->descrTable);
450 }
451
452 // Setting username/password etc. for upload-user:
453 $this->fe_user['username'] = $this->MOD_SETTINGS['fe_u'];
454 $this->fe_user['password'] = $this->MOD_SETTINGS['fe_p'];
455 parent::init();
456 $this->handleExternalFunctionValue('singleDetails');
457 }
458
459 /**
460 * This function is a copy of the same function in t3lib_SCbase with one modification:
461 * In contrast to t3lib_SCbase::handleExternalFunctionValue() this function merges the $this->extClassConf array
462 * instead of overwriting it. That was necessary for including the Kickstarter as a submodule into the 'singleDetails'
463 * selectorbox as well as in the main 'function' selectorbox.
464 *
465 * @param string Mod-setting array key
466 * @param string Mod setting value, overriding the one in the key
467 * @return void
468 * @see t3lib_SCbase::handleExternalFunctionValue()
469 */
470 function handleExternalFunctionValue($MM_key='function', $MS_value=NULL) {
471 $MS_value = is_null($MS_value) ? $this->MOD_SETTINGS[$MM_key] : $MS_value;
472 $externalItems = $this->getExternalItemConfig($this->MCONF['name'],$MM_key,$MS_value);
473 if (is_array($externalItems)) $this->extClassConf = array_merge($externalItems,is_array($this->extClassConf)?$this->extClassConf:array());
474 if (is_array($this->extClassConf) && $this->extClassConf['path']) {
475 $this->include_once[]=$this->extClassConf['path'];
476 }
477 }
478
479 /**
480 * Configuration of which mod-menu items can be used
481 *
482 * @return void
483 */
484 function menuConfig() {
485 global $BE_USER, $TYPO3_CONF_VARS;
486
487 // MENU-ITEMS:
488 $this->MOD_MENU = array(
489 'function' => array(
490 0 => $GLOBALS['LANG']->getLL('menu_loaded_extensions'),
491 1 => $GLOBALS['LANG']->getLL('menu_install_extensions'),
492 2 => $GLOBALS['LANG']->getLL('menu_import_extensions'),
493 4 => $GLOBALS['LANG']->getLL('menu_translation_handling'),
494 3 => $GLOBALS['LANG']->getLL('menu_settings'),
495 5 => $GLOBALS['LANG']->getLL('menu_extension_updates'),
496 ),
497 'listOrder' => array(
498 'cat' => $GLOBALS['LANG']->getLL('list_order_category'),
499 'author_company' => $GLOBALS['LANG']->getLL('list_order_author'),
500 'state' => $GLOBALS['LANG']->getLL('list_order_state'),
501 'type' => $GLOBALS['LANG']->getLL('list_order_type'),
502 ),
503 'display_details' => array(
504 1 => $GLOBALS['LANG']->getLL('show_details'),
505 0 => $GLOBALS['LANG']->getLL('show_description'),
506 2 => $GLOBALS['LANG']->getLL('show_more_details'),
507
508 3 => $GLOBALS['LANG']->getLL('show_technical'),
509 4 => $GLOBALS['LANG']->getLL('show_validating'),
510 5 => $GLOBALS['LANG']->getLL('show_changed'),
511 ),
512 'display_shy' => '',
513 'display_own' => '',
514 'display_unchecked' => '',
515 'display_obsolete' => '',
516 'display_installed' => '',
517 'display_files' => '',
518
519
520 'singleDetails' => array(
521 'info' => $GLOBALS['LANG']->getLL('details_info'),
522 'edit' => $GLOBALS['LANG']->getLL('details_edit'),
523 'backup' => $GLOBALS['LANG']->getLL('details_backup_delete'),
524 'dump' => $GLOBALS['LANG']->getLL('details_dump_db'),
525 'upload' => $GLOBALS['LANG']->getLL('details_upload'),
526 'updateModule' => $GLOBALS['LANG']->getLL('details_update'),
527 ),
528 'fe_u' => '',
529 'fe_p' => '',
530
531 'mirrorListURL' => '',
532 'rep_url' => '',
533 'extMirrors' => '',
534 'selectedMirror' => '',
535
536 'selectedLanguages' => ''
537 );
538
539 $this->MOD_MENU['singleDetails'] = $this->mergeExternalItems($this->MCONF['name'],'singleDetails',$this->MOD_MENU['singleDetails']);
540
541 // page/be_user TSconfig settings and blinding of menu-items
542 if (!$BE_USER->getTSConfigVal('mod.'.$this->MCONF['name'].'.allowTVlisting')) {
543 unset($this->MOD_MENU['display_details'][3]);
544 unset($this->MOD_MENU['display_details'][4]);
545 unset($this->MOD_MENU['display_details'][5]);
546 }
547
548 // CLEANSE SETTINGS
549 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
550
551 if ($this->MOD_SETTINGS['function']==2) {
552 // If listing from online repository, certain items are removed though:
553 unset($this->MOD_MENU['listOrder']['type']);
554 unset($this->MOD_MENU['display_details'][2]);
555 unset($this->MOD_MENU['display_details'][3]);
556 unset($this->MOD_MENU['display_details'][4]);
557 unset($this->MOD_MENU['display_details'][5]);
558 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
559 }
560 parent::menuConfig();
561 }
562
563 /**
564 * Main function for Extension Manager module.
565 *
566 * @return void
567 */
568 function main() {
569 global $BE_USER,$LANG,$TYPO3_CONF_VARS;
570
571 if (empty($this->MOD_SETTINGS['mirrorListURL'])) $this->MOD_SETTINGS['mirrorListURL'] = $TYPO3_CONF_VARS['EXT']['em_mirrorListURL'];
572
573 // Starting page:
574 $this->content.=$this->doc->header($GLOBALS['LANG']->getLL('header'));
575 $this->content.=$this->doc->spacer(5);
576
577 // Command given which is executed regardless of main menu setting:
578 if ($this->CMD['showExt']) { // Show details for a single extension
579 $this->showExtDetails($this->CMD['showExt']);
580 } elseif ($this->CMD['requestInstallExtensions']) { // Show details for a single extension
581 $this->requestInstallExtensions($this->CMD['requestInstallExtensions']);
582 } elseif ($this->CMD['importExt'] || $this->CMD['uploadExt']) { // Imports an extension from online rep.
583 $err = $this->importExtFromRep($this->CMD['importExt'],$this->CMD['extVersion'],$this->CMD['loc'],$this->CMD['uploadExt']);
584 if ($err) {
585 $this->content.=$this->doc->section('',$GLOBALS['TBE_TEMPLATE']->rfw($err));
586 }
587 if(!$err && $this->CMD['importExt']) {
588 $this->installTranslationsForExtension($this->CMD['importExt'], $this->getMirrorURL());
589 }
590 } elseif ($this->CMD['importExtInfo']) { // Gets detailed information of an extension from online rep.
591 $this->importExtInfo($this->CMD['importExtInfo'],$this->CMD['extVersion']);
592 } else { // No command - we show what the menu setting tells us:
593 if (t3lib_div::inList('0,1,2',$this->MOD_SETTINGS['function'])) {
594 $menu .= '&nbsp;' . $GLOBALS['LANG']->getLL('group_by') . '&nbsp;' . t3lib_BEfunc::getFuncMenu(0, 'SET[listOrder]', $this->MOD_SETTINGS['listOrder'], $this->MOD_MENU['listOrder']) .
595 '&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 />';
596 }
597 if (t3lib_div::inList('0,1,5',$this->MOD_SETTINGS['function'])) {
598 $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"');
599 }
600 if (t3lib_div::inList('2',$this->MOD_SETTINGS['function']) && strlen($this->fe_user['username'])) {
601 $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"');
602 }
603 if (t3lib_div::inList('0,1,2',$this->MOD_SETTINGS['function'])) {
604 $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"');
605 }
606
607 $this->content.=$this->doc->section('','<form action="index.php" method="post" name="pageform"><span class="nobr">'.$menu.'</span></form>');
608 $this->content.=$this->doc->spacer(10);
609
610 switch((string)$this->MOD_SETTINGS['function']) {
611 case '0':
612 // Lists loaded (installed) extensions
613 $this->extensionList_loaded();
614 break;
615 case '1':
616 // Lists the installed (available) extensions
617 $this->extensionList_installed();
618 break;
619 case '2':
620 // Lists the extensions available from online rep.
621 $this->extensionList_import();
622 break;
623 case '3':
624 // Shows the settings screen
625 $this->alterSettings();
626 break;
627 case '4':
628 // Allows to set the translation preferences and check the status
629 $this->translationHandling();
630 break;
631 case '5':
632 // Shows a list of extensions with updates in TER
633 $this->checkForUpdates();
634 break;
635 default:
636 $this->extObjContent();
637 break;
638 }
639 }
640
641 // closing any form?
642 $formTags = substr_count($this->content, '<form') + substr_count($this->content, '</form');
643 if ($formTags % 2 > 0) {
644 $this->content .= '</form>';
645 }
646
647 // Setting up the buttons and markers for docheader
648 $docHeaderButtons = $this->getButtons();
649 $markers = array(
650 'CSH' => $docHeaderButtons['csh'],
651 'FUNC_MENU' => $this->getFuncMenu(),
652 'CONTENT' => $this->content
653 );
654
655 // Build the <body> for the module
656 $this->content = $this->doc->startPage('Extension Manager');
657 $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
658 $this->content.= $this->doc->endPage();
659 $this->content = $this->doc->insertStylesAndJS($this->content);
660 }
661
662 /**
663 * Print module content. Called as last thing in the global scope.
664 *
665 * @return void
666 */
667 function printContent() {
668 if ($this->doPrintContent) {
669 echo $this->content;
670 }
671 }
672
673 /**
674 * Create the function menu
675 *
676 * @return string HTML of the function menu
677 */
678 protected function getFuncMenu() {
679 $funcMenu = '';
680 if(!$this->CMD['showExt'] && !$this->CMD['requestInstallExtensions'] && !$this->CMD['importExt'] && !$this->CMD['uploadExt'] && !$this->CMD['importExtInfo']) {
681 $funcMenu = t3lib_BEfunc::getFuncMenu(0, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']);
682 } elseif($this->CMD['showExt'] && (!$this->CMD['standAlone'] && !t3lib_div::_GP('standAlone'))) {
683 $funcMenu = t3lib_BEfunc::getFuncMenu(0, 'SET[singleDetails]', $this->MOD_SETTINGS['singleDetails'], $this->MOD_MENU['singleDetails'], '', '&CMD[showExt]=' . $this->CMD['showExt']);
684 }
685 return $funcMenu;
686 }
687
688 /**
689 * Create the panel of buttons for submitting the form or otherwise perform operations.
690 *
691 * @return array all available buttons as an assoc. array
692 */
693 protected function getButtons() {
694
695 $buttons = array(
696 'csh' => '',
697 'back' => '',
698 'shortcut' => ''
699 );
700 // CSH
701 //$buttons['csh'] = t3lib_BEfunc::cshItem('_MOD_web_func', '', $GLOBALS['BACK_PATH']);
702
703 // Shortcut
704 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
705 $buttons['shortcut'] = $this->doc->makeShortcutIcon('CMD','function',$this->MCONF['name']);
706 }
707 // Back
708 if(($this->CMD['showExt'] && (!$this->CMD['standAlone'] && !t3lib_div::_GP('standAlone'))) || ($this->CMD['importExt'] || $this->CMD['uploadExt'] && (!$this->CMD['standAlone'])) || $this->CMD['importExtInfo']) {
709 $buttons['back'] = '<a href="index.php" class="typo3-goBack"><img' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/goback.gif') . ' title="' . $GLOBALS['LANG']->getLL('go_back') . '" class="absmiddle" alt="" /></a>';
710 }
711
712 return $buttons;
713 }
714
715
716
717
718
719
720
721
722 /*********************************
723 *
724 * Function Menu Applications
725 *
726 *********************************/
727
728 /**
729 * Listing of loaded (installed) extensions
730 *
731 * @return void
732 */
733 function extensionList_loaded() {
734 global $TYPO3_LOADED_EXT;
735
736 list($list,$cat) = $this->getInstalledExtensions();
737
738 // Loaded extensions
739 $content = '';
740 $lines = array();
741
742 // Available extensions
743 if (is_array($cat[$this->MOD_SETTINGS['listOrder']])) {
744 $content='';
745 $lines=array();
746 $lines[] = $this->extensionListRowHeader(' class="bgColor5"',array('<td><img src="clear.gif" width="1" height="1" alt="" /></td>'));
747
748 foreach($cat[$this->MOD_SETTINGS['listOrder']] as $catName => $extEkeys) {
749 natcasesort($extEkeys);
750 reset($extEkeys);
751 $extensions = array();
752 while(list($extKey)=each($extEkeys)) {
753 if (array_key_exists($extKey,$TYPO3_LOADED_EXT) && ($this->MOD_SETTINGS['display_shy'] || !$list[$extKey]['EM_CONF']['shy']) && $this->searchExtension($extKey,$list[$extKey])) {
754 if (in_array($extKey, $this->requiredExt)) {
755 $loadUnloadLink = '<strong>' . $GLOBALS['TBE_TEMPLATE']->rfw($GLOBALS['LANG']->getLL('extension_required_short')) . '</strong>';
756 } else {
757 $loadUnloadLink = '<a href="'.htmlspecialchars('index.php?CMD[showExt]='.$extKey.'&CMD[remove]=1').'">'.$this->removeButton().'</a>';
758 }
759
760 $extensions[] = $this->extensionListRow($extKey,$list[$extKey],array('<td class="bgColor">'.$loadUnloadLink.'</td>'));
761 }
762 }
763 if(count($extensions)) {
764 $lines[]='<tr><td colspan="'.(3+$this->detailCols[$this->MOD_SETTINGS['display_details']]).'"><br /></td></tr>';
765 $lines[]='<tr><td colspan="'.(3+$this->detailCols[$this->MOD_SETTINGS['display_details']]).'"><img '.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/i/sysf.gif"', 'width="18" height="16"').' align="top" alt="" /><strong>'.$this->listOrderTitle($this->MOD_SETTINGS['listOrder'],$catName).'</strong></td></tr>';
766 $lines[] = implode(chr(10),$extensions);
767 }
768 }
769 }
770
771 $content.= t3lib_BEfunc::cshItem('_MOD_tools_em', 'loaded', $GLOBALS['BACK_PATH'],'');
772 $content.= '<form action="index.php" method="post" name="lookupform">';
773 $content.= '<label for="_lookUp">' . $GLOBALS['LANG']->getLL('look_up') . '</label> <input type="text" id="_lookUp" name="_lookUp" value="' . htmlspecialchars($this->lookUpStr) . '" /><input type="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:search') . '" /><br /><br />';
774
775 $content.= '</form>
776
777 <!-- Loaded Extensions List -->
778 <table border="0" cellpadding="2" cellspacing="1">'.implode('',$lines).'</table>';
779
780 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('loaded_exts'),$content,0,1);
781 }
782
783 /**
784 * Listing of available (installed) extensions
785 *
786 * @return void
787 */
788 function extensionList_installed() {
789 global $TYPO3_LOADED_EXT;
790
791 list($list,$cat)=$this->getInstalledExtensions();
792
793 // Available extensions
794 if (is_array($cat[$this->MOD_SETTINGS['listOrder']])) {
795 $content='';
796 $lines=array();
797 $lines[]=$this->extensionListRowHeader(' class="bgColor5"',array('<td><img src="clear.gif" width="18" height="1" alt="" /></td>'));
798
799 $allKeys=array();
800 foreach($cat[$this->MOD_SETTINGS['listOrder']] as $catName => $extEkeys) {
801 if(!$this->MOD_SETTINGS['display_obsolete'] && $catName=='obsolete') continue;
802
803 $allKeys[]='';
804 $allKeys[]='TYPE: '.$catName;
805
806 natcasesort($extEkeys);
807 reset($extEkeys);
808 $extensions = array();
809 while(list($extKey)=each($extEkeys)) {
810 $allKeys[]=$extKey;
811 if ((!$list[$extKey]['EM_CONF']['shy'] || $this->MOD_SETTINGS['display_shy']) &&
812 ($list[$extKey]['EM_CONF']['state']!='obsolete' || $this->MOD_SETTINGS['display_obsolete'])
813 && $this->searchExtension($extKey,$list[$extKey])) {
814 $loadUnloadLink = t3lib_extMgm::isLoaded($extKey)?
815 '<a href="'.htmlspecialchars('index.php?CMD[showExt]='.$extKey.'&CMD[remove]=1&CMD[clrCmd]=1&SET[singleDetails]=info').'">'.$this->removeButton().'</a>':
816 '<a href="'.htmlspecialchars('index.php?CMD[showExt]='.$extKey.'&CMD[load]=1&CMD[clrCmd]=1&SET[singleDetails]=info').'">'.$this->installButton().'</a>';
817 if (in_array($extKey,$this->requiredExt)) {
818 $loadUnloadLink = '<strong>' . $GLOBALS['TBE_TEMPLATE']->rfw($GLOBALS['LANG']->getLL('extension_required_short')) . '</strong>';
819 }
820 $theRowClass = t3lib_extMgm::isLoaded($extKey)? 'em-listbg1' : 'em-listbg2';
821 $extensions[]=$this->extensionListRow($extKey,$list[$extKey],array('<td class="bgColor">'.$loadUnloadLink.'</td>'),$theRowClass);
822 }
823 }
824 if(count($extensions)) {
825 $lines[]='<tr><td colspan="'.(3+$this->detailCols[$this->MOD_SETTINGS['display_details']]).'"><br /></td></tr>';
826 $lines[]='<tr><td colspan="'.(3+$this->detailCols[$this->MOD_SETTINGS['display_details']]).'"><img '.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/i/sysf.gif"', 'width="18" height="16"').'align="top" alt="" /><strong>'.$this->listOrderTitle($this->MOD_SETTINGS['listOrder'],$catName).'</strong></td></tr>';
827 $lines[] = implode(chr(10),$extensions);
828 }
829 }
830
831 $content.='
832
833
834 <!--
835 EXTENSION KEYS:
836
837 '.trim(implode(chr(10),$allKeys)).'
838
839 -->
840
841 ';
842
843 $content.= t3lib_BEfunc::cshItem('_MOD_tools_em', 'avail', $GLOBALS['BACK_PATH'], '|<br />');
844 $content.= sprintf($GLOBALS['LANG']->getLL('how_to_install'), $this->installButton()) . ' <br />' .
845 sprintf($GLOBALS['LANG']->getLL('how_to_uninstall'), $this->removeButton()). ' <br /><br />';
846 $content .= '<form action="index.php" method="post" name="lookupform">';
847 $content .= '<label for="_lookUp">' . $GLOBALS['LANG']->getLL('look_up') . '</label> <input type="text" id="_lookUp" name="_lookUp" value="' . htmlspecialchars($this->lookUpStr) . '" /><input type="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:search') . '" /></form><br /><br />';
848 $content.= $this->securityHint.'<br /><br />';
849
850 $content.= '<table border="0" cellpadding="2" cellspacing="1">'.implode('',$lines).'</table>';
851
852 $this->content.=$this->doc->section(sprintf($GLOBALS['LANG']->getLL('available_extensions'), $this->MOD_MENU['listOrder'][$this->MOD_SETTINGS['listOrder']]),$content,0,1);
853 }
854 }
855
856 /**
857 * Listing remote extensions from online repository
858 *
859 * @return void
860 */
861 function extensionList_import() {
862 global $TYPO3_LOADED_EXT;
863 $content='';
864
865 // Listing from online repository:
866 if ($this->listRemote) {
867 list($inst_list,) = $this->getInstalledExtensions();
868 $this->inst_keys = array_flip(array_keys($inst_list));
869
870 $this->detailCols[1]+=6;
871
872 // see if we have an extensionlist at all
873 $this->extensionCount = $this->xmlhandler->countExtensions();
874 if (!$this->extensionCount) {
875 $content .= $this->fetchMetaData('extensions');
876 }
877
878 if($this->MOD_SETTINGS['listOrder']=='author_company') {
879 $this->listingLimit = $this->listingLimitAuthor;
880 }
881
882 $this->pointer = intval(t3lib_div::_GP('pointer'));
883 $offset = $this->listingLimit*$this->pointer;
884
885 if($this->MOD_SETTINGS['display_own'] && strlen($this->fe_user['username'])) {
886 $this->xmlhandler->searchExtensionsXML($this->listRemote_search, $this->fe_user['username'], $this->MOD_SETTINGS['listOrder']);
887 } else {
888 $this->xmlhandler->searchExtensionsXML($this->listRemote_search, '', $this->MOD_SETTINGS['listOrder'], false, false, $offset, $this->listingLimit);
889 }
890 if (count($this->xmlhandler->extensionsXML)) {
891 list($list,$cat) = $this->prepareImportExtList(true);
892
893 // Available extensions
894 if (is_array($cat[$this->MOD_SETTINGS['listOrder']])) {
895 $lines=array();
896 $lines[]=$this->extensionListRowHeader(' class="bgColor5"',array('<td><img src="clear.gif" width="18" height="1" alt="" /></td>'),1);
897
898 foreach($cat[$this->MOD_SETTINGS['listOrder']] as $catName => $extEkeys) {
899 if (count($extEkeys)) {
900 $lines[]='<tr><td colspan="'.(3+$this->detailCols[$this->MOD_SETTINGS['display_details']]).'"><br /></td></tr>';
901 $lines[]='<tr><td colspan="'.(3+$this->detailCols[$this->MOD_SETTINGS['display_details']]).'"><img '.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/i/sysf.gif"', 'width="18" height="16"').'align="top" alt="" /><strong>'.$this->listOrderTitle($this->MOD_SETTINGS['listOrder'],$catName).'</strong></td></tr>';
902
903 natcasesort($extEkeys);
904 reset($extEkeys);
905 while(list($extKey)=each($extEkeys)) {
906 $version = array_keys($list[$extKey]['versions']);
907 $version = end($version);
908 $ext = $list[$extKey]['versions'][$version];
909 $ext['downloadcounter_all'] = $list[$extKey]['downloadcounter'];
910 $ext['_ICON'] = $list[$extKey]['_ICON'];
911 $loadUnloadLink='';
912 if ($inst_list[$extKey]['type']!='S' && (!isset($inst_list[$extKey]) || $this->versionDifference($version,$inst_list[$extKey]['EM_CONF']['version'],$this->versionDiffFactor))) {
913 if (isset($inst_list[$extKey])) {
914 // update
915 if ($inst_list[$extKey]['EM_CONF']['state'] != 'excludeFromUpdates') {
916 $loc= ($inst_list[$extKey]['type']=='G'?'G':'L');
917 $aUrl = 'index.php?CMD[importExt]='.$extKey.'&CMD[extVersion]='.$version.'&CMD[loc]='.$loc;
918 $loadUnloadLink .= '<a href="' . htmlspecialchars($aUrl) . '"><img src="' . $GLOBALS['BACK_PATH'] . 'gfx/import_update.gif" width="12" height="12" title="' . sprintf($GLOBALS['LANG']->getLL('do_update'), ($loc == 'G' ? $GLOBALS['LANG']->getLL('global') : $GLOBALS['LANG']->getLL('local'))) . '" alt="" /></a>';
919 } else {
920 // extension is marked as "excludeFromUpdates"
921 $loadUnloadLink .= '<img src="' . $GLOBALS['BACK_PATH'] . 'gfx/icon_warning.gif" width="18" height="16" title="' . $GLOBALS['LANG']->getLL('excluded_from_updates') . '" alt="" />';
922 }
923 } else {
924 // import
925 $aUrl = 'index.php?CMD[importExt]='.$extKey.'&CMD[extVersion]='.$version.'&CMD[loc]=L';
926 $loadUnloadLink .= '<a href="' . htmlspecialchars($aUrl) . '"><img src="' . $GLOBALS['BACK_PATH'] . 'gfx/import.gif" width="12" height="12" title="' . $GLOBALS['LANG']->getLL('import_to_local_dir') . '" alt="" /></a>';
927 }
928 } else {
929 $loadUnloadLink = '&nbsp;';
930 }
931
932 if (isset($inst_list[$extKey])) {
933 $theRowClass = t3lib_extMgm::isLoaded($extKey) ? 'em-listbg1' : 'em-listbg2';
934 } else {
935 $theRowClass = 'em-listbg3';
936 }
937
938 $lines[]=$this->extensionListRow($extKey,$ext,array('<td class="bgColor">'.$loadUnloadLink.'</td>'),$theRowClass,$inst_list,1,'index.php?CMD[importExtInfo]='.rawurlencode($extKey));
939 unset($list[$extKey]);
940 }
941 }
942 }
943 unset($list);
944
945 // CSH:
946 $content .= t3lib_BEfunc::cshItem('_MOD_tools_em', 'import_ter', $GLOBALS['BACK_PATH'], '|<br />');
947 $onsubmit = "window.location.href='index.php?ter_connect=1&ter_search='+escape(this.elements['_lookUp'].value);return false;";
948 $content .= '<form action="index.php" method="post" onsubmit="' . htmlspecialchars($onsubmit) .
949 '"><label for="_lookUp">' .
950 sprintf($GLOBALS['LANG']->getLL('list_or_look_up'),
951 ($this->MOD_SETTINGS['display_unchecked'] ?
952 '<strong style="color:#900;">' . $GLOBALS['LANG']->getLL('list_or_look_up_all') . '</strong>'
953 : '<strong style="color:#090;">' . $GLOBALS['LANG']->getLL('list_or_look_up_reviewed') . '</strong>'
954 )
955 ) .
956 '</label><br />
957 <input type="text" id="_lookUp" name="_lookUp" value="' . htmlspecialchars($this->listRemote_search) .
958 '" /> <input type="submit" value="' . $GLOBALS['LANG']->getLL('look_up_button') . '" /></form><br /><br />';
959
960 $content .= $this->browseLinks();
961
962 $content.= '
963
964 <!-- TER Extensions list -->
965 <table border="0" cellpadding="2" cellspacing="1">'.implode(chr(10),$lines).'</table>';
966 $content .= '<br />'.$this->browseLinks();
967 $content.= '<br /><br />'.$this->securityHint;
968 $content .= '<br /><br /><strong>' . $GLOBALS['LANG']->getLL('privacy_notice_header') .
969 '</strong><br /> ' . $this->privacyNotice;
970
971 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('extensions_repository_group_by') . ' ' .
972 $this->MOD_MENU['listOrder'][$this->MOD_SETTINGS['listOrder']], $content, 0, 1);
973
974 // Plugins which are NOT uploaded to repository but present on this server.
975 $content='';
976 $lines=array();
977 if (count($this->inst_keys)) {
978 reset($this->inst_keys);
979 while(list($extKey)=each($this->inst_keys)) {
980 $this->xmlhandler->searchExtensionsXMLExact($extKey, '', '', true);
981 if((strlen($this->listRemote_search) && !stristr($extKey,$this->listRemote_search)) || isset($this->xmlhandler->extensionsXML[$extKey])) continue;
982
983 $loadUnloadLink = t3lib_extMgm::isLoaded($extKey)?
984 '<a href="'.htmlspecialchars('index.php?CMD[showExt]='.$extKey.'&CMD[remove]=1&CMD[clrCmd]=1&SET[singleDetails]=info').'">'.$this->removeButton().'</a>':
985 '<a href="'.htmlspecialchars('index.php?CMD[showExt]='.$extKey.'&CMD[load]=1&CMD[clrCmd]=1&SET[singleDetails]=info').'">'.$this->installButton().'</a>';
986 if (in_array($extKey,$this->requiredExt)) {
987 $loadUnloadLink = '<strong>' .$GLOBALS['TBE_TEMPLATE']->rfw($GLOBALS['LANG']->getLL('extension_required_short')) . '</strong>';
988 }
989 $lines[]=$this->extensionListRow($extKey,$inst_list[$extKey],array('<td class="bgColor">'.$loadUnloadLink.'</td>'),t3lib_extMgm::isLoaded($extKey)?'em-listbg1':'em-listbg2');
990 }
991 }
992 if(count($lines)) {
993 $content .= $GLOBALS['LANG']->getLL('list_of_local_extensions') .
994 '<br />' . $GLOBALS['LANG']->getLL('might_be_user_defined') . '<br /><br />';
995 $content.= '<table border="0" cellpadding="2" cellspacing="1">'.
996 $this->extensionListRowHeader(' class="bgColor5"',array('<td><img src="clear.gif" width="18" height="1" alt="" /></td>')).
997 implode('',$lines).'</table>';
998 $this->content.=$this->doc->spacer(20);
999 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('only_on_this_server'), $content, 0, 1);
1000 }
1001 }
1002 } else {
1003 $content .= t3lib_BEfunc::cshItem('_MOD_tools_em', 'import_ter', $GLOBALS['BACK_PATH'], '|<br />');
1004 $onsubmit = "window.location.href='index.php?ter_connect=1&ter_search='+escape(this.elements['_lookUp'].value);return false;";
1005 $content .= '<form action="index.php" method="post" onsubmit="' . htmlspecialchars($onsubmit) .
1006 '"><label for="_lookUp">' .
1007 sprintf($GLOBALS['LANG']->getLL('list_or_look_up'),
1008 ($this->MOD_SETTINGS['display_unchecked'] ?
1009 '<strong style="color:#900;">' . $GLOBALS['LANG']->getLL('list_or_look_up_all') . '</strong>'
1010 : '<strong style="color:#090;">' . $GLOBALS['LANG']->getLL('list_or_look_up_reviewed') . '</strong>'
1011 )
1012 ) .
1013 '</label><br />
1014 <input type="text" id="_lookUp" name="_lookUp" value="' . htmlspecialchars($this->listRemote_search) .
1015 '" /> <input type="submit" value="' . $GLOBALS['LANG']->getLL('look_up_button') . '" /></form><br /><br />';
1016
1017 $content .= '<p><strong>' . $GLOBALS['LANG']->getLL('no_matching_extensions') . '</strong></p>';
1018
1019 $content .= '<br /><br /><strong>' . $GLOBALS['LANG']->getLL('privacy_notice_header') .
1020 '</strong><br /> ' . $this->privacyNotice;
1021 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('extensions_repository_group_by') . ' ' .
1022 $this->MOD_MENU['listOrder'][$this->MOD_SETTINGS['listOrder']], $content, 0, 1);
1023 }
1024 } else {
1025 // CSH
1026 $content .= t3lib_BEfunc::cshItem('_MOD_tools_em', 'import', $GLOBALS['BACK_PATH'], '|<br />');
1027
1028 $onsubmit = "window.location.href='index.php?ter_connect=1&ter_search='+escape(this.elements['_lookUp'].value);return false;";
1029 $content .= '<form action="index.php" method="post" onsubmit="' . htmlspecialchars($onsubmit) .
1030 '"><label for="_lookUp">' .
1031 sprintf($GLOBALS['LANG']->getLL('list_or_look_up'),
1032 ($this->MOD_SETTINGS['display_unchecked'] ?
1033 '<strong style="color:#900;">' . $GLOBALS['LANG']->getLL('list_or_look_up_all') . '</strong>'
1034 : '<strong style="color:#090;">' . $GLOBALS['LANG']->getLL('list_or_look_up_reviewed') . '</strong>'
1035 )
1036 ) .
1037 '</label><br />
1038 <input type="text" id="_lookUp" name="_lookUp" value="" /> <input type="submit" value="' .
1039 $GLOBALS['LANG']->getLL('look_up_button') . '" /><br /><br />';
1040
1041 if ($this->CMD['fetchMetaData']) { // fetches mirror/extension data from online rep.
1042 $content .= $this->fetchMetaData($this->CMD['fetchMetaData']);
1043 } else {
1044 $onCLick = "window.location.href='index.php?CMD[fetchMetaData]=extensions';return false;";
1045 $content .= $GLOBALS['LANG']->getLL('connect_to_ter') . '<br />
1046 <input type="submit" value="' . $GLOBALS['LANG']->getLL('retrieve_update') .
1047 '" onclick="' . htmlspecialchars($onCLick) . '" />';
1048 if (is_file(PATH_site.'typo3temp/extensions.xml.gz')) {
1049 $dateFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'];
1050 $timeFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'];
1051 $content .= ' ' . sprintf($GLOBALS['LANG']->getLL('ext_list_last_updated') . ' ',
1052 date(
1053 $dateFormat . ', ' . $timeFormat,
1054 filemtime(PATH_site . 'typo3temp/extensions.xml.gz')
1055 )
1056 );
1057 }
1058 }
1059 $content.= '</form><br /><br />'.$this->securityHint;
1060 $content .= '<br /><br /><strong>' . $GLOBALS['LANG']->getLL('privacy_notice_header') .
1061 '</strong><br />' . $this->privacyNotice;
1062
1063 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('in_repository'), $content, 0, 1);
1064 }
1065
1066 // Upload:
1067 if ($this->importAtAll()) {
1068 $content= '<form action="index.php" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'" method="post">
1069 <label for="upload_ext_file">' . $GLOBALS['LANG']->getLL('upload_t3x') . '</label><br />
1070 <input type="file" size="60" id="upload_ext_file" name="upload_ext_file" /><br />' .
1071 $GLOBALS['LANG']->getLL('upload_to_location') . '<br />
1072 <select name="CMD[loc]">';
1073 if ($this->importAsType('L')) $content .= '<option value="L">' . $GLOBALS['LANG']->getLL('local_folder') . '</option>';
1074 if ($this->importAsType('G')) $content .= '<option value="G">' . $GLOBALS['LANG']->getLL('global_folder') . '</option>';
1075 if ($this->importAsType('S')) $content .= '<option value="S">' . $GLOBALS['LANG']->getLL('system_folder') . '</option>';
1076 $content.='</select><br />
1077 <input type="checkbox" value="1" name="CMD[uploadOverwrite]" id="checkUploadOverwrite" /> <label for="checkUploadOverwrite">' .
1078 $GLOBALS['LANG']->getLL('overwrite_ext') . '</label><br />
1079 <input type="submit" name="CMD[uploadExt]" value="' . $GLOBALS['LANG']->getLL('upload_ext_file') . '" /></form><br />
1080 ';
1081 } else $content=$this->noImportMsg();
1082
1083 $this->content.=$this->doc->spacer(20);
1084 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('upload_ext_directly'), $content, 0, 1);
1085 }
1086
1087 /**
1088 * Generates a link to the next page of extensions
1089 *
1090 * @return void
1091 */
1092 function browseLinks() {
1093 $content = '';
1094 if ($this->pointer) {
1095 $content .= '<a href="' . t3lib_div::linkThisScript(array('pointer' => $this->pointer-1)) .
1096 '" class="typo3-prevPage"><img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],
1097 'gfx/pilleft_n.gif', 'width="14" height="14"') .
1098 ' alt="' . $GLOBALS['LANG']->getLL('previous_page') . '" /> ' .
1099 $GLOBALS['LANG']->getLL('previous_page') . '</a>';
1100 }
1101 if ($content) $content .= '&nbsp;&nbsp;&nbsp;';
1102 if (intval($this->xmlhandler->matchingCount/$this->listingLimit)>$this->pointer) {
1103 $content .= '<a href="' . t3lib_div::linkThisScript(array('pointer' => $this->pointer+1)) .
1104 '" class="typo3-nextPage"><img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],
1105 'gfx/pilright_n.gif', 'width="14" height="14"') .
1106 ' alt="' . $GLOBALS['LANG']->getLL('next_page') . '" /> ' .
1107 $GLOBALS['LANG']->getLL('next_page') . '</a>';
1108 }
1109 $upper = (($this->pointer+1)*$this->listingLimit);
1110 if ($upper>$this->xmlhandler->matchingCount) {
1111 $upper = $this->xmlhandler->matchingCount;
1112 }
1113 if ($content) $content .= '<br /><br />' .
1114 sprintf($GLOBALS['LANG']->getLL('showing_extensions_from_to'),
1115 '<strong>' . ($this->pointer*$this->listingLimit+1) . '</strong>',
1116 '<strong>' . $upper . '</strong>'
1117 );
1118 if ($content) $content .= '<br /><br />';
1119 return $content;
1120 }
1121
1122 /**
1123 * Allows changing of settings
1124 *
1125 * @return void
1126 */
1127 function alterSettings() {
1128
1129 // Prepare the HTML output:
1130 $content.= '
1131 ' . t3lib_BEfunc::cshItem('_MOD_tools_em', 'settings', $GLOBALS['BACK_PATH'], '|<br />') . '
1132 <form action="index.php" method="post" name="altersettings">
1133 <fieldset><legend>' . $GLOBALS['LANG']->getLL('security_settings') . '</legend>
1134 <table border="0" cellpadding="2" cellspacing="2">
1135 <tr class="bgColor4">
1136 <td><label for="display_unchecked">' . $GLOBALS['LANG']->getLL('show_exts_without_security_check') . '</label></td>
1137 <td>'.t3lib_BEfunc::getFuncCheck(0,'SET[display_unchecked]',$this->MOD_SETTINGS['display_unchecked'],'','','id="display_unchecked"').'</td>
1138 </tr>
1139 </table>
1140 <strong>' . $GLOBALS['LANG']->getLL('notice') . '</strong> ' .
1141 sprintf($GLOBALS['LANG']->getLL('security_notice'),
1142 '<a href="http://typo3.org/extensions/what-are-reviews/" target="_blank">', '</a>'
1143 ) .
1144 '</fieldset>
1145 <br />
1146 <br />
1147 <fieldset><legend>' . $GLOBALS['LANG']->getLL('user_settings') . '</legend>
1148 <table border="0" cellpadding="2" cellspacing="2">
1149 <tr class="bgColor4">
1150 <td><label for="set_fe_u">' . $GLOBALS['LANG']->getLL('enter_repository_username') . '</label></td>
1151 <td><input type="text" id="set_fe_u" name="SET[fe_u]" value="'.htmlspecialchars($this->MOD_SETTINGS['fe_u']).'" /></td>
1152 </tr>
1153 <tr class="bgColor4">
1154 <td><label for="set_fe_p">' . $GLOBALS['LANG']->getLL('enter_repository_password') . '</label></td>
1155 <td><input type="password" id="set_fe_p" name="SET[fe_p]" value="'.htmlspecialchars($this->MOD_SETTINGS['fe_p']).'" /></td>
1156 </tr>
1157 </table>
1158 <strong>' . $GLOBALS['LANG']->getLL('notice') . '</strong> ' .
1159 $GLOBALS['LANG']->getLL('repository_password_info') . '
1160 </fieldset>
1161 <br />
1162 <br />
1163 <fieldset><legend>' . $GLOBALS['LANG']->getLL('mirror_selection') . '</legend>
1164 <table border="0" cellpadding="2" cellspacing="2">
1165 <tr class="bgColor4">
1166 <td><label for="set_mirror_list_url">' . $GLOBALS['LANG']->getLL('mirror_list_url') . '</label></a></td>
1167 <td><input type="text" size="50" id="set_mirror_list_url" name="SET[mirrorListURL]" value="'.htmlspecialchars($this->MOD_SETTINGS['mirrorListURL']).'" /></td>
1168 </tr>
1169 </table>
1170 <br />
1171 <p>' . $GLOBALS['LANG']->getLL('mirror_select') . '<br /><br /></p>
1172 <fieldset><legend>' . $GLOBALS['LANG']->getLL('mirror_list') . '</legend>';
1173 if(!empty($this->MOD_SETTINGS['mirrorListURL'])) {
1174 if ($this->CMD['fetchMetaData']) { // fetches mirror/extension data from online rep.
1175 $content .= $this->fetchMetaData($this->CMD['fetchMetaData']);
1176 } else {
1177 $content .= '<a href="index.php?CMD[fetchMetaData]=mirrors">' . $GLOBALS['LANG']->getLL('mirror_list_reload') . '</a>';
1178 }
1179 }
1180 $content .= '<br />
1181 <table cellspacing="4" style="text-align:left; vertical-alignment:top;">
1182 <tr>
1183 <td>' . $GLOBALS['LANG']->getLL('mirror_use') . '</td>
1184 <td>' . $GLOBALS['LANG']->getLL('mirror_name') . '</td>
1185 <td>' . $GLOBALS['LANG']->getLL('mirror_url') . '</td>
1186 <td>' . $GLOBALS['LANG']->getLL('mirror_country') . '</td>
1187 <td>' . $GLOBALS['LANG']->getLL('mirror_sponsored_by') . '</td>
1188 </tr>
1189 ';
1190
1191 if (!strlen($this->MOD_SETTINGS['extMirrors'])) $this->fetchMetaData('mirrors');
1192 $extMirrors = unserialize($this->MOD_SETTINGS['extMirrors']);
1193 $extMirrors[''] = array('title'=>$GLOBALS['LANG']->getLL('mirror_use_random'));
1194 ksort($extMirrors);
1195 if(is_array($extMirrors)) {
1196 foreach($extMirrors as $k => $v) {
1197 if(isset($v['sponsor'])) {
1198 $sponsor = '<a href="'.htmlspecialchars($v['sponsor']['link']).'" target="_new"><img src="'.$v['sponsor']['logo'].'" title="'.htmlspecialchars($v['sponsor']['name']).'" alt="'.htmlspecialchars($v['sponsor']['name']).'" /></a>';
1199 }
1200 $selected = ($this->MOD_SETTINGS['selectedMirror']==$k) ? 'checked="checked"' : '';
1201 $content.='<tr class="bgColor4">
1202 <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>';
1203 }
1204 }
1205 $content.= '
1206 </table>
1207 </fieldset>
1208 <br />
1209 <table border="0" cellpadding="2" cellspacing="2">
1210 <tr class="bgColor4">
1211 <td><label for="set_rep_url">' . $GLOBALS['LANG']->getLL('enter_repository_url') . '</label></td>
1212 <td><input type="text" size="50" id="set_rep_url" name="SET[rep_url]" value="'.htmlspecialchars($this->MOD_SETTINGS['rep_url']).'" /></td>
1213 </tr>
1214 </table>
1215
1216 ' . $GLOBALS['LANG']->getLL('repository_url_hint') . '<br />
1217 </fieldset>
1218 <br />
1219 <input type="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_tsfe.xml:update') . '" />
1220 </form>
1221 ';
1222
1223 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('repository_settings'), $content, 0, 1);
1224 }
1225
1226 /**
1227 * Allows to set the translation preferences and check the status
1228 *
1229 * @return void
1230 */
1231 function translationHandling() {
1232 global $LANG, $TYPO3_LOADED_EXT;
1233 $LANG->includeLLFile('EXT:setup/mod/locallang.xml');
1234
1235 //prepare docheader
1236 $docHeaderButtons = $this->getButtons();
1237 $markers = array(
1238 'CSH' => $docHeaderButtons['csh'],
1239 'FUNC_MENU' => $this->getFuncMenu(),
1240 );
1241
1242
1243 $incoming = t3lib_div::_POST('SET');
1244 if(isset($incoming['selectedLanguages']) && is_array($incoming['selectedLanguages'])) {
1245 t3lib_BEfunc::getModuleData($this->MOD_MENU, array('selectedLanguages' => serialize($incoming['selectedLanguages'])), $this->MCONF['name'], '', 'selectedLanguages');
1246 $this->MOD_SETTINGS['selectedLanguages'] = serialize($incoming['selectedLanguages']);
1247 }
1248
1249 $selectedLanguages = unserialize($this->MOD_SETTINGS['selectedLanguages']);
1250 if(count($selectedLanguages)==1 && empty($selectedLanguages[0])) $selectedLanguages = array();
1251 $theLanguages = t3lib_div::trimExplode('|',TYPO3_languages);
1252 foreach($theLanguages as $val) {
1253 if ($val!='default') {
1254 $localLabel = ' - ['.htmlspecialchars($GLOBALS['LOCAL_LANG']['default']['lang_'.$val]).']';
1255 $selected = (is_array($selectedLanguages) && in_array($val, $selectedLanguages)) ? ' selected="selected"' : '';
1256 $opt[$GLOBALS['LOCAL_LANG']['default']['lang_'.$val].'--'.$val]='
1257 <option value="'.$val.'"'.$selected.'>'.$LANG->getLL('lang_'.$val,1).$localLabel.'</option>';
1258 }
1259 }
1260 ksort($opt);
1261
1262 // Prepare the HTML output:
1263 $content.= '
1264 ' . t3lib_BEfunc::cshItem('_MOD_tools_em', 'translation', $GLOBALS['BACK_PATH'], '|<br />') . '
1265 <form action="index.php" method="post" name="translationform">
1266 <fieldset><legend>' . $GLOBALS['LANG']->getLL('translation_settings') . '</legend>
1267 <table border="0" cellpadding="2" cellspacing="2">
1268 <tr class="bgColor4">
1269 <td>' . $GLOBALS['LANG']->getLL('languages_to_fetch') . '</td>
1270 <td>
1271 <select name="SET[selectedLanguages][]" multiple="multiple" size="10">
1272 <option></option>'.
1273 implode('',$opt).'
1274 </select>
1275 </td>
1276 </tr>
1277 </table>
1278 <br />
1279 <p>' . $GLOBALS['LANG']->getLL('translation_info') . '<br />
1280 <br />' . $GLOBALS['LANG']->getLL('translation_loaded_exts') . '</p>
1281 </fieldset>
1282 <br />
1283 <input type="submit" value="' . $GLOBALS['LANG']->getLL('translation_save_selection') . '" />
1284 <br />
1285 </fieldset>
1286 </form>';
1287
1288 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('translation_settings'), $content, 0, 1);
1289
1290 if(count($selectedLanguages)>0) {
1291 $mirrorURL = $this->getMirrorURL();
1292 $content = '<input type="button" value="' . $GLOBALS['LANG']->getLL('translation_check_status_button') .
1293 '" onclick="document.location.href=\'' . t3lib_div::linkThisScript(array('l10n'=>'check')) .
1294 '\'" />&nbsp;<input type="button" value="' . $GLOBALS['LANG']->getLL('translation_update_button') .
1295 '" onclick="document.location.href=\'' . t3lib_div::linkThisScript(array('l10n'=>'update')) .
1296 '\'" />';
1297
1298 if(t3lib_div::_GET('l10n') == 'check') {
1299 $loadedExtensions = array_keys($TYPO3_LOADED_EXT);
1300 $loadedExtensions = array_diff($loadedExtensions,array('_CACHEFILE'));
1301
1302 // Override content output - we now do that ourselves:
1303 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('translation_status'), $content, 0, 1);
1304 // Setting up the buttons and markers for docheader
1305 $content = $this->doc->startPage('Extension Manager');
1306 $content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
1307 $contentParts=explode('###CONTENT###',$content);
1308 ob_end_flush();
1309 echo $contentParts[0].$this->content;
1310
1311 $this->doPrintContent = FALSE;
1312 flush();
1313
1314 echo '
1315 <br />
1316 <br />
1317 <p id="progress-message">
1318 ' . $GLOBALS['LANG']->getLL('translation_check_status') . '
1319 </p>
1320 <br />
1321 <div style="width:100%; height:20px; border: 1px solid black;">
1322 <div id="progress-bar" style="float: left; width: 0%; height: 20px; background-color:green;">&nbsp;</div>
1323 <div id="transparent-bar" style="float: left; width: 100%; height: 20px; background-color:'.$this->doc->bgColor2.';">&nbsp;</div>
1324 </div>
1325 <br />
1326 <br /><p>' . $GLOBALS['LANG']->getLL('translation_table_check') . '</p><br />
1327 <table border="0" cellpadding="2" cellspacing="2">
1328 <tr class="bgColor2"><td>' . $GLOBALS['LANG']->getLL('translation_extension_key') . '</td>
1329 ';
1330
1331 foreach($selectedLanguages as $lang) {
1332 echo ('<td>'.$LANG->getLL('lang_'.$lang,1).'</td>');
1333 }
1334 echo ('</tr>');
1335
1336 $counter = 1;
1337 foreach($loadedExtensions as $extKey) {
1338
1339 $percentDone = intval (($counter / count($loadedExtensions)) * 100);
1340 echo ('
1341 <script>
1342 document.getElementById("progress-bar").style.width = "'.$percentDone.'%";
1343 document.getElementById("transparent-bar").style.width = "'.(100-$percentDone).'%";
1344 document.getElementById("progress-message").firstChild.data="' .
1345 sprintf($GLOBALS['LANG']->getLL('translation_checking_extension'), $extKey) . '";
1346 </script>
1347 ');
1348
1349 flush();
1350 $translationStatusArr = $this->terConnection->fetchTranslationStatus($extKey,$mirrorURL);
1351
1352 echo ('<tr class="bgColor4"><td>'.$extKey.'</td>');
1353 foreach($selectedLanguages as $lang) {
1354 // remote unknown -> no l10n available
1355 if(!isset($translationStatusArr[$lang])) {
1356 echo ('<td title="' . $GLOBALS['LANG']->getLL('translation_no_translation') . '">' .
1357 $GLOBALS['LANG']->getLL('translation_n_a') . '</td>');
1358 continue;
1359 }
1360 // determine local md5 from zip
1361 if(is_file(PATH_site.'typo3temp/'.$extKey.'-l10n-'.$lang.'.zip')) {
1362 $localmd5 = md5_file(PATH_site.'typo3temp/'.$extKey.'-l10n-'.$lang.'.zip');
1363 } else {
1364 echo ('<td title="' . $GLOBALS['LANG']->getLL('translation_not_installed') .
1365 '" style="background-color:#ff0">' . $GLOBALS['LANG']->getLL('translation_status_unknown') .
1366 '</td>');
1367 continue;
1368 }
1369 // local!=remote -> needs update
1370 if($localmd5 != $translationStatusArr[$lang]['md5']) {
1371 echo ('<td title="' . $GLOBALS['LANG']->getLL('translation_needs_update') .
1372 '" style="background-color:#ff0">' . $GLOBALS['LANG']->getLL('translation_status_update') .
1373 '</td>');
1374 continue;
1375 }
1376 echo ('<td title="' . $GLOBALS['LANG']->getLL('translation_is_ok') .
1377 '" style="background-color:#69a550">' . $GLOBALS['LANG']->getLL('translation_status_ok') .
1378 '</td>');
1379 }
1380 echo ('</tr>');
1381
1382 $counter ++;
1383 }
1384 echo '</table>
1385 <script>
1386 document.getElementById("progress-message").firstChild.data="' .
1387 $GLOBALS['LANG']->getLL('translation_check_done') . '";
1388 </script>
1389 ';
1390 echo $contentParts[1] . $this->doc->endPage();
1391 exit;
1392
1393 } elseif(t3lib_div::_GET('l10n') == 'update') {
1394 $loadedExtensions = array_keys($TYPO3_LOADED_EXT);
1395 $loadedExtensions = array_diff($loadedExtensions,array('_CACHEFILE'));
1396
1397 // Override content output - we now do that ourselves:
1398 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('translation_status'), $content, 0, 1);
1399 // Setting up the buttons and markers for docheader
1400 $content = $this->doc->startPage('Extension Manager');
1401 $content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
1402 $contentParts=explode('###CONTENT###',$content);
1403 ob_end_flush();
1404 echo $contentParts[0].$this->content;
1405
1406 $this->doPrintContent = FALSE;
1407 flush();
1408
1409 echo ('
1410 <br />
1411 <br />
1412 <p id="progress-message">
1413 ' . $GLOBALS['LANG']->getLL('translation_update_status') . '
1414 </p>
1415 <br />
1416 <div style="width:100%; height:20px; border: 1px solid black;">
1417 <div id="progress-bar" style="float: left; width: 0%; height: 20px; background-color:green;">&nbsp;</div>
1418 <div id="transparent-bar" style="float: left; width: 100%; height: 20px; background-color:'.$this->doc->bgColor2.';">&nbsp;</div>
1419 </div>
1420 <br />
1421 <br /><p>' . $GLOBALS['LANG']->getLL('translation_table_update') . '<br />
1422 <em>' . $GLOBALS['LANG']->getLL('translation_full_check_update') . '</em></p><br />
1423 <table border="0" cellpadding="2" cellspacing="2">
1424 <tr class="bgColor2"><td>' . $GLOBALS['LANG']->getLL('translation_extension_key') . '</td>
1425 ');
1426
1427 foreach($selectedLanguages as $lang) {
1428 echo '<td>'.$LANG->getLL('lang_'.$lang,1).'</td>';
1429 }
1430 echo '</tr>';
1431
1432 $counter = 1;
1433 foreach($loadedExtensions as $extKey) {
1434 $percentDone = intval (($counter / count($loadedExtensions)) * 100);
1435 echo ('
1436 <script>
1437 document.getElementById("progress-bar").style.width = "'.$percentDone.'%";
1438 document.getElementById("transparent-bar").style.width = "'.(100-$percentDone).'%";
1439 document.getElementById("progress-message").firstChild.data="' .
1440 sprintf($GLOBALS['LANG']->getLL('translation_updating_extension'), $extKey) . '";
1441 </script>
1442 ');
1443
1444 flush();
1445 $translationStatusArr = $this->terConnection->fetchTranslationStatus($extKey,$mirrorURL);
1446
1447 echo ('<tr class="bgColor4"><td>'.$extKey.'</td>');
1448 if(is_array($translationStatusArr)) {
1449 foreach($selectedLanguages as $lang) {
1450 // remote unknown -> no l10n available
1451 if(!isset($translationStatusArr[$lang])) {
1452 echo ('<td title="' . $GLOBALS['LANG']->getLL('translation_no_translation') .
1453 '">' . $GLOBALS['LANG']->getLL('translation_n_a') . '</td>');
1454 continue;
1455 }
1456 // determine local md5 from zip
1457 if(is_file(PATH_site.'typo3temp/'.$extKey.'-l10n-'.$lang.'.zip')) {
1458 $localmd5 = md5_file(PATH_site.'typo3temp/'.$extKey.'-l10n-'.$lang.'.zip');
1459 } else {
1460 $localmd5 = 'zzz';
1461 }
1462 // local!=remote or not installed -> needs update
1463 if($localmd5 != $translationStatusArr[$lang]['md5']) {
1464 $ret = $this->updateTranslation($extKey, $lang, $mirrorURL);
1465 if($ret === true) {
1466 echo ('<td title="' . $GLOBALS['LANG']->getLL('translation_has_been_updated') .
1467 '" style="background-color:#69a550">' . $GLOBALS['LANG']->getLL('translation_status_update') .
1468 '</td>');
1469 } else {
1470 echo ('<td title="' . htmlspecialchars($ret) .
1471 '" style="background-color:#cb3352">' . $GLOBALS['LANG']->getLL('translation_status_error') .
1472 '</td>');
1473 }
1474 continue;
1475 }
1476 echo ('<td title="' . $GLOBALS['LANG']->getLL('translation_is_ok') .
1477 '" style="background-color:#69a550">' . $GLOBALS['LANG']->getLL('translation_status_ok') . '</td>');
1478 }
1479 } else {
1480 echo ('<td colspan="' . count($selectedLanguages) .
1481 '" title="' . $GLOBALS['LANG']->getLL('translation_problems') .
1482 '">' . $GLOBALS['LANG']->getLL('translation_status_could_not_fetch') . '</td>');
1483 }
1484 echo ('</tr>');
1485 $counter++;
1486 }
1487 echo '</table>
1488 <script>
1489 document.getElementById("progress-message").firstChild.data="' .
1490 $GLOBALS['LANG']->getLL('translation_update_done') . '";
1491 </script>
1492 ';
1493 echo $contentParts[1] . $this->doc->endPage();
1494 exit;
1495 }
1496
1497 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('translation_status'), $content, 0, 1);
1498 }
1499 }
1500
1501 /**
1502 * Install translations for all selected languages for an extension
1503 *
1504 * @param string $extKey The extension key to install the translations for
1505 * @param string $lang Language code of translation to fetch
1506 * @param string $mirrorURL Mirror URL to fetch data from
1507 * @return mixed true on success, error string on fauilure
1508 */
1509 function updateTranslation($extKey, $lang, $mirrorURL) {
1510 $l10n = $this->terConnection->fetchTranslation($extKey, $lang, $mirrorURL);
1511 if(is_array($l10n)) {
1512 $file = PATH_site.'typo3temp/'.$extKey.'-l10n-'.$lang.'.zip';
1513 $path = 'l10n/'.$lang.'/';
1514 if(!is_dir(PATH_typo3conf.$path)) t3lib_div::mkdir_deep(PATH_typo3conf,$path);
1515 t3lib_div::writeFile($file, $l10n[0]);
1516 if($this->unzip($file, PATH_typo3conf.$path)) {
1517 return true;
1518 } else {
1519 return $GLOBALS['LANG']->getLL('translation_unpacking_failed');
1520 }
1521 } else {
1522 return $l10n;
1523 }
1524 }
1525
1526 /**
1527 * Install translations for all selected languages for an extension
1528 *
1529 * @param string $extKey The extension key to install the translations for
1530 * @param string $mirrorURL Mirror URL to fetch data from
1531 * @return mixed true on success, error string on fauilure
1532 */
1533 function installTranslationsForExtension($extKey, $mirrorURL) {
1534 $selectedLanguages = unserialize($this->MOD_SETTINGS['selectedLanguages']);
1535 if(!is_array($selectedLanguages)) $selectedLanguages = array();
1536 foreach($selectedLanguages as $lang) {
1537 $l10n = $this->terConnection->fetchTranslation($extKey, $lang, $mirrorURL);
1538 if(is_array($l10n)) {
1539 $file = PATH_typo3conf.'l10n/'.$extKey.'-l10n-'.$lang.'.zip';
1540 $path = 'l10n/'.$lang.'/'.$extKey;
1541 t3lib_div::writeFile($file, $l10n[0]);
1542 if(!is_dir(PATH_typo3conf.$path)) t3lib_div::mkdir_deep(PATH_typo3conf,$path);
1543 if($this->unzip($file, PATH_typo3conf.$path)) {
1544 return true;
1545 } else {
1546 return $GLOBALS['LANG']->getLL('translation_unpacking_failed');
1547 }
1548 } else {
1549 return $l10n;
1550 }
1551 }
1552 }
1553
1554 /**
1555 * Unzips a zip file in the given path.
1556 *
1557 * Uses unzip binary if available, otherwise a pure PHP unzip is used.
1558 *
1559 * @param string $file Full path to zip file
1560 * @param string $path Path to change to before extracting
1561 * @return boolean True on success, false in failure
1562 */
1563 function unzip($file, $path) {
1564 if(strlen($GLOBALS['TYPO3_CONF_VARS']['BE']['unzip_path'])) {
1565 chdir($path);
1566 $cmd = $GLOBALS['TYPO3_CONF_VARS']['BE']['unzip_path'].' -o '.escapeshellarg($file);
1567 exec($cmd, $list, $ret);
1568 return ($ret === 0);
1569 } else {
1570 // we use a pure PHP unzip
1571 $unzip = new em_unzip($file);
1572 $ret = $unzip->extract(array('add_path'=>$path));
1573 return (is_array($ret));
1574 }
1575 }
1576
1577
1578
1579 /*********************************
1580 *
1581 * Command Applications (triggered by GET var)
1582 *
1583 *********************************/
1584
1585 /**
1586 * Returns detailed info about an extension in the online repository
1587 *
1588 * @param string Extension repository uid + optional "private key": [uid]-[key].
1589 * @param [type] $version: ...
1590 * @return void
1591 */
1592 function importExtInfo($extKey, $version='') {
1593
1594 $content = '<form action="index.php" method="post" name="pageform">';
1595
1596 // Fetch remote data:
1597 $this->xmlhandler->searchExtensionsXMLExact($extKey, '', '', true, true);
1598 list($fetchData,) = $this->prepareImportExtList(true);
1599
1600 $versions = array_keys($fetchData[$extKey]['versions']);
1601 $version = ($version == '') ? end($versions) : $version;
1602
1603 $opt = array();
1604 foreach(array_keys($fetchData[$extKey]['versions']) as $ver) {
1605 $opt[]='<option value="'.$ver.'"'.(($version == $ver) ? ' selected="selected"' : '').'>'.$ver.'</option>';
1606 }
1607
1608 // "Select version" box:
1609 $onClick = 'window.location.href=\'index.php?CMD[importExtInfo]='.$extKey.'&CMD[extVersion]=\'+document.pageform.extVersion.options[document.pageform.extVersion.selectedIndex].value; return false;';
1610 $select = '<select name="extVersion">' . implode('', $opt) .
1611 '</select> <input type="submit" value="' . $GLOBALS['LANG']->getLL('ext_load_details_button') .
1612 '" onclick="' . htmlspecialchars($onClick) . '" />';
1613
1614 if ($this->importAtAll()) {
1615 // Check for write-protected extension
1616 list($inst_list,) = $this->getInstalledExtensions();
1617 if ($inst_list[$extKey]['EM_CONF']['state'] != 'excludeFromUpdates') {
1618 $onClick = '
1619 window.location.href=\'index.php?CMD[importExt]='.$extKey.'\'
1620 +\'&CMD[extVersion]=\'+document.pageform.extVersion.options[document.pageform.extVersion.selectedIndex].value
1621 +\'&CMD[loc]=\'+document.pageform.loc.options[document.pageform.loc.selectedIndex].value;
1622 return false;';
1623 $select .= ' ' . $GLOBALS['LANG']->getLL('ext_or') . '<br /><br />
1624 <input type="submit" value="' . $GLOBALS['LANG']->getLL('ext_import_update_button') .
1625 '" onclick="' . htmlspecialchars($onClick) . '"> ' . $GLOBALS['LANG']->getLL('ext_import_update_to') . '
1626 <select name="loc">'.
1627 ($this->importAsType('G', $fetchData['emconf_lockType']) ?
1628 '<option value="G">' . $GLOBALS['LANG']->getLL('ext_import_global') . ' ' . $this->typePaths['G'] . $extKey . '/' .
1629 (@is_dir(PATH_site . $this->typePaths['G'] . $extKey) ?
1630 ' ' . $GLOBALS['LANG']->getLL('ext_import_overwrite') :
1631 ' ' . $GLOBALS['LANG']->getLL('ext_import_folder_empty')
1632 ) . '</option>' : ''
1633 ) .
1634 ($this->importAsType('L', $fetchData['emconf_lockType']) ?
1635 '<option value="L">' . $GLOBALS['LANG']->getLL('ext_import_local') . ' ' . $this->typePaths['L'] . $extKey . '/' .
1636 (@is_dir(PATH_site . $this->typePaths['L'] . $extKey) ?
1637 ' ' . $GLOBALS['LANG']->getLL('ext_import_overwrite') :
1638 ' ' . $GLOBALS['LANG']->getLL('ext_import_folder_empty')
1639 ) . '</option>' : ''
1640 ) .
1641 ($this->importAsType('S', $fetchData['emconf_lockType']) ?
1642 '<option value="S">' . $GLOBALS['LANG']->getLL('ext_import_system') . ' ' . $this->typePaths['S'] . $extKey . '/' .
1643 (@is_dir(PATH_site . $this->typePaths['S'] . $extKey) ?
1644 ' ' . $GLOBALS['LANG']->getLL('ext_import_overwrite') :
1645 ' ' . $GLOBALS['LANG']->getLL('ext_import_folder_empty')
1646 ) . '</option>' : ''
1647 ) .
1648 '</select>
1649 </form>';
1650 } else {
1651 $select .= '<br /><br />' . $GLOBALS['LANG']->getLL('ext_import_excluded_from_updates');
1652 }
1653 } else {
1654 $select .= '<br /><br />' . $this->noImportMsg();
1655 }
1656 $content.= $select;
1657 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('ext_import_select_command'), $content, 0, 1);
1658
1659 // Details:
1660 $eInfo = $fetchData[$extKey]['versions'][$version];
1661 $content='<strong>'.$fetchData[$extKey]['_ICON'].' &nbsp;'.$eInfo['EM_CONF']['title'].' ('.$extKey.', '.$version.')</strong><br /><br />';
1662 $content.=$this->extInformationArray($extKey,$eInfo,1);
1663 $this->content.=$this->doc->spacer(10);
1664 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('ext_import_remote_ext_details'), $content, 0, 1);
1665 }
1666
1667 /**
1668 * Fetches metadata and stores it to the corresponding place. This includes the mirror list,
1669 * extension XML files.
1670 *
1671 * @param string Type of data to fetch: (mirrors)
1672 * @param boolean If true the method doesn't produce any output
1673 * @return void
1674 */
1675 function fetchMetaData($metaType) {
1676 global $TYPO3_CONF_VARS;
1677
1678 switch($metaType) {
1679 case 'mirrors':
1680 $mfile = t3lib_div::tempnam('mirrors');
1681 $mirrorsFile = t3lib_div::getURL($this->MOD_SETTINGS['mirrorListURL'], 0, array(TYPO3_user_agent));
1682 if($mirrorsFile===false) {
1683 t3lib_div::unlink_tempfile($mfile);
1684 $content = '<p>' .
1685 sprintf($GLOBALS['LANG']->getLL('ext_import_list_not_updated'),
1686 $this->MOD_SETTINGS['mirrorListURL']
1687 ) . ' ' .
1688 $GLOBALS['LANG']->getLL('translation_problems') . '</p>';
1689 } else {
1690 t3lib_div::writeFile($mfile, $mirrorsFile);
1691 $mirrors = implode('',gzfile($mfile));
1692 t3lib_div::unlink_tempfile($mfile);
1693
1694 $mirrors = $this->xmlhandler->parseMirrorsXML($mirrors);
1695 if(is_array($mirrors) && count($mirrors)) {
1696 t3lib_BEfunc::getModuleData($this->MOD_MENU, array('extMirrors' => serialize($mirrors)), $this->MCONF['name'], '', 'extMirrors');
1697 $this->MOD_SETTINGS['extMirrors'] = serialize($mirrors);
1698 $content = '<p>' .
1699 sprintf($GLOBALS['LANG']->getLL('ext_import_list_updated'),
1700 count($mirrors)
1701 ) . '</p>';
1702 }
1703 else {
1704 $content = '<p>' . $mirrors . '<br />' . $GLOBALS['LANG']->getLL('ext_import_list_empty') . '</p>';
1705 }
1706 }
1707 break;
1708 case 'extensions':
1709 $this->fetchMetaData('mirrors'); // if we fetch the extensions anyway, we can as well keep this up-to-date
1710
1711 $mirror = $this->getMirrorURL();
1712 $extfile = $mirror.'extensions.xml.gz';
1713 $extmd5 = t3lib_div::getURL($mirror.'extensions.md5', 0, array(TYPO3_user_agent));
1714 if (is_file(PATH_site.'typo3temp/extensions.xml.gz')) {
1715 $localmd5 = md5_file(PATH_site.'typo3temp/extensions.xml.gz');
1716 }
1717
1718 if($extmd5 === false) {
1719 $content .= '<p>' .
1720 sprintf($GLOBALS['LANG']->getLL('ext_import_md5_not_updated'),
1721 $mirror . 'extensions.md5'
1722 ) .
1723 $GLOBALS['LANG']->getLL('translation_problems') . '</p>';
1724 } elseif($extmd5 == $localmd5) {
1725 $content .= '<p>' . $GLOBALS['LANG']->getLL('ext_import_list_unchanged') . '</p>';
1726 } else {
1727 $extXML = t3lib_div::getURL($extfile, 0, array(TYPO3_user_agent));
1728 if($extXML === false) {
1729 $content .= '<p>' .
1730 sprintf($GLOBALS['LANG']->getLL('ext_import_list_unchanged'),
1731 $extfile
1732 ) . ' ' .
1733 $GLOBALS['LANG']->getLL('translation_problems') . '</p>';
1734 } else {
1735 t3lib_div::writeFile(PATH_site.'typo3temp/extensions.xml.gz', $extXML);
1736 $content .= $this->xmlhandler->parseExtensionsXML(PATH_site.'typo3temp/extensions.xml.gz');
1737 }
1738 }
1739 break;
1740 }
1741
1742 return $content;
1743 }
1744
1745 /**
1746 * Returns the base URL for the slected or a random mirror.
1747 *
1748 * @return string The URL for the selected or a random mirror
1749 */
1750 function getMirrorURL() {
1751 if(strlen($this->MOD_SETTINGS['rep_url'])) return $this->MOD_SETTINGS['rep_url'];
1752
1753 $mirrors = unserialize($this->MOD_SETTINGS['extMirrors']);
1754 if(!is_array($mirrors)) {
1755 $this->fetchMetaData('mirrors');
1756 $mirrors = unserialize($this->MOD_SETTINGS['extMirrors']);
1757 if(!is_array($mirrors)) return false;
1758 }
1759 if($this->MOD_SETTINGS['selectedMirror']=='') {
1760 $rand = array_rand($mirrors);
1761 $url = 'http://'.$mirrors[$rand]['host'].$mirrors[$rand]['path'];
1762 }
1763 else {
1764 $url = 'http://'.$mirrors[$this->MOD_SETTINGS['selectedMirror']]['host'].$mirrors[$this->MOD_SETTINGS['selectedMirror']]['path'];
1765 }
1766
1767 return $url;
1768 }
1769
1770
1771
1772 /**
1773 * Installs (activates) an extension
1774 *
1775 * For $mode use the three constants EM_INSTALL_VERSION_MIN, EM_INSTALL_VERSION_MAX, EM_INSTALL_VERSION_STRICT
1776 *
1777 * If an extension is loaded or imported already and the version requirement is matched, it will not be
1778 * fetched from the repository. This means, if you use EM_INSTALL_VERSION_MIN, you will not always get the latest
1779 * version of an extension!
1780 *
1781 * @param string $extKey The extension key to install
1782 * @param string $version A version number that should be installed
1783 * @param int $mode If a version is requested, this determines if it is the min, max or strict version requested
1784 * @return [type] ...
1785 * @todo Make the method able to handle needed interaction somehow (unmatched dependencies)
1786 */
1787 function installExtension($extKey, $version=null, $mode=EM_INSTALL_VERSION_MIN) {
1788 list($inst_list,) = $this->getInstalledExtensions();
1789
1790 // check if it is already installed and loaded with sufficient version
1791 if(isset($inst_list[$extKey])) {
1792 $currentVersion = $inst_list[$extKey]['EM_CONF']['version'];
1793
1794 if(t3lib_extMgm::isLoaded($extKey)) {
1795 if($version===null) {
1796 return array(true, $GLOBALS['LANG']->getLL('ext_import_ext_already_installed_loaded'));
1797 } else {
1798 switch($mode) {
1799 case EM_INSTALL_VERSION_STRICT:
1800 if ($currentVersion == $version) {
1801 return array(true, $GLOBALS['LANG']->getLL('ext_import_ext_already_installed_loaded'));
1802 }
1803 break;
1804 case EM_INSTALL_VERSION_MIN:
1805 if (version_compare($currentVersion, $version, '>=')) {
1806 return array(true, $GLOBALS['LANG']->getLL('ext_import_ext_already_installed_loaded'));
1807 }
1808 break;
1809 case EM_INSTALL_VERSION_MAX:
1810 if (version_compare($currentVersion, $version, '<=')) {
1811 return array(true, $GLOBALS['LANG']->getLL('ext_import_ext_already_installed_loaded'));
1812 }
1813 break;
1814 }
1815 }
1816 } else {
1817 if (!t3lib_extMgm::isLocalconfWritable()) {
1818 return array(false, $GLOBALS['LANG']->getLL('ext_import_p_localconf'));
1819 }
1820 $newExtList = -1;
1821 switch($mode) {
1822 case EM_INSTALL_VERSION_STRICT:
1823 if ($currentVersion == $version) {
1824 $newExtList = $this->addExtToList($extKey, $inst_list);
1825 }
1826 break;
1827 case EM_INSTALL_VERSION_MIN:
1828 if (version_compare($currentVersion, $version, '>=')) {
1829 $newExtList = $this->addExtToList($extKey, $inst_list);
1830 }
1831 break;
1832 case EM_INSTALL_VERSION_MAX:
1833 if (version_compare($currentVersion, $version, '<=')) {
1834 $newExtList = $this->addExtToList($extKey, $inst_list);
1835 }
1836 break;
1837 }
1838 if ($newExtList!=-1) {
1839 $this->writeNewExtensionList($newExtList);
1840 $this->refreshGlobalExtList();
1841 $this->forceDBupdates($extKey, $inst_list[$extKey]);
1842 return array(true, $GLOBALS['LANG']->getLL('ext_import_ext_loaded'));
1843 }
1844 }
1845 }
1846
1847 // at this point we know we need to import (a matching version of) the extension from TER2
1848
1849 // see if we have an extension list at all
1850 if (!$this->xmlhandler->countExtensions()) {
1851 $this->fetchMetaData('extensions');
1852 }
1853 $this->xmlhandler->searchExtensionsXMLExact($extKey, '', '', true);
1854
1855 // check if extension can be fetched
1856 if(isset($this->xmlhandler->extensionsXML[$extKey])) {
1857 $versions = array_keys($this->xmlhandler->extensionsXML[$extKey]['versions']);
1858 $latestVersion = end($versions);
1859 switch($mode) {
1860 case EM_INSTALL_VERSION_STRICT:
1861 if(!isset($this->xmlhandler->extensionsXML[$extKey]['versions'][$version])) {
1862 return array(false, $GLOBALS['LANG']->getLL('ext_import_ext_n_a'));
1863 }
1864 break;
1865 case EM_INSTALL_VERSION_MIN:
1866 if (version_compare($latestVersion, $version, '>=')) {
1867 $version = $latestVersion;
1868 } else {
1869 return array(false, $GLOBALS['LANG']->getLL('ext_import_ext_n_a'));
1870 }
1871 break;
1872 case EM_INSTALL_VERSION_MAX:
1873 while (($v = array_pop($versions)) && version_compare($v, $version, '>=')) {
1874 // Loop until a version is found
1875 }
1876
1877 if ($v !== null && version_compare($v, $version, '<=')) {
1878 $version = $v;
1879 } else {
1880 return array(false, $GLOBALS['LANG']->getLL('ext_import_ext_n_a'));
1881 }
1882 break;
1883 }
1884 $this->importExtFromRep($extKey, $version, 'L');
1885 $newExtList = $this->addExtToList($extKey, $inst_list);
1886 if ($newExtList!=-1) {
1887 $this->writeNewExtensionList($newExtList);
1888 $this->refreshGlobalExtList();
1889 $this->forceDBupdates($extKey, $inst_list[$extKey]);
1890 $this->installTranslationsForExtension($extKey, $this->getMirrorURL());
1891 return array(true, $GLOBALS['LANG']->getLL('ext_import_ext_imported'));
1892 } else {
1893 return array(false, $GLOBALS['LANG']->getLL('ext_import_ext_not_loaded'));
1894 }
1895 } else {
1896 return array(false, $GLOBALS['LANG']->getLL('ext_import_ext_n_a_rep'));
1897 }
1898 }
1899
1900 function refreshGlobalExtList() {
1901 global $TYPO3_LOADED_EXT;
1902
1903 $TYPO3_LOADED_EXT = t3lib_extMgm::typo3_loadExtensions();
1904 if ($TYPO3_LOADED_EXT['_CACHEFILE']) {
1905 require(PATH_typo3conf.$TYPO3_LOADED_EXT['_CACHEFILE'].'_ext_localconf.php');
1906 }
1907 return;
1908
1909 $GLOBALS['TYPO3_LOADED_EXT'] = t3lib_extMgm::typo3_loadExtensions();
1910 if ($TYPO3_LOADED_EXT['_CACHEFILE']) {
1911 require(PATH_typo3conf.$TYPO3_LOADED_EXT['_CACHEFILE'].'_ext_localconf.php');
1912 } else {
1913 $temp_TYPO3_LOADED_EXT = $TYPO3_LOADED_EXT;
1914 reset($temp_TYPO3_LOADED_EXT);
1915 while(list($_EXTKEY,$temp_lEDat)=each($temp_TYPO3_LOADED_EXT)) {
1916 if (is_array($temp_lEDat) && $temp_lEDat['ext_localconf.php']) {
1917 $_EXTCONF = $TYPO3_CONF_VARS['EXT']['extConf'][$_EXTKEY];
1918 require($temp_lEDat['ext_localconf.php']);
1919 }
1920 }
1921 }
1922 }
1923
1924
1925 /**
1926 * Imports an extensions from the online repository
1927 * NOTICE: in version 4.0 this changed from "importExtFromRep_old($extRepUid,$loc,$uploadFlag=0,$directInput='',$recentTranslations=0,$incManual=0,$dontDelete=0)"
1928 *
1929 * @param string Extension key
1930 * @param string Version
1931 * @param string Install scope: "L" or "G" or "S"
1932 * @param boolean If true, extension is uploaded as file
1933 * @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.
1934 * @param array Direct input array (like from kickstarter)
1935 * @return string Return false on success, returns error message if error.
1936 */
1937 function importExtFromRep($extKey,$version,$loc,$uploadFlag=0,$dontDelete=0,$directInput='') {
1938
1939 $uploadSucceed = false;
1940 $uploadedTempFile = '';
1941 if (is_array($directInput)) {
1942 $fetchData = array($directInput,'');
1943 $loc = ($loc==='G'||$loc==='S') ? $loc : 'L';
1944 } elseif ($uploadFlag) {
1945 if (($uploadedTempFile = $this->CMD['alreadyUploaded']) || $_FILES['upload_ext_file']['tmp_name']) {
1946
1947 // Read uploaded file:
1948 if (!$uploadedTempFile) {
1949 if (!is_uploaded_file($_FILES['upload_ext_file']['tmp_name'])) {
1950 t3lib_div::sysLog('Possible file upload attack: '.$_FILES['upload_ext_file']['tmp_name'], 'Extension Manager', 3);
1951
1952 return $GLOBALS['LANG']->getLL('ext_import_file_not_uploaded');
1953 }
1954
1955 $uploadedTempFile = t3lib_div::upload_to_tempfile($_FILES['upload_ext_file']['tmp_name']);
1956 }
1957 $fileContent = t3lib_div::getUrl($uploadedTempFile);
1958
1959 if (!$fileContent) return $GLOBALS['LANG']->getLL('ext_import_file_empty');
1960
1961 // Decode file data:
1962 $fetchData = $this->terConnection->decodeExchangeData($fileContent);
1963
1964 if (is_array($fetchData)) {
1965 $extKey = $fetchData[0]['extKey'];
1966 if ($extKey) {
1967 if (!$this->CMD['uploadOverwrite']) {
1968 $loc = ($loc==='G'||$loc==='S') ? $loc : 'L';
1969 $comingExtPath = PATH_site.$this->typePaths[$loc].$extKey.'/';
1970 if (@is_dir($comingExtPath)) {
1971 return sprintf($GLOBALS['LANG']->getLL('ext_import_ext_present_no_overwrite'), $comingExtPath) .
1972 '<br />' . $GLOBALS['LANG']->getLL('ext_import_ext_present_nothing_done');
1973 } // ... else go on, install...
1974 } // ... else go on, install...
1975 } else return $GLOBALS['LANG']->getLL('ext_import_no_key');
1976 } else return sprintf($GLOBALS['LANG']->getLL('ext_import_wrong_file_format'), $fetchData);
1977 } else return $GLOBALS['LANG']->getLL('ext_import_no_file');
1978 } else {
1979 $this->xmlhandler->searchExtensionsXMLExact($extKey, '', '', true, true);
1980
1981 // Fetch extension from TER:
1982 if(!strlen($version)) {
1983 $versions = array_keys($this->xmlhandler->extensionsXML[$extKey]['versions']);
1984 $version = end($versions);
1985 }
1986 $fetchData = $this->terConnection->fetchExtension($extKey, $version, $this->xmlhandler->extensionsXML[$extKey]['versions'][$version]['t3xfilemd5'], $this->getMirrorURL());
1987 }
1988
1989 // At this point the extension data should be present; so we want to write it to disc:
1990 if ($this->importAsType($loc)) {
1991 if (is_array($fetchData)) { // There was some data successfully transferred
1992 if ($fetchData[0]['extKey'] && is_array($fetchData[0]['FILES'])) {
1993 $extKey = $fetchData[0]['extKey'];
1994 if(!isset($fetchData[0]['EM_CONF']['constraints'])) $fetchData[0]['EM_CONF']['constraints'] = $this->xmlhandler->extensionsXML[$extKey]['versions'][$version]['dependencies'];
1995 $EM_CONF = $this->fixEMCONF($fetchData[0]['EM_CONF']);
1996 if (!$EM_CONF['lockType'] || !strcmp($EM_CONF['lockType'],$loc)) {
1997 // check dependencies, act accordingly if ext is loaded
1998 list($instExtInfo,)=$this->getInstalledExtensions();
1999 $depStatus = $this->checkDependencies($extKey, $EM_CONF, $instExtInfo);
2000 if(t3lib_extMgm::isLoaded($extKey) && !$depStatus['returnCode']) {
2001 $this->content .= $depStatus['html'];
2002 if ($uploadedTempFile) {
2003 $this->content .= '<input type="hidden" name="CMD[alreadyUploaded]" value="'.$uploadedTempFile.'" />';
2004 }
2005 } else {
2006 $res = $this->clearAndMakeExtensionDir($fetchData[0],$loc,$dontDelete);
2007 if (is_array($res)) {
2008 $extDirPath = trim($res[0]);
2009 if ($extDirPath && @is_dir($extDirPath) && substr($extDirPath,-1)=='/') {
2010
2011 $emConfFile = $this->construct_ext_emconf_file($extKey,$EM_CONF);
2012 $dirs = $this->extractDirsFromFileList(array_keys($fetchData[0]['FILES']));
2013
2014 $res = $this->createDirsInPath($dirs,$extDirPath);
2015 if (!$res) {
2016 $writeFiles = $fetchData[0]['FILES'];
2017 $writeFiles['ext_emconf.php']['content'] = $emConfFile;
2018 $writeFiles['ext_emconf.php']['content_md5'] = md5($emConfFile);
2019
2020 // Write files:
2021 foreach($writeFiles as $theFile => $fileData) {
2022 t3lib_div::writeFile($extDirPath.$theFile,$fileData['content']);
2023 if (!@is_file($extDirPath.$theFile)) {
2024 $content .= sprintf($GLOBALS['LANG']->getLL('ext_import_file_not_created'),
2025 $extDirPath . $theFile) . '<br />';
2026 } elseif (md5(t3lib_div::getUrl($extDirPath.$theFile)) != $fileData['content_md5']) {
2027 $content .= sprintf($GLOBALS['LANG']->getLL('ext_import_file_corrupted'),
2028 $extDirPath . $theFile) . '<br />';
2029 }
2030 }
2031
2032 // No content, no errors. Create success output here:
2033 if (!$content) {
2034 $content = $GLOBALS['LANG']->getLL('ext_import_success') . '<br /><br />' .
2035 sprintf($GLOBALS['LANG']->getLL('ext_import_success_folder'), $extDirPath) . '<br />';
2036
2037 $uploadSucceed = true;
2038
2039 // Fix TYPO3_MOD_PATH for backend modules in extension:
2040 $modules = t3lib_div::trimExplode(',',$EM_CONF['module'],1);
2041 if (count($modules)) {
2042 foreach($modules as $mD) {
2043 $confFileName = $extDirPath.$mD.'/conf.php';
2044 if (@is_file($confFileName)) {
2045 $content.= $this->writeTYPO3_MOD_PATH($confFileName,$loc,$extKey.'/'.$mD.'/').'<br />';
2046 } else $content .= sprintf($GLOBALS['LANG']->getLL('ext_import_no_conf_file'),
2047 $confFileName) . '<br />';
2048 }
2049 }
2050 // NOTICE: I used two hours trying to find out why a script, ext_emconf.php, written twice and in between included by PHP did not update correct the second time. Probably something with PHP-A cache and mtime-stamps.
2051 // But this order of the code works.... (using the empty Array with type, EMCONF and files hereunder).
2052
2053 // Writing to ext_emconf.php:
2054 $sEMD5A = $this->serverExtensionMD5Array($extKey,array('type' => $loc, 'EM_CONF' => array(), 'files' => array()));
2055 $EM_CONF['_md5_values_when_last_written'] = serialize($sEMD5A);
2056 $emConfFile = $this->construct_ext_emconf_file($extKey,$EM_CONF);
2057 t3lib_div::writeFile($extDirPath.'ext_emconf.php',$emConfFile);
2058
2059 $content .= 'ext_emconf.php: '.$extDirPath.'ext_emconf.php<br />';
2060 $content .= $GLOBALS['LANG']->getLL('ext_import_ext_type') . ' ' . $loc . '<br />';
2061
2062 // Remove cache files:
2063 if (t3lib_extMgm::isLoaded($extKey)) {
2064 if ($this->removeCacheFiles()) {
2065 $content .= $GLOBALS['LANG']->getLL('ext_import_cache_files_removed') . '<br />';
2066 }
2067
2068 list($new_list)=$this->getInstalledExtensions();
2069 $content.=$this->updatesForm($extKey,$new_list[$extKey],1,'index.php?CMD[showExt]='.$extKey.'&SET[singleDetails]=info');
2070 }
2071
2072 // Install / Uninstall:
2073 if(!$this->CMD['standAlone']) {
2074 $content .= '<h3>' . $GLOBALS['LANG']->getLL('ext_import_install_uninstall') . '</h3>';
2075 $content.= $new_list[$extKey] ?
2076 '<a href="' . htmlspecialchars('index.php?CMD[showExt]=' . $extKey .
2077 '&CMD[remove]=1&CMD[clrCmd]=1&SET[singleDetails]=info') . '">' .
2078 $this->removeButton() . ' ' . $GLOBALS['LANG']->getLL('ext_import_uninstall') . '</a>' :
2079 '<a href="' . htmlspecialchars('index.php?CMD[showExt]=' . $extKey .
2080 '&CMD[load]=1&CMD[clrCmd]=1&SET[singleDetails]=info') . '">' .
2081 $this->installButton() . ' ' . $GLOBALS['LANG']->getLL('ext_import_install') . '</a>';
2082 } else {
2083 $content = $GLOBALS['LANG']->getLL('ext_import_imported') .
2084 '<br /><br /><a href="javascript:opener.top.content.document.forms[0].submit();window.close();">' .
2085 $GLOBALS['LANG']->getLL('ext_import_close_check') . '</a>';
2086 }
2087
2088 }
2089 } else $content = $res;
2090 } else $content = sprintf($GLOBALS['LANG']->getLL('ext_import_ext_path_different'), $extDirPath);
2091 } else $content = $res;
2092 }
2093 } else $content = sprintf($GLOBALS['LANG']->getLL('ext_import_ext_only_here'),
2094 $this->typePaths[$EM_CONF['lockType']], $EM_CONF['lockType']);
2095 } else $content = $GLOBALS['LANG']->getLL('ext_import_no_ext_key_files');
2096 } else $content = sprintf($GLOBALS['LANG']->getLL('ext_import_data_transfer'), $fetchData);
2097 } else $content = sprintf($GLOBALS['LANG']->getLL('ext_import_no_install_here'), $this->typePaths[$loc]);
2098
2099 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('ext_import_results'), $content, 0, 1);
2100
2101 if ($uploadSucceed && $uploadedTempFile) {
2102 t3lib_div::unlink_tempfile($uploadedTempFile);
2103 }
2104
2105 return false;
2106 }
2107
2108 /**
2109 * Display extensions details.
2110 *
2111 * @param string Extension key
2112 * @return void Writes content to $this->content
2113 */
2114 function showExtDetails($extKey) {
2115 global $TYPO3_LOADED_EXT;
2116
2117 list($list,)=$this->getInstalledExtensions();
2118 $absPath = $this->getExtPath($extKey,$list[$extKey]['type']);
2119
2120 // Check updateModule:
2121 if (isset($list[$extKey]) && @is_file($absPath.'class.ext_update.php')) {
2122 require_once($absPath.'class.ext_update.php');
2123 $updateObj = new ext_update;
2124 if (!$updateObj->access()) {
2125 unset($this->MOD_MENU['singleDetails']['updateModule']);
2126 }
2127 } else {
2128 unset($this->MOD_MENU['singleDetails']['updateModule']);
2129 }
2130
2131 if($this->CMD['doDelete']) {
2132 $this->MOD_MENU['singleDetails'] = array();
2133 }
2134
2135 // Function menu here:
2136 if(!$this->CMD['standAlone'] && !t3lib_div::_GP('standAlone')) {
2137 $content = $GLOBALS['LANG']->getLL('ext_details_ext') . '&nbsp;<strong>' .
2138 $this->extensionTitleIconHeader($extKey, $list[$extKey]) . '</strong> (' . $extKey . ')';
2139 $this->content.= $this->doc->section('', $content);
2140 }
2141
2142 // Show extension details:
2143 if ($list[$extKey]) {
2144
2145 // Checking if a command for install/uninstall is executed:
2146 if (($this->CMD['remove'] || $this->CMD['load']) && !in_array($extKey,$this->requiredExt)) {
2147
2148 // Install / Uninstall extension here:
2149 if (t3lib_extMgm::isLocalconfWritable()) {
2150 // Check dependencies:
2151 $depStatus = $this->checkDependencies($extKey, $list[$extKey]['EM_CONF'], $list);
2152 if(!$this->CMD['remove'] && !$depStatus['returnCode']) {
2153 $this->content .= $depStatus['html'];
2154 $newExtList = -1;
2155 } elseif ($this->CMD['remove']) {
2156 $newExtList = $this->removeExtFromList($extKey,$list);
2157 } else {
2158 $newExtList = $this->addExtToList($extKey,$list);
2159 }
2160
2161 // Successful installation:
2162 if ($newExtList!=-1) {
2163 $updates = '';
2164 if ($this->CMD['load']) {
2165 if($_SERVER['REQUEST_METHOD'] == 'POST') {
2166 $script = t3lib_div::linkThisScript(array('CMD[showExt]' => $extKey, 'CMD[load]' => 1, 'CMD[clrCmd]' => $this->CMD['clrCmd'], 'SET[singleDetails]' => 'info'));
2167 } else {
2168 $script = '';
2169 }
2170 if($this->CMD['standAlone']) {
2171 $standaloneUpdates = '<input type="hidden" name="standAlone" value="1" />';
2172 }
2173 $depsolver = t3lib_div::_POST('depsolver');
2174 if(is_array($depsolver['ignore'])) {
2175 foreach($depsolver['ignore'] as $depK => $depV) {
2176 $dependencyUpdates .= '<input type="hidden" name="depsolver[ignore]['.$depK.']" value="1" />';
2177 }
2178 }
2179 $updatesForm = $this->updatesForm($extKey,$list[$extKey],1,$script, $dependencyUpdates.$standaloneUpdates.'<input type="hidden" name="_do_install" value="1" /><input type="hidden" name="_clrCmd" value="'.$this->CMD['clrCmd'].'" />');
2180 if ($updatesForm) {
2181 $updates = $GLOBALS['LANG']->getLL('ext_details_new_tables_fields') . '<br />' .
2182 $GLOBALS['LANG']->getLL('ext_details_new_tables_fields_select') . $updatesForm;
2183 $labelDBUpdate = $GLOBALS['LANG']->csConvObj->conv_case(
2184 $GLOBALS['LANG']->charSet,
2185 $GLOBALS['LANG']->getLL('ext_details_db_needs_update'),
2186 'toUpper'
2187 );
2188 $this->content .= $this->doc->section(
2189 sprintf($GLOBALS['LANG']->getLL('ext_details_installing') . ' ',
2190 $this->extensionTitleIconHeader($extKey, $list[$extKey])
2191 ) . ' ' .
2192 $labelDBUpdate,
2193 $updates, 1, 1, 1, 1
2194 );
2195 }
2196 } elseif ($this->CMD['remove']) {
2197 $updates.= $this->checkClearCache($list[$extKey]);
2198 if ($updates) {
2199 $updates = '
2200 <form action="'.t3lib_div::linkThisScript().'" method="post">'.$updates.'
2201 <br /><input type="submit" name="write" value="' .
2202 $GLOBALS['LANG']->getLL('ext_details_remove_ext') . '" />
2203 <input type="hidden" name="_do_install" value="1" />
2204 <input type="hidden" name="_clrCmd" value="'.$this->CMD['clrCmd'].'" />
2205 <input type="hidden" name="standAlone" value="'.$this->CMD['standAlone'].'" />
2206 </form>';
2207 $labelDBUpdate = $GLOBALS['LANG']->csConvObj->conv_case(
2208 $GLOBALS['LANG']->charSet,
2209 $GLOBALS['LANG']->getLL('ext_details_db_needs_update'),
2210 'toUpper'
2211 );
2212 $this->content .= $this->doc->section(
2213 sprintf($GLOBALS['LANG']->getLL('ext_details_removing') . ' ',
2214 $this->extensionTitleIconHeader($extKey, $list[$extKey])
2215 ) . ' ' .
2216 $labelDBUpdate,
2217 $updates, 1, 1, 1, 1
2218 );
2219 }
2220 }
2221 if (!$updates || t3lib_div::_GP('_do_install')) {
2222 $this->writeNewExtensionList($newExtList);
2223 $GLOBALS['BE_USER']->writelog(5,1,0,0,'Extension list has been changed, extension %s has been %s',array($extKey,($this->CMD['load']?'installed':'removed')));
2224 if ($this->CMD['clrCmd'] || t3lib_div::_GP('_clrCmd')) {
2225 if ($this->CMD['load'] && @is_file($absPath.'ext_conf_template.txt')) {
2226 $vA = array('CMD'=>Array('showExt'=>$extKey));
2227 } else {
2228 $vA = array('CMD'=>'');
2229 }
2230 } else {
2231 $vA = array('CMD'=>Array('showExt'=>$extKey));
2232 }
2233 if($this->CMD['standAlone'] || t3lib_div::_GP('standAlone')) {
2234 $this->content .= sprintf($GLOBALS['LANG']->getLL('ext_details_ext_installed_removed'),
2235 ($this->CMD['load'] ?
2236 $GLOBALS['LANG']->getLL('ext_details_installed') :
2237 $GLOBALS['LANG']->getLL('ext_details_removed')
2238 )
2239 ) .
2240 '<br /><br /><a href="javascript:opener.top.content.document.forms[0].submit();window.close();">' .
2241 $GLOBALS['LANG']->getLL('ext_import_close_check') . '</a>';
2242 } else {
2243 // Determine if new modules were installed:
2244 $techInfo = $this->makeDetailedExtensionAnalysis($extKey, $list[$extKey]);
2245 if (($this->CMD['load'] || $this->CMD['remove']) && is_array($techInfo['flags']) && in_array('Module', $techInfo['flags'], true)) {
2246 $vA['CMD']['refreshMenu'] = 1;
2247 }
2248 header('Location: '.t3lib_div::linkThisScript($vA));
2249 }
2250 }
2251 }
2252 } else {
2253 $writeAccessError = $GLOBALS['LANG']->csConvObj->conv_case(
2254 $GLOBALS['LANG']->charSet,
2255 $GLOBALS['LANG']->getLL('ext_details_write_access_error'),
2256 'toUpper'
2257 );
2258 $this->content .= $this->doc->section(
2259 sprintf($GLOBALS['LANG']->getLL('ext_details_installing') . ' ',
2260 $this->extensionTitleIconHeader($extKey, $list[$extKey])
2261 ) . ' ' .
2262 $writeAccessError,
2263 $GLOBALS['LANG']->getLL('ext_details_write_error_localconf'),
2264 1, 1, 2, 1
2265 );
2266 }
2267
2268 } elseif ($this->CMD['downloadFile'] && !in_array($extKey,$this->requiredExt)) {
2269
2270 // Link for downloading extension has been clicked - deliver content stream:
2271 $dlFile = $this->CMD['downloadFile'];
2272 if (t3lib_div::isFirstPartOfStr($dlFile,PATH_site) && t3lib_div::isFirstPartOfStr($dlFile,$absPath) && @is_file($dlFile)) {
2273 $mimeType = 'application/octet-stream';
2274 Header('Content-Type: '.$mimeType);
2275 Header('Content-Disposition: attachment; filename='.basename($dlFile));
2276 echo t3lib_div::getUrl($dlFile);
2277 exit;
2278 } else die($GLOBALS['LANG']->getLL('ext_details_error_downloading'));
2279
2280 } elseif ($this->CMD['editFile'] && !in_array($extKey,$this->requiredExt)) {
2281
2282 // Editing extension file:
2283 $editFile = $this->CMD['editFile'];
2284 if (t3lib_div::isFirstPartOfStr($editFile,PATH_site) && t3lib_div::isFirstPartOfStr($editFile,$absPath)) { // Paranoia...
2285
2286 $fI = t3lib_div::split_fileref($editFile);
2287 if (@is_file($editFile) && t3lib_div::inList($this->editTextExtensions,($fI['fileext']?$fI['fileext']:$fI['filebody']))) {
2288 if (filesize($editFile)<($this->kbMax*1024)) {
2289 $outCode = '<form action="index.php" method="post" name="editfileform">';
2290 $info = '';
2291 $submittedContent = t3lib_div::_POST('edit');
2292 $saveFlag = 0;
2293
2294 if(isset($submittedContent['file']) && !$GLOBALS['TYPO3_CONF_VARS']['EXT']['noEdit']) { // Check referer here?
2295 $oldFileContent = t3lib_div::getUrl($editFile);
2296 if($oldFileContent != $submittedContent['file']) {
2297 $oldMD5 = md5(str_replace(chr(13),'',$oldFileContent));
2298 $info .= sprintf(
2299 $GLOBALS['LANG']->getLL('ext_details_md5_previous'),
2300 '<b>' . $oldMD5 . '</b>'
2301 ) . '<br />';
2302 t3lib_div::writeFile($editFile,$submittedContent['file']);
2303 $saveFlag = 1;
2304 } else {
2305 $info .= $GLOBALS['LANG']->getLL('ext_details_no_changes') . '<br />';
2306 }
2307 }
2308
2309 $fileContent = t3lib_div::getUrl($editFile);
2310
2311 $outCode.= sprintf(
2312 $GLOBALS['LANG']->getLL('ext_details_file'),
2313 '<b>' . substr($editFile, strlen($absPath)) . '</b> (' .
2314 t3lib_div::formatSize(filesize($editFile)) . ')<br />'
2315 );
2316 $fileMD5 = md5(str_replace(chr(13),'',$fileContent));
2317 $info .= sprintf(
2318 $GLOBALS['LANG']->getLL('ext_details_md5_current'),
2319 '<b>' . $fileMD5 . '</b>'
2320 ) . '<br />';
2321 if($saveFlag) {
2322 $saveMD5 = md5(str_replace(chr(13),'',$submittedContent['file']));
2323 $info .= sprintf(
2324 $GLOBALS['LANG']->getLL('ext_details_md5_submitted'),
2325 '<b>' . $saveMD5 . '</b>'
2326 ) . '<br />';
2327 if ($fileMD5!=$saveMD5) {
2328 $info .= $GLOBALS['TBE_TEMPLATE']->rfw(
2329 '<br /><strong>' . $GLOBALS['LANG']->getLL('ext_details_saving_failed_changes_lost') . '</strong>'
2330 ) . '<br />';
2331 }
2332 else {
2333 $info .= $GLOBALS['TBE_TEMPLATE']->rfw(
2334 '<br /><strong>' . $GLOBALS['LANG']->getLL('ext_details_file_saved') . '</strong>'
2335 ) . '<br />';
2336 }
2337 }
2338
2339 $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>';
2340 $outCode.= '<input type="hidden" name="edit[filename]" value="'.$editFile.'" />';
2341 $outCode.= '<input type="hidden" name="CMD[editFile]" value="'.htmlspecialchars($editFile).'" />';
2342 $outCode.= '<input type="hidden" name="CMD[showExt]" value="'.$extKey.'" />';
2343 $outCode.= $info;
2344
2345 if (!$GLOBALS['TYPO3_CONF_VARS']['EXT']['noEdit']) {
2346 $outCode .= '<br /><input type="submit" name="save_file" value="' .
2347 $GLOBALS['LANG']->getLL('ext_details_file_save_button') . '" />';
2348 }
2349 else {
2350 $outCode .= $GLOBALS['TBE_TEMPLATE']->rfw(
2351 '<br />' . $GLOBALS['LANG']->getLL('ext_details_saving_disabled') . ' '
2352 );
2353 }
2354
2355 $onClick = 'window.location.href=\'index.php?CMD[showExt]='.$extKey.'\';return false;';
2356 $outCode .= '<input type="submit" name="cancel" value="' .
2357 $GLOBALS['LANG']->getLL('ext_details_cancel_button') . '" onclick="' .
2358 htmlspecialchars($onClick) . '" /></form>';
2359
2360 $theOutput.=$this->doc->spacer(15);
2361 $theOutput .= $this->doc->section($GLOBALS['LANG']->getLL('ext_details_edit_file'), '', 0, 1);
2362 $theOutput.=$this->doc->sectionEnd().$outCode;
2363 $this->content.=$theOutput;
2364 } else {
2365 $theOutput.=$this->doc->spacer(15);
2366 $theOutput .= $this->doc->section(
2367 sprintf(
2368 $GLOBALS['LANG']->getLL('ext_details_filesize_exceeded_kb'),
2369 $this->kbMax
2370 ),
2371 sprintf(
2372 $GLOBALS['LANG']->getLL('ext_details_file_too_large'),
2373 $this->kbMax
2374 )
2375 );
2376 }
2377 }
2378 } else {
2379 die (sprintf($GLOBALS['LANG']->getLL('ext_details_fatal_edit_error'),
2380 $editFile
2381 )
2382 );
2383 }
2384 } else {
2385
2386 // MAIN:
2387 switch((string)$this->MOD_SETTINGS['singleDetails']) {
2388 case 'info':
2389 // Loaded / Not loaded:
2390 if (!in_array($extKey,$this->requiredExt)) {
2391 if ($TYPO3_LOADED_EXT[$extKey]) {
2392 $content = '<strong>' . $GLOBALS['LANG']->getLL('ext_details_loaded_and_running') . '</strong><br />' .
2393 '<a href="' . htmlspecialchars('index.php?CMD[showExt]=' . $extKey . '&CMD[remove]=1') .
2394 '">' . $GLOBALS['LANG']->getLL('ext_details_remove_button') . ' ' . $this->removeButton() . '</a>';
2395 } else {
2396 $content = $GLOBALS['LANG']->getLL('ext_details_not_loaded') . '<br />'.
2397 '<a href="' . htmlspecialchars('index.php?CMD[showExt]=' . $extKey . '&CMD[load]=1') .
2398 '">' . $GLOBALS['LANG']->getLL('ext_details_install_button') . ' ' . $this->installButton() . '</a>';
2399 }
2400 } else {
2401 $content = $GLOBALS['LANG']->getLL('ext_details_always_loaded');
2402 }
2403 $this->content.=$this->doc->spacer(10);
2404 $this->content .= $this->doc->section(
2405 $GLOBALS['LANG']->getLL('ext_details_current_status'), $content, 0, 1
2406 );
2407
2408 if (t3lib_extMgm::isLoaded($extKey)) {
2409 $updates=$this->updatesForm($extKey,$list[$extKey]);
2410 if ($updates) {
2411 $this->content.=$this->doc->spacer(10);
2412 $this->content .= $this->doc->section(
2413 $GLOBALS['LANG']->getLL('ext_details_update_needed'),
2414 $updates . '<br /><br />' . $GLOBALS['LANG']->getLL('ext_details_notice_static_data'),
2415 0, 1
2416 );
2417 }
2418 }
2419
2420 // Config:
2421 if (@is_file($absPath.'ext_conf_template.txt')) {
2422 $this->content.=$this->doc->spacer(10);
2423 $this->content .= $this->doc->section(
2424 $GLOBALS['LANG']->getLL('ext_details_configuration'),
2425 $GLOBALS['LANG']->getLL('ext_details_notice_clear_cache') . '<br /><br />',
2426 0, 1
2427 );
2428
2429 $this->tsStyleConfigForm($extKey, $list[$extKey]);
2430 }
2431
2432 // Show details:
2433 $content = t3lib_BEfunc::cshItem('_MOD_tools_em', 'info', $GLOBALS['BACK_PATH'], '|<br />');
2434 $content.= $this->extInformationArray($extKey,$list[$extKey]);
2435
2436 $this->content.=$this->doc->spacer(10);
2437 $this->content .= $this->doc->section(
2438 $GLOBALS['LANG']->getLL('ext_details_details'), $content, 0, 1
2439 );
2440 break;
2441 case 'upload':
2442 $em = t3lib_div::_POST('em');
2443 if($em['action'] == 'doUpload') {
2444 $em['extKey'] = $extKey;
2445 $em['extInfo'] = $list[$extKey];
2446 $content = $this->uploadExtensionToTER($em);
2447 $content .= $this->doc->spacer(10);
2448 // Must reload this, because EM_CONF information has been updated!
2449 list($list,)=$this->getInstalledExtensions();
2450 } else {
2451 // CSH:
2452 $content = t3lib_BEfunc::cshItem('_MOD_tools_em', 'upload', $GLOBALS['BACK_PATH'], '|<br />');
2453
2454 // Upload:
2455 if (substr($extKey,0,5)!='user_') {
2456 $content.= $this->getRepositoryUploadForm($extKey,$list[$extKey]);
2457 $eC=0;
2458 } else {
2459 $content .= $GLOBALS['LANG']->getLL('ext_details_no_unique_ext');
2460 $eC=2;
2461 }
2462 if (!$this->fe_user['username']) {
2463 $content .= '<br /><br /><img src="' . $GLOBALS['BACK_PATH'] .
2464 'gfx/icon_note.gif" width="18" height="16" align="top" alt="" />' .
2465 sprintf($GLOBALS['LANG']->getLL('ext_details_no_username'),
2466 '<a href="index.php?SET[function]=3">', '</a>'
2467 ) .
2468 '<br />';
2469 }
2470 }
2471 $this->content .= $this->doc->section(
2472 $GLOBALS['LANG']->getLL('ext_details_upload_to_ter'),
2473 $content, 0, 1, $eC
2474 );
2475 break;
2476 case 'backup':
2477 if($this->CMD['doDelete']) {
2478 $content = $this->extDelete($extKey,$list[$extKey]);
2479 $this->content .= $this->doc->section(
2480 $GLOBALS['LANG']->getLL('ext_details_delete'),
2481 $content, 0, 1
2482 );
2483 } else {
2484 $content = t3lib_BEfunc::cshItem('_MOD_tools_em', 'backup_delete', $GLOBALS['BACK_PATH'], '|<br />');
2485 $content.= $this->extBackup($extKey,$list[$extKey]);
2486 $this->content .= $this->doc->section(
2487 $GLOBALS['LANG']->getLL('ext_details_backup'),
2488 $content, 0, 1
2489 );
2490
2491 $content = $this->extDelete($extKey,$list[$extKey]);
2492 $this->content .= $this->doc->section(
2493 $GLOBALS['LANG']->getLL('ext_details_delete'),
2494 $content, 0, 1
2495 );
2496
2497 $content = $this->extUpdateEMCONF($extKey,$list[$extKey]);
2498 $this->content .= $this->doc->section(
2499 $GLOBALS['LANG']->getLL('ext_details_update_em_conf'),
2500 $content, 0, 1
2501 );
2502 }
2503 break;
2504 case 'dump':
2505 $this->extDumpTables($extKey,$list[$extKey]);
2506 break;
2507 case 'edit':
2508 $content = t3lib_BEfunc::cshItem('_MOD_tools_em', 'editfiles', $GLOBALS['BACK_PATH'], '|<br />');
2509 $content.= $this->getFileListOfExtension($extKey,$list[$extKey]);
2510
2511 $this->content.=$this->doc->section(
2512 $GLOBALS['LANG']->getLL('ext_details_ext_files'),
2513 $content, 0, 1
2514 );
2515 break;
2516 case 'updateModule':
2517 $this->content .= $this->doc->section(
2518 $GLOBALS['LANG']->getLL('ext_details_update'),
2519 is_object($updateObj) ?
2520 $updateObj->main() :
2521 $GLOBALS['LANG']->getLL('ext_details_no_update_object'),
2522 0, 1
2523 );
2524 break;
2525 default:
2526 $this->extObjContent();
2527 break;
2528 }
2529 }
2530 }
2531 }
2532
2533 /**
2534 * Outputs a screen from where you can install multiple extensions in one go
2535 * This can be called from external modules with "...index.php?CMD[requestInstallExtensions]=
2536 *
2537 * @param string Comma list of extension keys to install. Renders a screen with checkboxes for all extensions not already imported or installed
2538 * @return void
2539 */
2540 function requestInstallExtensions($extList) {
2541
2542 // Return URL:
2543 $returnUrl = t3lib_div::_GP('returnUrl');
2544 $installOrImportExtension = t3lib_div::_POST('installOrImportExtension');
2545
2546 // Extension List:
2547 $extArray = explode(',',$extList);
2548 $outputRow = array();
2549 $outputRow[] = '
2550 <tr class="bgColor5 tableheader">
2551 <td>' . $GLOBALS['LANG']->getLL('reqInstExt_install_import') . '</td>