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