2 /***************************************************************
5 * (c) 2010 Steffen Kamper (info@sk-typo3.de)
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.
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.
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.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
28 * Module: Extension manager, (un-)install extensions
30 * $Id: class.tx_em_install.php 2073 2010-03-19 10:42:38Z steffenk $
32 * @author Steffen Kamper <info@sk-typo3.de>
39 * Parent module object
41 * @var SC_mod_tools_em_index
43 protected $parentObject;
59 protected $systemInstall = 0; // If "1" then installs in the sysext directory is allowed. Default: 0
64 protected $silentMode;
69 * @param SC_mod_tools_em_index $parentObject
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'];
81 * Set silent mode to prevent flashmessages
83 * @param boolean $silentMode
86 public function setSilentMode($silentMode) {
87 $this->silentMode
= $silentMode ?
TRUE : FALSE;
91 * Imports the data of an extension from upload
93 * @param $uploadedTempFile
95 * @param bool $uploadOverwrite
98 public function uploadExtensionFile($uploadedTempFile, $location, $uploadOverwrite = FALSE) {
100 $fileContent = t3lib_div
::getUrl($uploadedTempFile);
104 'error' => $GLOBALS['LANG']->getLL('ext_import_file_empty')
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'];
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');
120 } // ... else go on, install...
121 } // ... else go on, install...
123 $error = $GLOBALS['LANG']->getLL('ext_import_no_key');
126 $error = sprintf($GLOBALS['LANG']->getLL('ext_import_wrong_file_format'), $fetchData);
130 return array(FALSE, $error);
132 return array(TRUE, $fetchData);
138 * Installs an extension.
143 * @param $uploadedTempFile
145 * @return mixed|string
147 public function installExtension($fetchData, $loc, $version, $uploadedTempFile, $dontDelete) {
148 $xmlHandler =& $this->parentObject
->xmlHandler
;
149 $extensionList =& $this->parentObject
->extensionList
;
150 $extensionDetails =& $this->parentObject
->extensionDetails
;
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'];
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 . '" />';
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) == '/') {
176 $emConfFile = $extensionDetails->construct_ext_emconf_file($extKey, $EM_CONF);
177 $dirs = tx_em_Tools
::extractDirsFromFileList(array_keys($fetchData[0]['FILES']));
179 $res = tx_em_Tools
::createDirsInPath($dirs, $extDirPath);
181 $writeFiles = $fetchData[0]['FILES'];
182 $writeFiles['ext_emconf.php']['content'] = $emConfFile;
183 $writeFiles['ext_emconf.php']['content_md5'] = md5($emConfFile);
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),
195 t3lib_FlashMessage
::ERROR
197 $content .= $flashMessage->render();
199 if (!$this->silentMode
) {
200 $flashMessage = t3lib_div
::makeInstance(
201 't3lib_FlashMessage',
202 sprintf($GLOBALS['LANG']->getLL('ext_import_file_not_created'), $extDirPath . $theFile),
204 t3lib_FlashMessage
::ERROR
206 $content .= $flashMessage->render();
208 $content .= sprintf($GLOBALS['LANG']->getLL('ext_import_file_not_created'),
209 $extDirPath . $theFile) . '<br />';
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 />';
218 t3lib_div
::fixPermissions($extDirPath, TRUE);
220 // No content, no errors. Create success output here:
222 $messageContent = sprintf($GLOBALS['LANG']->getLL('ext_import_success_folder'), $extDirPath) . '<br />';
224 $uploadSucceed = true;
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 />';
234 $messageContent .= sprintf($GLOBALS['LANG']->getLL('ext_import_no_conf_file'),
235 $confFileName) . '<br />';
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).
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);
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 />';
253 // Remove cache files:
255 if (t3lib_extMgm
::isLoaded($extKey)) {
256 if (t3lib_extMgm
::removeCacheFiles()) {
257 $messageContent .= $GLOBALS['LANG']->getLL('ext_import_cache_files_removed') . '<br />';
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'
267 if (!$this->silentMode
) {
268 $flashMessage = t3lib_div
::makeInstance(
269 't3lib_FlashMessage',
271 $GLOBALS['LANG']->getLL('ext_import_success')
273 $content = $flashMessage->render();
275 $content = $updateContent;
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,
287 'SET[singleDetails]' => 'info'
289 tx_em_Tools
::removeButton() . ' ' . $GLOBALS['LANG']->getLL('ext_import_uninstall') . '</a>' :
290 '<a href="' . htmlspecialchars(t3lib_div
::linkThisScript(array(
291 'CMD[showExt]' => $extKey,
294 'SET[singleDetails]' => 'info'
296 tx_em_Tools
::installButton() . ' ' . $GLOBALS['LANG']->getLL('ext_import_install') . '</a>';
298 $content = $GLOBALS['LANG']->getLL('ext_import_imported') .
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>';
303 $content .= '<a href="javascript:opener.top.list.iframe.document.forms[0].submit();window.close();">' .
304 $GLOBALS['LANG']->getLL('ext_import_close_check') . '</a>';
310 if (!$this->silentMode
) {
311 $flashMessage = t3lib_div
::makeInstance(
312 't3lib_FlashMessage',
315 t3lib_FlashMessage
::ERROR
317 $content = $flashMessage->render();
323 if (!$this->silentMode
) {
324 $flashMessage = t3lib_div
::makeInstance(
325 't3lib_FlashMessage',
326 sprintf($GLOBALS['LANG']->getLL('ext_import_ext_path_different'), $extDirPath),
328 t3lib_FlashMessage
::ERROR
330 $content = $flashMessage->render();
332 $content = sprintf($GLOBALS['LANG']->getLL('ext_import_ext_path_different'), $extDirPath);
336 if (!$this->silentMode
) {
337 $flashMessage = t3lib_div
::makeInstance(
338 't3lib_FlashMessage',
341 t3lib_FlashMessage
::ERROR
343 $content = $flashMessage->render();
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']),
356 t3lib_FlashMessage
::ERROR
358 $content = $flashMessage->render();
360 $content = sprintf($GLOBALS['LANG']->getLL('ext_import_ext_only_here'),
361 tx_em_Tools
::typePath($EM_CONF['lockType']), $EM_CONF['lockType']);
365 if (!$this->silentMode
) {
366 $flashMessage = t3lib_div
::makeInstance(
367 't3lib_FlashMessage',
368 $GLOBALS['LANG']->getLL('ext_import_no_ext_key_files'),
370 t3lib_FlashMessage
::ERROR
372 $content = $flashMessage->render();
374 $content = $GLOBALS['LANG']->getLL('ext_import_no_ext_key_files');
378 if (!$this->silentMode
) {
379 $flashMessage = t3lib_div
::makeInstance(
380 't3lib_FlashMessage',
381 sprintf($GLOBALS['LANG']->getLL('ext_import_data_transfer'), $fetchData),
383 t3lib_FlashMessage
::ERROR
385 $content = $flashMessage->render();
387 $content = sprintf($GLOBALS['LANG']->getLL('ext_import_data_transfer'), $fetchData);
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]),
396 t3lib_FlashMessage
::ERROR
398 $content = $flashMessage->render();
400 $content = sprintf($GLOBALS['LANG']->getLL('ext_import_no_install_here'), tx_em_Tools
::typePath($loc));
408 *Check extension dependencies
410 * @param string $extKey
412 * @param array $instExtInfo
415 function checkDependencies($extKey, $conf, $instExtInfo) {
420 $depsolver = t3lib_div
::_POST('depsolver');
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'),
427 <input type="hidden" value="1" name="depsolver[ignore][' . $depK . ']" />';
431 if ($depK == 'php') {
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[] = ' <input type="checkbox" value="1" name="depsolver[ignore][' . $depK . ']" id="checkIgnore_' . $depK . '" />
441 <label for="checkIgnore_' . $depK . '">' . $GLOBALS['LANG']->getLL('checkDependencies_ignore_requirement') . '</label>';
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[] = ' <input type="checkbox" value="1" name="depsolver[ignore][' . $depK . ']" id="checkIgnore_' . $depK . '" />
448 <label for="checkIgnore_' . $depK . '">' . $GLOBALS['LANG']->getLL('checkDependencies_ignore_requirement') . '</label>';
453 } elseif ($depK == 'typo3') {
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';
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[] = ' <input type="checkbox" value="1" name="depsolver[ignore][' . $depK . ']" id="checkIgnore_' . $depK . '" />
474 <label for="checkIgnore_' . $depK . '">' . $GLOBALS['LANG']->getLL('checkDependencies_ignore_requirement') . '</label>';
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[] = ' <input type="checkbox" value="1" name="depsolver[ignore][' . $depK . ']" id="checkIgnore_' . $depK . '" />
481 <label for="checkIgnore_' . $depK . '">' . $GLOBALS['LANG']->getLL('checkDependencies_ignore_requirement') . '</label>';
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'),
489 $msg[] = ' ' . t3lib_iconWorks
::getSpriteIcon('actions-system-extension-import', array('title' => $GLOBALS['LANG']->getLL('checkDependencies_import_ext'))) . '
490 <a href="' . t3lib_div
::linkThisUrl($this->parentObject
->script
, array(
491 'CMD[importExt]' => $depK,
493 'CMD[standAlone]' => 1
494 )) . '" target="_blank">' . $GLOBALS['LANG']->getLL('checkDependencies_import_now') . '</a>';
495 $msg[] = ' <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>';
498 $msg[] = '<br />' . sprintf($GLOBALS['LANG']->getLL('checkDependencies_ext_not_installed'),
499 $depK, $instExtInfo[$depK]['EM_CONF']['title']);
500 $msg[] = ' ' . tx_em_Tools
::installButton() . '
501 <a href="' . t3lib_div
::linkThisUrl($this->parentObject
->script
, array(
502 'CMD[showExt]' => $depK,
505 'CMD[standAlone]' => 1,
506 'SET[singleDetails]' => 'info'
508 '" target="_blank">' . $GLOBALS['LANG']->getLL('checkDependencies_install_now') . '</a>';
509 $msg[] = ' <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>';
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[] = ' <input type="checkbox" value="1" name="depsolver[ignore][' . $depK . ']" id="checkIgnore_' . $depK . '" />
519 <label for="checkIgnore_' . $depK . '">' . $GLOBALS['LANG']->getLL('checkDependencies_ignore_requirement') . '</label>';
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[] = ' <input type="checkbox" value="1" name="depsolver[ignore][' . $depK . ']" id="checkIgnore_' . $depK . '" />
526 <label for="checkIgnore_' . $depK . '">' . $GLOBALS['LANG']->getLL('checkDependencies_ignore_requirement') . '</label>';
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
541 // Check conflicts with other extensions:
542 $conflictError = false;
543 $conflictIgnore = false;
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'),
551 <input type="hidden" value="1" name="depsolver[ignore][' . $conflictK . ']" />';
552 $conflictIgnore = true;
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], '<')) {
560 elseif ($versionRange[1] != '0.0.0' && version_compare($instExtInfo[$conflictK]['EM_CONF']['version'], $versionRange[1], '>')) {
563 $msg[] = sprintf($GLOBALS['LANG']->getLL('checkDependencies_conflict_remove'),
564 $extKey, $conflictK, $instExtInfo[$conflictK]['EM_CONF']['title'], $conflictK, $extKey);
565 $msg[] = ' ' . tx_em_Tools
::removeButton() . '
566 <a href="' . htmlspecialchars(t3lib_div
::linkThisScript(array(
567 'CMD[showExt]' => $conflictK,
570 'CMD[standAlone]' => 1,
571 'SET[singleDetails]' => 'info'
573 '" target="_blank">' . $GLOBALS['LANG']->getLL('checkDependencies_remove_now') . '</a>';
574 $msg[] = ' <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;
580 if ($conflictError ||
$conflictIgnore) {
581 $content .= $this->parentObject
->doc
->section(
582 $GLOBALS['LANG']->getLL('checkDependencies_conflict_error'), implode('<br />', $msg), 0, 1, 2
586 // Check suggests on other extensions:
587 if (isset($conf['constraints']['suggests']) && is_array($conf['constraints']['suggests'])) {
589 $suggestionIgnore = false;
591 foreach ($conf['constraints']['suggests'] as $suggestK => $suggestV) {
592 if ($depsolver['ignore'][$suggestK]) {
593 $msg[] = '<br />' . sprintf($GLOBALS['LANG']->getLL('checkDependencies_suggestion_ignored'),
595 <input type="hidden" value="1" name="depsolver[ignore][' . $suggestK . ']" />';
596 $suggestionIgnore = true;
599 if (!t3lib_extMgm
::isLoaded($suggestK)) {
600 if (!isset($instExtInfo[$suggestK])) {
601 $msg[] = sprintf($GLOBALS['LANG']->getLL('checkDependencies_suggest_import'),
603 $msg[] = ' ' . t3lib_iconWorks
::getSpriteIcon('actions-system-extension-import', array('title' => $GLOBALS['LANG']->getLL('checkDependencies_import_ext'))) . '
604 <a href="' . t3lib_div
::linkThisScript(array(
605 'CMD[importExt]' => $suggestK,
607 'CMD[standAlone]' => 1
608 )) . '" target="_blank">' . $GLOBALS['LANG']->getLL('checkDependencies_import_now') . '</a>';
609 $msg[] = ' <input type="checkbox" value="1" name="depsolver[ignore][' . $suggestK . ']" id="checkIgnore_' . $suggestK . '" />
610 <label for="checkIgnore_' . $suggestK . '">' . $GLOBALS['LANG']->getLL('checkDependencies_ignore_suggestion') . '</label>';
612 $msg[] = sprintf($GLOBALS['LANG']->getLL('checkDependencies_suggest_installation'),
613 $suggestK, $instExtInfo[$suggestK]['EM_CONF']['title']);
614 $msg[] = ' ' . tx_em_Tools
::installButton() . '
615 <a href="' . htmlspecialchars(t3lib_div
::linkThisScript(array(
616 'CMD[showExt]' => $suggestK,
619 'CMD[standAlone]' => 1,
620 'SET[singleDetails]' => 'info'
622 '" target="_blank">' . $GLOBALS['LANG']->getLL('checkDependencies_install_now') . '</a>';
623 $msg[] = ' <input type="checkbox" value="1" name="depsolver[ignore][' . $suggestK . ']" id="checkIgnore_' . $suggestK . '" />
624 <label for="checkIgnore_' . $suggestK . '">' . $GLOBALS['LANG']->getLL('checkDependencies_ignore_suggestion') . '</label>';
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
637 if ($depError ||
$conflictError ||
$suggestion) {
638 foreach ($this->parentObject
->CMD
as $k => $v) {
639 $content .= '<input type="hidden" name="CMD[' . $k . ']" value="' . $v . '" />';
641 $content .= '<br /><br /><input type="submit" value="' . $GLOBALS['LANG']->getLL('checkDependencies_try_again') . '" />';
643 if (t3lib_div
::_GP('nodoc')) {
644 $content .= '<input type="hidden" name="nodoc" value="1" />';
648 'returnCode' => FALSE,
649 'html' => '<form action="' . $this->parentObject
->script
. '" method="post" name="depform">' . $content . '</form>');
659 * Delete extension from the file system
661 * @param string Extension key
662 * @param array Extension info array
663 * @return string Returns message string about the status of the operation
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']]
673 } elseif (t3lib_div
::inList('G,L', $extInfo['type'])) {
674 if ($command['doDelete'] && !strcmp($absPath, urldecode($command['absPath']))) {
675 $res = $this->removeExtDirectory($absPath);
677 if (!$this->silentMode
) {
678 $flashMessage = t3lib_div
::makeInstance(
679 't3lib_FlashMessage',
681 sprintf($GLOBALS['LANG']->getLL('extDelete_remove_dir_failed'), $absPath),
682 t3lib_FlashMessage
::ERROR
684 return $flashMessage->render();
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
695 return $flashMessage->render();
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)
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
))
713 $content .= '<br /><br />' . $GLOBALS['LANG']->getLL('extDelete_backup');
717 return $GLOBALS['LANG']->getLL('extDelete_neither_global_nor_local');
722 * Removes the extension directory (including content)
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.
728 function removeExtDirectory($removePath, $removeContentOnly = 0) {
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...
737 // All files in extension directory:
738 $fileArr = t3lib_div
::getAllFilesAndFoldersInPath(array(), $removePath, '', 1);
739 if (is_array($fileArr)) {
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);
747 if (@is_file
($removeFile)) {
748 $errors[] = sprintf($GLOBALS['LANG']->getLL('rmExtDir_could_not_be_deleted'),
753 $errors[] = sprintf($GLOBALS['LANG']->getLL('rmExtDir_error_file'),
754 $removeFile, $removePath
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)) {
768 if (@is_dir
($removeDir)) {
769 $errors[] = sprintf($GLOBALS['LANG']->getLL('rmExtDir_error_files_left'),
774 $errors[] = sprintf($GLOBALS['LANG']->getLL('rmExtDir_error_no_dir'),
780 // If extension dir should also be removed:
781 if (!$removeContentOnly) {
784 if (@is_dir
($removePath)) {
785 $errors[] = sprintf($GLOBALS['LANG']->getLL('rmExtDir_error_folders_left'),
791 $errors[] = $GLOBALS['LANG']->getLL('rmExtDir_error') . ' ' . $fileArr;
794 $errors[] = $GLOBALS['LANG']->getLL('rmExtDir_error_unallowed_path') . ' ' . $removePath;
797 // Return errors if any:
798 return implode(LF
, $errors);
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)
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.
811 function checkDBupdates($extKey, $extInfo, $infoOnly = 0) {
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');
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);
828 $dbStatus['structure']['tables_fields'] = $FDfile;
829 $dbStatus['structure']['diff'] = $diff;
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']);
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'));
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');
851 $statements = $this->install
->getStatementarray($fileContent, 1);
852 list($statements_table, $insertCount) = $this->install
->getCreateTables($statements, 1);
854 // Execute import of static table content:
855 if (!$infoOnly && is_array($this->install
->INSTALL
['database_import'])) {
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]);
863 if ($insertCount[$table]) {
864 $statements_insert = $this->install
->getTableInsertStatements($statements, $table);
866 foreach ($statements_insert as $v) {
867 $GLOBALS['TYPO3_DB']->admin_query($v);
873 $whichTables = $this->install
->getListOfTables();
874 if (count($statements_table)) {
876 foreach ($statements_table as $table => $definition) {
877 $exist = isset($whichTables[$table]);
879 $dbStatus['static'][$table]['exists'] = $exist;
880 $dbStatus['static'][$table]['count'] = $insertCount[$table];
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]
891 <td><img src="clear.gif" width="10" height="1" alt="" /></td>
892 <td nowrap="nowrap">' .
894 t3lib_iconWorks
::getSpriteIcon('status-dialog-warning') .
895 $GLOBALS['LANG']->getLL('checkDBupdates_table_exists')
902 <h3>' . $GLOBALS['LANG']->getLL('checkDBupdates_import_static_data') . '</h3>
903 <table border="0" cellpadding="0" cellspacing="0">' . $out . '</table>
909 // Return array of information if $infoOnly, otherwise content.
910 return $infoOnly ?
$dbStatus : $content;
914 * Removes the current extension of $type and creates the base folder for the new one (which is going to be imported)
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.
921 function clearAndMakeExtensionDir($importedData, $type, $dontDelete = 0) {
922 if (!$importedData['extKey']) {
923 return $GLOBALS['LANG']->getLL('clearMakeExtDir_no_ext_key');
926 // Setting install path (L, G, S or fileadmin/_temp_/)
928 switch ((string) $type) {
931 $path = tx_em_Tools
::typePath($type);
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);
940 if ($this->systemInstall
&& (string) $type == 'S') {
941 $path = tx_em_Tools
::typePath($type);
944 $path = PATH_site
. $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] . '_temp_/';
945 $suffix = '_' . date('dmy-His');
950 // If the install path is OK...
951 if ($path && @is_dir
($path)) {
953 // Set extension directory:
954 $extDirPath = $path . $importedData['extKey'] . $suffix . '/';
956 // Install dir was found, remove it then:
957 if (@is_dir
($extDirPath)) {
959 return array($extDirPath);
961 $res = $this->removeExtDirectory($extDirPath);
963 if (!$this->silentMode
) {
964 $flashMessage = t3lib_div
::makeInstance(
965 't3lib_FlashMessage',
967 sprintf($GLOBALS['LANG']->getLL('clearMakeExtDir_could_not_remove_dir'), $extDirPath),
968 t3lib_FlashMessage
::ERROR
970 return $flashMessage->render();
977 t3lib_div
::mkdir($extDirPath);
978 if (!is_dir($extDirPath)) {
979 return sprintf($GLOBALS['LANG']->getLL('clearMakeExtDir_could_not_create_dir'),
982 return array($extDirPath);
984 return sprintf($GLOBALS['LANG']->getLL('clearMakeExtDir_no_dir'),
990 /*******************************
992 * Extension analyzing (detailed information)
994 ******************************/
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.
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.
1006 function makeDetailedExtensionAnalysis($extKey, $extInfo, $validity = 0) {
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();
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);
1017 $dbInfo = $this->checkDBupdates($extKey, $extInfo, 1);
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();
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') : '') .
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;
1037 $infoArray['NSok']['fields'][$fN] = $fN;
1041 if (is_array($d['keys'])) {
1042 foreach ($d['keys'] as $fN => $value) {
1043 $infoArray['dump_tf'][] = $tN . '.KEY:' . $fN;
1047 $infoArray['dump_tf'][] = $tN;
1048 $infoArray['tables'][] = $tN;
1049 if (!t3lib_div
::isFirstPartOfStr($tN, $table_class_prefix)) {
1050 $infoArray['NSerrors']['tables'][$tN] = $tN;
1052 $infoArray['NSok']['tables'][$tN] = $tN;
1056 if (count($dbInfo['structure']['diff']['diff']) ||
count($dbInfo['structure']['diff']['extra'])) {
1058 if (count($dbInfo['structure']['diff']['diff'])) {
1059 $msg[] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_tables_are_missing');
1061 if (count($dbInfo['structure']['diff']['extra'])) {
1062 $msg[] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_tables_are_of_wrong_type');
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)
1074 if (is_array($dbInfo['static'])) {
1075 $infoArray['static'] = array_keys($dbInfo['static']);
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');
1083 if (!t3lib_div
::isFirstPartOfStr($tN, $table_class_prefix)) {
1084 $infoArray['NSerrors']['tables'][$tN] = $tN;
1086 $infoArray['NSok']['tables'][$tN] = $tN;
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],
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!';
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;
1118 $infoArray['NSok']['modname'][] = $mName;
1121 $infoArray['errors'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_mconf_missing');
1124 $infoArray['errors'][] = sprintf($GLOBALS['LANG']->getLL('detailedExtAnalysis_be_module_conf_missing'),
1129 $infoArray['errors'][] = sprintf($GLOBALS['LANG']->getLL('detailedExtAnalysis_module_folder_missing'),
1134 $dirs = t3lib_div
::get_dirs($absPath);
1135 if (is_array($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'),
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');
1155 if (stristr($content, 't3lib_extMgm::insertModuleFunction')) {
1156 $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_module_and_more');
1158 if (stristr($content, 't3lib_div::loadTCA')) {
1159 $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_loadTCA');
1161 if (stristr($content, '$TCA[')) {
1162 $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_TCA');
1164 if (stristr($content, 't3lib_extMgm::addPlugin')) {
1165 $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_plugin');
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');
1175 if (stristr($content, 't3lib_extMgm::addPageTSConfig')) {
1176 $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_page_ts');
1178 if (stristr($content, 't3lib_extMgm::addUserTSConfig')) {
1179 $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_user_ts');
1181 if (stristr($content, 't3lib_extMgm::addTypoScriptSetup')) {
1182 $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_ts_setup');
1184 if (stristr($content, 't3lib_extMgm::addTypoScriptConstants')) {
1185 $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_ts_constants');
1189 if (@is_file
($absPath . 'ext_typoscript_constants.txt')) {
1190 $infoArray['TSfiles'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_constants');
1192 if (@is_file
($absPath . 'ext_typoscript_setup.txt')) {
1193 $infoArray['TSfiles'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_setup');
1195 if (@is_file
($absPath . 'ext_conf_template.txt')) {
1196 $infoArray['conf'] = 1;
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']);
1205 if (is_array($filesInside['NSerrors'])) {
1206 $infoArray['NSerrors'] = array_merge((array) $infoArray['NSerrors'], $filesInside['NSerrors']);
1208 if (is_array($filesInside['NSok'])) {
1209 $infoArray['NSok'] = array_merge((array) $infoArray['NSok'], $filesInside['NSok']);
1211 $infoArray['locallang'] = $filesInside['locallang'];
1212 $infoArray['classes'] = $filesInside['classes'];
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']
1222 $infoArray['uploadfolder'] = '';
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'),
1238 // Return result array:
1244 * Produces the config form for an extension (if any template file, ext_conf_template.txt is found)
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.
1253 function tsStyleConfigForm($extKey, $extInfo, $output = 0, $script = '', $addFields = '') {
1254 global $TYPO3_CONF_VARS;
1257 $absPath = tx_em_Tools
::getExtPath($extKey, $extInfo['type']);
1258 $relPath = tx_em_Tools
::typeRelPath($extInfo['type']) . $extKey . '/';
1262 // Look for template file for form:
1263 if (t3lib_extMgm
::isLoaded($extKey) && @is_file
($absPath . 'ext_conf_template.txt')) {
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'),
1272 $GLOBALS['BACK_PATH']
1275 // Load the list of resources.
1276 $tsStyleConfig->ext_loadResources($absPath . 'res/');
1278 // Load current value:
1279 $arr = unserialize($TYPO3_CONF_VARS['EXT']['extConf'][$extKey]);
1280 $arr = is_array($arr) ?
$arr : array();
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);
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);
1298 // Setting value array
1299 $tsStyleConfig->ext_setValuearray($theConstants, $arr);
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');
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);
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);
1318 $form .= '<h3>' . '<span class="nobr">' . $menu . '</span></h3>';
1322 // Category and constant editor config:
1324 <table border="0" cellpadding="0" cellspacing="0" width="600">
1326 <td>' . $tsStyleConfig->ext_getForm($MOD_SETTINGS['constant_editor_cat'], $theConstants, $script, $addFields, $extKey, !$this->silentMode
) . '</form></td>
1330 if (!$this->silentMode
) {
1331 $flashMessage = t3lib_div
::makeInstance(
1332 't3lib_FlashMessage',
1333 $GLOBALS['LANG']->getLL('tsStyleConfigForm_additional_config'),
1335 t3lib_FlashMessage
::INFO
1340 <table border="0" cellpadding="0" cellspacing="0" width="600">
1343 <form action="' . htmlspecialchars($script) . '" method="post">' .
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') . '" />
1360 * Writes the TSstyleconf values to "localconf.php"
1361 * Removes the temp_CACHED* files before return.
1363 * @param string Extension key
1364 * @param array Configuration array to write back
1367 function writeTsStyleConfig($extKey, $arr) {
1369 // Instance of install tool
1370 $instObj = new t3lib_install
;
1371 $instObj->allowUpdateLocalConf
= 1;
1372 $instObj->updateIdentity
= 'TYPO3 Extension Manager';
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);
1379 t3lib_extMgm
::removeCacheFiles();
1384 * Creates a form for an extension which contains all options for configuration, updates of database, clearing of cache etc.
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
1395 function updatesForm($extKey, $extInfo, $notSilent = FALSE, $script = '', $addFields = '', $addFormTag = TRUE, $excludeDatabaseCheck = FALSE) {
1396 $script = $script ?
$script : t3lib_div
::linkThisScript();
1398 $formWrap = array('<form action="' . htmlspecialchars($script) . '" method="POST">', '</form>');
1400 $formWrap = array('', '');
1402 $extensionDetails = t3lib_div
::makeInstance('tx_em_Extensions_Details', $this);
1405 if (!$excludeDatabaseCheck) {
1406 $updates .= $this->checkDBupdates($extKey, $extInfo);
1409 $uCache = $this->checkClearCache($extInfo);
1411 $updates .= $uCache;
1413 $updates .= $extensionDetails->checkUploadFolder($extKey, $extInfo);
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 />');
1420 if ($updates ||
$configForm) {
1422 $updates = $configForm;
1424 $updates = $formWrap[0] . $updates . $addFields . '
1425 <br /><input type="submit" name="write" id="update-submit-' . $extKey . '" value="' . $GLOBALS['LANG']->getLL('updatesForm_make_updates') . '" />
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.
1438 * @param string Extension key
1439 * @param array Extension information array
1440 * @return string HTML output (if form is shown)
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:
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 />
1464 * Writes the extension list to "localconf.php" file
1465 * Removes the temp_CACHED* files before return.
1467 * @param string List of extensions
1470 function writeNewExtensionList($newExtList) {
1471 $strippedExtensionList = $this->stripNonFrontendExtensions($newExtList);
1473 // Instance of install tool
1474 $instObj = new t3lib_install
;
1475 $instObj->allowUpdateLocalConf
= 1;
1476 $instObj->updateIdentity
= 'TYPO3 Extension Manager';
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);
1484 $GLOBALS['TYPO3_CONF_VARS']['EXT']['extList'] = $newExtList;
1485 $GLOBALS['TYPO3_CONF_VARS']['EXT']['extList_FE'] = $strippedExtensionList;
1486 t3lib_extMgm
::removeCacheFiles();
1490 * Removes unneeded extensions from the frontend based on
1491 * EMCONF doNotLoadInFE = 1
1493 * @param string $extList
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]);
1504 $nonFEList = implode(',', $extListArray);
1509 * Updates the database according to extension requirements
1510 * DBAL compliant (based on Install Tool code)
1512 * @param string Extension key
1513 * @param array Extension information array
1516 function forceDBupdates($extKey, $extInfo) {
1517 $instObj = new t3lib_install
;
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');
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);
1529 foreach ((array) $update_statements['add'] as $string) {
1530 $GLOBALS['TYPO3_DB']->admin_query($string);
1532 foreach ((array) $update_statements['change'] as $string) {
1533 $GLOBALS['TYPO3_DB']->admin_query($string);
1535 foreach ((array) $update_statements['create_table'] as $string) {
1536 $GLOBALS['TYPO3_DB']->admin_query($string);
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');
1545 $statements = $instObj->getStatementarray($fileContent, 1);
1546 list($statements_table, $insertCount) = $instObj->getCreateTables($statements, 1);
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);
1553 if ($insertCount[$table]) {
1554 $statements_insert = $instObj->getTableInsertStatements($statements, $table);
1556 foreach ($statements_insert as $v) {
1557 $GLOBALS['TYPO3_DB']->admin_query($v);
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']);