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