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