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