Fixed bug #9981: EM does not test for usage of mod.php-API and spuriously displays...
[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 $securityMessage = sprintf($GLOBALS['LANG']->getLL('security_descr'),
386 '<a href="http://typo3.org/teams/security/" target="_blank">', '</a>'
387 );
388 $flashMessage = t3lib_div::makeInstance(
389 't3lib_FlashMessage',
390 $securityMessage,
391 $GLOBALS['LANG']->getLL('security_header'),
392 t3lib_FlashMessage::INFO
393 );
394 $this->securityHint = $flashMessage->render();
395
396 $this->excludeForPackaging = $GLOBALS['TYPO3_CONF_VARS']['EXT']['excludeForPackaging'];
397
398 // Setting module configuration:
399 $this->MCONF = $GLOBALS['MCONF'];
400
401 // Setting GPvars:
402 $this->CMD = is_array(t3lib_div::_GP('CMD')) ? t3lib_div::_GP('CMD') : array();
403 $this->lookUpStr = trim(t3lib_div::_GP('lookUp'));
404 $this->listRemote = t3lib_div::_GP('ter_connect');
405 $this->listRemote_search = trim(t3lib_div::_GP('ter_search'));
406
407
408 // Configure menu
409 $this->menuConfig();
410
411 // Setting internal static:
412 if ($TYPO3_CONF_VARS['EXT']['allowSystemInstall']) $this->systemInstall = 1;
413 $this->requiredExt = t3lib_div::trimExplode(',',$TYPO3_CONF_VARS['EXT']['requiredExt'],1);
414
415
416 // Initialize helper object
417 $this->terConnection = t3lib_div::makeInstance('SC_mod_tools_em_terconnection');
418 $this->terConnection->emObj = $this;
419 $this->terConnection->wsdlURL = $TYPO3_CONF_VARS['EXT']['em_wsdlURL'];
420 $this->xmlhandler = t3lib_div::makeInstance('SC_mod_tools_em_xmlhandler');
421 $this->xmlhandler->emObj = $this;
422 $this->xmlhandler->useUnchecked = $this->MOD_SETTINGS['display_unchecked'];
423 $this->xmlhandler->useObsolete = $this->MOD_SETTINGS['display_obsolete'];
424
425 // Initialize Document Template object:
426 $this->doc = t3lib_div::makeInstance('template');
427 $this->doc->backPath = $BACK_PATH;
428 $this->doc->setModuleTemplate('templates/em_index.html');
429
430 // JavaScript
431 $this->doc->JScode = $this->doc->wrapScriptTags('
432 script_ended = 0;
433 function jumpToUrl(URL) { //
434 window.location.href = URL;
435 }
436 ');
437
438 // Reload left frame menu
439 if ($this->CMD['refreshMenu']) {
440 $this->doc->JScode .= $this->doc->wrapScriptTags('
441 if(top.refreshMenu) {
442 top.refreshMenu();
443 } else {
444 top.TYPO3ModuleMenu.refreshMenu();
445 }
446 ');
447 }
448
449
450 // Descriptions:
451 $this->descrTable = '_MOD_'.$this->MCONF['name'];
452 if ($BE_USER->uc['edit_showFieldHelp']) {
453 $LANG->loadSingleTableDescription($this->descrTable);
454 }
455
456 // Setting username/password etc. for upload-user:
457 $this->fe_user['username'] = $this->MOD_SETTINGS['fe_u'];
458 $this->fe_user['password'] = $this->MOD_SETTINGS['fe_p'];
459 parent::init();
460 $this->handleExternalFunctionValue('singleDetails');
461 }
462
463 /**
464 * This function is a copy of the same function in t3lib_SCbase with one modification:
465 * In contrast to t3lib_SCbase::handleExternalFunctionValue() this function merges the $this->extClassConf array
466 * instead of overwriting it. That was necessary for including the Kickstarter as a submodule into the 'singleDetails'
467 * selectorbox as well as in the main 'function' selectorbox.
468 *
469 * @param string Mod-setting array key
470 * @param string Mod setting value, overriding the one in the key
471 * @return void
472 * @see t3lib_SCbase::handleExternalFunctionValue()
473 */
474 function handleExternalFunctionValue($MM_key='function', $MS_value=NULL) {
475 $MS_value = is_null($MS_value) ? $this->MOD_SETTINGS[$MM_key] : $MS_value;
476 $externalItems = $this->getExternalItemConfig($this->MCONF['name'],$MM_key,$MS_value);
477 if (is_array($externalItems)) $this->extClassConf = array_merge($externalItems,is_array($this->extClassConf)?$this->extClassConf:array());
478 if (is_array($this->extClassConf) && $this->extClassConf['path']) {
479 $this->include_once[]=$this->extClassConf['path'];
480 }
481 }
482
483 /**
484 * Configuration of which mod-menu items can be used
485 *
486 * @return void
487 */
488 function menuConfig() {
489 global $BE_USER, $TYPO3_CONF_VARS;
490
491 // MENU-ITEMS:
492 $this->MOD_MENU = array(
493 'function' => array(
494 0 => $GLOBALS['LANG']->getLL('menu_loaded_extensions'),
495 1 => $GLOBALS['LANG']->getLL('menu_install_extensions'),
496 2 => $GLOBALS['LANG']->getLL('menu_import_extensions'),
497 4 => $GLOBALS['LANG']->getLL('menu_translation_handling'),
498 3 => $GLOBALS['LANG']->getLL('menu_settings'),
499 5 => $GLOBALS['LANG']->getLL('menu_extension_updates'),
500 ),
501 'listOrder' => array(
502 'cat' => $GLOBALS['LANG']->getLL('list_order_category'),
503 'author_company' => $GLOBALS['LANG']->getLL('list_order_author'),
504 'state' => $GLOBALS['LANG']->getLL('list_order_state'),
505 'type' => $GLOBALS['LANG']->getLL('list_order_type'),
506 ),
507 'display_details' => array(
508 1 => $GLOBALS['LANG']->getLL('show_details'),
509 0 => $GLOBALS['LANG']->getLL('show_description'),
510 2 => $GLOBALS['LANG']->getLL('show_more_details'),
511
512 3 => $GLOBALS['LANG']->getLL('show_technical'),
513 4 => $GLOBALS['LANG']->getLL('show_validating'),
514 5 => $GLOBALS['LANG']->getLL('show_changed'),
515 ),
516 'display_shy' => '',
517 'display_own' => '',
518 'display_unchecked' => '',
519 'display_obsolete' => '',
520 'display_installed' => '',
521 'display_files' => '',
522
523
524 'singleDetails' => array(
525 'info' => $GLOBALS['LANG']->getLL('details_info'),
526 'edit' => $GLOBALS['LANG']->getLL('details_edit'),
527 'backup' => $GLOBALS['LANG']->getLL('details_backup_delete'),
528 'dump' => $GLOBALS['LANG']->getLL('details_dump_db'),
529 'upload' => $GLOBALS['LANG']->getLL('details_upload'),
530 'updateModule' => $GLOBALS['LANG']->getLL('details_update'),
531 ),
532 'fe_u' => '',
533 'fe_p' => '',
534
535 'mirrorListURL' => '',
536 'rep_url' => '',
537 'extMirrors' => '',
538 'selectedMirror' => '',
539
540 'selectedLanguages' => ''
541 );
542
543 $this->MOD_MENU['singleDetails'] = $this->mergeExternalItems($this->MCONF['name'],'singleDetails',$this->MOD_MENU['singleDetails']);
544
545 // page/be_user TSconfig settings and blinding of menu-items
546 if (!$BE_USER->getTSConfigVal('mod.'.$this->MCONF['name'].'.allowTVlisting')) {
547 unset($this->MOD_MENU['display_details'][3]);
548 unset($this->MOD_MENU['display_details'][4]);
549 unset($this->MOD_MENU['display_details'][5]);
550 }
551
552 // CLEANSE SETTINGS
553 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
554
555 if ($this->MOD_SETTINGS['function']==2) {
556 // If listing from online repository, certain items are removed though:
557 unset($this->MOD_MENU['listOrder']['type']);
558 unset($this->MOD_MENU['display_details'][2]);
559 unset($this->MOD_MENU['display_details'][3]);
560 unset($this->MOD_MENU['display_details'][4]);
561 unset($this->MOD_MENU['display_details'][5]);
562 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
563 }
564 parent::menuConfig();
565 }
566
567 /**
568 * Main function for Extension Manager module.
569 *
570 * @return void
571 */
572 function main() {
573 global $BE_USER,$LANG,$TYPO3_CONF_VARS;
574
575 if (empty($this->MOD_SETTINGS['mirrorListURL'])) $this->MOD_SETTINGS['mirrorListURL'] = $TYPO3_CONF_VARS['EXT']['em_mirrorListURL'];
576
577 // Starting page:
578 $this->content.=$this->doc->header($GLOBALS['LANG']->getLL('header'));
579 $this->content.=$this->doc->spacer(5);
580
581 // Command given which is executed regardless of main menu setting:
582 if ($this->CMD['showExt']) { // Show details for a single extension
583 $this->showExtDetails($this->CMD['showExt']);
584 } elseif ($this->CMD['requestInstallExtensions']) { // Show details for a single extension
585 $this->requestInstallExtensions($this->CMD['requestInstallExtensions']);
586 } elseif ($this->CMD['importExt'] || $this->CMD['uploadExt']) { // Imports an extension from online rep.
587 $err = $this->importExtFromRep($this->CMD['importExt'],$this->CMD['extVersion'],$this->CMD['loc'],$this->CMD['uploadExt']);
588 if ($err) {
589 $this->content.=$this->doc->section('',$GLOBALS['TBE_TEMPLATE']->rfw($err));
590 }
591 if(!$err && $this->CMD['importExt']) {
592 $this->installTranslationsForExtension($this->CMD['importExt'], $this->getMirrorURL());
593 }
594 } elseif ($this->CMD['importExtInfo']) { // Gets detailed information of an extension from online rep.
595 $this->importExtInfo($this->CMD['importExtInfo'],$this->CMD['extVersion']);
596 } else { // No command - we show what the menu setting tells us:
597 if (t3lib_div::inList('0,1,2',$this->MOD_SETTINGS['function'])) {
598 $menu .= '&nbsp;' . $GLOBALS['LANG']->getLL('group_by') . '&nbsp;' . t3lib_BEfunc::getFuncMenu(0, 'SET[listOrder]', $this->MOD_SETTINGS['listOrder'], $this->MOD_MENU['listOrder']) .
599 '&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 />';
600 }
601 if (t3lib_div::inList('0,1,5',$this->MOD_SETTINGS['function'])) {
602 $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"');
603 }
604 if (t3lib_div::inList('2',$this->MOD_SETTINGS['function']) && strlen($this->fe_user['username'])) {
605 $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"');
606 }
607 if (t3lib_div::inList('0,1,2',$this->MOD_SETTINGS['function'])) {
608 $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"');
609 }
610
611 $this->content.=$this->doc->section('','<form action="index.php" method="post" name="pageform"><span class="nobr">' . ($menu ? $menu : '&nbsp;') . '</span></form>');
612 $this->content.=$this->doc->spacer(10);
613
614 switch((string)$this->MOD_SETTINGS['function']) {
615 case '0':
616 // Lists loaded (installed) extensions
617 $this->extensionList_loaded();
618 break;
619 case '1':
620 // Lists the installed (available) extensions
621 $this->extensionList_installed();
622 break;
623 case '2':
624 // Lists the extensions available from online rep.
625 $this->extensionList_import();
626 break;
627 case '3':
628 // Shows the settings screen
629 $this->alterSettings();
630 break;
631 case '4':
632 // Allows to set the translation preferences and check the status
633 $this->translationHandling();
634 break;
635 case '5':
636 // Shows a list of extensions with updates in TER
637 $this->checkForUpdates();
638 break;
639 default:
640 $this->extObjContent();
641 break;
642 }
643 }
644
645 // closing any form?
646 $formTags = substr_count($this->content, '<form') + substr_count($this->content, '</form');
647 if ($formTags % 2 > 0) {
648 $this->content .= '</form>';
649 }
650
651 // Setting up the buttons and markers for docheader
652 $docHeaderButtons = $this->getButtons();
653 $markers = array(
654 'CSH' => $docHeaderButtons['csh'],
655 'FUNC_MENU' => $this->getFuncMenu(),
656 'CONTENT' => $this->content
657 );
658
659 // Build the <body> for the module
660 $this->content = $this->doc->startPage('Extension Manager');
661 $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
662 $this->content.= $this->doc->endPage();
663 $this->content = $this->doc->insertStylesAndJS($this->content);
664 }
665
666 /**
667 * Print module content. Called as last thing in the global scope.
668 *
669 * @return void
670 */
671 function printContent() {
672 if ($this->doPrintContent) {
673 echo $this->content;
674 }
675 }
676
677 /**
678 * Create the function menu
679 *
680 * @return string HTML of the function menu
681 */
682 protected function getFuncMenu() {
683 $funcMenu = '';
684 if(!$this->CMD['showExt'] && !$this->CMD['requestInstallExtensions'] && !$this->CMD['importExt'] && !$this->CMD['uploadExt'] && !$this->CMD['importExtInfo']) {
685 $funcMenu = t3lib_BEfunc::getFuncMenu(0, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']);
686 } elseif($this->CMD['showExt'] && (!$this->CMD['standAlone'] && !t3lib_div::_GP('standAlone'))) {
687 $funcMenu = t3lib_BEfunc::getFuncMenu(0, 'SET[singleDetails]', $this->MOD_SETTINGS['singleDetails'], $this->MOD_MENU['singleDetails'], '', '&CMD[showExt]=' . $this->CMD['showExt']);
688 }
689 return $funcMenu;
690 }
691
692 /**
693 * Create the panel of buttons for submitting the form or otherwise perform operations.
694 *
695 * @return array all available buttons as an assoc. array
696 */
697 protected function getButtons() {
698
699 $buttons = array(
700 'csh' => '',
701 'back' => '',
702 'shortcut' => ''
703 );
704 // CSH
705 //$buttons['csh'] = t3lib_BEfunc::cshItem('_MOD_web_func', '', $GLOBALS['BACK_PATH']);
706
707 // Shortcut
708 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
709 $buttons['shortcut'] = $this->doc->makeShortcutIcon('CMD','function',$this->MCONF['name']);
710 }
711 // Back
712 if(($this->CMD['showExt'] && (!$this->CMD['standAlone'] && !t3lib_div::_GP('standAlone'))) || ($this->CMD['importExt'] || $this->CMD['uploadExt'] && (!$this->CMD['standAlone'])) || $this->CMD['importExtInfo']) {
713 $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>';
714 }
715
716 return $buttons;
717 }
718
719
720
721
722
723
724
725
726 /*********************************
727 *
728 * Function Menu Applications
729 *
730 *********************************/
731
732 /**
733 * Listing of loaded (installed) extensions
734 *
735 * @return void
736 */
737 function extensionList_loaded() {
738 global $TYPO3_LOADED_EXT;
739
740 list($list,$cat) = $this->getInstalledExtensions();
741
742 // Loaded extensions
743 $content = '';
744 $lines = array();
745
746 // Available extensions
747 if (is_array($cat[$this->MOD_SETTINGS['listOrder']])) {
748 $content='';
749 $lines=array();
750 $lines[] = $this->extensionListRowHeader(' class="bgColor5"',array('<td><img src="clear.gif" width="1" height="1" alt="" /></td>'));
751
752 foreach($cat[$this->MOD_SETTINGS['listOrder']] as $catName => $extEkeys) {
753 natcasesort($extEkeys);
754 reset($extEkeys);
755 $extensions = array();
756 while(list($extKey)=each($extEkeys)) {
757 if (array_key_exists($extKey,$TYPO3_LOADED_EXT) && ($this->MOD_SETTINGS['display_shy'] || !$list[$extKey]['EM_CONF']['shy']) && $this->searchExtension($extKey,$list[$extKey])) {
758 if (in_array($extKey, $this->requiredExt)) {
759 $loadUnloadLink = '<strong>' . $GLOBALS['TBE_TEMPLATE']->rfw($GLOBALS['LANG']->getLL('extension_required_short')) . '</strong>';
760 } else {
761 $loadUnloadLink = '<a href="'.htmlspecialchars('index.php?CMD[showExt]='.$extKey.'&CMD[remove]=1').'">'.$this->removeButton().'</a>';
762 }
763
764 $extensions[] = $this->extensionListRow($extKey,$list[$extKey],array('<td class="bgColor">'.$loadUnloadLink.'</td>'));
765 }
766 }
767 if(count($extensions)) {
768 $lines[]='<tr><td colspan="'.(3+$this->detailCols[$this->MOD_SETTINGS['display_details']]).'"><br /></td></tr>';
769 $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>'.htmlspecialchars($this->listOrderTitle($this->MOD_SETTINGS['listOrder'],$catName)).'</strong></td></tr>';
770 $lines[] = implode(chr(10),$extensions);
771 }
772 }
773 }
774
775 $content.= t3lib_BEfunc::cshItem('_MOD_tools_em', 'loaded', $GLOBALS['BACK_PATH'],'');
776 $content.= '<form action="index.php" method="post" name="lookupform">';
777 $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 />';
778
779 $content.= '</form>
780
781 <!-- Loaded Extensions List -->
782 <table border="0" cellpadding="2" cellspacing="1">'.implode('',$lines).'</table>';
783
784 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('loaded_exts'),$content,0,1);
785 }
786
787 /**
788 * Listing of available (installed) extensions
789 *
790 * @return void
791 */
792 function extensionList_installed() {
793 global $TYPO3_LOADED_EXT;
794
795 list($list,$cat)=$this->getInstalledExtensions();
796
797 // Available extensions
798 if (is_array($cat[$this->MOD_SETTINGS['listOrder']])) {
799 $content='';
800 $lines=array();
801 $lines[]=$this->extensionListRowHeader(' class="bgColor5"',array('<td><img src="clear.gif" width="18" height="1" alt="" /></td>'));
802
803 $allKeys=array();
804 foreach($cat[$this->MOD_SETTINGS['listOrder']] as $catName => $extEkeys) {
805 if(!$this->MOD_SETTINGS['display_obsolete'] && $catName=='obsolete') continue;
806
807 $allKeys[]='';
808 $allKeys[]='TYPE: '.$catName;
809
810 natcasesort($extEkeys);
811 reset($extEkeys);
812 $extensions = array();
813 while(list($extKey)=each($extEkeys)) {
814 $allKeys[]=$extKey;
815 if ((!$list[$extKey]['EM_CONF']['shy'] || $this->MOD_SETTINGS['display_shy']) &&
816 ($list[$extKey]['EM_CONF']['state']!='obsolete' || $this->MOD_SETTINGS['display_obsolete'])
817 && $this->searchExtension($extKey,$list[$extKey])) {
818 $loadUnloadLink = t3lib_extMgm::isLoaded($extKey)?
819 '<a href="'.htmlspecialchars('index.php?CMD[showExt]='.$extKey.'&CMD[remove]=1&CMD[clrCmd]=1&SET[singleDetails]=info').'">'.$this->removeButton().'</a>':
820 '<a href="'.htmlspecialchars('index.php?CMD[showExt]='.$extKey.'&CMD[load]=1&CMD[clrCmd]=1&SET[singleDetails]=info').'">'.$this->installButton().'</a>';
821 if (in_array($extKey,$this->requiredExt)) {
822 $loadUnloadLink = '<strong>' . $GLOBALS['TBE_TEMPLATE']->rfw($GLOBALS['LANG']->getLL('extension_required_short')) . '</strong>';
823 }
824 $theRowClass = t3lib_extMgm::isLoaded($extKey)? 'em-listbg1' : 'em-listbg2';
825 $extensions[]=$this->extensionListRow($extKey,$list[$extKey],array('<td class="bgColor">'.$loadUnloadLink.'</td>'),$theRowClass);
826 }
827 }
828 if(count($extensions)) {
829 $lines[]='<tr><td colspan="'.(3+$this->detailCols[$this->MOD_SETTINGS['display_details']]).'"><br /></td></tr>';
830 $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>'.htmlspecialchars($this->listOrderTitle($this->MOD_SETTINGS['listOrder'],$catName)).'</strong></td></tr>';
831 $lines[] = implode(chr(10),$extensions);
832 }
833 }
834
835 $content.='
836
837
838 <!--
839 EXTENSION KEYS:
840
841 '.trim(implode(chr(10),$allKeys)).'
842
843 -->
844
845 ';
846
847 $content.= t3lib_BEfunc::cshItem('_MOD_tools_em', 'avail', $GLOBALS['BACK_PATH'], '|<br />');
848 $content.= sprintf($GLOBALS['LANG']->getLL('how_to_install'), $this->installButton()) . ' <br />' .
849 sprintf($GLOBALS['LANG']->getLL('how_to_uninstall'), $this->removeButton()). ' <br /><br />';
850 $content .= '<form action="index.php" method="post" name="lookupform">';
851 $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 />';
852 $content.= $this->securityHint.'<br /><br />';
853
854 $content.= '<table border="0" cellpadding="2" cellspacing="1">'.implode('',$lines).'</table>';
855
856 $this->content.=$this->doc->section(sprintf($GLOBALS['LANG']->getLL('available_extensions'), $this->MOD_MENU['listOrder'][$this->MOD_SETTINGS['listOrder']]),$content,0,1);
857 }
858 }
859
860 /**
861 * Listing remote extensions from online repository
862 *
863 * @return void
864 */
865 function extensionList_import() {
866 global $TYPO3_LOADED_EXT;
867 $content='';
868
869 // Listing from online repository:
870 if ($this->listRemote) {
871 list($inst_list,) = $this->getInstalledExtensions();
872 $this->inst_keys = array_flip(array_keys($inst_list));
873
874 $this->detailCols[1]+=6;
875
876 // see if we have an extensionlist at all
877 $this->extensionCount = $this->xmlhandler->countExtensions();
878 if (!$this->extensionCount) {
879 $content .= $this->fetchMetaData('extensions');
880 }
881
882 if($this->MOD_SETTINGS['listOrder']=='author_company') {
883 $this->listingLimit = $this->listingLimitAuthor;
884 }
885
886 $this->pointer = intval(t3lib_div::_GP('pointer'));
887 $offset = $this->listingLimit*$this->pointer;
888
889 if($this->MOD_SETTINGS['display_own'] && strlen($this->fe_user['username'])) {
890 $this->xmlhandler->searchExtensionsXML($this->listRemote_search, $this->fe_user['username'], $this->MOD_SETTINGS['listOrder']);
891 } else {
892 $this->xmlhandler->searchExtensionsXML($this->listRemote_search, '', $this->MOD_SETTINGS['listOrder'], false, false, $offset, $this->listingLimit);
893 }
894 if (count($this->xmlhandler->extensionsXML)) {
895 list($list,$cat) = $this->prepareImportExtList(true);
896
897 // Available extensions
898 if (is_array($cat[$this->MOD_SETTINGS['listOrder']])) {
899 $lines=array();
900 $lines[]=$this->extensionListRowHeader(' class="bgColor5"',array('<td><img src="clear.gif" width="18" height="1" alt="" /></td>'),1);
901
902 foreach($cat[$this->MOD_SETTINGS['listOrder']] as $catName => $extEkeys) {
903 if (count($extEkeys)) {
904 $lines[]='<tr><td colspan="'.(3+$this->detailCols[$this->MOD_SETTINGS['display_details']]).'"><br /></td></tr>';
905 $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>'.htmlspecialchars($this->listOrderTitle($this->MOD_SETTINGS['listOrder'],$catName)).'</strong></td></tr>';
906
907 natcasesort($extEkeys);
908 reset($extEkeys);
909 while(list($extKey)=each($extEkeys)) {
910 $version = array_keys($list[$extKey]['versions']);
911 $version = end($version);
912 $ext = $list[$extKey]['versions'][$version];
913 $ext['downloadcounter_all'] = $list[$extKey]['downloadcounter'];
914 $ext['_ICON'] = $list[$extKey]['_ICON'];
915 $loadUnloadLink='';
916 if ($inst_list[$extKey]['type']!='S' && (!isset($inst_list[$extKey]) || $this->versionDifference($version,$inst_list[$extKey]['EM_CONF']['version'],$this->versionDiffFactor))) {
917 if (isset($inst_list[$extKey])) {
918 // update
919 if ($inst_list[$extKey]['EM_CONF']['state'] != 'excludeFromUpdates') {
920 $loc= ($inst_list[$extKey]['type']=='G'?'G':'L');
921 $aUrl = 'index.php?CMD[importExt]='.$extKey.'&CMD[extVersion]='.$version.'&CMD[loc]='.$loc;
922 $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>';
923 } else {
924 // extension is marked as "excludeFromUpdates"
925 $loadUnloadLink .= '<img src="' . $GLOBALS['BACK_PATH'] . 'gfx/icon_warning.gif" width="18" height="16" title="' . $GLOBALS['LANG']->getLL('excluded_from_updates') . '" alt="" />';
926 }
927 } else {
928 // import
929 $aUrl = 'index.php?CMD[importExt]='.$extKey.'&CMD[extVersion]='.$version.'&CMD[loc]=L';
930 $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>';
931 }
932 } else {
933 $loadUnloadLink = '&nbsp;';
934 }
935
936 if (isset($inst_list[$extKey])) {
937 $theRowClass = t3lib_extMgm::isLoaded($extKey) ? 'em-listbg1' : 'em-listbg2';
938 } else {
939 $theRowClass = 'em-listbg3';
940 }
941
942 $lines[]=$this->extensionListRow($extKey,$ext,array('<td class="bgColor">'.$loadUnloadLink.'</td>'),$theRowClass,$inst_list,1,'index.php?CMD[importExtInfo]='.rawurlencode($extKey));
943 unset($list[$extKey]);
944 }
945 }
946 }
947 unset($list);
948
949 // CSH:
950 $content .= t3lib_BEfunc::cshItem('_MOD_tools_em', 'import_ter', $GLOBALS['BACK_PATH'], '|<br />');
951 $onsubmit = "window.location.href='index.php?ter_connect=1&ter_search='+escape(this.elements['lookUp'].value);return false;";
952 $content .= '<form action="index.php" method="post" onsubmit="' . htmlspecialchars($onsubmit) .
953 '"><label for="lookUp">' .
954 sprintf($GLOBALS['LANG']->getLL('list_or_look_up'),
955 ($this->MOD_SETTINGS['display_unchecked'] ?
956 '<strong style="color:#900;">' . $GLOBALS['LANG']->getLL('list_or_look_up_all') . '</strong>'
957 : '<strong style="color:#090;">' . $GLOBALS['LANG']->getLL('list_or_look_up_reviewed') . '</strong>'
958 )
959 ) .
960 '</label><br />
961 <input type="text" id="lookUp" name="lookUp" value="' . htmlspecialchars($this->listRemote_search) .
962 '" /> <input type="submit" value="' . $GLOBALS['LANG']->getLL('look_up_button') . '" /></form><br /><br />';
963
964 $content .= $this->browseLinks();
965
966 $content.= '
967
968 <!-- TER Extensions list -->
969 <table border="0" cellpadding="2" cellspacing="1">'.implode(chr(10),$lines).'</table>';
970 $content .= '<br />'.$this->browseLinks();
971 $content.= '<br /><br />'.$this->securityHint;
972 $content .= '<br /><br /><strong>' . $GLOBALS['LANG']->getLL('privacy_notice_header') .
973 '</strong><br /> ' . $this->privacyNotice;
974
975 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('extensions_repository_group_by') . ' ' .
976 $this->MOD_MENU['listOrder'][$this->MOD_SETTINGS['listOrder']], $content, 0, 1);
977
978 // Plugins which are NOT uploaded to repository but present on this server.
979 $content='';
980 $lines=array();
981 if (count($this->inst_keys)) {
982 reset($this->inst_keys);
983 while(list($extKey)=each($this->inst_keys)) {
984 $this->xmlhandler->searchExtensionsXMLExact($extKey, '', '', true);
985 if((strlen($this->listRemote_search) && !stristr($extKey,$this->listRemote_search)) || isset($this->xmlhandler->extensionsXML[$extKey])) continue;
986
987 $loadUnloadLink = t3lib_extMgm::isLoaded($extKey)?
988 '<a href="'.htmlspecialchars('index.php?CMD[showExt]='.$extKey.'&CMD[remove]=1&CMD[clrCmd]=1&SET[singleDetails]=info').'">'.$this->removeButton().'</a>':
989 '<a href="'.htmlspecialchars('index.php?CMD[showExt]='.$extKey.'&CMD[load]=1&CMD[clrCmd]=1&SET[singleDetails]=info').'">'.$this->installButton().'</a>';
990 if (in_array($extKey,$this->requiredExt)) {
991 $loadUnloadLink = '<strong>' .$GLOBALS['TBE_TEMPLATE']->rfw($GLOBALS['LANG']->getLL('extension_required_short')) . '</strong>';
992 }
993 $lines[]=$this->extensionListRow($extKey,$inst_list[$extKey],array('<td class="bgColor">'.$loadUnloadLink.'</td>'),t3lib_extMgm::isLoaded($extKey)?'em-listbg1':'em-listbg2');
994 }
995 }
996 if(count($lines)) {
997 $content .= $GLOBALS['LANG']->getLL('list_of_local_extensions') .
998 '<br />' . $GLOBALS['LANG']->getLL('might_be_user_defined') . '<br /><br />';
999 $content.= '<table border="0" cellpadding="2" cellspacing="1">'.
1000 $this->extensionListRowHeader(' class="bgColor5"',array('<td><img src="clear.gif" width="18" height="1" alt="" /></td>')).
1001 implode('',$lines).'</table>';
1002 $this->content.=$this->doc->spacer(20);
1003 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('only_on_this_server'), $content, 0, 1);
1004 }
1005 }
1006 } else {
1007 $content .= t3lib_BEfunc::cshItem('_MOD_tools_em', 'import_ter', $GLOBALS['BACK_PATH'], '|<br />');
1008 $onsubmit = "window.location.href='index.php?ter_connect=1&ter_search='+escape(this.elements['lookUp'].value);return false;";
1009 $content .= '<form action="index.php" method="post" onsubmit="' . htmlspecialchars($onsubmit) .
1010 '"><label for="lookUp">' .
1011 sprintf($GLOBALS['LANG']->getLL('list_or_look_up'),
1012 ($this->MOD_SETTINGS['display_unchecked'] ?
1013 '<strong style="color:#900;">' . $GLOBALS['LANG']->getLL('list_or_look_up_all') . '</strong>'
1014 : '<strong style="color:#090;">' . $GLOBALS['LANG']->getLL('list_or_look_up_reviewed') . '</strong>'
1015 )
1016 ) .
1017 '</label><br />
1018 <input type="text" id="lookUp" name="lookUp" value="' . htmlspecialchars($this->listRemote_search) .
1019 '" /> <input type="submit" value="' . $GLOBALS['LANG']->getLL('look_up_button') . '" /></form><br /><br />';
1020
1021 $content .= '<p><strong>' . $GLOBALS['LANG']->getLL('no_matching_extensions') . '</strong></p>';
1022
1023 $content .= '<br /><br /><strong>' . $GLOBALS['LANG']->getLL('privacy_notice_header') .
1024 '</strong><br /> ' . $this->privacyNotice;
1025 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('extensions_repository_group_by') . ' ' .
1026 $this->MOD_MENU['listOrder'][$this->MOD_SETTINGS['listOrder']], $content, 0, 1);
1027 }
1028 } else {
1029 // CSH
1030 $content .= t3lib_BEfunc::cshItem('_MOD_tools_em', 'import', $GLOBALS['BACK_PATH'], '|<br />');
1031
1032 $onsubmit = "window.location.href='index.php?ter_connect=1&ter_search='+escape(this.elements['lookUp'].value);return false;";
1033 $content .= '<form action="index.php" method="post" onsubmit="' . htmlspecialchars($onsubmit) .
1034 '"><label for="lookUp">' .
1035 sprintf($GLOBALS['LANG']->getLL('list_or_look_up'),
1036 ($this->MOD_SETTINGS['display_unchecked'] ?
1037 '<strong style="color:#900;">' . $GLOBALS['LANG']->getLL('list_or_look_up_all') . '</strong>'
1038 : '<strong style="color:#090;">' . $GLOBALS['LANG']->getLL('list_or_look_up_reviewed') . '</strong>'
1039 )
1040 ) .
1041 '</label><br />
1042 <input type="text" id="lookUp" name="lookUp" value="" /> <input type="submit" value="' .
1043 $GLOBALS['LANG']->getLL('look_up_button') . '" /><br /><br />';
1044
1045 if ($this->CMD['fetchMetaData']) { // fetches mirror/extension data from online rep.
1046 $content .= $this->fetchMetaData($this->CMD['fetchMetaData']);
1047 } else {
1048 $onCLick = "window.location.href='index.php?CMD[fetchMetaData]=extensions';return false;";
1049 $content .= $GLOBALS['LANG']->getLL('connect_to_ter') . '<br />
1050 <input type="submit" value="' . $GLOBALS['LANG']->getLL('retrieve_update') .
1051 '" onclick="' . htmlspecialchars($onCLick) . '" />';
1052 if (is_file(PATH_site.'typo3temp/extensions.xml.gz')) {
1053 $dateFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'];
1054 $timeFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'];
1055 $content .= ' ' . sprintf($GLOBALS['LANG']->getLL('ext_list_last_updated') . ' ',
1056 date(
1057 $dateFormat . ', ' . $timeFormat,
1058 filemtime(PATH_site . 'typo3temp/extensions.xml.gz')
1059 )
1060 );
1061 }
1062 }
1063 $content.= '</form><br /><br />'.$this->securityHint;
1064 $content .= '<br /><br /><strong>' . $GLOBALS['LANG']->getLL('privacy_notice_header') .
1065 '</strong><br />' . $this->privacyNotice;
1066
1067 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('in_repository'), $content, 0, 1);
1068 }
1069
1070 // Upload:
1071 if ($this->importAtAll()) {
1072 $content= '<form action="index.php" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'" method="post">
1073 <label for="upload_ext_file">' . $GLOBALS['LANG']->getLL('upload_t3x') . '</label><br />
1074 <input type="file" size="60" id="upload_ext_file" name="upload_ext_file" /><br />' .
1075 $GLOBALS['LANG']->getLL('upload_to_location') . '<br />
1076 <select name="CMD[loc]">';
1077 if ($this->importAsType('L')) $content .= '<option value="L">' . $GLOBALS['LANG']->getLL('local_folder') . '</option>';
1078 if ($this->importAsType('G')) $content .= '<option value="G">' . $GLOBALS['LANG']->getLL('global_folder') . '</option>';
1079 if ($this->importAsType('S')) $content .= '<option value="S">' . $GLOBALS['LANG']->getLL('system_folder') . '</option>';
1080 $content.='</select><br />
1081 <input type="checkbox" value="1" name="CMD[uploadOverwrite]" id="checkUploadOverwrite" /> <label for="checkUploadOverwrite">' .
1082 $GLOBALS['LANG']->getLL('overwrite_ext') . '</label><br />
1083 <input type="submit" name="CMD[uploadExt]" value="' . $GLOBALS['LANG']->getLL('upload_ext_file') . '" /></form><br />
1084 ';
1085 } else $content=$this->noImportMsg();
1086
1087 $this->content.=$this->doc->spacer(20);
1088 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('upload_ext_directly'), $content, 0, 1);
1089 }
1090
1091 /**
1092 * Generates a link to the next page of extensions
1093 *
1094 * @return void
1095 */
1096 function browseLinks() {
1097 $content = '';
1098 if ($this->pointer) {
1099 $content .= '<a href="' . t3lib_div::linkThisScript(array('pointer' => $this->pointer-1)) .
1100 '" class="typo3-prevPage"><img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],
1101 'gfx/pilleft_n.gif', 'width="14" height="14"') .
1102 ' alt="' . $GLOBALS['LANG']->getLL('previous_page') . '" /> ' .
1103 $GLOBALS['LANG']->getLL('previous_page') . '</a>';
1104 }
1105 if ($content) $content .= '&nbsp;&nbsp;&nbsp;';
1106 if (intval($this->xmlhandler->matchingCount/$this->listingLimit)>$this->pointer) {
1107 $content .= '<a href="' . t3lib_div::linkThisScript(array('pointer' => $this->pointer+1)) .
1108 '" class="typo3-nextPage"><img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],
1109 'gfx/pilright_n.gif', 'width="14" height="14"') .
1110 ' alt="' . $GLOBALS['LANG']->getLL('next_page') . '" /> ' .
1111 $GLOBALS['LANG']->getLL('next_page') . '</a>';
1112 }
1113 $upper = (($this->pointer+1)*$this->listingLimit);
1114 if ($upper>$this->xmlhandler->matchingCount) {
1115 $upper = $this->xmlhandler->matchingCount;
1116 }
1117 if ($content) $content .= '<br /><br />' .
1118 sprintf($GLOBALS['LANG']->getLL('showing_extensions_from_to'),
1119 '<strong>' . ($this->pointer*$this->listingLimit+1) . '</strong>',
1120 '<strong>' . $upper . '</strong>'
1121 );
1122 if ($content) $content .= '<br /><br />';
1123 return $content;
1124 }
1125
1126 /**
1127 * Allows changing of settings
1128 *
1129 * @return void
1130 */
1131 function alterSettings() {
1132
1133 // Prepare the HTML output:
1134 $content.= '
1135 ' . t3lib_BEfunc::cshItem('_MOD_tools_em', 'settings', $GLOBALS['BACK_PATH'], '|<br />') . '
1136 <form action="index.php" method="post" name="altersettings">
1137 <fieldset><legend>' . $GLOBALS['LANG']->getLL('security_settings') . '</legend>
1138 <table border="0" cellpadding="2" cellspacing="2">
1139 <tr class="bgColor4">
1140 <td><label for="display_unchecked">' . $GLOBALS['LANG']->getLL('show_exts_without_security_check') . '</label></td>
1141 <td>'.t3lib_BEfunc::getFuncCheck(0,'SET[display_unchecked]',$this->MOD_SETTINGS['display_unchecked'],'','','id="display_unchecked"').'</td>
1142 </tr>
1143 </table>
1144 <strong>' . $GLOBALS['LANG']->getLL('notice') . '</strong> ' .
1145 sprintf($GLOBALS['LANG']->getLL('security_notice'),
1146 '<a href="http://typo3.org/extensions/what-are-reviews/" target="_blank">', '</a>'
1147 ) .
1148 '</fieldset>
1149 <br />
1150 <br />
1151 <fieldset><legend>' . $GLOBALS['LANG']->getLL('user_settings') . '</legend>
1152 <table border="0" cellpadding="2" cellspacing="2">
1153 <tr class="bgColor4">
1154 <td><label for="set_fe_u">' . $GLOBALS['LANG']->getLL('enter_repository_username') . '</label></td>
1155 <td><input type="text" id="set_fe_u" name="SET[fe_u]" value="'.htmlspecialchars($this->MOD_SETTINGS['fe_u']).'" /></td>
1156 </tr>
1157 <tr class="bgColor4">
1158 <td><label for="set_fe_p">' . $GLOBALS['LANG']->getLL('enter_repository_password') . '</label></td>
1159 <td><input type="password" id="set_fe_p" name="SET[fe_p]" value="'.htmlspecialchars($this->MOD_SETTINGS['fe_p']).'" /></td>
1160 </tr>
1161 </table>
1162 <strong>' . $GLOBALS['LANG']->getLL('notice') . '</strong> ' .
1163 $GLOBALS['LANG']->getLL('repository_password_info') . '
1164 </fieldset>
1165 <br />
1166 <br />
1167 <fieldset><legend>' . $GLOBALS['LANG']->getLL('mirror_selection') . '</legend>
1168 <table border="0" cellpadding="2" cellspacing="2">
1169 <tr class="bgColor4">
1170 <td><label for="set_mirror_list_url">' . $GLOBALS['LANG']->getLL('mirror_list_url') . '</label></td>
1171 <td><input type="text" size="50" id="set_mirror_list_url" name="SET[mirrorListURL]" value="'.htmlspecialchars($this->MOD_SETTINGS['mirrorListURL']).'" /></td>
1172 </tr>
1173 </table>
1174 </fieldset>
1175 <br />
1176 <p>' . $GLOBALS['LANG']->getLL('mirror_select') . '<br /><br /></p>
1177 <fieldset><legend>' . $GLOBALS['LANG']->getLL('mirror_list') . '</legend>';
1178 if(!empty($this->MOD_SETTINGS['mirrorListURL'])) {
1179 if ($this->CMD['fetchMetaData']) { // fetches mirror/extension data from online rep.
1180 $content .= $this->fetchMetaData($this->CMD['fetchMetaData']);
1181 } else {
1182 $content .= '<a href="index.php?CMD[fetchMetaData]=mirrors">' . $GLOBALS['LANG']->getLL('mirror_list_reload') . '</a>';
1183 }
1184 }
1185 $content .= '<br />
1186 <table cellspacing="4" style="text-align:left; vertical-alignment:top;">
1187 <tr>
1188 <td>' . $GLOBALS['LANG']->getLL('mirror_use') . '</td>
1189 <td>' . $GLOBALS['LANG']->getLL('mirror_name') . '</td>
1190 <td>' . $GLOBALS['LANG']->getLL('mirror_url') . '</td>
1191 <td>' . $GLOBALS['LANG']->getLL('mirror_country') . '</td>
1192 <td>' . $GLOBALS['LANG']->getLL('mirror_sponsored_by') . '</td>
1193 </tr>
1194 ';
1195
1196 if (!strlen($this->MOD_SETTINGS['extMirrors'])) $this->fetchMetaData('mirrors');
1197 $extMirrors = unserialize($this->MOD_SETTINGS['extMirrors']);
1198 $extMirrors[''] = array('title'=>$GLOBALS['LANG']->getLL('mirror_use_random'));
1199 ksort($extMirrors);
1200 if(is_array($extMirrors)) {
1201 foreach($extMirrors as $k => $v) {
1202 if(isset($v['sponsor'])) {
1203 $sponsor = '<a href="'.htmlspecialchars($v['sponsor']['link']).'" target="_blank"><img src="'.$v['sponsor']['logo'].'" title="'.htmlspecialchars($v['sponsor']['name']).'" alt="'.htmlspecialchars($v['sponsor']['name']).'" /></a>';
1204 }
1205 $selected = ($this->MOD_SETTINGS['selectedMirror']==$k) ? 'checked="checked"' : '';
1206 $content.='<tr class="bgColor4">
1207 <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>';
1208 }
1209 }
1210 $content.= '
1211 </table>
1212 </fieldset>
1213 <fieldset>
1214 <br />
1215 <table border="0" cellpadding="2" cellspacing="2">
1216 <tr class="bgColor4">
1217 <td><label for="set_rep_url">' . $GLOBALS['LANG']->getLL('enter_repository_url') . '</label></td>
1218 <td><input type="text" size="50" id="set_rep_url" name="SET[rep_url]" value="'.htmlspecialchars($this->MOD_SETTINGS['rep_url']).'" /></td>
1219 </tr>
1220 </table>
1221
1222 ' . $GLOBALS['LANG']->getLL('repository_url_hint') . '<br />
1223 </fieldset>
1224 <br />
1225 <input type="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_tsfe.xml:update') . '" />
1226 </form>
1227 ';
1228
1229 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('repository_settings'), $content, 0, 1);
1230 }
1231
1232 /**
1233 * Allows to set the translation preferences and check the status
1234 *
1235 * @return void
1236 */
1237 function translationHandling() {
1238 global $LANG, $TYPO3_LOADED_EXT;
1239 $LANG->includeLLFile('EXT:setup/mod/locallang.xml');
1240
1241 //prepare docheader
1242 $docHeaderButtons = $this->getButtons();
1243 $markers = array(
1244 'CSH' => $docHeaderButtons['csh'],
1245 'FUNC_MENU' => $this->getFuncMenu(),
1246 );
1247
1248
1249 $incoming = t3lib_div::_POST('SET');
1250 if(isset($incoming['selectedLanguages']) && is_array($incoming['selectedLanguages'])) {
1251 t3lib_BEfunc::getModuleData($this->MOD_MENU, array('selectedLanguages' => serialize($incoming['selectedLanguages'])), $this->MCONF['name'], '', 'selectedLanguages');
1252 $this->MOD_SETTINGS['selectedLanguages'] = serialize($incoming['selectedLanguages']);
1253 }
1254
1255 $selectedLanguages = unserialize($this->MOD_SETTINGS['selectedLanguages']);
1256 if(count($selectedLanguages)==1 && empty($selectedLanguages[0])) $selectedLanguages = array();
1257 $theLanguages = t3lib_div::trimExplode('|',TYPO3_languages);
1258 foreach($theLanguages as $val) {
1259 if ($val!='default') {
1260 $localLabel = ' - ['.htmlspecialchars($GLOBALS['LOCAL_LANG']['default']['lang_'.$val]).']';
1261 $selected = (is_array($selectedLanguages) && in_array($val, $selectedLanguages)) ? ' selected="selected"' : '';
1262 $opt[$GLOBALS['LOCAL_LANG']['default']['lang_'.$val].'--'.$val]='
1263 <option value="'.$val.'"'.$selected.'>'.$LANG->getLL('lang_'.$val,1).$localLabel.'</option>';
1264 }
1265 }
1266 ksort($opt);
1267
1268 // Prepare the HTML output:
1269 $content.= '
1270 ' . t3lib_BEfunc::cshItem('_MOD_tools_em', 'translation', $GLOBALS['BACK_PATH'], '|<br />') . '
1271 <form action="index.php" method="post" name="translationform">
1272 <fieldset><legend>' . $GLOBALS['LANG']->getLL('translation_settings') . '</legend>
1273 <table border="0" cellpadding="2" cellspacing="2">
1274 <tr class="bgColor4">
1275 <td>' . $GLOBALS['LANG']->getLL('languages_to_fetch') . '</td>
1276 <td>
1277 <select name="SET[selectedLanguages][]" multiple="multiple" size="10">
1278 <option>&nbsp;</option>'.
1279 implode('',$opt).'
1280 </select>
1281 </td>
1282 </tr>
1283 </table>
1284 <br />
1285 <p>' . $GLOBALS['LANG']->getLL('translation_info') . '<br />
1286 <br />' . $GLOBALS['LANG']->getLL('translation_loaded_exts') . '</p>
1287 </fieldset>
1288 <br />
1289 <input type="submit" value="' . $GLOBALS['LANG']->getLL('translation_save_selection') . '" />
1290 <br />
1291 </form>';
1292
1293 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('translation_settings'), $content, 0, 1);
1294
1295 if(count($selectedLanguages)>0) {
1296 $mirrorURL = $this->getMirrorURL();
1297 $content = '<input type="button" value="' . $GLOBALS['LANG']->getLL('translation_check_status_button') .
1298 '" onclick="document.location.href=\'' . htmlspecialchars(t3lib_div::linkThisScript(array('l10n'=>'check'))) .
1299 '\'" />&nbsp;<input type="button" value="' . $GLOBALS['LANG']->getLL('translation_update_button') .
1300 '" onclick="document.location.href=\'' . htmlspecialchars(t3lib_div::linkThisScript(array('l10n'=>'update'))) .
1301 '\'" />';
1302
1303 // as this page loads dynamically, quit output buffering caused by ob_gzhandler
1304 t3lib_div::cleanOutputBuffers();
1305
1306 if(t3lib_div::_GET('l10n') == 'check') {
1307 $loadedExtensions = array_keys($TYPO3_LOADED_EXT);
1308 $loadedExtensions = array_diff($loadedExtensions,array('_CACHEFILE'));
1309
1310 // Override content output - we now do that ourselves:
1311 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('translation_status'), $content, 0, 1);
1312 // Setting up the buttons and markers for docheader
1313 $content = $this->doc->startPage('Extension Manager');
1314 $content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
1315 $contentParts=explode('###CONTENT###',$content);
1316
1317 echo $contentParts[0].$this->content;
1318
1319 $this->doPrintContent = FALSE;
1320 flush();
1321
1322 echo '
1323 <br />
1324 <br />
1325 <p id="progress-message">
1326 ' . $GLOBALS['LANG']->getLL('translation_check_status') . '
1327 </p>
1328 <br />
1329 <div style="width:100%; height:20px; border: 1px solid black;">
1330 <div id="progress-bar" style="float: left; width: 0%; height: 20px; background-color:green;">&nbsp;</div>
1331 <div id="transparent-bar" style="float: left; width: 100%; height: 20px; background-color:'.$this->doc->bgColor2.';">&nbsp;</div>
1332 </div>
1333 <br />
1334 <br /><p>' . $GLOBALS['LANG']->getLL('translation_table_check') . '</p><br />
1335 <table border="0" cellpadding="2" cellspacing="2">
1336 <tr class="bgColor2"><td>' . $GLOBALS['LANG']->getLL('translation_extension_key') . '</td>
1337 ';
1338
1339 foreach($selectedLanguages as $lang) {
1340 echo ('<td>'.$LANG->getLL('lang_'.$lang,1).'</td>');
1341 }
1342 echo ('</tr>');
1343
1344 $counter = 1;
1345 foreach($loadedExtensions as $extKey) {
1346
1347 $percentDone = intval (($counter / count($loadedExtensions)) * 100);
1348 echo ('
1349 <script type="text/javascript">
1350 document.getElementById("progress-bar").style.width = "'.$percentDone.'%";
1351 document.getElementById("transparent-bar").style.width = "'.(100-$percentDone).'%";
1352 document.getElementById("progress-message").firstChild.data="' .
1353 sprintf($GLOBALS['LANG']->getLL('translation_checking_extension'), $extKey) . '";
1354 </script>
1355 ');
1356
1357 flush();
1358 $translationStatusArr = $this->terConnection->fetchTranslationStatus($extKey,$mirrorURL);
1359
1360 echo ('<tr class="bgColor4"><td>'.$extKey.'</td>');
1361 foreach($selectedLanguages as $lang) {
1362 // remote unknown -> no l10n available
1363 if(!isset($translationStatusArr[$lang])) {
1364 echo ('<td title="' . $GLOBALS['LANG']->getLL('translation_no_translation') . '">' .
1365 $GLOBALS['LANG']->getLL('translation_n_a') . '</td>');
1366 continue;
1367 }
1368 // determine local md5 from zip
1369 if(is_file(PATH_site.'typo3temp/'.$extKey.'-l10n-'.$lang.'.zip')) {
1370 $localmd5 = md5_file(PATH_site.'typo3temp/'.$extKey.'-l10n-'.$lang.'.zip');
1371 } else {
1372 echo ('<td title="' . $GLOBALS['LANG']->getLL('translation_not_installed') .
1373 '" style="background-color:#ff0">' . $GLOBALS['LANG']->getLL('translation_status_unknown') .
1374 '</td>');
1375 continue;
1376 }
1377 // local!=remote -> needs update
1378 if($localmd5 != $translationStatusArr[$lang]['md5']) {
1379 echo ('<td title="' . $GLOBALS['LANG']->getLL('translation_needs_update') .
1380 '" style="background-color:#ff0">' . $GLOBALS['LANG']->getLL('translation_status_update') .
1381 '</td>');
1382 continue;
1383 }
1384 echo ('<td title="' . $GLOBALS['LANG']->getLL('translation_is_ok') .
1385 '" style="background-color:#69a550">' . $GLOBALS['LANG']->getLL('translation_status_ok') .
1386 '</td>');
1387 }
1388 echo ('</tr>');
1389
1390 $counter ++;
1391 }
1392 echo '</table>
1393 <script type="text/javascript">
1394 document.getElementById("progress-message").firstChild.data="' .
1395 $GLOBALS['LANG']->getLL('translation_check_done') . '";
1396 </script>
1397 ';
1398 echo $contentParts[1] . $this->doc->endPage();
1399 exit;
1400
1401 } elseif(t3lib_div::_GET('l10n') == 'update') {
1402 $loadedExtensions = array_keys($TYPO3_LOADED_EXT);
1403 $loadedExtensions = array_diff($loadedExtensions,array('_CACHEFILE'));
1404
1405 // Override content output - we now do that ourselves:
1406 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('translation_status'), $content, 0, 1);
1407 // Setting up the buttons and markers for docheader
1408 $content = $this->doc->startPage('Extension Manager');
1409 $content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
1410 $contentParts=explode('###CONTENT###',$content);
1411
1412 echo $contentParts[0].$this->content;
1413
1414 $this->doPrintContent = FALSE;
1415 flush();
1416
1417 echo ('
1418 <br />
1419 <br />
1420 <p id="progress-message">
1421 ' . $GLOBALS['LANG']->getLL('translation_update_status') . '
1422 </p>
1423 <br />
1424 <div style="width:100%; height:20px; border: 1px solid black;">
1425 <div id="progress-bar" style="float: left; width: 0%; height: 20px; background-color:green;">&nbsp;</div>
1426 <div id="transparent-bar" style="float: left; width: 100%; height: 20px; background-color:'.$this->doc->bgColor2.';">&nbsp;</div>
1427 </div>
1428 <br />
1429 <br /><p>' . $GLOBALS['LANG']->getLL('translation_table_update') . '<br />
1430 <em>' . $GLOBALS['LANG']->getLL('translation_full_check_update') . '</em></p><br />
1431 <table border="0" cellpadding="2" cellspacing="2">
1432 <tr class="bgColor2"><td>' . $GLOBALS['LANG']->getLL('translation_extension_key') . '</td>
1433 ');
1434
1435 foreach($selectedLanguages as $lang) {
1436 echo '<td>'.$LANG->getLL('lang_'.$lang,1).'</td>';
1437 }
1438 echo '</tr>';
1439
1440 $counter = 1;
1441 foreach($loadedExtensions as $extKey) {
1442 $percentDone = intval (($counter / count($loadedExtensions)) * 100);
1443 echo ('
1444 <script type="text/javascript">
1445 document.getElementById("progress-bar").style.width = "'.$percentDone.'%";
1446 document.getElementById("transparent-bar").style.width = "'.(100-$percentDone).'%";
1447 document.getElementById("progress-message").firstChild.data="' .
1448 sprintf($GLOBALS['LANG']->getLL('translation_updating_extension'), $extKey) . '";
1449 </script>
1450 ');
1451
1452 flush();
1453 $translationStatusArr = $this->terConnection->fetchTranslationStatus($extKey,$mirrorURL);
1454
1455 echo ('<tr class="bgColor4"><td>'.$extKey.'</td>');
1456 if(is_array($translationStatusArr)) {
1457 foreach($selectedLanguages as $lang) {
1458 // remote unknown -> no l10n available
1459 if(!isset($translationStatusArr[$lang])) {
1460 echo ('<td title="' . $GLOBALS['LANG']->getLL('translation_no_translation') .
1461 '">' . $GLOBALS['LANG']->getLL('translation_n_a') . '</td>');
1462 continue;
1463 }
1464 // determine local md5 from zip
1465 if(is_file(PATH_site.'typo3temp/'.$extKey.'-l10n-'.$lang.'.zip')) {
1466 $localmd5 = md5_file(PATH_site.'typo3temp/'.$extKey.'-l10n-'.$lang.'.zip');
1467 } else {
1468 $localmd5 = 'zzz';
1469 }
1470 // local!=remote or not installed -> needs update
1471 if($localmd5 != $translationStatusArr[$lang]['md5']) {
1472 $ret = $this->updateTranslation($extKey, $lang, $mirrorURL);
1473 if($ret === true) {
1474 echo ('<td title="' . $GLOBALS['LANG']->getLL('translation_has_been_updated') .
1475 '" style="background-color:#69a550">' . $GLOBALS['LANG']->getLL('translation_status_update') .
1476 '</td>');
1477 } else {
1478 echo ('<td title="' . htmlspecialchars($ret) .
1479 '" style="background-color:#cb3352">' . $GLOBALS['LANG']->getLL('translation_status_error') .
1480 '</td>');
1481 }
1482 continue;
1483 }
1484 echo ('<td title="' . $GLOBALS['LANG']->getLL('translation_is_ok') .
1485 '" style="background-color:#69a550">' . $GLOBALS['LANG']->getLL('translation_status_ok') . '</td>');
1486 }
1487 } else {
1488 echo ('<td colspan="' . count($selectedLanguages) .
1489 '" title="' . $GLOBALS['LANG']->getLL('translation_problems') .
1490 '">' . $GLOBALS['LANG']->getLL('translation_status_could_not_fetch') . '</td>');
1491 }
1492 echo ('</tr>');
1493 $counter++;
1494 }
1495 echo '</table>
1496 <script type="text/javascript">
1497 document.getElementById("progress-message").firstChild.data="' .
1498 $GLOBALS['LANG']->getLL('translation_update_done') . '";
1499 </script>
1500 ';
1501 echo $contentParts[1] . $this->doc->endPage();
1502 exit;
1503 }
1504
1505 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('translation_status'), $content, 0, 1);
1506 }
1507 }
1508
1509 /**
1510 * Install translations for all selected languages for an extension
1511 *
1512 * @param string $extKey The extension key to install the translations for
1513 * @param string $lang Language code of translation to fetch
1514 * @param string $mirrorURL Mirror URL to fetch data from
1515 * @return mixed true on success, error string on fauilure
1516 */
1517 function updateTranslation($extKey, $lang, $mirrorURL) {
1518 $l10n = $this->terConnection->fetchTranslation($extKey, $lang, $mirrorURL);
1519 if(is_array($l10n)) {
1520 $file = PATH_site.'typo3temp/'.$extKey.'-l10n-'.$lang.'.zip';
1521 $path = 'l10n/'.$lang.'/';
1522 if(!is_dir(PATH_typo3conf.$path)) t3lib_div::mkdir_deep(PATH_typo3conf,$path);
1523 t3lib_div::writeFile($file, $l10n[0]);
1524 if($this->unzip($file, PATH_typo3conf.$path)) {
1525 return true;
1526 } else {
1527 return $GLOBALS['LANG']->getLL('translation_unpacking_failed');
1528 }
1529 } else {
1530 return $l10n;
1531 }
1532 }
1533
1534 /**
1535 * Install translations for all selected languages for an extension
1536 *
1537 * @param string $extKey The extension key to install the translations for
1538 * @param string $mirrorURL Mirror URL to fetch data from
1539 * @return mixed true on success, error string on fauilure
1540 */
1541 function installTranslationsForExtension($extKey, $mirrorURL) {
1542 $selectedLanguages = unserialize($this->MOD_SETTINGS['selectedLanguages']);
1543 if(!is_array($selectedLanguages)) $selectedLanguages = array();
1544 foreach($selectedLanguages as $lang) {
1545 $l10n = $this->terConnection->fetchTranslation($extKey, $lang, $mirrorURL);
1546 if(is_array($l10n)) {
1547 $file = PATH_typo3conf.'l10n/'.$extKey.'-l10n-'.$lang.'.zip';
1548 $path = 'l10n/'.$lang.'/'.$extKey;
1549 t3lib_div::writeFile($file, $l10n[0]);
1550 if(!is_dir(PATH_typo3conf.$path)) t3lib_div::mkdir_deep(PATH_typo3conf,$path);
1551 if($this->unzip($file, PATH_typo3conf.$path)) {
1552 return true;
1553 } else {
1554 return $GLOBALS['LANG']->getLL('translation_unpacking_failed');
1555 }
1556 } else {
1557 return $l10n;
1558 }
1559 }
1560 }
1561
1562 /**
1563 * Unzips a zip file in the given path.
1564 *
1565 * Uses unzip binary if available, otherwise a pure PHP unzip is used.
1566 *
1567 * @param string $file Full path to zip file
1568 * @param string $path Path to change to before extracting
1569 * @return boolean True on success, false in failure
1570 */
1571 function unzip($file, $path) {
1572 if(strlen($GLOBALS['TYPO3_CONF_VARS']['BE']['unzip_path'])) {
1573 chdir($path);
1574 $cmd = $GLOBALS['TYPO3_CONF_VARS']['BE']['unzip_path'].' -o '.escapeshellarg($file);
1575 exec($cmd, $list, $ret);
1576 return ($ret === 0);
1577 } else {
1578 // we use a pure PHP unzip
1579 $unzip = new em_unzip($file);
1580 $ret = $unzip->extract(array('add_path'=>$path));
1581 return (is_array($ret));
1582 }
1583 }
1584
1585
1586
1587 /*********************************
1588 *
1589 * Command Applications (triggered by GET var)
1590 *
1591 *********************************/
1592
1593 /**
1594 * Returns detailed info about an extension in the online repository
1595 *
1596 * @param string Extension repository uid + optional "private key": [uid]-[key].
1597 * @param [type] $version: ...
1598 * @return void
1599 */
1600 function importExtInfo($extKey, $version='') {
1601
1602 $content = '<form action="index.php" method="post" name="pageform">';
1603
1604 // Fetch remote data:
1605 $this->xmlhandler->searchExtensionsXMLExact($extKey, '', '', true, true);
1606 list($fetchData,) = $this->prepareImportExtList(true);
1607
1608 $versions = array_keys($fetchData[$extKey]['versions']);
1609 $version = ($version == '') ? end($versions) : $version;
1610
1611 $opt = array();
1612 foreach(array_keys($fetchData[$extKey]['versions']) as $ver) {
1613 $opt[]='<option value="'.$ver.'"'.(($version == $ver) ? ' selected="selected"' : '').'>'.$ver.'</option>';
1614 }
1615
1616 // "Select version" box:
1617 $onClick = 'window.location.href=\'index.php?CMD[importExtInfo]='.$extKey.'&CMD[extVersion]=\'+document.pageform.extVersion.options[document.pageform.extVersion.selectedIndex].value; return false;';
1618 $select = '<select name="extVersion">' . implode('', $opt) .
1619 '</select> <input type="submit" value="' . $GLOBALS['LANG']->getLL('ext_load_details_button') .
1620 '" onclick="' . htmlspecialchars($onClick) . '" />';
1621
1622 if ($this->importAtAll()) {
1623 // Check for write-protected extension
1624 list($inst_list,) = $this->getInstalledExtensions();
1625 if ($inst_list[$extKey]['EM_CONF']['state'] != 'excludeFromUpdates') {
1626 $onClick = '
1627 window.location.href=\'index.php?CMD[importExt]='.$extKey.'\'
1628 +\'&CMD[extVersion]=\'+document.pageform.extVersion.options[document.pageform.extVersion.selectedIndex].value
1629 +\'&CMD[loc]=\'+document.pageform.loc.options[document.pageform.loc.selectedIndex].value;
1630 return false;';
1631 $select .= ' ' . $GLOBALS['LANG']->getLL('ext_or') . '<br /><br />
1632 <input type="submit" value="' . $GLOBALS['LANG']->getLL('ext_import_update_button') .
1633 '" onclick="' . htmlspecialchars($onClick) . '" /> ' . $GLOBALS['LANG']->getLL('ext_import_update_to') . '
1634 <select name="loc">'.
1635 ($this->importAsType('G', $fetchData['emconf_lockType']) ?
1636 '<option value="G">' . $GLOBALS['LANG']->getLL('ext_import_global') . ' ' . $this->typePaths['G'] . $extKey . '/' .
1637 (@is_dir(PATH_site . $this->typePaths['G'] . $extKey) ?
1638 ' ' . $GLOBALS['LANG']->getLL('ext_import_overwrite') :
1639 ' ' . $GLOBALS['LANG']->getLL('ext_import_folder_empty')
1640 ) . '</option>' : ''
1641 ) .
1642 ($this->importAsType('L', $fetchData['emconf_lockType']) ?
1643 '<option value="L">' . $GLOBALS['LANG']->getLL('ext_import_local') . ' ' . $this->typePaths['L'] . $extKey . '/' .
1644 (@is_dir(PATH_site . $this->typePaths['L'] . $extKey) ?
1645 ' ' . $GLOBALS['LANG']->getLL('ext_import_overwrite') :
1646 ' ' . $GLOBALS['LANG']->getLL('ext_import_folder_empty')
1647 ) . '</option>' : ''
1648 ) .
1649 ($this->importAsType('S', $fetchData['emconf_lockType']) ?
1650 '<option value="S">' . $GLOBALS['LANG']->getLL('ext_import_system') . ' ' . $this->typePaths['S'] . $extKey . '/' .
1651 (@is_dir(PATH_site . $this->typePaths['S'] . $extKey) ?
1652 ' ' . $GLOBALS['LANG']->getLL('ext_import_overwrite') :
1653 ' ' . $GLOBALS['LANG']->getLL('ext_import_folder_empty')
1654 ) . '</option>' : ''
1655 ) .
1656 '</select>
1657 </form>';
1658 } else {
1659 $select .= '<br /><br />' . $GLOBALS['LANG']->getLL('ext_import_excluded_from_updates');
1660 }
1661 } else {
1662 $select .= '<br /><br />' . $this->noImportMsg();
1663 }
1664 $content.= $select;
1665 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('ext_import_select_command'), $content, 0, 1);
1666
1667 // Details:
1668 $eInfo = $fetchData[$extKey]['versions'][$version];
1669 $content='<strong>'.$fetchData[$extKey]['_ICON'].' &nbsp;'.$eInfo['EM_CONF']['title'].' ('.$extKey.', '.$version.')</strong><br /><br />';
1670 $content.=$this->extInformationArray($extKey,$eInfo,1);
1671 $this->content.=$this->doc->spacer(10);
1672 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('ext_import_remote_ext_details'), $content, 0, 1);
1673 }
1674
1675 /**
1676 * Fetches metadata and stores it to the corresponding place. This includes the mirror list,
1677 * extension XML files.
1678 *
1679 * @param string Type of data to fetch: (mirrors)
1680 * @param boolean If true the method doesn't produce any output
1681 * @return void
1682 */
1683 function fetchMetaData($metaType) {
1684 global $TYPO3_CONF_VARS;
1685
1686 switch($metaType) {
1687 case 'mirrors':
1688 $mfile = t3lib_div::tempnam('mirrors');
1689 $mirrorsFile = t3lib_div::getURL($this->MOD_SETTINGS['mirrorListURL'], 0, array(TYPO3_user_agent));
1690 if($mirrorsFile===false) {
1691 t3lib_div::unlink_tempfile($mfile);
1692 $content = '<p>' .
1693 sprintf($GLOBALS['LANG']->getLL('ext_import_list_not_updated'),
1694 $this->MOD_SETTINGS['mirrorListURL']
1695 ) . ' ' .
1696 $GLOBALS['LANG']->getLL('translation_problems') . '</p>';
1697 } else {
1698 t3lib_div::writeFile($mfile, $mirrorsFile);
1699 $mirrors = implode('',gzfile($mfile));
1700 t3lib_div::unlink_tempfile($mfile);
1701
1702 $mirrors = $this->xmlhandler->parseMirrorsXML($mirrors);
1703 if(is_array($mirrors) && count($mirrors)) {
1704 t3lib_BEfunc::getModuleData($this->MOD_MENU, array('extMirrors' => serialize($mirrors)), $this->MCONF['name'], '', 'extMirrors');
1705 $this->MOD_SETTINGS['extMirrors'] = serialize($mirrors);
1706 $content = '<p>' .
1707 sprintf($GLOBALS['LANG']->getLL('ext_import_list_updated'),
1708 count($mirrors)
1709 ) . '</p>';
1710 }
1711 else {
1712 $content = '<p>' . $mirrors . '<br />' . $GLOBALS['LANG']->getLL('ext_import_list_empty') . '</p>';
1713 }
1714 }
1715 break;
1716 case 'extensions':
1717 $this->fetchMetaData('mirrors'); // if we fetch the extensions anyway, we can as well keep this up-to-date
1718
1719 $mirror = $this->getMirrorURL();
1720 $extfile = $mirror.'extensions.xml.gz';
1721 $extmd5 = t3lib_div::getURL($mirror.'extensions.md5', 0, array(TYPO3_user_agent));
1722 if (is_file(PATH_site.'typo3temp/extensions.xml.gz')) {
1723 $localmd5 = md5_file(PATH_site.'typo3temp/extensions.xml.gz');
1724 }
1725
1726 // count cached extensions. If cache is empty re-fill it
1727 $cacheCount = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('extkey', 'cache_extensions');
1728
1729 if($extmd5 === false) {
1730 $content .= '<p>' .
1731 sprintf($GLOBALS['LANG']->getLL('ext_import_md5_not_updated'),
1732 $mirror . 'extensions.md5'
1733 ) .
1734 $GLOBALS['LANG']->getLL('translation_problems') . '</p>';
1735 } elseif($extmd5 == $localmd5 && $cacheCount) {
1736 $flashMessage = t3lib_div::makeInstance(
1737 't3lib_FlashMessage',
1738 $GLOBALS['LANG']->getLL('ext_import_list_unchanged'),
1739 $GLOBALS['LANG']->getLL('ext_import_list_unchanged_header'),
1740 t3lib_FlashMessage::INFO
1741 );
1742 $content .= $flashMessage->render();
1743 } else {
1744 $extXML = t3lib_div::getURL($extfile, 0, array(TYPO3_user_agent));
1745 if($extXML === false) {
1746 $content .= '<p>' .
1747 sprintf($GLOBALS['LANG']->getLL('ext_import_list_unchanged'),
1748 $extfile
1749 ) . ' ' .
1750 $GLOBALS['LANG']->getLL('translation_problems') . '</p>';
1751 } else {
1752 t3lib_div::writeFile(PATH_site.'typo3temp/extensions.xml.gz', $extXML);
1753 $content .= $this->xmlhandler->parseExtensionsXML(PATH_site.'typo3temp/extensions.xml.gz');
1754 }
1755 }
1756 break;
1757 }
1758
1759 return $content;
1760 }
1761
1762 /**
1763 * Returns the base URL for the slected or a random mirror.
1764 *
1765 * @return string The URL for the selected or a random mirror
1766 */
1767 function getMirrorURL() {
1768 if(strlen($this->MOD_SETTINGS['rep_url'])) return $this->MOD_SETTINGS['rep_url'];
1769
1770 $mirrors = unserialize($this->MOD_SETTINGS['extMirrors']);
1771 if(!is_array($mirrors)) {
1772 $this->fetchMetaData('mirrors');
1773 $mirrors = unserialize($this->MOD_SETTINGS['extMirrors']);
1774 if(!is_array($mirrors)) return false;
1775 }
1776 if($this->MOD_SETTINGS['selectedMirror']=='') {
1777 $rand = array_rand($mirrors);
1778 $url = 'http://'.$mirrors[$rand]['host'].$mirrors[$rand]['path'];
1779 }
1780 else {
1781 $url = 'http://'.$mirrors[$this->MOD_SETTINGS['selectedMirror']]['host'].$mirrors[$this->MOD_SETTINGS['selectedMirror']]['path'];
1782 }
1783
1784 return $url;
1785 }
1786
1787
1788
1789 /**
1790 * Installs (activates) an extension
1791 *
1792 * For $mode use the three constants EM_INSTALL_VERSION_MIN, EM_INSTALL_VERSION_MAX, EM_INSTALL_VERSION_STRICT
1793 *
1794 * If an extension is loaded or imported already and the version requirement is matched, it will not be
1795 * fetched from the repository. This means, if you use EM_INSTALL_VERSION_MIN, you will not always get the latest
1796 * version of an extension!
1797 *
1798 * @param string $extKey The extension key to install
1799 * @param string $version A version number that should be installed
1800 * @param int $mode If a version is requested, this determines if it is the min, max or strict version requested
1801 * @return [type] ...
1802 * @todo Make the method able to handle needed interaction somehow (unmatched dependencies)
1803 */
1804 function installExtension($extKey, $version=null, $mode=EM_INSTALL_VERSION_MIN) {
1805 list($inst_list,) = $this->getInstalledExtensions();
1806
1807 // check if it is already installed and loaded with sufficient version
1808 if(isset($inst_list[$extKey])) {
1809 $currentVersion = $inst_list[$extKey]['EM_CONF']['version'];
1810
1811 if(t3lib_extMgm::isLoaded($extKey)) {
1812 if($version===null) {
1813 return array(true, $GLOBALS['LANG']->getLL('ext_import_ext_already_installed_loaded'));
1814 } else {
1815 switch($mode) {
1816 case EM_INSTALL_VERSION_STRICT:
1817 if ($currentVersion == $version) {
1818 return array(true, $GLOBALS['LANG']->getLL('ext_import_ext_already_installed_loaded'));
1819 }
1820 break;
1821 case EM_INSTALL_VERSION_MIN:
1822 if (version_compare($currentVersion, $version, '>=')) {
1823 return array(true, $GLOBALS['LANG']->getLL('ext_import_ext_already_installed_loaded'));
1824 }
1825 break;
1826 case EM_INSTALL_VERSION_MAX:
1827 if (version_compare($currentVersion, $version, '<=')) {
1828 return array(true, $GLOBALS['LANG']->getLL('ext_import_ext_already_installed_loaded'));
1829 }
1830 break;
1831 }
1832 }
1833 } else {
1834 if (!t3lib_extMgm::isLocalconfWritable()) {
1835 return array(false, $GLOBALS['LANG']->getLL('ext_import_p_localconf'));
1836 }
1837 $newExtList = -1;
1838 switch($mode) {
1839 case EM_INSTALL_VERSION_STRICT:
1840 if ($currentVersion == $version) {
1841 $newExtList = $this->addExtToList($extKey, $inst_list);
1842 }
1843 break;
1844 case EM_INSTALL_VERSION_MIN:
1845 if (version_compare($currentVersion, $version, '>=')) {
1846 $newExtList = $this->addExtToList($extKey, $inst_list);
1847 }
1848 break;
1849 case EM_INSTALL_VERSION_MAX:
1850 if (version_compare($currentVersion, $version, '<=')) {
1851 $newExtList = $this->addExtToList($extKey, $inst_list);
1852 }
1853 break;
1854 }
1855 if ($newExtList!=-1) {
1856 $this->writeNewExtensionList($newExtList);
1857 $this->refreshGlobalExtList();
1858 $this->forceDBupdates($extKey, $inst_list[$extKey]);
1859 return array(true, $GLOBALS['LANG']->getLL('ext_import_ext_loaded'));
1860 }
1861 }
1862 }
1863
1864 // at this point we know we need to import (a matching version of) the extension from TER2
1865
1866 // see if we have an extension list at all
1867 if (!$this->xmlhandler->countExtensions()) {
1868 $this->fetchMetaData('extensions');
1869 }
1870 $this->xmlhandler->searchExtensionsXMLExact($extKey, '', '', true);
1871
1872 // check if extension can be fetched
1873 if(isset($this->xmlhandler->extensionsXML[$extKey])) {
1874 $versions = array_keys($this->xmlhandler->extensionsXML[$extKey]['versions']);
1875 $latestVersion = end($versions);
1876 switch($mode) {
1877 case EM_INSTALL_VERSION_STRICT:
1878 if(!isset($this->xmlhandler->extensionsXML[$extKey]['versions'][$version])) {
1879 return array(false, $GLOBALS['LANG']->getLL('ext_import_ext_n_a'));
1880 }
1881 break;
1882 case EM_INSTALL_VERSION_MIN:
1883 if (version_compare($latestVersion, $version, '>=')) {
1884 $version = $latestVersion;
1885 } else {
1886 return array(false, $GLOBALS['LANG']->getLL('ext_import_ext_n_a'));
1887 }
1888 break;
1889 case EM_INSTALL_VERSION_MAX:
1890 while (($v = array_pop($versions)) && version_compare($v, $version, '>=')) {
1891 // Loop until a version is found
1892 }
1893
1894 if ($v !== null && version_compare($v, $version, '<=')) {
1895 $version = $v;
1896 } else {
1897 return array(false, $GLOBALS['LANG']->getLL('ext_import_ext_n_a'));
1898 }
1899 break;
1900 }
1901 $this->importExtFromRep($extKey, $version, 'L');
1902 $newExtList = $this->addExtToList($extKey, $inst_list);
1903 if ($newExtList!=-1) {
1904 $this->writeNewExtensionList($newExtList);
1905 $this->refreshGlobalExtList();
1906 $this->forceDBupdates($extKey, $inst_list[$extKey]);
1907 $this->installTranslationsForExtension($extKey, $this->getMirrorURL());
1908 return array(true, $GLOBALS['LANG']->getLL('ext_import_ext_imported'));
1909 } else {
1910 return array(false, $GLOBALS['LANG']->getLL('ext_import_ext_not_loaded'));
1911 }
1912 } else {
1913 return array(false, $GLOBALS['LANG']->getLL('ext_import_ext_n_a_rep'));
1914 }
1915 }
1916
1917 function refreshGlobalExtList() {
1918 global $TYPO3_LOADED_EXT;
1919
1920 $TYPO3_LOADED_EXT = t3lib_extMgm::typo3_loadExtensions();
1921 if ($TYPO3_LOADED_EXT['_CACHEFILE']) {
1922 require(PATH_typo3conf.$TYPO3_LOADED_EXT['_CACHEFILE'].'_ext_localconf.php');
1923 }
1924 return;
1925
1926 $GLOBALS['TYPO3_LOADED_EXT'] = t3lib_extMgm::typo3_loadExtensions();
1927 if ($TYPO3_LOADED_EXT['_CACHEFILE']) {
1928 require(PATH_typo3conf.$TYPO3_LOADED_EXT['_CACHEFILE'].'_ext_localconf.php');
1929 } else {
1930 $temp_TYPO3_LOADED_EXT = $TYPO3_LOADED_EXT;
1931 reset($temp_TYPO3_LOADED_EXT);
1932 while(list($_EXTKEY,$temp_lEDat)=each($temp_TYPO3_LOADED_EXT)) {
1933 if (is_array($temp_lEDat) && $temp_lEDat['ext_localconf.php']) {
1934 $_EXTCONF = $TYPO3_CONF_VARS['EXT']['extConf'][$_EXTKEY];
1935 require($temp_lEDat['ext_localconf.php']);
1936 }
1937 }
1938 }
1939 }
1940
1941
1942 /**
1943 * Imports an extensions from the online repository
1944 * NOTICE: in version 4.0 this changed from "importExtFromRep_old($extRepUid,$loc,$uploadFlag=0,$directInput='',$recentTranslations=0,$incManual=0,$dontDelete=0)"
1945 *
1946 * @param string Extension key
1947 * @param string Version
1948 * @param string Install scope: "L" or "G" or "S"
1949 * @param boolean If true, extension is uploaded as file
1950 * @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.
1951 * @param array Direct input array (like from kickstarter)
1952 * @return string Return false on success, returns error message if error.
1953 */
1954 function importExtFromRep($extKey,$version,$loc,$uploadFlag=0,$dontDelete=0,$directInput='') {
1955
1956 $uploadSucceed = false;
1957 $uploadedTempFile = '';
1958 if (is_array($directInput)) {
1959 $fetchData = array($directInput,'');
1960 $loc = ($loc==='G'||$loc==='S') ? $loc : 'L';
1961 } elseif ($uploadFlag) {
1962 if (($uploadedTempFile = $this->CMD['alreadyUploaded']) || $_FILES['upload_ext_file']['tmp_name']) {
1963
1964 // Read uploaded file:
1965 if (!$uploadedTempFile) {
1966 if (!is_uploaded_file($_FILES['upload_ext_file']['tmp_name'])) {
1967 t3lib_div::sysLog('Possible file upload attack: '.$_FILES['upload_ext_file']['tmp_name'], 'Extension Manager', 3);
1968
1969 return $GLOBALS['LANG']->getLL('ext_import_file_not_uploaded');
1970 }
1971
1972 $uploadedTempFile = t3lib_div::upload_to_tempfile($_FILES['upload_ext_file']['tmp_name']);
1973 }
1974 $fileContent = t3lib_div::getUrl($uploadedTempFile);
1975
1976 if (!$fileContent) return $GLOBALS['LANG']->getLL('ext_import_file_empty');
1977
1978 // Decode file data:
1979 $fetchData = $this->terConnection->decodeExchangeData($fileContent);
1980
1981 if (is_array($fetchData)) {
1982 $extKey = $fetchData[0]['extKey'];
1983 if ($extKey) {
1984 if (!$this->CMD['uploadOverwrite']) {
1985 $loc = ($loc==='G'||$loc==='S') ? $loc : 'L';
1986 $comingExtPath = PATH_site.$this->typePaths[$loc].$extKey.'/';
1987 if (@is_dir($comingExtPath)) {
1988 $flashMessage = t3lib_div::makeInstance(
1989 't3lib_FlashMessage',
1990 sprintf($GLOBALS['LANG']->getLL('ext_import_ext_present_no_overwrite'), $comingExtPath) .
1991 '<br />' . $GLOBALS['LANG']->getLL('ext_import_ext_present_nothing_done'),
1992 '',
1993 t3lib_FlashMessage::ERROR
1994 );
1995 return $flashMessage->render();
1996 } // ... else go on, install...
1997 } // ... else go on, install...
1998 } else return $GLOBALS['LANG']->getLL('ext_import_no_key');
1999 } else return sprintf($GLOBALS['LANG']->getLL('ext_import_wrong_file_format'), $fetchData);
2000 } else return $GLOBALS['LANG']->getLL('ext_import_no_file');
2001 } else {
2002 $this->xmlhandler->searchExtensionsXMLExact($extKey, '', '', true, true);
2003
2004 // Fetch extension from TER:
2005 if(!strlen($version)) {
2006 $versions = array_keys($this->xmlhandler->extensionsXML[$extKey]['versions']);
2007 $version = end($versions);
2008 }
2009 $fetchData = $this->terConnection->fetchExtension($extKey, $version, $this->xmlhandler->extensionsXML[$extKey]['versions'][$version]['t3xfilemd5'], $this->getMirrorURL());
2010 }
2011
2012 // At this point the extension data should be present; so we want to write it to disc:
2013 if ($this->importAsType($loc)) {
2014 if (is_array($fetchData)) { // There was some data successfully transferred
2015 if ($fetchData[0]['extKey'] && is_array($fetchData[0]['FILES'])) {
2016 $extKey = $fetchData[0]['extKey'];
2017 if(!isset($fetchData[0]['EM_CONF']['constraints'])) $fetchData[0]['EM_CONF']['constraints'] = $this->xmlhandler->extensionsXML[$extKey]['versions'][$version]['dependencies'];
2018 $EM_CONF = $this->fixEMCONF($fetchData[0]['EM_CONF']);
2019 if (!$EM_CONF['lockType'] || !strcmp($EM_CONF['lockType'],$loc)) {
2020 // check dependencies, act accordingly if ext is loaded
2021 list($instExtInfo,)=$this->getInstalledExtensions();
2022 $depStatus = $this->checkDependencies($extKey, $EM_CONF, $instExtInfo);
2023 if(t3lib_extMgm::isLoaded($extKey) && !$depStatus['returnCode']) {
2024 $this->content .= $depStatus['html'];
2025 if ($uploadedTempFile) {
2026 $this->content .= '<input type="hidden" name="CMD[alreadyUploaded]" value="'.$uploadedTempFile.'" />';
2027 }
2028 } else {
2029 $res = $this->clearAndMakeExtensionDir($fetchData[0],$loc,$dontDelete);
2030 if (is_array($res)) {
2031 $extDirPath = trim($res[0]);
2032 if ($extDirPath && @is_dir($extDirPath) && substr($extDirPath,-1)=='/') {
2033
2034 $emConfFile = $this->construct_ext_emconf_file($extKey,$EM_CONF);
2035 $dirs = $this->extractDirsFromFileList(array_keys($fetchData[0]['FILES']));
2036
2037 $res = $this->createDirsInPath($dirs,$extDirPath);
2038 if (!$res) {
2039 $writeFiles = $fetchData[0]['FILES'];
2040 $writeFiles['ext_emconf.php']['content'] = $emConfFile;
2041 $writeFiles['ext_emconf.php']['content_md5'] = md5($emConfFile);
2042
2043 // Write files:
2044 foreach($writeFiles as $theFile => $fileData) {
2045 t3lib_div::writeFile($extDirPath.$theFile,$fileData['content']);
2046 if (!@is_file($extDirPath.$theFile)) {
2047 $content .= sprintf($GLOBALS['LANG']->getLL('ext_import_file_not_created'),
2048 $extDirPath . $theFile) . '<br />';
2049 } elseif (md5(t3lib_div::getUrl($extDirPath.$theFile)) != $fileData['content_md5']) {
2050 $content .= sprintf($GLOBALS['LANG']->getLL('ext_import_file_corrupted'),
2051 $extDirPath . $theFile) . '<br />';
2052 }
2053 }
2054
2055 // No content, no errors. Create success output here:
2056 if (!$content) {
2057 $messageContent = sprintf($GLOBALS['LANG']->getLL('ext_import_success_folder'), $extDirPath) . '<br />';
2058
2059 $uploadSucceed = true;
2060
2061 // Fix TYPO3_MOD_PATH for backend modules in extension:
2062 $modules = t3lib_div::trimExplode(',', $EM_CONF['module'], 1);
2063 if (count($modules)) {
2064 foreach($modules as $mD) {
2065 $confFileName = $extDirPath . $mD . '/conf.php';
2066 if (@is_file($confFileName)) {
2067 $messageContent .= $this->writeTYPO3_MOD_PATH($confFileName, $loc, $extKey . '/' . $mD . '/') . '<br />';
2068 } else {
2069 $messageContent .= sprintf($GLOBALS['LANG']->getLL('ext_import_no_conf_file'),
2070 $confFileName) . '<br />';
2071 }
2072 }
2073 }
2074 // 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.
2075 // But this order of the code works.... (using the empty Array with type, EMCONF and files hereunder).
2076
2077 // Writing to ext_emconf.php:
2078 $sEMD5A = $this->serverExtensionMD5Array($extKey,array('type' => $loc, 'EM_CONF' => array(), 'files' => array()));
2079 $EM_CONF['_md5_values_when_last_written'] = serialize($sEMD5A);
2080 $emConfFile = $this->construct_ext_emconf_file($extKey, $EM_CONF);
2081 t3lib_div::writeFile($extDirPath . 'ext_emconf.php', $emConfFile);
2082
2083 $messageContent .= 'ext_emconf.php: ' . $extDirPath . 'ext_emconf.php<br />';
2084 $messageContent .= $GLOBALS['LANG']->getLL('ext_import_ext_type') . ' ';
2085 $messageContent .= $this->typeLabels[$loc] . '<br />';
2086 $messageContent .= '<br />';
2087
2088 // Remove cache files:
2089 $updateContent = '';
2090 if (t3lib_extMgm::isLoaded($extKey)) {
2091 if ($this->removeCacheFiles()) {
2092 $messageContent .= $GLOBALS['LANG']->getLL('ext_import_cache_files_removed') . '<br />';
2093 }
2094
2095 list($new_list) = $this->getInstalledExtensions();
2096 $updateContent = $this->updatesForm($extKey, $new_list[$extKey], 1, 'index.php?CMD[showExt]=' . $extKey . '&SET[singleDetails]=info');
2097 }
2098
2099 $flashMessage = t3lib_div::makeInstance(
2100 't3lib_FlashMessage',
2101 $messageContent,
2102 $GLOBALS['LANG']->getLL('ext_import_success')
2103 );
2104 $content = $flashMessage->render() . $updateContent;
2105
2106
2107 // Install / Uninstall:
2108 if(!$this->CMD['standAlone']) {
2109 $content .= '<h3>' . $GLOBALS['LANG']->getLL('ext_import_install_uninstall') . '</h3>';
2110 $content.= $new_list[$extKey] ?
2111 '<a href="' . htmlspecialchars('index.php?CMD[showExt]=' . $extKey .
2112 '&CMD[remove]=1&CMD[clrCmd]=1&SET[singleDetails]=info') . '">' .
2113 $this->removeButton() . ' ' . $GLOBALS['LANG']->getLL('ext_import_uninstall') . '</a>' :
2114 '<a href="' . htmlspecialchars('index.php?CMD[showExt]=' . $extKey .
2115 '&CMD[load]=1&CMD[clrCmd]=1&SET[singleDetails]=info') . '">' .
2116 $this->installButton() . ' ' . $GLOBALS['LANG']->getLL('ext_import_install') . '</a>';
2117 } else {
2118 $content = $GLOBALS['LANG']->getLL('ext_import_imported') .
2119 '<br /><br /><a href="javascript:opener.top.content.document.forms[0].submit();window.close();">' .
2120 $GLOBALS['LANG']->getLL('ext_import_close_check') . '</a>';
2121 }
2122 }
2123 } else $content = $res;
2124 } else $content = sprintf($GLOBALS['LANG']->getLL('ext_import_ext_path_different'), $extDirPath);
2125 } else $content = $res;
2126 }
2127 } else $content = sprintf($GLOBALS['LANG']->getLL('ext_import_ext_only_here'),
2128 $this->typePaths[$EM_CONF['lockType']], $EM_CONF['lockType']);
2129 } else $content = $GLOBALS['LANG']->getLL('ext_import_no_ext_key_files');
2130 } else $content = sprintf($GLOBALS['LANG']->getLL('ext_import_data_transfer'), $fetchData);
2131 } else $content = sprintf($GLOBALS['LANG']->getLL('ext_import_no_install_here'), $this->typePaths[$loc]);
2132
2133 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('ext_import_results'), $content, 0, 1);
2134
2135 if ($uploadSucceed && $uploadedTempFile) {
2136 t3lib_div::unlink_tempfile($uploadedTempFile);
2137 }
2138
2139 return false;
2140 }
2141
2142 /**
2143 * Display extensions details.
2144 *
2145 * @param string Extension key
2146 * @return void Writes content to $this->content
2147 */
2148 function showExtDetails($extKey) {
2149 global $TYPO3_LOADED_EXT;
2150
2151 list($list,)=$this->getInstalledExtensions();
2152 $absPath = $this->getExtPath($extKey,$list[$extKey]['type']);
2153
2154 // Check updateModule:
2155 if (isset($list[$extKey]) && @is_file($absPath.'class.ext_update.php')) {
2156 require_once($absPath.'class.ext_update.php');
2157 $updateObj = new ext_update;
2158 if (!$updateObj->access()) {
2159 unset($this->MOD_MENU['singleDetails']['updateModule']);
2160 }
2161 } else {
2162 unset($this->MOD_MENU['singleDetails']['updateModule']);
2163 }
2164
2165 if($this->CMD['doDelete']) {
2166 $this->MOD_MENU['singleDetails'] = array();
2167 }
2168
2169 // Function menu here:
2170 if(!$this->CMD['standAlone'] && !t3lib_div::_GP('standAlone')) {
2171 $content = $GLOBALS['LANG']->getLL('ext_details_ext') . '&nbsp;<strong>' .
2172 $this->extensionTitleIconHeader($extKey, $list[$extKey]) . '</strong> (' . $extKey . ')';
2173 $this->content.= $this->doc->section('', $content);
2174 }
2175
2176 // Show extension details:
2177 if ($list[$extKey]) {
2178
2179 // Checking if a command for install/uninstall is executed:
2180 if (($this->CMD['remove'] || $this->CMD['load']) && !in_array($extKey,$this->requiredExt)) {
2181
2182 // Install / Uninstall extension here:
2183 if (t3lib_extMgm::isLocalconfWritable()) {
2184 // Check dependencies:
2185 $depStatus = $this->checkDependencies($extKey, $list[$extKey]['EM_CONF'], $list);
2186 if(!$this->CMD['remove'] && !$depStatus['returnCode']) {
2187 $this->content .= $depStatus['html'];
2188 $newExtList = -1;
2189 } elseif ($this->CMD['remove']) {
2190 $newExtList = $this->removeExtFromList($extKey,$list);
2191 } else {
2192 $newExtList = $this->addExtToList($extKey,$list);
2193 }
2194
2195 // Successful installation:
2196 if ($newExtList!=-1) {
2197 $updates = '';
2198 if ($this->CMD['load']) {
2199 if($_SERVER['REQUEST_METHOD'] == 'POST') {
2200 $script = t3lib_div::linkThisScript(array('CMD[showExt]' => $extKey, 'CMD[load]' => 1, 'CMD[clrCmd]' => $this->CMD['clrCmd'], 'SET[singleDetails]' => 'info'));
2201 } else {
2202 $script = '';
2203 }
2204 if($this->CMD['standAlone']) {
2205 $standaloneUpdates = '<input type="hidden" name="standAlone" value="1" />';
2206 }
2207 $depsolver = t3lib_div::_POST('depsolver');
2208 if(is_array($depsolver['ignore'])) {
2209 foreach($depsolver['ignore'] as $depK => $depV) {
2210 $dependencyUpdates .= '<input type="hidden" name="depsolver[ignore]['.$depK.']" value="1" />';
2211 }
2212 }
2213 $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'].'" />', TRUE);
2214 if ($updatesForm) {
2215 $updates = $GLOBALS['LANG']->getLL('ext_details_new_tables_fields') . '<br />' .
2216 $GLOBALS['LANG']->getLL('ext_details_new_tables_fields_select') . $updatesForm;
2217 $labelDBUpdate = $GLOBALS['LANG']->csConvObj->conv_case(
2218 $GLOBALS['LANG']->charSet,
2219 $GLOBALS['LANG']->getLL('ext_details_db_needs_update'),
2220 'toUpper'
2221 );
2222 $this->content .= $this->doc->section(
2223 sprintf($GLOBALS['LANG']->getLL('ext_details_installing') . ' ',
2224 $this->extensionTitleIconHeader($extKey, $list[$extKey])
2225 ) . ' ' .
2226 $labelDBUpdate,
2227 $updates, 1, 1, 1, 1
2228 );
2229 }
2230 } elseif ($this->CMD['remove']) {
2231 $updates.= $this->checkClearCache($list[$extKey]);
2232 if ($updates) {
2233 $updates = '
2234 <form action="'.t3lib_div::linkThisScript().'" method="post">'.$updates.'
2235 <br /><input type="submit" name="write" value="' .
2236 $GLOBALS['LANG']->getLL('ext_details_remove_ext') . '" />
2237 <input type="hidden" name="_do_install" value="1" />
2238 <input type="hidden" name="_clrCmd" value="'.$this->CMD['clrCmd'].'" />
2239 <input type="hidden" name="standAlone" value="'.$this->CMD['standAlone'].'" />
2240 </form>';
2241 $labelDBUpdate = $GLOBALS['LANG']->csConvObj->conv_case(
2242 $GLOBALS['LANG']->charSet,
2243 $GLOBALS['LANG']->getLL('ext_details_db_needs_update'),
2244 'toUpper'
2245 );
2246 $this->content .= $this->doc->section(
2247 sprintf($GLOBALS['LANG']->getLL('ext_details_removing') . ' ',
2248 $this->extensionTitleIconHeader($extKey, $list[$extKey])
2249 ) . ' ' .
2250 $labelDBUpdate,
2251 $updates, 1, 1, 1, 1
2252 );
2253 }
2254 }
2255 if (!$updates || t3lib_div::_GP('_do_install')) {
2256 $this->writeNewExtensionList($newExtList);
2257 $action = $this->CMD['load'] ? 'installed' : 'removed';
2258 $GLOBALS['BE_USER']->writelog(5, 1, 0, 0, 'Extension list has been changed, extension %s has been %s', array($extKey, $action));
2259
2260 $messageLabel = 'ext_details_ext_' . $action . '_with_key';
2261 $flashMessage = t3lib_div::makeInstance(
2262 't3lib_FlashMessage',
2263 sprintf($GLOBALS['LANG']->getLL($messageLabel), $extKey),
2264 '',
2265 t3lib_FlashMessage::OK,
2266 TRUE
2267 );
2268 t3lib_FlashMessageQueue::addMessage($flashMessage);
2269
2270 if ($this->CMD['clrCmd'] || t3lib_div::_GP('_clrCmd')) {
2271 if ($this->CMD['load'] && @is_file($absPath.'ext_conf_template.txt')) {
2272 $vA = array('CMD'=>Array('showExt'=>$extKey));
2273 } else {
2274 $vA = array('CMD'=>'');
2275 }
2276 } else {
2277 $vA = array('CMD'=>Array('showExt'=>$extKey));
2278 }
2279 if($this->CMD['standAlone'] || t3lib_div::_GP('standAlone')) {
2280 $this->content .= sprintf($GLOBALS['LANG']->getLL('ext_details_ext_installed_removed'),
2281 ($this->CMD['load'] ?
2282 $GLOBALS['LANG']->getLL('ext_details_installed') :
2283 $GLOBALS['LANG']->getLL('ext_details_removed')
2284 )
2285 ) .
2286 '<br /><br /><a href="javascript:opener.top.content.document.forms[0].submit();window.close();">' .
2287 $GLOBALS['LANG']->getLL('ext_import_close_check') . '</a>';
2288 } else {
2289 // Determine if new modules were installed:
2290 $techInfo = $this->makeDetailedExtensionAnalysis($extKey, $list[$extKey]);
2291 if (($this->CMD['load'] || $this->CMD['remove']) && is_array($techInfo['flags']) && in_array('Module', $techInfo['flags'], true)) {
2292 $vA['CMD']['refreshMenu'] = 1;
2293 }
2294 header('Location: '.t3lib_div::linkThisScript($vA));
2295 exit;
2296 }
2297 }
2298 }
2299 } else {
2300 $writeAccessError = $GLOBALS['LANG']->csConvObj->conv_case(
2301 $GLOBALS['LANG']->charSet,
2302 $GLOBALS['LANG']->getLL('ext_details_write_access_error'),
2303 'toUpper'
2304 );
2305 $this->content .= $this->doc->section(
2306 sprintf($GLOBALS['LANG']->getLL('ext_details_installing') . ' ',
2307 $this->extensionTitleIconHeader($extKey, $list[$extKey])
2308 ) . ' ' .
2309 $writeAccessError,
2310 $GLOBALS['LANG']->getLL('ext_details_write_error_localconf'),
2311 1, 1, 2, 1
2312 );
2313 }
2314
2315 } elseif ($this->CMD['downloadFile'] && !in_array($extKey,$this->requiredExt)) {
2316
2317 // Link for downloading extension has been clicked - deliver content stream:
2318 $dlFile = $this->CMD['downloadFile'];
2319 if (t3lib_div::isFirstPartOfStr($dlFile,PATH_site) && t3lib_div::isFirstPartOfStr($dlFile,$absPath) && @is_file($dlFile)) {
2320 $mimeType = 'application/octet-stream';
2321 Header('Content-Type: '.$mimeType);
2322 Header('Content-Disposition: attachment; filename='.basename($dlFile));
2323 echo t3lib_div::getUrl($dlFile);
2324 exit;
2325 } else die($GLOBALS['LANG']->getLL('ext_details_error_downloading'));
2326
2327 } elseif ($this->CMD['editFile'] && !in_array($extKey,$this->requiredExt)) {
2328
2329 // Editing extension file:
2330 $editFile = $this->CMD['editFile'];
2331 if (t3lib_div::isFirstPartOfStr($editFile,PATH_site) && t3lib_div::isFirstPartOfStr($editFile,$absPath)) { // Paranoia...
2332
2333 $fI = t3lib_div::split_fileref($editFile);
2334 if (@is_file($editFile) && t3lib_div::inList($this->editTextExtensions,($fI['fileext']?$fI['fileext']:$fI['filebody']))) {
2335 if (filesize($editFile)<($this->kbMax*1024)) {
2336 $outCode = '<form action="index.php" method="post" name="editfileform">';
2337 $info = '';
2338 $submittedContent = t3lib_div::_POST('edit');
2339 $saveFlag = 0;
2340
2341 if(isset($submittedContent['file']) && !$GLOBALS['TYPO3_CONF_VARS']['EXT']['noEdit']) { // Check referer here?
2342 $oldFileContent = t3lib_div::getUrl($editFile);
2343 if($oldFileContent != $submittedContent['file']) {
2344 $oldMD5 = md5(str_replace(chr(13),'',$oldFileContent));
2345 $info .= sprintf(
2346 $GLOBALS['LANG']->getLL('ext_details_md5_previous'),
2347 '<b>' . $oldMD5 . '</b>'
2348 ) . '<br />';
2349 t3lib_div::writeFile($editFile,$submittedContent['file']);
2350 $saveFlag = 1;
2351 } else {
2352 $info .= $GLOBALS['LANG']->getLL('ext_details_no_changes') . '<br />';
2353 }
2354 }
2355
2356 $fileContent = t3lib_div::getUrl($editFile);
2357
2358 $outCode.= sprintf(
2359 $GLOBALS['LANG']->getLL('ext_details_file'),
2360 '<b>' . substr($editFile, strlen($absPath)) . '</b> (' .
2361 t3lib_div::formatSize(filesize($editFile)) . ')<br />'
2362 );
2363 $fileMD5 = md5(str_replace(chr(13),'',$fileContent));
2364 $info .= sprintf(
2365 $GLOBALS['LANG']->getLL('ext_details_md5_current'),
2366 '<b>' . $fileMD5 . '</b>'
2367 ) . '<br />';
2368 if($saveFlag) {
2369 $saveMD5 = md5(str_replace(chr(13),'',$submittedContent['file']));
2370 $info .= sprintf(
2371 $GLOBALS['LANG']->getLL('ext_details_md5_submitted'),
2372 '<b>' . $saveMD5 . '</b>'
2373 ) . '<br />';
2374 if ($fileMD5!=$saveMD5) {
2375 $info .= $GLOBALS['TBE_TEMPLATE']->rfw(
2376 '<br /><strong>' . $GLOBALS['LANG']->getLL('ext_details_saving_failed_changes_lost') . '</strong>'
2377 ) . '<br />';
2378 }
2379 else {
2380 $info .= $GLOBALS['TBE_TEMPLATE']->rfw(
2381 '<br /><strong>' . $GLOBALS['LANG']->getLL('ext_details_file_saved') . '</strong>'
2382 ) . '<br />';
2383 }
2384 }
2385
2386 $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>';
2387 $outCode.= '<input type="hidden" name="edit[filename]" value="'.$editFile.'" />';
2388 $outCode.= '<input type="hidden" name="CMD[editFile]" value="'.htmlspecialchars($editFile).'" />';
2389 $outCode.= '<input type="hidden" name="CMD[showExt]" value="'.$extKey.'" />';
2390 $outCode.= $info;
2391
2392 if (!$GLOBALS['TYPO3_CONF_VARS']['EXT']['noEdit']) {
2393 $outCode .= '<br /><input type="submit" name="save_file" value="' .
2394 $GLOBALS['LANG']->getLL('ext_details_file_save_button') . '" />';
2395 }
2396 else {
2397 $outCode .= $GLOBALS['TBE_TEMPLATE']->rfw(
2398 '<br />' . $GLOBALS['LANG']->getLL('ext_details_saving_disabled') . ' '
2399 );
2400 }
2401
2402 $onClick = 'window.location.href=\'index.php?CMD[showExt]='.$extKey.'\';return false;';
2403 $outCode .= '<input type="submit" name="cancel" value="' .
2404 $GLOBALS['LANG']->getLL('ext_details_cancel_button') . '" onclick="' .
2405 htmlspecialchars($onClick) . '" /></form>';
2406
2407 $theOutput.=$this->doc->spacer(15);
2408 $theOutput .= $this->doc->section($GLOBALS['LANG']->getLL('ext_details_edit_file'), '', 0, 1);
2409 $theOutput.=$this->doc->sectionEnd().$outCode;
2410 $this->content.=$theOutput;
2411 } else {
2412 $theOutput.=$this->doc->spacer(15);
2413 $theOutput .= $this->doc->section(
2414 sprintf(
2415 $GLOBALS['LANG']->getLL('ext_details_filesize_exceeded_kb'),
2416 $this->kbMax
2417 ),
2418 sprintf(
2419 $GLOBALS['LANG']->getLL('ext_details_file_too_large'),
2420 $this->kbMax
2421 )
2422 );
2423 }
2424 }
2425 } else {
2426 die (sprintf($GLOBALS['LANG']->getLL('ext_details_fatal_edit_error'),
2427 $editFile
2428 )
2429 );
2430 }
2431 } else {
2432
2433 // MAIN:
2434 switch((string)$this->MOD_SETTINGS['singleDetails']) {
2435 case 'info':
2436 // Loaded / Not loaded:
2437 if (!in_array($extKey,$this->requiredExt)) {
2438 if ($TYPO3_LOADED_EXT[$extKey]) {
2439 $content = '<strong>' . $GLOBALS['LANG']->getLL('ext_details_loaded_and_running') . '</strong><br />' .
2440 '<a href="' . htmlspecialchars('index.php?CMD[showExt]=' . $extKey . '&CMD[remove]=1') .
2441 '">' . $GLOBALS['LANG']->getLL('ext_details_remove_button') . ' ' . $this->removeButton() . '</a>';
2442 } else {
2443 $content = $GLOBALS['LANG']->getLL('ext_details_not_loaded') . '<br />'.
2444 '<a href="' . htmlspecialchars('index.php?CMD[showExt]=' . $extKey . '&CMD[load]=1') .
2445 '">' . $GLOBALS['LANG']->getLL('ext_details_install_button') . ' ' . $this->installButton() . '</a>';
2446 }
2447 } else {
2448 $content = $GLOBALS['LANG']->getLL('ext_details_always_loaded');
2449 }
2450 $this->content.=$this->doc->spacer(10);
2451 $this->content .= $this->doc->section(
2452 $GLOBALS['LANG']->getLL('ext_details_current_status'), $content, 0, 1
2453 );
2454
2455 if (t3lib_extMgm::isLoaded($extKey)) {
2456 $updates=$this->updatesForm($extKey,$list[$extKey]);
2457 if ($updates) {
2458 $this->content.=$this->doc->spacer(10);
2459 $this->content .= $this->doc->section(
2460 $GLOBALS['LANG']->getLL('ext_details_update_needed'),
2461 $updates . '<br /><br />' . $GLOBALS['LANG']->getLL('ext_details_notice_static_data'),
2462 0, 1
2463 );
2464 }
2465 }
2466
2467 // Config:
2468 if (@is_file($absPath.'ext_conf_template.txt')) {
2469 $this->content.=$this->doc->spacer(10);
2470 $this->content .= $this->doc->section(
2471 $GLOBALS['LANG']->getLL('ext_details_configuration'),
2472 $GLOBALS['LANG']->getLL('ext_details_notice_clear_cache') . '<br /><br />',
2473 0, 1
2474 );
2475
2476 $this->tsStyleConfigForm($extKey, $list[$extKey]);
2477 }
2478
2479 // Show details:
2480 $content = t3lib_BEfunc::cshItem('_MOD_tools_em', 'info', $GLOBALS['BACK_PATH'], '|<br />');
2481 $content.= $this->extInformationArray($extKey,$list[$extKey]);
2482
2483 $this->content.=$this->doc->spacer(10);
2484 $this->content .= $this->doc->section(
2485 $GLOBALS['LANG']->getLL('ext_details_details'), $content, 0, 1
2486 );
2487 break;
2488 case 'upload':
2489 $em = t3lib_div::_POST('em');
2490 if($em['action'] == 'doUpload') {
2491 $em['extKey'] = $extKey;
2492 $em['extInfo'] = $list[$extKey];
2493 $content = $this->uploadExtensionToTER($em);
2494 $content .= $this->doc->spacer(10);
2495 // Must reload this, because EM_CONF information has been updated!
2496 list($list,)=$this->getInstalledExtensions();
2497 } else {
2498 // CSH:
2499 $content = t3lib_BEfunc::cshItem('_MOD_tools_em', 'upload', $GLOBALS['BACK_PATH'], '|<br />');
2500
2501 // Upload:
2502 if (substr($extKey,0,5)!='user_') {
2503 $content.= $this->getRepositoryUploadForm($extKey,$list[$extKey]);
2504 $eC=0;
2505 } else {
2506 $content .= $GLOBALS['LANG']->getLL('ext_details_no_unique_ext');
2507 $eC=2;
2508 }
2509 if (!$this->fe_user['username']) {
2510 $content .= '<br /><br /><img src="' . $GLOBALS['BACK_PATH'] .
2511 'gfx/icon_note.gif" width="18" height="16" align="top" alt="" />' .
2512 sprintf($GLOBALS['LANG']->getLL('ext_details_no_username'),
2513 '<a href="index.php?SET[function]=3">', '</a>'
2514 ) .
2515 '<br />';
2516 }
2517 }
2518 $this->content .= $this->doc->section(
2519 $GLOBALS['LANG']->getLL('ext_details_upload_to_ter'),
2520 $content, 0, 1, $eC
2521 );
2522 break;
2523 case 'backup':
2524 if($this->CMD['doDelete']) {
2525 $content = $this->extDelete($extKey,$list[$extKey]);
2526 $this->content .= $this->doc->section(
2527 $GLOBALS['LANG']->getLL('ext_details_delete'),
2528 $content, 0, 1
2529 );
2530 } else {
2531 $content = t3lib_BEfunc::cshItem('_MOD_tools_em', 'backup_delete', $GLOBALS['BACK_PATH'], '|<br />');
2532 $content.= $this->extBackup($extKey,$list[$extKey]);
2533 $this->content .= $this->doc->section(
2534 $GLOBALS['LANG']->getLL('ext_details_backup'),
2535 $content, 0, 1
2536 );
2537
2538 $content = $this->extDelete($extKey,$list[$extKey]);
2539 $this->content .= $this->doc->section(
2540 $GLOBALS['LANG']->getLL('ext_details_delete'),
2541 $content, 0, 1
2542 );
2543
2544 $content = $this->extUpdateEMCONF($extKey,$list[$extKey]);
2545 $this->content .= $this->doc->section(
2546 $GLOBALS['LANG']->getLL('ext_details_update_em_conf'),
2547 $content, 0, 1
2548 );
2549 }
2550 break;
2551 case 'dump':
2552 $this->extDumpTables($extKey,$list[$extKey]);
2553 break;
2554 case 'edit':
2555 $content = t3lib_BEfunc::cshItem('_MOD_tools_em', 'editfiles', $GLOBALS['BACK_PATH'], '|<br />');
2556 $content.= $this->getFileListOfExtension($extKey,$list[$extKey]);
2557
2558 $this->content.=$this->doc->section(
2559 $GLOBALS['LANG']->getLL('ext_details_ext_files'),
2560 $content, 0, 1
2561 );
2562 break;
2563 case 'updateModule':
2564 $this->content .= $this->doc->section(
2565 $GLOBALS['LANG']->getLL('ext_details_update'),
2566 is_object($updateObj) ?
2567 $updateObj->main() :
2568 $GLOBALS['LANG']->getLL('ext_details_no_update_object'),
2569 0, 1
2570 );
2571 break;
2572 default:
2573 $this->extObjContent();
2574 break;
2575 }
2576 }
2577 }
2578 }
2579
2580 /**
2581 * Outputs a screen from where you can install multiple extensions in one go
2582 * This can be called from external modules with "...index.php?CMD[requestInstallExtensions]=
2583 *
2584 * @param string Comma list of extension keys to install. Renders a screen with checkboxes for all extensions not already imported or installed
2585 * @return void
2586 */
2587 function requestInstallExtensions($extList) {
2588
2589 // Return URL:
2590 $returnUrl = t3lib_div::_GP('returnUrl');
2591 $installOrImportExtension = t3lib_div::_POST('installOrImportExtension');
2592
2593 // Extension List:
2594 $extArray = explode(',',$extList);
2595 $outputRow = array();
2596 $outputRow[] = '
2597 <tr class="bgColor5 tableheader">
2598 <td>' . $GLOBALS['LANG']->getLL('reqInstExt_install_import') . '</td>
2599 <td>' . $GLOBALS['LANG']->getLL('reqInstExt_ext_key') . '</td>
2600 </tr>
2601 ';
2602
2603 foreach($extArray as $extKey) {
2604
2605 // Check for the request:
2606 if ($installOrImportExtension[$extKey]) {
2607 $this->installExtension($extKey);
2608 }
2609
2610 // Display:
2611 if (!t3lib_extMgm::isLoaded($extKey)) {