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