ee83ebe7d4d1a36d2e11b0dee08e1e036413c144
[Packages/TYPO3.CMS.git] / typo3 / sysext / em / classes / install / class.tx_em_install.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2010 Steffen Kamper (info@sk-typo3.de)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Module: Extension manager, (un-)install extensions
29 *
30 * @author Steffen Kamper <info@sk-typo3.de>
31 */
32
33
34 class tx_em_Install {
35
36 /**
37 * Parent module object
38 *
39 * @var SC_mod_tools_em_index
40 */
41 protected $parentObject;
42
43 /**
44 * Instance of EM API
45 *
46 * @var tx_em_API
47 */
48 protected $api;
49
50 /**
51 *
52 * @var t3lib_install
53 */
54 public $install;
55
56 /**
57 * @var t3lib_install_Sql
58 */
59 protected $installerSql = NULL;
60
61 /**
62 * @var integer
63 */
64 protected $systemInstall = 0; // If "1" then installs in the sysext directory is allowed. Default: 0
65
66 /**
67 * @var boolean
68 */
69 protected $silentMode;
70
71 /**
72 * Constructor
73 *
74 * @param SC_mod_tools_em_index $parentObject
75 */
76 public function __construct($parentObject = NULL) {
77 $GLOBALS['LANG']->includeLLFile(t3lib_extMgm::extPath('em', 'language/locallang.xml'));
78 $this->parentObject = $parentObject;
79 $this->api = t3lib_div::makeInstance('tx_em_API');
80 $this->install = t3lib_div::makeInstance('t3lib_install');
81 $this->installerSql = t3lib_div::makeInstance('t3lib_install_Sql');
82 $this->install->INSTALL = t3lib_div::_GP('TYPO3_INSTALL');
83 $this->systemInstall = isset($GLOBALS['TYPO3_CONF_VARS']['EXT']['allowSystemInstall']) && $GLOBALS['TYPO3_CONF_VARS']['EXT']['allowSystemInstall'];
84 }
85
86 /**
87 * Set silent mode to prevent flashmessages
88 *
89 * @param boolean $silentMode
90 * @return void
91 */
92 public function setSilentMode($silentMode) {
93 $this->silentMode = $silentMode ? TRUE : FALSE;
94 }
95
96 /**
97 * Imports the data of an extension from upload
98 *
99 * @param $uploadedTempFile
100 * @param $location
101 * @param bool $uploadOverwrite
102 * @return array
103 */
104 public function uploadExtensionFile($uploadedTempFile, $location, $uploadOverwrite = FALSE) {
105 $error = '';
106 $fileContent = t3lib_div::getUrl($uploadedTempFile);
107 if (!$fileContent) {
108 return array(
109 'success' => FALSE,
110 'error' => $GLOBALS['LANG']->getLL('ext_import_file_empty')
111 );
112 }
113
114 // Decode file data:
115 $terConnection = t3lib_div::makeInstance('tx_em_Connection_Ter', $this);
116 $fetchData = $terConnection->decodeExchangeData($fileContent);
117 if (is_array($fetchData)) {
118 $extKey = $fetchData[0]['extKey'];
119 if ($extKey) {
120 if (!$uploadOverwrite) {
121 $comingExtPath = tx_em_Tools::typePath($location) . $extKey . '/';
122 if (@is_dir($comingExtPath)) {
123 $error = sprintf($GLOBALS['LANG']->getLL('ext_import_ext_present_no_overwrite'), $comingExtPath) .
124 '<br />' . $GLOBALS['LANG']->getLL('ext_import_ext_present_nothing_done');
125
126 } // ... else go on, install...
127 } // ... else go on, install...
128 } else {
129 $error = $GLOBALS['LANG']->getLL('ext_import_no_key');
130 }
131 } else {
132 $error = sprintf($GLOBALS['LANG']->getLL('ext_import_wrong_file_format'), $fetchData);
133 }
134
135 if ($error) {
136 return array(FALSE, $error);
137 } else {
138 return array(TRUE, $fetchData);
139 }
140
141 }
142
143 /**
144 * Installs an extension.
145 *
146 * @param $fetchData
147 * @param $loc
148 * @param $version
149 * @param $uploadedTempFile
150 * @param $dontDelete
151 * @return mixed|string
152 */
153 public function installExtension($fetchData, $loc, $version, $uploadedTempFile, $dontDelete) {
154 $xmlHandler =& $this->parentObject->xmlHandler;
155 $extensionList =& $this->parentObject->extensionList;
156 $extensionDetails =& $this->parentObject->extensionDetails;
157 $content = '';
158
159 if (tx_em_Tools::importAsType($loc)) {
160 if (is_array($fetchData)) { // There was some data successfully transferred
161 if ($fetchData[0]['extKey'] && is_array($fetchData[0]['FILES'])) {
162 $extKey = $fetchData[0]['extKey'];
163 if (!isset($fetchData[0]['EM_CONF']['constraints'])) {
164 $fetchData[0]['EM_CONF']['constraints'] = $xmlHandler->extensionsXML[$extKey]['versions'][$version]['dependencies'];
165 }
166 $EM_CONF = tx_em_Tools::fixEMCONF($fetchData[0]['EM_CONF']);
167 if (!$EM_CONF['lockType'] || !strcmp($EM_CONF['lockType'], $loc)) {
168 // check dependencies, act accordingly if ext is loaded
169 list($instExtInfo,) = $extensionList->getInstalledExtensions();
170 $depStatus = $this->checkDependencies($extKey, $EM_CONF, $instExtInfo);
171 if (t3lib_extMgm::isLoaded($extKey) && !$depStatus['returnCode']) {
172 $content .= $depStatus['html'];
173 if ($uploadedTempFile) {
174 $content .= '<input type="hidden" name="CMD[alreadyUploaded]" value="' . $uploadedTempFile . '" />';
175 }
176 } else {
177 $res = $this->clearAndMakeExtensionDir($fetchData[0], $loc, $dontDelete);
178 if (is_array($res)) {
179 $extDirPath = trim($res[0]);
180 if ($extDirPath && @is_dir($extDirPath) && substr($extDirPath, -1) == '/') {
181
182 $emConfFile = $extensionDetails->construct_ext_emconf_file($extKey, $EM_CONF);
183 $dirs = tx_em_Tools::extractDirsFromFileList(array_keys($fetchData[0]['FILES']));
184
185 $res = tx_em_Tools::createDirsInPath($dirs, $extDirPath);
186 if (!$res) {
187 $writeFiles = $fetchData[0]['FILES'];
188 $writeFiles['ext_emconf.php']['content'] = $emConfFile;
189 $writeFiles['ext_emconf.php']['content_md5'] = md5($emConfFile);
190
191 // Write files:
192 foreach ($writeFiles as $theFile => $fileData) {
193 t3lib_div::writeFile($extDirPath . $theFile, $fileData['content']);
194 if (!@is_file($extDirPath . $theFile)) {
195 if (!$this->silentMode) {
196 $flashMessage = t3lib_div::makeInstance(
197 't3lib_FlashMessage',
198 sprintf($GLOBALS['LANG']->getLL('ext_import_file_not_created'),
199 $extDirPath . $theFile),
200 '',
201 t3lib_FlashMessage::ERROR
202 );
203 $content .= $flashMessage->render();
204 } else {
205 if (!$this->silentMode) {
206 $flashMessage = t3lib_div::makeInstance(
207 't3lib_FlashMessage',
208 sprintf($GLOBALS['LANG']->getLL('ext_import_file_not_created'), $extDirPath . $theFile),
209 '',
210 t3lib_FlashMessage::ERROR
211 );
212 $content .= $flashMessage->render();
213 } else {
214 $content .= sprintf($GLOBALS['LANG']->getLL('ext_import_file_not_created'),
215 $extDirPath . $theFile) . '<br />';
216 }
217 }
218 } elseif (md5(t3lib_div::getUrl($extDirPath . $theFile)) != $fileData['content_md5']) {
219 $content .= sprintf($GLOBALS['LANG']->getLL('ext_import_file_corrupted'),
220 $extDirPath . $theFile) . '<br />';
221 }
222 }
223
224 t3lib_div::fixPermissions($extDirPath, TRUE);
225
226 // No content, no errors. Create success output here:
227 if (!$content) {
228 $messageContent = sprintf($GLOBALS['LANG']->getLL('ext_import_success_folder'), $extDirPath) . '<br />';
229
230 $uploadSucceed = TRUE;
231
232 // Fix TYPO3_MOD_PATH for backend modules in extension:
233 $modules = t3lib_div::trimExplode(',', $EM_CONF['module'], 1);
234 if (count($modules)) {
235 foreach ($modules as $mD) {
236 $confFileName = $extDirPath . $mD . '/conf.php';
237 if (@is_file($confFileName)) {
238 $messageContent .= tx_em_Tools::writeTYPO3_MOD_PATH($confFileName, $loc, $extKey . '/' . $mD . '/') . '<br />';
239 } else {
240 $messageContent .= sprintf($GLOBALS['LANG']->getLL('ext_import_no_conf_file'),
241 $confFileName) . '<br />';
242 }
243 }
244 }
245 // 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.
246 // But this order of the code works.... (using the empty Array with type, EMCONF and files hereunder).
247
248 // Writing to ext_emconf.php:
249 $sEMD5A = $extensionDetails->serverExtensionMD5array($extKey, array('type' => $loc, 'EM_CONF' => array(), 'files' => array()));
250 $EM_CONF['_md5_values_when_last_written'] = serialize($sEMD5A);
251 $emConfFile = $extensionDetails->construct_ext_emconf_file($extKey, $EM_CONF);
252 t3lib_div::writeFile($extDirPath . 'ext_emconf.php', $emConfFile);
253
254 $messageContent .= 'ext_emconf.php: ' . $extDirPath . 'ext_emconf.php<br />';
255 $messageContent .= $GLOBALS['LANG']->getLL('ext_import_ext_type') . ' ';
256 $messageContent .= $this->api->typeLabels[$loc] . '<br />';
257 $messageContent .= '<br />';
258
259 // Remove cache files:
260 $updateContent = '';
261 if (t3lib_extMgm::isLoaded($extKey)) {
262 if (t3lib_extMgm::removeCacheFiles()) {
263 $messageContent .= $GLOBALS['LANG']->getLL('ext_import_cache_files_removed') . '<br />';
264 }
265
266 list($new_list) = $this->parentObject->extensionList->getInstalledExtensions();
267 $updateContent = $this->updatesForm($extKey, $new_list[$extKey], 1, t3lib_div::linkThisScript(array(
268 'CMD[showExt]' => $extKey,
269 'SET[singleDetails]' => 'info'
270 )));
271 }
272
273 if (!$this->silentMode) {
274 $flashMessage = t3lib_div::makeInstance(
275 't3lib_FlashMessage',
276 $messageContent,
277 $GLOBALS['LANG']->getLL('ext_import_success')
278 );
279 $content = $flashMessage->render();
280 } else {
281 $content = $updateContent;
282 }
283
284
285 // Install / Uninstall:
286 if (!$this->parentObject->CMD['standAlone']) {
287 $content .= '<h3>' . $GLOBALS['LANG']->getLL('ext_import_install_uninstall') . '</h3>';
288 $content .= $new_list[$extKey] ?
289 '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array(
290 'CMD[showExt]' => $extKey,
291 'CMD[remove]' => 1,
292 'CMD[clrCmd]' => 1,
293 'SET[singleDetails]' => 'info'
294 ))) . '">' .
295 tx_em_Tools::removeButton() . ' ' . $GLOBALS['LANG']->getLL('ext_import_uninstall') . '</a>' :
296 '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array(
297 'CMD[showExt]' => $extKey,
298 'CMD[load]' => 1,
299 'CMD[clrCmd]' => 1,
300 'SET[singleDetails]' => 'info'
301 ))) . '">' .
302 tx_em_Tools::installButton() . ' ' . $GLOBALS['LANG']->getLL('ext_import_install') . '</a>';
303 } else {
304 $content = $GLOBALS['LANG']->getLL('ext_import_imported') .
305 '<br /><br />';
306 if ($this->silentMode || t3lib_div::_GP('nodoc')) {
307 $content .= '<a id="closewindow" href="javascript:parent.TYPO3.EM.Tools.closeImportWindow();">' . $GLOBALS['LANG']->getLL('ext_import_close') . '</a>';
308 } else {
309 $content .= '<a href="javascript:opener.top.list.iframe.document.forms[0].submit();window.close();">' .
310 $GLOBALS['LANG']->getLL('ext_import_close_check') . '</a>';
311 }
312
313 }
314 }
315 } else {
316 if (!$this->silentMode) {
317 $flashMessage = t3lib_div::makeInstance(
318 't3lib_FlashMessage',
319 $res,
320 '',
321 t3lib_FlashMessage::ERROR
322 );
323 $content = $flashMessage->render();
324 } else {
325 $content = $res;
326 }
327 }
328 } else {
329 if (!$this->silentMode) {
330 $flashMessage = t3lib_div::makeInstance(
331 't3lib_FlashMessage',
332 sprintf($GLOBALS['LANG']->getLL('ext_import_ext_path_different'), $extDirPath),
333 '',
334 t3lib_FlashMessage::ERROR
335 );
336 $content = $flashMessage->render();
337 } else {
338 $content = sprintf($GLOBALS['LANG']->getLL('ext_import_ext_path_different'), $extDirPath);
339 }
340 }
341 } else {
342 if (!$this->silentMode) {
343 $flashMessage = t3lib_div::makeInstance(
344 't3lib_FlashMessage',
345 $res,
346 '',
347 t3lib_FlashMessage::ERROR
348 );
349 $content = $flashMessage->render();
350 } else {
351 $content = $res;
352 }
353 }
354 }
355 } else {
356 if (!$this->silentMode) {
357 $flashMessage = t3lib_div::makeInstance(
358 't3lib_FlashMessage',
359 sprintf($GLOBALS['LANG']->getLL('ext_import_ext_only_here'),
360 $this->typePaths[$EM_CONF['lockType']], $EM_CONF['lockType']),
361 '',
362 t3lib_FlashMessage::ERROR
363 );
364 $content = $flashMessage->render();
365 } else {
366 $content = sprintf($GLOBALS['LANG']->getLL('ext_import_ext_only_here'),
367 tx_em_Tools::typePath($EM_CONF['lockType']), $EM_CONF['lockType']);
368 }
369 }
370 } else {
371 if (!$this->silentMode) {
372 $flashMessage = t3lib_div::makeInstance(
373 't3lib_FlashMessage',
374 $GLOBALS['LANG']->getLL('ext_import_no_ext_key_files'),
375 '',
376 t3lib_FlashMessage::ERROR
377 );
378 $content = $flashMessage->render();
379 } else {
380 $content = $GLOBALS['LANG']->getLL('ext_import_no_ext_key_files');
381 }
382 }
383 } else {
384 if (!$this->silentMode) {
385 $flashMessage = t3lib_div::makeInstance(
386 't3lib_FlashMessage',
387 sprintf($GLOBALS['LANG']->getLL('ext_import_data_transfer'), $fetchData),
388 '',
389 t3lib_FlashMessage::ERROR
390 );
391 $content = $flashMessage->render();
392 } else {
393 $content = sprintf($GLOBALS['LANG']->getLL('ext_import_data_transfer'), $fetchData);
394 }
395 }
396 } else {
397 if (!$this->silentMode) {
398 $flashMessage = t3lib_div::makeInstance(
399 't3lib_FlashMessage',
400 sprintf($GLOBALS['LANG']->getLL('ext_import_no_install_here'), $this->typePaths[$loc]),
401 '',
402 t3lib_FlashMessage::ERROR
403 );
404 $content = $flashMessage->render();
405 } else {
406 $content = sprintf($GLOBALS['LANG']->getLL('ext_import_no_install_here'), tx_em_Tools::typePath($loc));
407 }
408 }
409
410 return $content;
411 }
412
413 /**
414 *Check extension dependencies
415 *
416 * @param string $extKey
417 * @param array $conf
418 * @param array $instExtInfo
419 * @return array
420 */
421 function checkDependencies($extKey, $conf, $instExtInfo) {
422 $content = '';
423 $depError = FALSE;
424 $depIgnore = FALSE;
425 $msg = array();
426 $depsolver = t3lib_div::_POST('depsolver');
427
428 if (isset($conf['constraints']['depends']) && is_array($conf['constraints']['depends'])) {
429 foreach ($conf['constraints']['depends'] as $depK => $depV) {
430 if ($depsolver['ignore'][$depK]) {
431 $msg[] = '<br />' . sprintf($GLOBALS['LANG']->getLL('checkDependencies_ignored'),
432 $depK) . '
433 <input type="hidden" value="1" name="depsolver[ignore][' . $depK . ']" />';
434 $depIgnore = TRUE;
435 continue;
436 }
437 if ($depK == 'php') {
438 if (!$depV) {
439 continue;
440 }
441 $versionRange = tx_em_Tools::splitVersionRange($depV);
442 $phpv = strstr(PHP_VERSION, '-') ? substr(PHP_VERSION, 0, strpos(PHP_VERSION, '-')) : PHP_VERSION; // Linux distributors like to add suffixes, like in 5.1.2-1. Those must be ignored!
443 if ($versionRange[0] != '0.0.0' && version_compare($phpv, $versionRange[0], '<')) {
444 $msg[] = '<br />' . sprintf($GLOBALS['LANG']->getLL('checkDependencies_php_too_low'),
445 $phpv, $versionRange[0]);
446 $msg[] = '&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" value="1" name="depsolver[ignore][' . $depK . ']" id="checkIgnore_' . $depK . '" />
447 <label for="checkIgnore_' . $depK . '">' . $GLOBALS['LANG']->getLL('checkDependencies_ignore_requirement') . '</label>';
448 $depError = TRUE;
449 continue;
450 } elseif ($versionRange[1] != '0.0.0' && version_compare($phpv, $versionRange[1], '>')) {
451 $msg[] = '<br />' . sprintf($GLOBALS['LANG']->getLL('checkDependencies_php_too_high'),
452 $phpv, $versionRange[1]);
453 $msg[] = '&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" value="1" name="depsolver[ignore][' . $depK . ']" id="checkIgnore_' . $depK . '" />
454 <label for="checkIgnore_' . $depK . '">' . $GLOBALS['LANG']->getLL('checkDependencies_ignore_requirement') . '</label>';
455 $depError = TRUE;
456 continue;
457 }
458
459 } elseif ($depK == 'typo3') {
460 if (!$depV) {
461 continue;
462 }
463
464 // if the current TYPO3 version is a development version (like TYPO3 4.4-dev),
465 // then it should behave like TYPO3 4.4.0
466 $t3version = TYPO3_version;
467 if (stripos($t3version, '-dev')
468 || stripos($t3version, '-alpha')
469 || stripos($t3version, '-beta')
470 || stripos($t3version, '-RC')) {
471 // find the last occurence of "-" and replace that part with a ".0"
472 $t3version = substr($t3version, 0, strrpos($t3version, '-')) . '.0';
473 }
474
475 $versionRange = tx_em_Tools::splitVersionRange($depV);
476 if ($versionRange[0] != '0.0.0' && version_compare($t3version, $versionRange[0], '<')) {
477 $msg[] = '<br />' . sprintf($GLOBALS['LANG']->getLL('checkDependencies_typo3_too_low'),
478 $t3version, $versionRange[0]);
479 $msg[] = '&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" value="1" name="depsolver[ignore][' . $depK . ']" id="checkIgnore_' . $depK . '" />
480 <label for="checkIgnore_' . $depK . '">' . $GLOBALS['LANG']->getLL('checkDependencies_ignore_requirement') . '</label>';
481 $depError = TRUE;
482 continue;
483 } elseif ($versionRange[1] != '0.0.0' && version_compare($t3version, $versionRange[1], '>')) {
484 $msg[] = '<br />' . sprintf($GLOBALS['LANG']->getLL('checkDependencies_typo3_too_high'),
485 $t3version, $versionRange[1]);
486 $msg[] = '&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" value="1" name="depsolver[ignore][' . $depK . ']" id="checkIgnore_' . $depK . '" />
487 <label for="checkIgnore_' . $depK . '">' . $GLOBALS['LANG']->getLL('checkDependencies_ignore_requirement') . '</label>';
488 $depError = TRUE;
489 continue;
490 }
491 } elseif (strlen($depK) && !t3lib_extMgm::isLoaded($depK)) { // strlen check for braindead empty dependencies coming from extensions...
492 if (!isset($instExtInfo[$depK])) {
493 $msg[] = '<br />' . sprintf($GLOBALS['LANG']->getLL('checkDependencies_ext_not_available'),
494 $depK);
495 $msg[] = '&nbsp;&nbsp;&nbsp;&nbsp;' . t3lib_iconWorks::getSpriteIcon('actions-system-extension-import', array('title' => $GLOBALS['LANG']->getLL('checkDependencies_import_ext'))) . '&nbsp;
496 <a href="' . t3lib_div::linkThisUrl($this->parentObject->script, array(
497 'CMD[importExt]' => $depK,
498 'CMD[loc]' => 'L',
499 'CMD[standAlone]' => 1
500 )) . '" target="_blank">' . $GLOBALS['LANG']->getLL('checkDependencies_import_now') . '</a>';
501 $msg[] = '&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" value="1" name="depsolver[ignore][' . $depK . ']" id="checkIgnore_' . $depK . '" />
502 <label for="checkIgnore_' . $depK . '">' . $GLOBALS['LANG']->getLL('checkDependencies_ignore_ext_requirement') . '</label>';
503 } else {
504 $msg[] = '<br />' . sprintf($GLOBALS['LANG']->getLL('checkDependencies_ext_not_installed'),
505 $depK, $instExtInfo[$depK]['EM_CONF']['title']);
506 $msg[] = '&nbsp;&nbsp;&nbsp;&nbsp;' . tx_em_Tools::installButton() . '&nbsp;
507 <a href="' . t3lib_div::linkThisUrl($this->parentObject->script, array(
508 'CMD[showExt]' => $depK,
509 'CMD[load]' => 1,
510 'CMD[clrCmd]' => 1,
511 'CMD[standAlone]' => 1,
512 'SET[singleDetails]' => 'info'
513 )) .
514 '" target="_blank">' . $GLOBALS['LANG']->getLL('checkDependencies_install_now') . '</a>';
515 $msg[] = '&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" value="1" name="depsolver[ignore][' . $depK . ']" id="checkIgnore_' . $depK . '" />
516 <label for="checkIgnore_' . $depK . '">' . $GLOBALS['LANG']->getLL('checkDependencies_ignore_ext_requirement') . '</label>';
517 }
518 $depError = TRUE;
519 } else {
520 $versionRange = tx_em_Tools::splitVersionRange($depV);
521 if ($versionRange[0] != '0.0.0' && version_compare($instExtInfo[$depK]['EM_CONF']['version'], $versionRange[0], '<')) {
522 $msg[] = '<br />' . sprintf($GLOBALS['LANG']->getLL('checkDependencies_ext_too_low'),
523 $depK, $instExtInfo[$depK]['EM_CONF']['version'], $versionRange[0]);
524 $msg[] = '&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" value="1" name="depsolver[ignore][' . $depK . ']" id="checkIgnore_' . $depK . '" />
525 <label for="checkIgnore_' . $depK . '">' . $GLOBALS['LANG']->getLL('checkDependencies_ignore_requirement') . '</label>';
526 $depError = TRUE;
527 continue;
528 } elseif ($versionRange[1] != '0.0.0' && version_compare($instExtInfo[$depK]['EM_CONF']['version'], $versionRange[1], '>')) {
529 $msg[] = '<br />' . sprintf($GLOBALS['LANG']->getLL('checkDependencies_ext_too_high'),
530 $depK, $instExtInfo[$depK]['EM_CONF']['version'], $versionRange[1]);
531 $msg[] = '&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" value="1" name="depsolver[ignore][' . $depK . ']" id="checkIgnore_' . $depK . '" />
532 <label for="checkIgnore_' . $depK . '">' . $GLOBALS['LANG']->getLL('checkDependencies_ignore_requirement') . '</label>';
533 $depError = TRUE;
534 continue;
535 }
536 }
537 }
538 }
539
540 if (($depError || $depIgnore) && $this->parentObject instanceof SC_mod_tools_em_index) {
541 $content .= $this->parentObject->doc->section(
542 $GLOBALS['LANG']->getLL('removeExtFromList_dependency_error'),
543 implode('<br />', $msg), 0, 1, 2
544 );
545 }
546
547 // Check conflicts with other extensions:
548 $conflictError = FALSE;
549 $conflictIgnore = FALSE;
550 $msg = array();
551
552 if (isset($conf['constraints']['conflicts']) && is_array($conf['constraints']['conflicts'])) {
553 foreach ((array) $conf['constraints']['conflicts'] as $conflictK => $conflictV) {
554 if ($depsolver['ignore'][$conflictK]) {
555 $msg[] = '<br />' . sprintf($GLOBALS['LANG']->getLL('checkDependencies_conflict_ignored'),
556 $conflictK) . '
557 <input type="hidden" value="1" name="depsolver[ignore][' . $conflictK . ']" />';
558 $conflictIgnore = TRUE;
559 continue;
560 }
561 if (t3lib_extMgm::isLoaded($conflictK)) {
562 $versionRange = tx_em_Tools::splitVersionRange($conflictV);
563 if ($versionRange[0] != '0.0.0' && version_compare($instExtInfo[$conflictK]['EM_CONF']['version'], $versionRange[0], '<')) {
564 continue;
565 }
566 elseif ($versionRange[1] != '0.0.0' && version_compare($instExtInfo[$conflictK]['EM_CONF']['version'], $versionRange[1], '>')) {
567 continue;
568 }
569 $msg[] = sprintf($GLOBALS['LANG']->getLL('checkDependencies_conflict_remove'),
570 $extKey, $conflictK, $instExtInfo[$conflictK]['EM_CONF']['title'], $conflictK, $extKey);
571 $msg[] = '&nbsp;&nbsp;&nbsp;&nbsp;' . tx_em_Tools::removeButton() . '&nbsp;
572 <a href="' . htmlspecialchars(t3lib_div::linkThisScript(array(
573 'CMD[showExt]' => $conflictK,
574 'CMD[remove]' => 1,
575 'CMD[clrCmd]' => 1,
576 'CMD[standAlone]' => 1,
577 'SET[singleDetails]' => 'info'
578 ))) .
579 '" target="_blank">' . $GLOBALS['LANG']->getLL('checkDependencies_remove_now') . '</a>';
580 $msg[] = '&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" value="1" name="depsolver[ignore][' . $conflictK . ']" id="checkIgnore_' . $conflictK . '" />
581 <label for="checkIgnore_' . $conflictK . '">' . $GLOBALS['LANG']->getLL('checkDependencies_ignore_conflict') . '</label>';
582 $conflictError = TRUE;
583 }
584 }
585 }
586 if ($conflictError || $conflictIgnore) {
587 $content .= $this->parentObject->doc->section(
588 $GLOBALS['LANG']->getLL('checkDependencies_conflict_error'), implode('<br />', $msg), 0, 1, 2
589 );
590 }
591
592 // Check suggests on other extensions:
593 if (isset($conf['constraints']['suggests']) && is_array($conf['constraints']['suggests'])) {
594 $suggestion = FALSE;
595 $suggestionIgnore = FALSE;
596 $msg = array();
597 foreach ($conf['constraints']['suggests'] as $suggestK => $suggestV) {
598 if ($depsolver['ignore'][$suggestK]) {
599 $msg[] = '<br />' . sprintf($GLOBALS['LANG']->getLL('checkDependencies_suggestion_ignored'),
600 $suggestK) . '
601 <input type="hidden" value="1" name="depsolver[ignore][' . $suggestK . ']" />';
602 $suggestionIgnore = TRUE;
603 continue;
604 }
605 if (!t3lib_extMgm::isLoaded($suggestK)) {
606 if (!isset($instExtInfo[$suggestK])) {
607 $msg[] = sprintf($GLOBALS['LANG']->getLL('checkDependencies_suggest_import'),
608 $suggestK);
609 $msg[] = '&nbsp;&nbsp;&nbsp;&nbsp;' . t3lib_iconWorks::getSpriteIcon('actions-system-extension-import', array('title' => $GLOBALS['LANG']->getLL('checkDependencies_import_ext'))) . '&nbsp;
610 <a href="' . t3lib_div::linkThisScript(array(
611 'CMD[importExt]' => $suggestK,
612 'CMD[loc]' => 'L',
613 'CMD[standAlone]' => 1
614 )) . '" target="_blank">' . $GLOBALS['LANG']->getLL('checkDependencies_import_now') . '</a>';
615 $msg[] = '&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" value="1" name="depsolver[ignore][' . $suggestK . ']" id="checkIgnore_' . $suggestK . '" />
616 <label for="checkIgnore_' . $suggestK . '">' . $GLOBALS['LANG']->getLL('checkDependencies_ignore_suggestion') . '</label>';
617 } else {
618 $msg[] = sprintf($GLOBALS['LANG']->getLL('checkDependencies_suggest_installation'),
619 $suggestK, $instExtInfo[$suggestK]['EM_CONF']['title']);
620 $msg[] = '&nbsp;&nbsp;&nbsp;&nbsp;' . tx_em_Tools::installButton() . '&nbsp;
621 <a href="' . htmlspecialchars(t3lib_div::linkThisScript(array(
622 'CMD[showExt]' => $suggestK,
623 'CMD[load]' => 1,
624 'CMD[clrCmd]' => 1,
625 'CMD[standAlone]' => 1,
626 'SET[singleDetails]' => 'info'
627 ))) .
628 '" target="_blank">' . $GLOBALS['LANG']->getLL('checkDependencies_install_now') . '</a>';
629 $msg[] = '&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" value="1" name="depsolver[ignore][' . $suggestK . ']" id="checkIgnore_' . $suggestK . '" />
630 <label for="checkIgnore_' . $suggestK . '">' . $GLOBALS['LANG']->getLL('checkDependencies_ignore_suggestion') . '</label>';
631 }
632 $suggestion = TRUE;
633 }
634 }
635 if ($suggestion || $suggestionIgnore) {
636 $content .= $this->parentObject->doc->section(
637 sprintf($GLOBALS['LANG']->getLL('checkDependencies_exts_suggested_by_ext'), $extKey),
638 implode('<br />', $msg), 0, 1, 1
639 );
640 }
641 }
642
643 if ($depError || $conflictError || $suggestion) {
644 foreach ($this->parentObject->CMD as $k => $v) {
645 $content .= '<input type="hidden" name="CMD[' . $k . ']" value="' . $v . '" />';
646 }
647 $content .= '<br /><br /><input type="submit" value="' . $GLOBALS['LANG']->getLL('checkDependencies_try_again') . '" />';
648
649 if (t3lib_div::_GP('nodoc')) {
650 $content .= '<input type="hidden" name="nodoc" value="1" />';
651 }
652
653 return array(
654 'returnCode' => FALSE,
655 'html' => '<form action="' . $this->parentObject->script . '" method="post" name="depform">' . $content . '</form>');
656 }
657
658 return array(
659 'returnCode' => TRUE
660 );
661 }
662
663
664 /**
665 * Delete extension from the file system
666 *
667 * @param string Extension key
668 * @param array Extension info array
669 * @return string Returns message string about the status of the operation
670 */
671 function extDelete($extKey, $extInfo, $command) {
672 $content = '';
673 $absPath = tx_em_Tools::getExtPath($extKey, $extInfo['type']);
674 if (t3lib_extMgm::isLoaded($extKey)) {
675 return $GLOBALS['LANG']->getLL('extDelete_ext_active');
676 } elseif (!tx_em_Tools::deleteAsType($extInfo['type'])) {
677 return sprintf($GLOBALS['LANG']->getLL('extDelete_wrong_scope'),
678 $this->api->typeLabels[$extInfo['type']]
679 );
680 } elseif (t3lib_div::inList('G,L', $extInfo['type'])) {
681 if ($command['doDelete'] && !strcmp($absPath, urldecode($command['absPath']))) {
682 $res = $this->removeExtDirectory($absPath);
683 if ($res) {
684 if (!$this->silentMode) {
685 $flashMessage = t3lib_div::makeInstance(
686 't3lib_FlashMessage',
687 nl2br($res),
688 sprintf($GLOBALS['LANG']->getLL('extDelete_remove_dir_failed'), $absPath),
689 t3lib_FlashMessage::ERROR
690 );
691 return $flashMessage->render();
692 }
693 return '';
694 } else {
695 if (!$this->silentMode) {
696 $flashMessage = t3lib_div::makeInstance(
697 't3lib_FlashMessage',
698 sprintf($GLOBALS['LANG']->getLL('extDelete_removed'), $absPath),
699 $GLOBALS['LANG']->getLL('extDelete_removed_header'),
700 t3lib_FlashMessage::OK
701 );
702 return $flashMessage->render();
703 }
704 return '';
705 }
706 } else {
707 $areYouSure = $GLOBALS['LANG']->getLL('extDelete_sure');
708 $deleteFromServer = $GLOBALS['LANG']->getLL('extDelete_from_server');
709 $onClick = "if (confirm('$areYouSure')) {window.location.href='" . t3lib_div::linkThisScript(array(
710 'CMD[showExt]' => $extKey,
711 'CMD[doDelete]' => 1,
712 'CMD[absPath]' => rawurlencode($absPath)
713 )) . "';}";
714 $content .= '<a class="t3-link deleteLink" href="#" onclick="' . htmlspecialchars($onClick) .
715 ' return false;"><strong>' . $deleteFromServer . '</strong> ' .
716 sprintf($GLOBALS['LANG']->getLL('extDelete_from_location'),
717 $this->api->typeLabels[$extInfo['type']],
718 substr($absPath, strlen(PATH_site))
719 ) . '</a>';
720 $content .= '<br /><br />' . $GLOBALS['LANG']->getLL('extDelete_backup');
721 return $content;
722 }
723 } else {
724 return $GLOBALS['LANG']->getLL('extDelete_neither_global_nor_local');
725 }
726 }
727
728 /**
729 * Removes the extension directory (including content)
730 *
731 * @param string Extension directory to remove (with trailing slash)
732 * @param boolean If set, will leave the extension directory
733 * @return boolean False on success, otherwise error string.
734 */
735 function removeExtDirectory($removePath, $removeContentOnly = 0) {
736 $errors = array();
737 if (@is_dir($removePath) && substr($removePath, -1) == '/' && (
738 t3lib_div::isFirstPartOfStr($removePath, tx_em_Tools::typePath('G')) ||
739 t3lib_div::isFirstPartOfStr($removePath, tx_em_Tools::typePath('L')) ||
740 (t3lib_div::isFirstPartOfStr($removePath, tx_em_Tools::typePath('S')) && $this->systemInstall) ||
741 t3lib_div::isFirstPartOfStr($removePath, PATH_site . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] . '_temp_/')) // Playing-around directory...
742 ) {
743
744 // All files in extension directory:
745 $fileArr = t3lib_div::getAllFilesAndFoldersInPath(array(), $removePath, '', 1);
746 if (is_array($fileArr)) {
747
748 // Remove files in dirs:
749 foreach ($fileArr as $removeFile) {
750 if (!@is_dir($removeFile)) {
751 if (@is_file($removeFile) && t3lib_div::isFirstPartOfStr($removeFile, $removePath) && strcmp($removeFile, $removePath)) { // ... we are very paranoid, so we check what cannot go wrong: that the file is in fact within the prefix path!
752 @unlink($removeFile);
753 clearstatcache();
754 if (@is_file($removeFile)) {
755 $errors[] = sprintf($GLOBALS['LANG']->getLL('rmExtDir_could_not_be_deleted'),
756 $removeFile
757 );
758 }
759 } else {
760 $errors[] = sprintf($GLOBALS['LANG']->getLL('rmExtDir_error_file'),
761 $removeFile, $removePath
762 );
763 }
764 }
765 }
766
767 // Remove directories:
768 $remDirs = tx_em_Tools::extractDirsFromFileList(t3lib_div::removePrefixPathFromList($fileArr, $removePath));
769 $remDirs = array_reverse($remDirs); // Must delete outer directories first...
770 foreach ($remDirs as $removeRelDir) {
771 $removeDir = $removePath . $removeRelDir;
772 if (@is_dir($removeDir)) {
773 @rmdir($removeDir);
774 clearstatcache();
775 if (@is_dir($removeDir)) {
776 $errors[] = sprintf($GLOBALS['LANG']->getLL('rmExtDir_error_files_left'),
777 $removeDir
778 );
779 }
780 } else {
781 $errors[] = sprintf($GLOBALS['LANG']->getLL('rmExtDir_error_no_dir'),
782 $removeDir
783 );
784 }
785 }
786
787 // If extension dir should also be removed:
788 if (!$removeContentOnly) {
789 @rmdir($removePath);
790 clearstatcache();
791 if (@is_dir($removePath)) {
792 $errors[] = sprintf($GLOBALS['LANG']->getLL('rmExtDir_error_folders_left'),
793 $removePath
794 );
795 }
796 }
797 } else {
798 $errors[] = $GLOBALS['LANG']->getLL('rmExtDir_error') . ' ' . $fileArr;
799 }
800 } else {
801 $errors[] = $GLOBALS['LANG']->getLL('rmExtDir_error_unallowed_path') . ' ' . $removePath;
802 }
803
804 // Return errors if any:
805 return implode(LF, $errors);
806 }
807
808 /**
809 * Validates the database according to extension requirements
810 * Prints form for changes if any. If none, returns blank. If an update is ordered, empty is returned as well.
811 * DBAL compliant (based on Install Tool code)
812 *
813 * @param string Extension key
814 * @param array Extension information array
815 * @param boolean If TRUE, returns array with info.
816 * @return mixed If $infoOnly, returns array with information. Otherwise performs update.
817 */
818 function checkDBupdates($extKey, $extInfo, $infoOnly = 0) {
819
820
821 $dbStatus = array();
822 $content = '';
823
824 // Updating tables and fields?
825 if (is_array($extInfo['files']) && in_array('ext_tables.sql', $extInfo['files'])) {
826 $path = tx_em_Tools::getExtPath($extKey, $extInfo['type']);
827 $fileContent = t3lib_div::getUrl($path . 'ext_tables.sql');
828
829 $FDfile = $this->installerSql->getFieldDefinitions_fileContent($fileContent);
830 if (count($FDfile)) {
831 $FDdb = $this->installerSql->getFieldDefinitions_database(TYPO3_db);
832 $diff = $this->installerSql->getDatabaseExtra($FDfile, $FDdb);
833 $update_statements = $this->installerSql->getUpdateSuggestions($diff);
834
835 $dbStatus['structure']['tables_fields'] = $FDfile;
836 $dbStatus['structure']['diff'] = $diff;
837
838 // Updating database...
839 if (!$infoOnly && is_array($this->install->INSTALL['database_update'])) {
840 $this->installerSql->performUpdateQueries($update_statements['add'], $this->install->INSTALL['database_update']);
841 $this->installerSql->performUpdateQueries($update_statements['change'], $this->install->INSTALL['database_update']);
842 $this->installerSql->performUpdateQueries($update_statements['create_table'], $this->install->INSTALL['database_update']);
843 } else {
844 $content .= $this->install->generateUpdateDatabaseForm_checkboxes(
845 $update_statements['add'], $GLOBALS['LANG']->getLL('checkDBupdates_add_fields'));
846 $content .= $this->install->generateUpdateDatabaseForm_checkboxes(
847 $update_statements['change'], $GLOBALS['LANG']->getLL('checkDBupdates_changing_fields'), 1, 0, $update_statements['change_currentValue']);
848 $content .= $this->install->generateUpdateDatabaseForm_checkboxes(
849 $update_statements['create_table'], $GLOBALS['LANG']->getLL('checkDBupdates_add_tables'));
850 }
851 }
852 }
853
854 // Importing static tables?
855 if (is_array($extInfo['files']) && in_array('ext_tables_static+adt.sql', $extInfo['files'])) {
856 $fileContent = t3lib_div::getUrl(tx_em_Tools::getExtPath($extKey, $extInfo['type']) . 'ext_tables_static+adt.sql');
857
858 $statements = $this->installerSql->getStatementarray($fileContent, 1);
859 list($statements_table, $insertCount) = $this->installerSql->getCreateTables($statements, 1);
860
861 // Execute import of static table content:
862 if (!$infoOnly && is_array($this->install->INSTALL['database_import'])) {
863
864 // Traverse the tables
865 foreach ($this->install->INSTALL['database_import'] as $table => $md5str) {
866 if ($md5str == md5($statements_table[$table])) {
867 $GLOBALS['TYPO3_DB']->admin_query('DROP TABLE IF EXISTS ' . $table);
868 $GLOBALS['TYPO3_DB']->admin_query($statements_table[$table]);
869
870 if ($insertCount[$table]) {
871 $statements_insert = $this->installerSql->getTableInsertStatements($statements, $table);
872
873 foreach ($statements_insert as $v) {
874 $GLOBALS['TYPO3_DB']->admin_query($v);
875 }
876 }
877 }
878 }
879 } else {
880 $whichTables = $this->installerSql->getListOfTables();
881 if (count($statements_table)) {
882 $out = '';
883 foreach ($statements_table as $table => $definition) {
884 $exist = isset($whichTables[$table]);
885
886 $dbStatus['static'][$table]['exists'] = $exist;
887 $dbStatus['static'][$table]['count'] = $insertCount[$table];
888
889 $out .= '<tr>
890 <td><input type="checkbox" id="check_table_' . $table . '" name="TYPO3_INSTALL[database_import][' . $table . ']" checked="checked" value="' . md5($definition) . '" /></td>
891 <td><strong><label for="check_table_' . $table . '">' . $table . '</label></strong></td>
892 <td><img src="clear.gif" width="10" height="1" alt="" /></td>
893 <td nowrap="nowrap">' .
894 ($insertCount[$table] ?
895 $GLOBALS['LANG']->getLL('checkDBupdates_rows') . ' ' . $insertCount[$table]
896 : '') .
897 '</td>
898 <td><img src="clear.gif" width="10" height="1" alt="" /></td>
899 <td nowrap="nowrap">' .
900 ($exist ?
901 t3lib_iconWorks::getSpriteIcon('status-dialog-warning') .
902 $GLOBALS['LANG']->getLL('checkDBupdates_table_exists')
903 : '') .
904 '</td>
905 </tr>';
906 }
907 $content .= '
908 <br />
909 <h3>' . $GLOBALS['LANG']->getLL('checkDBupdates_import_static_data') . '</h3>
910 <table border="0" cellpadding="0" cellspacing="0">' . $out . '</table>
911 ';
912 }
913 }
914 }
915
916 // Return array of information if $infoOnly, otherwise content.
917 return $infoOnly ? $dbStatus : $content;
918 }
919
920 /**
921 * Removes the current extension of $type and creates the base folder for the new one (which is going to be imported)
922 *
923 * @param array Data for imported extension
924 * @param string Extension installation scope (L,G,S)
925 * @param boolean If set, nothing will be deleted (neither directory nor files)
926 * @return mixed Returns array on success (with extension directory), otherwise an error string.
927 */
928 function clearAndMakeExtensionDir($importedData, $type, $dontDelete = 0) {
929 if (!$importedData['extKey']) {
930 return $GLOBALS['LANG']->getLL('clearMakeExtDir_no_ext_key');
931 }
932
933 // Setting install path (L, G, S or fileadmin/_temp_/)
934 $path = '';
935 switch ((string) $type) {
936 case 'G':
937 case 'L':
938 $path = tx_em_Tools::typePath($type);
939 $suffix = '';
940
941 // Creates the typo3conf/ext/ directory if it does NOT already exist:
942 if ((string) $type == 'L' && !@is_dir($path)) {
943 t3lib_div::mkdir($path);
944 }
945 break;
946 default:
947 if ($this->systemInstall && (string) $type == 'S') {
948 $path = tx_em_Tools::typePath($type);
949 $suffix = '';
950 } else {
951 $path = PATH_site . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] . '_temp_/';
952 $suffix = '_' . date('dmy-His');
953 }
954 break;
955 }
956
957 // If the install path is OK...
958 if ($path && @is_dir($path)) {
959
960 // Set extension directory:
961 $extDirPath = $path . $importedData['extKey'] . $suffix . '/';
962
963 // Install dir was found, remove it then:
964 if (@is_dir($extDirPath)) {
965 if ($dontDelete) {
966 return array($extDirPath);
967 }
968 $res = $this->removeExtDirectory($extDirPath);
969 if ($res) {
970 if (!$this->silentMode) {
971 $flashMessage = t3lib_div::makeInstance(
972 't3lib_FlashMessage',
973 nl2br($res),
974 sprintf($GLOBALS['LANG']->getLL('clearMakeExtDir_could_not_remove_dir'), $extDirPath),
975 t3lib_FlashMessage::ERROR
976 );
977 return $flashMessage->render();
978 }
979 return '';
980 }
981 }
982
983 // We go create...
984 t3lib_div::mkdir($extDirPath);
985 if (!is_dir($extDirPath)) {
986 return sprintf($GLOBALS['LANG']->getLL('clearMakeExtDir_could_not_create_dir'),
987 $extDirPath);
988 }
989 return array($extDirPath);
990 } else {
991 return sprintf($GLOBALS['LANG']->getLL('clearMakeExtDir_no_dir'),
992 $path);
993 }
994 }
995
996
997 /*******************************
998 *
999 * Extension analyzing (detailed information)
1000 *
1001 ******************************/
1002
1003 /**
1004 * Perform a detailed, technical analysis of the available extension on server!
1005 * Includes all kinds of verifications
1006 * Takes some time to process, therfore use with care, in particular in listings.
1007 *
1008 * @param string Extension key
1009 * @param array Extension information
1010 * @param boolean If set, checks for validity of classes etc.
1011 * @return array Information in an array.
1012 */
1013 function makeDetailedExtensionAnalysis($extKey, $extInfo, $validity = 0) {
1014
1015 // Get absolute path of the extension
1016 $absPath = tx_em_Tools::getExtPath($extKey, $extInfo['type']);
1017 $extensionDetails = t3lib_div::makeInstance('tx_em_Extensions_Details', $this);
1018 $infoArray = array();
1019
1020 $table_class_prefix = substr($extKey, 0, 5) == 'user_' ? 'user_' : 'tx_' . str_replace('_', '', $extKey) . '_';
1021 $module_prefix = substr($extKey, 0, 5) == 'user_' ? 'u' : 'tx' . str_replace('_', '', $extKey);
1022
1023 // Database status:
1024 $dbInfo = $this->checkDBupdates($extKey, $extInfo, 1);
1025
1026 // Database structure required:
1027 if (is_array($dbInfo['structure']['tables_fields'])) {
1028 $modify_tables = t3lib_div::trimExplode(',', $extInfo['EM_CONF']['modify_tables'], 1);
1029 $infoArray['dump_tf'] = array();
1030
1031 foreach ($dbInfo['structure']['tables_fields'] as $tN => $d) {
1032 if (in_array($tN, $modify_tables)) {
1033 $infoArray['fields'][] = $tN . ': <i>' .
1034 (is_array($d['fields']) ? implode(', ', array_keys($d['fields'])) : '') .
1035 (is_array($d['keys']) ?
1036 ' + ' . count($d['keys']) . ' ' . $GLOBALS['LANG']->getLL('detailedExtAnalysis_keys') : '') .
1037 '</i>';
1038 if (is_array($d['fields'])) {
1039 foreach ($d['fields'] as $fN => $value) {
1040 $infoArray['dump_tf'][] = $tN . '.' . $fN;
1041 if (!t3lib_div::isFirstPartOfStr($fN, $table_class_prefix)) {
1042 $infoArray['NSerrors']['fields'][$fN] = $fN;
1043 } else {
1044 $infoArray['NSok']['fields'][$fN] = $fN;
1045 }
1046 }
1047 }
1048 if (is_array($d['keys'])) {
1049 foreach ($d['keys'] as $fN => $value) {
1050 $infoArray['dump_tf'][] = $tN . '.KEY:' . $fN;
1051 }
1052 }
1053 } else {
1054 $infoArray['dump_tf'][] = $tN;
1055 $infoArray['tables'][] = $tN;
1056 if (!t3lib_div::isFirstPartOfStr($tN, $table_class_prefix)) {
1057 $infoArray['NSerrors']['tables'][$tN] = $tN;
1058 } else {
1059 $infoArray['NSok']['tables'][$tN] = $tN;
1060 }
1061 }
1062 }
1063 if (count($dbInfo['structure']['diff']['diff']) || count($dbInfo['structure']['diff']['extra'])) {
1064 $msg = array();
1065 if (count($dbInfo['structure']['diff']['diff'])) {
1066 $msg[] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_tables_are_missing');
1067 }
1068 if (count($dbInfo['structure']['diff']['extra'])) {
1069 $msg[] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_tables_are_of_wrong_type');
1070 }
1071 $infoArray['tables_error'] = 1;
1072 if (t3lib_extMgm::isLoaded($extKey)) {
1073 $infoArray['errors'][] = sprintf($GLOBALS['LANG']->getLL('detailedExtAnalysis_tables_are'),
1074 implode(' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:and') . ' ', $msg)
1075 );
1076 }
1077 }
1078 }
1079
1080 // Static tables?
1081 if (is_array($dbInfo['static'])) {
1082 $infoArray['static'] = array_keys($dbInfo['static']);
1083
1084 foreach ($dbInfo['static'] as $tN => $d) {
1085 if (!$d['exists']) {
1086 $infoArray['static_error'] = 1;
1087 if (t3lib_extMgm::isLoaded($extKey)) {
1088 $infoArray['errors'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_static_tables_missing');
1089 }
1090 if (!t3lib_div::isFirstPartOfStr($tN, $table_class_prefix)) {
1091 $infoArray['NSerrors']['tables'][$tN] = $tN;
1092 } else {
1093 $infoArray['NSok']['tables'][$tN] = $tN;
1094 }
1095 }
1096 }
1097 }
1098
1099 // Backend Module-check:
1100 $knownModuleList = t3lib_div::trimExplode(',', $extInfo['EM_CONF']['module'], 1);
1101 foreach ($knownModuleList as $mod) {
1102 if (@is_dir($absPath . $mod)) {
1103 if (@is_file($absPath . $mod . '/conf.php')) {
1104 $confFileInfo = $extensionDetails->modConfFileAnalysis($absPath . $mod . '/conf.php');
1105 if (is_array($confFileInfo['TYPO3_MOD_PATH'])) {
1106 $shouldBePath = tx_em_Tools::typeRelPath($extInfo['type']) . $extKey . '/' . $mod . '/';
1107 if (strcmp($confFileInfo['TYPO3_MOD_PATH'][1][1], $shouldBePath)) {
1108 $infoArray['errors'][] = sprintf($GLOBALS['LANG']->getLL('detailedExtAnalysis_wrong_mod_path'),
1109 $confFileInfo['TYPO3_MOD_PATH'][1][1],
1110 $shouldBePath
1111 );
1112 }
1113 } else {
1114 // It seems like TYPO3_MOD_PATH and therefore also this warning is no longer needed.
1115 // $infoArray['errors'][] = 'No definition of TYPO3_MOD_PATH constant found inside!';
1116 }
1117 if (is_array($confFileInfo['MCONF_name'])) {
1118 $mName = $confFileInfo['MCONF_name'][1][1];
1119 $mNameParts = explode('_', $mName);
1120 $infoArray['moduleNames'][] = $mName;
1121 if (!t3lib_div::isFirstPartOfStr($mNameParts[0], $module_prefix) &&
1122 (!$mNameParts[1] || !t3lib_div::isFirstPartOfStr($mNameParts[1], $module_prefix))) {
1123 $infoArray['NSerrors']['modname'][] = $mName;
1124 } else {
1125 $infoArray['NSok']['modname'][] = $mName;
1126 }
1127 } else {
1128 $infoArray['errors'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_mconf_missing');
1129 }
1130 } else {
1131 $infoArray['errors'][] = sprintf($GLOBALS['LANG']->getLL('detailedExtAnalysis_be_module_conf_missing'),
1132 $mod . '/conf.php'
1133 );
1134 }
1135 } else {
1136 $infoArray['errors'][] = sprintf($GLOBALS['LANG']->getLL('detailedExtAnalysis_module_folder_missing'),
1137 $mod . '/'
1138 );
1139 }
1140 }
1141 $dirs = t3lib_div::get_dirs($absPath);
1142 if (is_array($dirs)) {
1143 reset($dirs);
1144 while (list(, $mod) = each($dirs)) {
1145 if (!in_array($mod, $knownModuleList) && @is_file($absPath . $mod . '/conf.php')) {
1146 $confFileInfo = $extensionDetails->modConfFileAnalysis($absPath . $mod . '/conf.php');
1147 if (is_array($confFileInfo)) {
1148 $infoArray['errors'][] = sprintf($GLOBALS['LANG']->getLL('detailedExtAnalysis_unconfigured_module'),
1149 $mod . '/conf.php'
1150 );
1151 }
1152 }
1153 }
1154 }
1155
1156 // ext_tables.php:
1157 if (@is_file($absPath . 'ext_tables.php')) {
1158 $content = t3lib_div::getUrl($absPath . 'ext_tables.php');
1159 if (stristr($content, 't3lib_extMgm::addModule')) {
1160 $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_module');
1161 }
1162 if (stristr($content, 't3lib_extMgm::insertModuleFunction')) {
1163 $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_module_and_more');
1164 }
1165 if (stristr($content, 't3lib_div::loadTCA')) {
1166 $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_loadTCA');
1167 }
1168 if (stristr($content, '$TCA[')) {
1169 $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_TCA');
1170 }
1171 if (stristr($content, 't3lib_extMgm::addPlugin')) {
1172 $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_plugin');
1173 }
1174 }
1175
1176 // ext_localconf.php:
1177 if (@is_file($absPath . 'ext_localconf.php')) {
1178 $content = t3lib_div::getUrl($absPath . 'ext_localconf.php');
1179 if (stristr($content, 't3lib_extMgm::addPItoST43')) {
1180 $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_plugin_st43');
1181 }
1182 if (stristr($content, 't3lib_extMgm::addPageTSConfig')) {
1183 $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_page_ts');
1184 }
1185 if (stristr($content, 't3lib_extMgm::addUserTSConfig')) {
1186 $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_user_ts');
1187 }
1188 if (stristr($content, 't3lib_extMgm::addTypoScriptSetup')) {
1189 $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_ts_setup');
1190 }
1191 if (stristr($content, 't3lib_extMgm::addTypoScriptConstants')) {
1192 $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_ts_constants');
1193 }
1194 }
1195
1196 if (@is_file($absPath . 'ext_typoscript_constants.txt')) {
1197 $infoArray['TSfiles'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_constants');
1198 }
1199 if (@is_file($absPath . 'ext_typoscript_setup.txt')) {
1200 $infoArray['TSfiles'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_setup');
1201 }
1202 if (@is_file($absPath . 'ext_conf_template.txt')) {
1203 $infoArray['conf'] = 1;
1204 }
1205
1206 // Classes:
1207 if ($validity) {
1208 $filesInside = tx_em_Tools::getClassIndexLocallangFiles($absPath, $table_class_prefix, $extKey);
1209 if (is_array($filesInside['errors'])) {
1210 $infoArray['errors'] = array_merge((array) $infoArray['errors'], $filesInside['errors']);
1211 }
1212 if (is_array($filesInside['NSerrors'])) {
1213 $infoArray['NSerrors'] = array_merge((array) $infoArray['NSerrors'], $filesInside['NSerrors']);
1214 }
1215 if (is_array($filesInside['NSok'])) {
1216 $infoArray['NSok'] = array_merge((array) $infoArray['NSok'], $filesInside['NSok']);
1217 }
1218 $infoArray['locallang'] = $filesInside['locallang'];
1219 $infoArray['classes'] = $filesInside['classes'];
1220 }
1221
1222 // Upload folders
1223 if ($extInfo['EM_CONF']['uploadfolder']) {
1224 $infoArray['uploadfolder'] = tx_em_Tools::uploadFolder($extKey);
1225 if (!@is_dir(PATH_site . $infoArray['uploadfolder'])) {
1226 $infoArray['errors'][] = sprintf($GLOBALS['LANG']->getLL('detailedExtAnalysis_no_upload_folder'),
1227 $infoArray['uploadfolder']
1228 );
1229 $infoArray['uploadfolder'] = '';
1230 }
1231 }
1232
1233 // Create directories:
1234 if ($extInfo['EM_CONF']['createDirs']) {
1235 $infoArray['createDirs'] = array_unique(t3lib_div::trimExplode(',', $extInfo['EM_CONF']['createDirs'], 1));
1236 foreach ($infoArray['createDirs'] as $crDir) {
1237 if (!@is_dir(PATH_site . $crDir)) {
1238 $infoArray['errors'][] = sprintf($GLOBALS['LANG']->getLL('detailedExtAnalysis_no_upload_folder'),
1239 $crDir
1240 );
1241 }
1242 }
1243 }
1244
1245 // Return result array:
1246 return $infoArray;
1247 }
1248
1249
1250 /**
1251 * Produces the config form for an extension (if any template file, ext_conf_template.txt is found)
1252 *
1253 * @param string Extension key
1254 * @param array Extension information array
1255 * @param boolean If TRUE, the form HTML content is returned, otherwise the content is set in $this->content.
1256 * @param string Submit-to URL (supposedly)
1257 * @param string Additional form fields to include.
1258 * @return string Depending on $output. Can return the whole form.
1259 */
1260 function tsStyleConfigForm($extKey, $extInfo, $output = 0, $script = '', $addFields = '') {
1261 global $TYPO3_CONF_VARS;
1262
1263 // Initialize:
1264 $absPath = tx_em_Tools::getExtPath($extKey, $extInfo['type']);
1265 $relPath = tx_em_Tools::typeRelPath($extInfo['type']) . $extKey . '/';
1266
1267 $form = '';
1268
1269 // Look for template file for form:
1270 if (t3lib_extMgm::isLoaded($extKey) && @is_file($absPath . 'ext_conf_template.txt')) {
1271
1272 // Load tsStyleConfig class and parse configuration template:
1273 $tsStyleConfig = t3lib_div::makeInstance('t3lib_tsStyleConfig');
1274 $tsStyleConfig->doNotSortCategoriesBeforeMakingForm = TRUE;
1275 $theConstants = $tsStyleConfig->ext_initTSstyleConfig(
1276 t3lib_div::getUrl($absPath . 'ext_conf_template.txt'),
1277 $relPath,
1278 $absPath,
1279 $GLOBALS['BACK_PATH']
1280 );
1281
1282 // Load the list of resources.
1283 $tsStyleConfig->ext_loadResources($absPath . 'res/');
1284
1285 // Load current value:
1286 $arr = unserialize($TYPO3_CONF_VARS['EXT']['extConf'][$extKey]);
1287 $arr = is_array($arr) ? $arr : array();
1288
1289 // Call processing function for constants config and data before write and form rendering:
1290 if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/mod/tools/em/index.php']['tsStyleConfigForm'])) {
1291 $_params = array('fields' => &$theConstants, 'data' => &$arr, 'extKey' => $extKey);
1292 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/mod/tools/em/index.php']['tsStyleConfigForm'] as $_funcRef) {
1293 t3lib_div::callUserFunction($_funcRef, $_params, $this);
1294 }
1295 unset($_params);
1296 }
1297
1298 // If saving operation is done:
1299 if (t3lib_div::_POST('submit')) {
1300 $tsStyleConfig->ext_procesInput(t3lib_div::_POST(), array(), $theConstants, array());
1301 $arr = $tsStyleConfig->ext_mergeIncomingWithExisting($arr);
1302 $this->writeTsStyleConfig($extKey, $arr);
1303 }
1304
1305 // Setting value array
1306 $tsStyleConfig->ext_setValuearray($theConstants, $arr);
1307
1308 // Getting session data:
1309 $MOD_MENU = array();
1310 $MOD_MENU['constant_editor_cat'] = $tsStyleConfig->ext_getCategoriesForModMenu();
1311 $MOD_SETTINGS = t3lib_BEfunc::getModuleData($MOD_MENU, t3lib_div::_GP('SET'), 'xMod_test');
1312
1313 // Resetting the menu (stop)
1314 if (count($MOD_MENU['constant_editor_cat']) > 1) {
1315 $menu = $GLOBALS['LANG']->getLL('extInfoArray_category') . ' ' .
1316 t3lib_BEfunc::getFuncMenu(0, 'SET[constant_editor_cat]', $MOD_SETTINGS['constant_editor_cat'], $MOD_MENU['constant_editor_cat'], '', '&CMD[showExt]=' . $extKey);
1317 // add class to select
1318 $menu = str_replace('<select', '<select class="mod-menu-template-select"', $menu);
1319 if ($this->silentMode) {
1320 $menu = str_replace('jumpToUrl', 'abc', $menu);
1321 }
1322
1323 if ($this->parentObject instanceof SC_mod_tools_em_index) {
1324 $this->parentObject->content .= $this->parentObject->doc->section('', '<span class="nobr">' . $menu . '</span>');
1325 $this->parentObject->content .= $this->parentObject->doc->spacer(10);
1326 } else {
1327 $form .= '<h3>' . '<span class="nobr">' . $menu . '</span></h3>';
1328 }
1329 }
1330
1331 // Category and constant editor config:
1332 $form .= '
1333 <table border="0" cellpadding="0" cellspacing="0" width="600">
1334 <tr>
1335 <td>' . $tsStyleConfig->ext_getForm(
1336 $MOD_SETTINGS['constant_editor_cat'],
1337 $theConstants,
1338 $script,
1339 $addFields,
1340 $extKey,
1341 !$this->silentMode
1342 ) . ($this->silentMode ? '' : '</form>') .'</td>
1343 </tr>
1344 </table>';
1345 } else {
1346 if (!$this->silentMode) {
1347 $flashMessage = t3lib_div::makeInstance(
1348 't3lib_FlashMessage',
1349 $GLOBALS['LANG']->getLL('tsStyleConfigForm_additional_config'),
1350 '',
1351 t3lib_FlashMessage::INFO
1352 );
1353 }
1354
1355 $form = '
1356 <table border="0" cellpadding="0" cellspacing="0" width="600">
1357 <tr>
1358 <td>
1359 <form action="' . htmlspecialchars($script) . '" method="post">' .
1360 $addFields .
1361 ($this->silentMode ? '' : $flashMessage->render()) .
1362 (t3lib_div::_GP('nodoc') ? '<input type="hidden" name="nodoc" value="1" />' : '') .
1363 '<br /><input type="submit" id="configuration-submit-' . $extKey . '" name="write" value="' . $GLOBALS['LANG']->getLL('updatesForm_make_updates') . '" />
1364 </form>
1365 </td>
1366 </tr>
1367 </table>';
1368 }
1369
1370
1371 return $form;
1372
1373 }
1374
1375 /**
1376 * Writes the TSstyleconf values to "localconf.php"
1377 * Removes the temp_CACHED* files before return.
1378 *
1379 * @param string Extension key
1380 * @param array Configuration array to write back
1381 * @return void
1382 */
1383 function writeTsStyleConfig($extKey, $arr) {
1384
1385 // Instance of install tool
1386 $instObj = new t3lib_install;
1387 $instObj->allowUpdateLocalConf = 1;
1388 $instObj->updateIdentity = 'TYPO3 Extension Manager';
1389
1390 // Get lines from localconf file
1391 $lines = $instObj->writeToLocalconf_control();
1392 $instObj->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'EXT\'][\'extConf\'][\'' . $extKey . '\']', serialize($arr)); // This will be saved only if there are no linebreaks in it !
1393 $instObj->writeToLocalconf_control($lines);
1394
1395 t3lib_extMgm::removeCacheFiles();
1396 }
1397
1398
1399 /**
1400 * Creates a form for an extension which contains all options for configuration, updates of database, clearing of cache etc.
1401 *
1402 * @param string $extKey Extension key
1403 * @param array $extInfo Extension information array
1404 * @param boolean $notSilent If set, the form will ONLY show if fields/tables should be updated (suppressing forms like general configuration and cache clearing).
1405 * @param string $script Alternative action=""-script
1406 * @param string $addFields Additional form fields
1407 * @param boolean $addFormTags TRUE if it shopuld be wrapped with form tag
1408 * @param boolean $excludeDatabaseCheck TRUE if no database check should be done
1409 * @return string
1410 */
1411 function updatesForm($extKey, $extInfo, $notSilent = FALSE, $script = '', $addFields = '', $addFormTag = TRUE, $excludeDatabaseCheck = FALSE) {
1412 $script = $script ? $script : t3lib_div::linkThisScript();
1413 if ($addFormTag) {
1414 $formWrap = array('<form action="' . htmlspecialchars($script) . '" method="POST">', '</form>');
1415 } else {
1416 $formWrap = array('', '');
1417 }
1418 $extensionDetails = t3lib_div::makeInstance('tx_em_Extensions_Details', $this);
1419 $updates = '';
1420
1421 if (!$excludeDatabaseCheck) {
1422 $updates .= $this->checkDBupdates($extKey, $extInfo);
1423 }
1424
1425 $uCache = $this->checkClearCache($extInfo);
1426 if ($notSilent) {
1427 $updates .= $uCache;
1428 }
1429 $updates .= $extensionDetails->checkUploadFolder($extKey, $extInfo);
1430
1431 $absPath = tx_em_Tools::getExtPath($extKey, $extInfo['type']);
1432 if ($notSilent && @is_file($absPath . 'ext_conf_template.txt')) {
1433 $configForm = $this->tsStyleConfigForm($extKey, $extInfo, 1, $script, $updates . $addFields . '<br />');
1434 }
1435
1436 if ($updates || $configForm) {
1437 if ($configForm) {
1438 $updates = $configForm;
1439 } else {
1440 $updates = $formWrap[0] . $updates . $addFields . '
1441 <br /><input type="submit" name="write" id="update-submit-' . $extKey . '" value="' . $GLOBALS['LANG']->getLL('updatesForm_make_updates') . '" />
1442 ' . $formWrap[1];
1443 }
1444 }
1445
1446 return $updates;
1447 }
1448
1449
1450 /**
1451 * Check if clear-cache should be performed, otherwise show form (for installation of extension)
1452 * Shown only if the extension has the clearCacheOnLoad flag set.
1453 *
1454 * @param string Extension key
1455 * @param array Extension information array
1456 * @return string HTML output (if form is shown)
1457 */
1458 function checkClearCache($extInfo) {
1459 $content = '';
1460 if ($extInfo['EM_CONF']['clearCacheOnLoad']) {
1461 if (t3lib_div::_POST('_clear_all_cache')) { // Action: Clearing the cache
1462 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
1463 $tce->stripslashes_values = 0;
1464 $tce->start(array(), array());
1465 $tce->clear_cacheCmd('all');
1466 } else { // Show checkbox for clearing cache:
1467 $content .= '
1468 <br />
1469 <h3>' . $GLOBALS['LANG']->getLL('checkUploadFolder_clear_cache') . '</h3>
1470 <p>' . $GLOBALS['LANG']->getLL('checkUploadFolder_clear_cache_requested') . '<br />
1471 <label for="check_clear_all_cache">' . $GLOBALS['LANG']->getLL('checkUploadFolder_clear_all_cache') . '</label>
1472 <input type="checkbox" name="_clear_all_cache" id="check_clear_all_cache" checked="checked" value="1" /><br />
1473 </p>
1474 ';
1475 }
1476 }
1477 return $content;
1478 }
1479
1480 /**
1481 * Writes the extension list to "localconf.php" file
1482 * Removes the temp_CACHED* files before return.
1483 *
1484 * @param string List of extensions
1485 * @return void
1486 */
1487 function writeNewExtensionList($newExtList) {
1488 $strippedExtensionList = $this->stripNonFrontendExtensions($newExtList);
1489
1490 // Instance of install tool
1491 $instObj = new t3lib_install;
1492 $instObj->allowUpdateLocalConf = 1;
1493 $instObj->updateIdentity = 'TYPO3 Extension Manager';
1494
1495 // Get lines from localconf file
1496 $lines = $instObj->writeToLocalconf_control();
1497 $instObj->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'EXT\'][\'extList\']', $newExtList);
1498 $instObj->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'EXT\'][\'extList_FE\']', $strippedExtensionList);
1499 $instObj->writeToLocalconf_control($lines);
1500
1501 $GLOBALS['TYPO3_CONF_VARS']['EXT']['extList'] = $newExtList;
1502 $GLOBALS['TYPO3_CONF_VARS']['EXT']['extList_FE'] = $strippedExtensionList;
1503 t3lib_extMgm::removeCacheFiles();
1504 $GLOBALS['typo3CacheManager']->getCache('cache_phpcode')->flushByTag('t3lib_autoloader');
1505 }
1506
1507 /**
1508 * Removes unneeded extensions from the frontend based on
1509 * EMCONF doNotLoadInFE = 1
1510 *
1511 * @param string $extList
1512 * @return string
1513 */
1514 function stripNonFrontendExtensions($extList) {
1515 $fullExtList = $this->parentObject->extensionList->getInstalledExtensions();
1516 $extListArray = t3lib_div::trimExplode(',', $extList);
1517 foreach ($extListArray as $arrayKey => $extKey) {
1518 if ($fullExtList[0][$extKey]['EM_CONF']['doNotLoadInFE'] == 1) {
1519 unset($extListArray[$arrayKey]);
1520 }
1521 }
1522 $nonFEList = implode(',', $extListArray);
1523 return $nonFEList;
1524 }
1525
1526 /**
1527 * Updates the database according to extension requirements
1528 * DBAL compliant (based on Install Tool code)
1529 *
1530 * @param string Extension key
1531 * @param array Extension information array
1532 * @return void
1533 */
1534 function forceDBupdates($extKey, $extInfo) {
1535 // Updating tables and fields?
1536 if (is_array($extInfo['files']) && in_array('ext_tables.sql', $extInfo['files'])) {
1537 $fileContent = t3lib_div::getUrl(tx_em_Tools::getExtPath($extKey, $extInfo['type']) . 'ext_tables.sql');
1538
1539 $FDfile = $this->installerSql->getFieldDefinitions_fileContent($fileContent);
1540 if (count($FDfile)) {
1541 $FDdb = $this->installerSql->getFieldDefinitions_database(TYPO3_db);
1542 $diff = $this->installerSql->getDatabaseExtra($FDfile, $FDdb);
1543 $update_statements = $this->installerSql->getUpdateSuggestions($diff);
1544
1545 foreach ((array) $update_statements['add'] as $string) {
1546 $GLOBALS['TYPO3_DB']->admin_query($string);
1547 }
1548 foreach ((array) $update_statements['change'] as $string) {
1549 $GLOBALS['TYPO3_DB']->admin_query($string);
1550 }
1551 foreach ((array) $update_statements['create_table'] as $string) {
1552 $GLOBALS['TYPO3_DB']->admin_query($string);
1553 }
1554 }
1555 }
1556
1557 // Importing static tables?
1558 if (is_array($extInfo['files']) && in_array('ext_tables_static+adt.sql', $extInfo['files'])) {
1559 $fileContent = t3lib_div::getUrl(tx_em_Tools::getExtPath($extKey, $extInfo['type']) . 'ext_tables_static+adt.sql');
1560
1561 $statements = $this->installerSql->getStatementarray($fileContent, 1);
1562 list($statements_table, $insertCount) = $this->installerSql->getCreateTables($statements, 1);
1563
1564 // Traverse the tables
1565 foreach ($statements_table as $table => $query) {
1566 $GLOBALS['TYPO3_DB']->admin_query('DROP TABLE IF EXISTS ' . $table);
1567 $GLOBALS['TYPO3_DB']->admin_query($query);
1568
1569 if ($insertCount[$table]) {
1570 $statements_insert = $this->installerSql->getTableInsertStatements($statements, $table);
1571
1572 foreach ($statements_insert as $v) {
1573 $GLOBALS['TYPO3_DB']->admin_query($v);
1574 }
1575 }
1576 }
1577 }
1578 }
1579
1580 }
1581
1582 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/sysext/em/classes/install/class.tx_em_install.php'])) {
1583 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/sysext/em/classes/install/class.tx_em_install.php']);
1584 }
1585
1586 ?>