Cleanup: Updated copyright comments
[Packages/TYPO3.CMS.git] / typo3 / sysext / em / classes / extensions / class.tx_em_extensions_details.php
1 <?php
2 /* **************************************************************
3 * Copyright notice
4 *
5 * (c) webservices.nl
6 * (c) 2006-2011 Karsten Dambekalns <karsten@typo3.org>
7 * (c) 2010-2011 Steffen Kamper <steffen@typo3.org>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29 /* $Id: class.tx_em_extensions_details.php 2058 2010-03-17 09:39:15Z steffenk $ */
30
31 /**
32 * This class handles extension details
33 *
34 */
35
36 class tx_em_Extensions_Details {
37
38 protected $maxUploadSize = 31457280;
39 protected $descrTable = '_MOD_tools_em';
40 protected $parentObject;
41
42 protected $categories;
43 protected $states;
44
45 /**
46 * Instance of EM API
47 *
48 * @var tx_em_API
49 */
50 protected $api;
51
52 /**
53 * Class for install extensions
54 *
55 * @var em_install
56 */
57 public $install;
58
59 /**
60 * Constructor
61 *
62 * @param object $parentObject
63 */
64 public function __construct($parentObject = NULL) {
65 $this->parentObject = $parentObject;
66 $this->api = t3lib_div::makeInstance('tx_em_API');
67 $this->install = t3lib_div::makeInstance('tx_em_Install', $this);
68 $GLOBALS['LANG']->includeLLFile(t3lib_extMgm::extPath('em') . 'language/locallang.xml');
69 $this->categories = array(
70 'be' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:category_BE'),
71 'module' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:category_BE_modules'),
72 'fe' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:category_FE'),
73 'plugin' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:category_FE_plugins'),
74 'misc' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:category_miscellanous'),
75 'services' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:category_services'),
76 'templates' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:category_templates'),
77 'example' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:category_examples'),
78 'doc' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:category_documentation')
79 );
80 $this->states = tx_em_Tools::getStates();
81 }
82
83
84 /**
85 * Reads $confFilePath (a module $conf-file) and returns information on the existence of TYPO3_MOD_PATH definition and MCONF_name
86 *
87 * @param string Absolute path to a "conf.php" file of a module which we are analysing.
88 * @return array Information found.
89 * @see writeTYPO3_MOD_PATH()
90 */
91 function modConfFileAnalysis($confFilePath) {
92 $lines = explode(LF, t3lib_div::getUrl($confFilePath));
93 $confFileInfo = array();
94 $confFileInfo['lines'] = $lines;
95 $reg = array();
96
97 foreach ($lines as $k => $l) {
98 $line = trim($l);
99
100 unset($reg);
101 if (preg_match('/^define[[:space:]]*\([[:space:]]*["\']TYPO3_MOD_PATH["\'][[:space:]]*,[[:space:]]*["\']([[:alnum:]_\/\.]+)["\'][[:space:]]*\)[[:space:]]*;/', $line, $reg)) {
102 $confFileInfo['TYPO3_MOD_PATH'] = array($k, $reg);
103 }
104
105 unset($reg);
106 if (preg_match('/^\$MCONF\[["\']?name["\']?\][[:space:]]*=[[:space:]]*["\']([[:alnum:]_]+)["\'];/', $line, $reg)) {
107 $confFileInfo['MCONF_name'] = array($k, $reg);
108 }
109 }
110 return $confFileInfo;
111 }
112
113 /**
114 * Check if upload folder / "createDir" directories should be created.
115 *
116 * @param string Extension key
117 * @param array Extension information array
118 * @return string HTML content.
119 */
120 function checkUploadFolder($extKey, $extInfo) {
121
122 // Checking for upload folder:
123 $uploadFolder = PATH_site . tx_em_Tools::uploadFolder($extKey);
124 if ($extInfo['EM_CONF']['uploadfolder'] && !@is_dir($uploadFolder)) {
125 if (t3lib_div::_POST('_uploadfolder')) { // CREATE dir:
126 t3lib_div::mkdir($uploadFolder);
127 $indexContent = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
128 <HTML>
129 <HEAD>
130 <TITLE></TITLE>
131 <META http-equiv=Refresh Content="0; Url=../../">
132 </HEAD>
133 </HTML>';
134 t3lib_div::writeFile($uploadFolder . 'index.html', $indexContent);
135 } else { // Show checkbox / HTML for creation:
136 $content .= '
137 <br /><h3>' . $GLOBALS['LANG']->getLL('checkUploadFolder_create_upload_folder') . '</h3>
138 <p>' . sprintf($GLOBALS['LANG']->getLL('checkUploadFolder_upload_folder_needed'),
139 tx_em_Tools::uploadFolder($extKey)
140 ) . '<br />
141 <label for="check_uploadfolder">' . sprintf($GLOBALS['LANG']->getLL('checkUploadFolder_create_dir'),
142 tx_em_Tools::uploadFolder($extKey)
143 ) . '</label>
144 <input type="checkbox" name="_uploadfolder" id="check_uploadfolder" checked="checked" value="1" /><br />
145 </p>
146 ';
147 }
148 }
149
150 // Additional directories that should be created:
151 if ($extInfo['EM_CONF']['createDirs']) {
152 $createDirs = array_unique(t3lib_div::trimExplode(',', $extInfo['EM_CONF']['createDirs'], 1));
153
154 foreach ($createDirs as $crDir) {
155 if (!@is_dir(PATH_site . $crDir)) {
156 if (t3lib_div::_POST('_createDir_' . md5($crDir))) { // CREATE dir:
157
158 // Initialize:
159 $crDirStart = '';
160 $dirs_in_path = explode('/', preg_replace('/\/$/', '', $crDir));
161
162 // Traverse each part of the dir path and create it one-by-one:
163 foreach ($dirs_in_path as $dirP) {
164 if (strcmp($dirP, '')) {
165 $crDirStart .= $dirP . '/';
166 if (!@is_dir(PATH_site . $crDirStart)) {
167 t3lib_div::mkdir(PATH_site . $crDirStart);
168 $finalDir = PATH_site . $crDirStart;
169 }
170 } else {
171 throw new RuntimeException(
172 'TYPO3 Fatal Error: ' . sprintf($GLOBALS['LANG']->getLL('checkUploadFolder_error'), PATH_site . $crDir),
173 1270853982
174 );
175 }
176 }
177 if ($finalDir) {
178 $indexContent = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
179 <HTML>
180 <HEAD>
181 <TITLE></TITLE>
182 <META http-equiv=Refresh Content="0; Url=/">
183 </HEAD>
184 </HTML>';
185 t3lib_div::writeFile($finalDir . 'index.html', $indexContent);
186 }
187 } else { // Show checkbox / HTML for creation:
188 $md5CrDir = md5($crDir);
189 $content .= '
190 <br />
191 <h3>' . $GLOBALS['LANG']->getLL('checkUploadFolder_create_folder') . '</h3>
192 <p>' . sprintf($GLOBALS['LANG']->getLL('checkUploadFolder_folder_needed'),
193 $crDir
194 ) . '<br />
195 <label for="check_createDir_' . $md5CrDir . '">' . sprintf($GLOBALS['LANG']->getLL('checkUploadFolder_create_dir'),
196 $crDir
197 ) . '</label>
198 <input type="checkbox" name="_createDir_' . $md5CrDir . '" id="check_createDir_' . $md5CrDir . '" checked="checked" value="1" /><br />
199 </p>
200 ';
201 }
202 }
203 }
204 }
205
206 return $content;
207 }
208
209
210 /**
211 * Processes return-data from online repository.
212 * Currently only the returned emconf array is written to extension.
213 *
214 * @param array Command array returned from TER
215 * @return string Message
216 */
217 function uploadExtensionToTER($em) {
218 $msg = '';
219 $response = $this->parentObject->terConnection->uploadToTER($em);
220
221 if (!is_array($response)) {
222 return $response;
223 }
224
225 if ($response['resultCode'] == TX_TER_RESULT_EXTENSIONSUCCESSFULLYUPLOADED) {
226 $em['extInfo']['EM_CONF']['version'] = $response['version'];
227 $response['resultMessages'][] = sprintf($GLOBALS['LANG']->getLL('terCommunication_ext_version'),
228 $response['version']
229 );
230 $response['resultMessages'][] = $this->updateLocalEM_CONF($em['extKey'], $em['extInfo']);
231 }
232
233 $msg = '<ul><li>' . implode('</li><li>', $response['resultMessages']) . '</li></ul>';
234 return $msg;
235 }
236
237 /**
238 * Forces update of local EM_CONF. This will renew the information of changed files.
239 *
240 * @param string Extension key
241 * @param array Extension information array
242 * @return string Status message
243 */
244 function updateLocalEM_CONF($extKey, $extInfo) {
245 $extInfo['EM_CONF']['_md5_values_when_last_written'] = serialize($this->serverExtensionMD5array($extKey, $extInfo));
246 $emConfFileContent = $this->construct_ext_emconf_file($extKey, $extInfo['EM_CONF']);
247
248 $absPath = tx_em_Tools::getExtPath($extKey, $extInfo['type']);
249 $emConfFileName = $absPath . 'ext_emconf.php';
250 if ($emConfFileContent) {
251
252 if (@is_file($emConfFileName)) {
253 if (t3lib_div::writeFile($emConfFileName, $emConfFileContent) === true) {
254 return sprintf($GLOBALS['LANG']->getLL('updateLocalEM_CONF_ok'),
255 substr($emConfFileName, strlen($absPath)));
256 } else {
257 return '<strong>' . sprintf($GLOBALS['LANG']->getLL('updateLocalEM_CONF_not_writable'),
258 $emConfFileName) . '</strong>';
259 }
260 } else {
261 return ('<strong>' . sprintf($GLOBALS['LANG']->getLL('updateLocalEM_CONF_not_found'),
262 $emConfFileName) . '</strong>');
263 }
264 } else {
265 return sprintf($GLOBALS['LANG']->getLL('updateLocalEM_CONF_no_content'),
266 substr($emConfFileName, strlen($absPath)));
267 }
268 }
269
270 /**
271 * Creates a MD5-hash array over the current files in the extension
272 *
273 * @param string Extension key
274 * @param array Extension information array
275 * @return array MD5-keys
276 */
277 function serverExtensionMD5array($extKey, $conf) {
278
279 // Creates upload-array - including filelist.
280 $mUA = $this->makeUploadarray($extKey, $conf);
281
282 $md5Array = array();
283 if (is_array($mUA['FILES'])) {
284
285 // Traverse files.
286 foreach ($mUA['FILES'] as $fN => $d) {
287 if ($fN != 'ext_emconf.php') {
288 $md5Array[$fN] = substr($d['content_md5'], 0, 4);
289 }
290 }
291 } else {
292 debug(array($mUA, $conf), 'serverExtensionMD5Array:' . $extKey);
293 }
294 return $md5Array;
295 }
296
297 /*******************************************
298 *
299 * Compiling upload information, emconf-file etc.
300 *
301 *******************************************/
302
303 /**
304 * Compiles the ext_emconf.php file
305 *
306 * @param string Extension key
307 * @param array EM_CONF array
308 * @return string PHP file content, ready to write to ext_emconf.php file
309 */
310 function construct_ext_emconf_file($extKey, $EM_CONF) {
311
312 // clean version number:
313 $vDat = tx_em_Tools::renderVersion($EM_CONF['version']);
314 $EM_CONF['version'] = $vDat['version'];
315
316 $code = '<?php
317
318 ########################################################################
319 # Extension Manager/Repository config file for ext "' . $extKey . '".
320 #
321 # Auto generated ' . date('d-m-Y H:i') . '
322 #
323 # Manual updates:
324 # Only the data in the array - everything else is removed by next
325 # writing. "version" and "dependencies" must not be touched!
326 ########################################################################
327
328 $EM_CONF[$_EXTKEY] = ' . tx_em_Tools::arrayToCode($EM_CONF, 0) . ';
329
330 ?>';
331 return str_replace(CR, '', $code);
332 }
333
334 /**
335 * Make upload array out of extension
336 *
337 * @param string Extension key
338 * @param array Extension information array
339 * @return mixed Returns array with extension upload array on success, otherwise an error string.
340 */
341 function makeUploadarray($extKey, $conf) {
342 $extPath = tx_em_Tools::getExtPath($extKey, $conf['type']);
343
344 if ($extPath) {
345
346 // Get files for extension:
347 $fileArr = array();
348 $fileArr = t3lib_div::getAllFilesAndFoldersInPath($fileArr, $extPath, '', 0, 99, $GLOBALS['TYPO3_CONF_VARS']['EXT']['excludeForPackaging']);
349
350 // Calculate the total size of those files:
351 $totalSize = 0;
352 foreach ($fileArr as $file) {
353 $totalSize += filesize($file);
354 }
355
356 // If the total size is less than the upper limit, proceed:
357 if ($totalSize < $this->maxUploadSize) {
358
359 // Initialize output array:
360 $uploadArray = array();
361 $uploadArray['extKey'] = $extKey;
362 $uploadArray['EM_CONF'] = $conf['EM_CONF'];
363 $uploadArray['misc']['codelines'] = 0;
364 $uploadArray['misc']['codebytes'] = 0;
365
366 $uploadArray['techInfo'] = $this->install->makeDetailedExtensionAnalysis($extKey, $conf, 1);
367
368 // Read all files:
369 foreach ($fileArr as $file) {
370 $relFileName = substr($file, strlen($extPath));
371 $fI = pathinfo($relFileName);
372 if ($relFileName != 'ext_emconf.php') { // This file should be dynamically written...
373 $uploadArray['FILES'][$relFileName] = array(
374 'name' => $relFileName,
375 'size' => filesize($file),
376 'mtime' => filemtime($file),
377 'is_executable' => (TYPO3_OS == 'WIN' ? 0 : is_executable($file)),
378 'content' => t3lib_div::getUrl($file)
379 );
380 if (t3lib_div::inList('php,inc', strtolower($fI['extension']))) {
381 $uploadArray['FILES'][$relFileName]['codelines'] = count(explode(LF, $uploadArray['FILES'][$relFileName]['content']));
382 $uploadArray['misc']['codelines'] += $uploadArray['FILES'][$relFileName]['codelines'];
383 $uploadArray['misc']['codebytes'] += $uploadArray['FILES'][$relFileName]['size'];
384
385 // locallang*.php files:
386 if (substr($fI['basename'], 0, 9) == 'locallang' && strstr($uploadArray['FILES'][$relFileName]['content'], '$LOCAL_LANG')) {
387 $uploadArray['FILES'][$relFileName]['LOCAL_LANG'] = tx_em_Tools::getSerializedLocalLang($file, $uploadArray['FILES'][$relFileName]['content']);
388 }
389 }
390 $uploadArray['FILES'][$relFileName]['content_md5'] = md5($uploadArray['FILES'][$relFileName]['content']);
391 }
392 }
393
394 // Return upload-array:
395 return $uploadArray;
396 } else {
397 return sprintf($GLOBALS['LANG']->getLL('makeUploadArray_error_size'),
398 $totalSize, t3lib_div::formatSize($this->maxUploadSize));
399 }
400 } else {
401 return sprintf($GLOBALS['LANG']->getLL('makeUploadArray_error_path'),
402 $extKey);
403 }
404 }
405
406
407 /**
408 * Prints a table with extension information in it.
409 *
410 * @param string Extension key
411 * @param array Extension information array
412 * @param boolean If set, the information array shows information for a remote extension in TER, not a local one.
413 * @return string HTML content.
414 */
415 function extInformationarray($extKey, $extInfo, $remote = 0) {
416 $emConf = $extInfo['EM_CONF'];
417
418 $lines = array();
419 $lines[] = '
420 <tr class="t3-row-header"><td colspan="2"><strong>' . $GLOBALS['LANG']->getLL('extInfoArray_general_info') . '</strong></td></tr>';
421
422 // row for the extension title
423 $key = 'title';
424 $dataCol = $emConf['_icon'] . $emConf[$key];
425 $lines[] = array(
426 $this->headerCol($key),
427 $dataCol
428 );
429
430 // row for the extension description
431 $key = 'description';
432 $dataCol = nl2br(htmlspecialchars($emConf[$key]));
433 $lines[] = array(
434 $this->headerCol($key),
435 $dataCol
436 );
437
438 // row for the extension author
439 $key = 'author';
440 $dataCol = tx_em_Tools::wrapEmail($emConf['author'] . ($emConf['author_email'] ? ' <' . $emConf['author_email'] . '>' : ''), $emConf['author_email']);
441 if ($emConf['author_company']) {
442 $dataCol .= ', ' . $emConf['author_company'];
443 }
444 $lines[] = array(
445 $this->headerCol($key),
446 $dataCol
447 );
448
449 // row for the version
450 $key = 'version';
451 $dataCol = $emConf[$key];
452 $lines[] = array(
453 $this->headerCol($key),
454 $dataCol
455 );
456
457 // row for the category
458 $key = 'category';
459 $dataCol = $this->categories[$emConf[$key]];
460 $lines[] = array(
461 $this->headerCol($key),
462 $dataCol
463 );
464
465 // row for the state
466 $key = 'state';
467 $dataCol = $this->states[$emConf[$key]];
468 $lines[] = array(
469 $this->headerCol($key),
470 $dataCol
471 );
472
473 // row for the shy state
474 $key = 'shy';
475 if ($emConf[$key]) {
476 $dataCol = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:yes');
477 } else {
478 $dataCol = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:no');
479 }
480 $lines[] = array(
481 $this->headerCol($key),
482 $dataCol
483 );
484
485 // row for the internal state
486 $key = 'internal';
487 if ($emConf[$key]) {
488 $dataCol = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:yes');
489 } else {
490 $dataCol = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:no');
491 }
492 $lines[] = array(
493 $this->headerCol($key),
494 $dataCol
495 );
496
497 // row for the dependencies
498 $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_depends_on');
499 $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_dependencies', $headerCol);
500 $dataCol = tx_em_Tools::depToString($emConf['constraints']);
501 $lines[] = array(
502 $headerCol,
503 $dataCol
504 );
505
506 // row for the conflicts
507 $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_conflicts_with');
508 $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_conflicts', $headerCol);
509 $dataCol = tx_em_Tools::depToString($emConf['constraints'], 'conflicts');
510 $lines[] = array(
511 $headerCol,
512 $dataCol
513 );
514
515 // row for the suggestions
516 $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_suggests');
517 $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_conflicts', $headerCol);
518 $dataCol = tx_em_Tools::depToString($emConf['constraints'], 'suggests');
519 $lines[] = array(
520 $this->headerCol('suggests'),
521 $dataCol
522 );
523
524 if (!$remote) {
525
526 $key = 'priority';
527 $lines[] = array(
528 $this->headerCol($key),
529 $emConf[$key]
530 );
531
532
533 $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_clear_cache');
534 $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_clearCacheOnLoad', $headerCol);
535 if ($emConf['clearCacheOnLoad']) {
536 $dataCol = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:yes');
537 } else {
538 $dataCol = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:no');
539 }
540 $lines[] = array(
541 $headerCol,
542 $dataCol
543 );
544
545 $key = 'module';
546 $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_incl_modules');
547 $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_module', $headerCol);
548 $lines[] = array(
549 $headerCol,
550 $emConf[$key]
551 );
552
553 $key = 'lockType';
554 $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_lock_type');
555 $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_lockType', $headerCol);
556 $lines[] = array(
557 $headerCol,
558 ($emConf[$key] ? $emConf[$key] : '')
559 );
560
561 $key = 'doNotLoadInFE';
562 $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_load_in_frontend');
563 $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_doNotLoadInFE', $headerCol);
564 if (!$emConf['doNotLoadInFE']) {
565 $dataCol = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:yes');
566 } else {
567 $dataCol = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:no');
568 }
569 $lines[] = array(
570 $headerCol,
571 $dataCol
572 );
573
574 $key = 'modify_tables';
575 $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_modifies_tables');
576 $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_modify_tables', $headerCol);
577 $lines[] = array(
578 $headerCol,
579 $emConf[$key]
580 );
581
582
583 // Installation status:
584 $techInfo = $this->install->makeDetailedExtensionAnalysis($extKey, $extInfo, 1);
585 $lines[] = array('<tr><td colspan="2">&nbsp;</td></tr>');
586 $lines[] = array('<tr class="t3-row-header"><td colspan="2"><strong>' . $GLOBALS['LANG']->getLL('extInfoArray_inst_status') . '</strong></td></tr>');
587
588
589 $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_inst_type');
590 $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_type', $headerCol);
591 $dataCol = $this->api->typeLabels[$extInfo['type']] . ' - <em>' . $this->api->typeDescr[$extInfo['type']] . '</em>';
592 $lines[] = array($headerCol, $dataCol);
593
594
595 $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_inst_twice');
596 $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_doubleInstall', $headerCol);
597 $dataCol = $this->extInformationArray_dbInst($extInfo['doubleInstall'], $extInfo['type']);
598 $lines[] = array($headerCol, $dataCol);
599
600
601 if (is_array($extInfo['files'])) {
602 sort($extInfo['files']);
603 $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_root_files');
604 $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_rootfiles', $headerCol);
605 $dataCol = implode('<br />', $extInfo['files']);
606 $lines[] = array($headerCol, $dataCol);
607 }
608
609 if ($techInfo['tables'] || $techInfo['static'] || $techInfo['fields']) {
610 if (!$remote && t3lib_extMgm::isLoaded($extKey)) {
611 $tableStatus = tx_em_Tools::rfw(($techInfo['tables_error'] ?
612 '<strong>' . $GLOBALS['LANG']->getLL('extInfoArray_table_error') . '</strong><br />' .
613 $GLOBALS['LANG']->getLL('extInfoArray_missing_fields') : '') .
614 ($techInfo['static_error'] ?
615 '<strong>' . $GLOBALS['LANG']->getLL('extInfoArray_static_table_error') . '</strong><br />' .
616 $GLOBALS['LANG']->getLL('extInfoArray_static_tables_missing_empty') : ''));
617 } else {
618 $tableStatus = $techInfo['tables_error'] || $techInfo['static_error'] ?
619 $GLOBALS['LANG']->getLL('extInfoArray_db_update_needed') : $GLOBALS['LANG']->getLL('extInfoArray_tables_ok');
620 }
621 }
622
623 $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_db_requirements');
624 $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_dbReq', $headerCol);
625 $dataCol = $this->extInformationArray_dbReq($techInfo, 1);
626 $lines[] = array($headerCol, $dataCol);
627
628 $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_db_status');
629 $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_dbStatus', $headerCol);
630 $lines[] = array($headerCol, $tableStatus);
631
632 $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_flags');
633 $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_flags', $headerCol);
634 $dataCol = (is_array($techInfo['flags']) ? implode('<br />', $techInfo['flags']) : '');
635 $lines[] = array($headerCol, $dataCol);
636
637 $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_config_template');
638 $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_conf', $headerCol);
639 $dataCol = ($techInfo['conf'] ? $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:yes') : '');
640 $lines[] = array($headerCol, $dataCol);
641
642 $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_typoscript_files');
643 $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_TSfiles', $headerCol);
644 $dataCol = (is_array($techInfo['TSfiles']) ? implode('<br />', $techInfo['TSfiles']) : '');
645 $lines[] = array($headerCol, $dataCol);
646
647 $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_language_files');
648 $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_locallang', $headerCol);
649 $dataCol = (is_array($techInfo['locallang']) ? implode('<br />', $techInfo['locallang']) : '');
650 $lines[] = array($headerCol, $dataCol);
651
652 $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_upload_folder');
653 $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_uploadfolder', $headerCol);
654 $dataCol = ($techInfo['uploadfolder'] ? $techInfo['uploadfolder'] : '');
655 $lines[] = array($headerCol, $dataCol);
656
657 $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_create_directories');
658 $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_createDirs', $headerCol);
659 $dataCol = (is_array($techInfo['createDirs']) ? implode('<br />', $techInfo['createDirs']) : '');
660 $lines[] = array($headerCol, $dataCol);
661
662 $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_module_names');
663 $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_moduleNames', $headerCol);
664 $dataCol = (is_array($techInfo['moduleNames']) ? implode('<br />', $techInfo['moduleNames']) : '');
665 $lines[] = array($headerCol, $dataCol);
666
667 $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_class_names');
668 $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_classNames', $headerCol);
669 $dataCol = (is_array($techInfo['classes']) ? implode('<br />', $techInfo['classes']) : '');
670 $lines[] = array($headerCol, $dataCol);
671
672 $currentMd5Array = $this->serverExtensionMD5array($extKey, $extInfo);
673
674 $msgLines = array();
675 if (strcmp($extInfo['EM_CONF']['_md5_values_when_last_written'], serialize($currentMd5Array))) {
676 $msgLines[] = tx_em_Tools::rfw('<br /><strong>' . $GLOBALS['LANG']->getLL('extInfoArray_difference_detected') . '</strong>');
677 $affectedFiles = tx_em_Tools::findMD5ArrayDiff($currentMd5Array, unserialize($extInfo['EM_CONF']['_md5_values_when_last_written']));
678 if (count($affectedFiles)) {
679 $msgLines[] = '<br /><strong>' . $GLOBALS['LANG']->getLL('extInfoArray_modified_files') . '</strong><br />' .
680 tx_em_Tools::rfw(implode('<br />', $affectedFiles));
681 }
682 }
683
684 $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_files_changed');
685 $headerCol = t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_filesChanged', $headerCol);
686 $dataCol = implode('<br />', $msgLines);
687 $lines[] = array($headerCol, $dataCol);
688 }
689
690 $output = '';
691 foreach ($lines as $cols) {
692 // if it's just one line, we assume it's a headline,
693 // thus no need to wrap it in HTML table tags
694 if (count($cols) == 1) {
695 $output .= $cols[0];
696 } else {
697 $output .= '
698 <tr class="bgColor4">
699 <td>' . $cols[0] . '</td>
700 <td>' . $cols[1] . '</td>
701 </tr>';
702 }
703 }
704
705
706 return '<table border="0" cellpadding="1" cellspacing="2">
707 ' . $output . '
708 </table>';
709 }
710
711 /**
712 * Returns HTML with information about database requirements
713 *
714 * @param array Technical information array
715 * @param boolean Table header displayed
716 * @return string HTML content.
717 */
718 function extInformationArray_dbReq($techInfo, $tableHeader = 0) {
719 return nl2br(trim((is_array($techInfo['tables']) ?
720 ($tableHeader ?
721 "\n\n<strong>" . $GLOBALS['LANG']->getLL('extDumpTables_tables') . "</strong>\n" : '') .
722 implode(LF, $techInfo['tables']) : '') .
723 (is_array($techInfo['static']) ?
724 "\n\n<strong>" . $GLOBALS['LANG']->getLL('extBackup_static_tables') . "</strong>\n" .
725 implode(LF, $techInfo['static']) : '') .
726 (is_array($techInfo['fields']) ?
727 "\n\n<strong>" . $GLOBALS['LANG']->getLL('extInfoArray_additional_fields') . "</strong>\n" .
728 implode('<hr />', $techInfo['fields']) : '')));
729 }
730
731 /**
732 * Double install warning.
733 *
734 * @param string Double-install string, eg. "LG" etc.
735 * @param string Current scope, eg. "L" or "G" or "S"
736 * @return string Message
737 */
738 function extInformationArray_dbInst($dbInst, $current) {
739 if (strlen($dbInst) > 1) {
740 $others = array();
741 for ($a = 0; $a < strlen($dbInst); $a++) {
742 if (substr($dbInst, $a, 1) != $current) {
743 $others[] = '"' . $this->api->typeLabels[substr($dbInst, $a, 1)] . '"';
744 }
745 }
746 return tx_em_Tools::rfw(
747 sprintf($GLOBALS['LANG']->getLL('extInfoArray_double_installation_infotext'),
748 implode(' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:and') . ' ', $others),
749 $this->api->typeLabels[$current]
750 )
751 );
752 } else {
753 return '';
754 }
755 }
756
757
758 /**
759 * Returns help text if applicable.
760 *
761 * @param string Help text key
762 * @return string HTML table cell
763 * @deprecated since TYPO3 4.5, will be removed in TYPO3 4.7
764 */
765 function helpCol($key) {
766 global $BE_USER;
767 if ($BE_USER->uc['edit_showFieldHelp']) {
768 if (empty($key)) {
769 return '<td>&nbsp;</td>';
770 }
771 else {
772 return t3lib_BEfunc::cshItem($this->descrTable, 'emconf_' . $key, $GLOBALS['BACK_PATH'], '<td>|</td>');
773 }
774 }
775 else {
776 return '';
777 }
778 }
779
780 /**
781 * Returns the header column (for the extension details item), and applies help text if available
782 *
783 * @param string field key
784 * @return string HTML ready to go
785 */
786 function headerCol($key) {
787 $headerCol = $GLOBALS['LANG']->getLL('extInfoArray_' . $key);
788 return t3lib_BEfunc::wrapInHelp($this->descrTable, 'emconf_' . $key, $headerCol);
789 }
790 }
791
792 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/sysext/em/classes/extensions/class.tx_em_extensions_details.php'])) {
793 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/sysext/em/classes/extensions/class.tx_em_extensions_details.php']);
794 }
795
796 ?>