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