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