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 $content .= sprintf($GLOBALS['LANG']->getLL('ext_import_file_not_created'),
190 $extDirPath . $theFile) . '<br />';
191 } elseif (md5(t3lib_div
::getUrl($extDirPath . $theFile)) != $fileData['content_md5']) {
192 $content .= sprintf($GLOBALS['LANG']->getLL('ext_import_file_corrupted'),
193 $extDirPath . $theFile) . '<br />';
197 t3lib_div
::fixPermissions($extDirPath, TRUE);
199 // No content, no errors. Create success output here:
201 $messageContent = sprintf($GLOBALS['LANG']->getLL('ext_import_success_folder'), $extDirPath) . '<br />';
203 $uploadSucceed = true;
205 // Fix TYPO3_MOD_PATH for backend modules in extension:
206 $modules = t3lib_div
::trimExplode(',', $EM_CONF['module'], 1);
207 if (count($modules)) {
208 foreach ($modules as $mD) {
209 $confFileName = $extDirPath . $mD . '/conf.php';
210 if (@is_file
($confFileName)) {
211 $messageContent .= tx_em_Tools
::writeTYPO3_MOD_PATH($confFileName, $loc, $extKey . '/' . $mD . '/') . '<br />';
213 $messageContent .= sprintf($GLOBALS['LANG']->getLL('ext_import_no_conf_file'),
214 $confFileName) . '<br />';
218 // 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.
219 // But this order of the code works.... (using the empty Array with type, EMCONF and files hereunder).
221 // Writing to ext_emconf.php:
222 $sEMD5A = $extensionDetails->serverExtensionMD5array($extKey, array('type' => $loc, 'EM_CONF' => array(), 'files' => array()));
223 $EM_CONF['_md5_values_when_last_written'] = serialize($sEMD5A);
224 $emConfFile = $extensionDetails->construct_ext_emconf_file($extKey, $EM_CONF);
225 t3lib_div
::writeFile($extDirPath . 'ext_emconf.php', $emConfFile);
227 $messageContent .= 'ext_emconf.php: ' . $extDirPath . 'ext_emconf.php<br />';
228 $messageContent .= $GLOBALS['LANG']->getLL('ext_import_ext_type') . ' ';
229 $messageContent .= $this->api
->typeLabels
[$loc] . '<br />';
230 $messageContent .= '<br />';
232 // Remove cache files:
234 if (t3lib_extMgm
::isLoaded($extKey)) {
235 if (t3lib_extMgm
::removeCacheFiles()) {
236 $messageContent .= $GLOBALS['LANG']->getLL('ext_import_cache_files_removed') . '<br />';
239 list($new_list) = $this->parentObject
->extensionList
->getInstalledExtensions();
240 $updateContent = $this->updatesForm($extKey, $new_list[$extKey], 1, t3lib_div
::linkThisScript(array(
241 'CMD[showExt]' => $extKey,
242 'SET[singleDetails]' => 'info'
246 if (!$this->silentMode
) {
247 $flashMessage = t3lib_div
::makeInstance(
248 't3lib_FlashMessage',
250 $GLOBALS['LANG']->getLL('ext_import_success')
252 $content = $flashMessage->render();
254 $content = $updateContent;
258 // Install / Uninstall:
259 if (!$this->parentObject
->CMD
['standAlone']) {
260 $content .= '<h3>' . $GLOBALS['LANG']->getLL('ext_import_install_uninstall') . '</h3>';
261 $content .= $new_list[$extKey] ?
262 '<a href="' . htmlspecialchars(t3lib_div
::linkThisScript(array(
263 'CMD[showExt]' => $extKey,
266 'SET[singleDetails]' => 'info'
268 tx_em_Tools
::removeButton() . ' ' . $GLOBALS['LANG']->getLL('ext_import_uninstall') . '</a>' :
269 '<a href="' . htmlspecialchars(t3lib_div
::linkThisScript(array(
270 'CMD[showExt]' => $extKey,
273 'SET[singleDetails]' => 'info'
275 tx_em_Tools
::installButton() . ' ' . $GLOBALS['LANG']->getLL('ext_import_install') . '</a>';
277 $content = $GLOBALS['LANG']->getLL('ext_import_imported') .
279 if ($this->silentMode
) {
280 $content .= '<a id="closewindow" href="javascript:parent.TYPO3.EM.Tools.closeImportWindow();">' . $GLOBALS['LANG']->getLL('ext_import_close') . '</a>';
282 $content .= '<a href="javascript:opener.top.list.iframe.document.forms[0].submit();window.close();">' .
283 $GLOBALS['LANG']->getLL('ext_import_close_check') . '</a>';
292 $content = sprintf($GLOBALS['LANG']->getLL('ext_import_ext_path_different'), $extDirPath);
299 $content = sprintf($GLOBALS['LANG']->getLL('ext_import_ext_only_here'),
300 tx_em_Tools
::typePath($EM_CONF['lockType']), $EM_CONF['lockType']);
303 $content = $GLOBALS['LANG']->getLL('ext_import_no_ext_key_files');
306 $content = sprintf($GLOBALS['LANG']->getLL('ext_import_data_transfer'), $fetchData);
309 $content = sprintf($GLOBALS['LANG']->getLL('ext_import_no_install_here'), tx_em_Tools
::typePath($loc));
316 *Check extension dependencies
318 * @param string $extKey
320 * @param array $instExtInfo
323 function checkDependencies($extKey, $conf, $instExtInfo) {
328 $depsolver = t3lib_div
::_POST('depsolver');
330 if (isset($conf['constraints']['depends']) && is_array($conf['constraints']['depends'])) {
331 foreach ($conf['constraints']['depends'] as $depK => $depV) {
332 if ($depsolver['ignore'][$depK]) {
333 $msg[] = '<br />' . sprintf($GLOBALS['LANG']->getLL('checkDependencies_ignored'),
335 <input type="hidden" value="1" name="depsolver[ignore][' . $depK . ']" />';
339 if ($depK == 'php') {
343 $versionRange = tx_em_Tools
::splitVersionRange($depV);
344 $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!
345 if ($versionRange[0] != '0.0.0' && version_compare($phpv, $versionRange[0], '<')) {
346 $msg[] = '<br />' . sprintf($GLOBALS['LANG']->getLL('checkDependencies_php_too_low'),
347 $phpv, $versionRange[0]);
348 $msg[] = ' <input type="checkbox" value="1" name="depsolver[ignore][' . $depK . ']" id="checkIgnore_' . $depK . '" />
349 <label for="checkIgnore_' . $depK . '">' . $GLOBALS['LANG']->getLL('checkDependencies_ignore_requirement') . '</label>';
352 } elseif ($versionRange[1] != '0.0.0' && version_compare($phpv, $versionRange[1], '>')) {
353 $msg[] = '<br />' . sprintf($GLOBALS['LANG']->getLL('checkDependencies_php_too_high'),
354 $phpv, $versionRange[1]);
355 $msg[] = ' <input type="checkbox" value="1" name="depsolver[ignore][' . $depK . ']" id="checkIgnore_' . $depK . '" />
356 <label for="checkIgnore_' . $depK . '">' . $GLOBALS['LANG']->getLL('checkDependencies_ignore_requirement') . '</label>';
361 } elseif ($depK == 'typo3') {
366 // if the current TYPO3 version is a development version (like TYPO3 4.4-dev),
367 // then it should behave like TYPO3 4.4.0
368 $t3version = TYPO3_version
;
369 if (stripos($t3version, '-dev')
370 ||
stripos($t3version, '-alpha')
371 ||
stripos($t3version, '-beta')
372 ||
stripos($t3version, '-RC')) {
373 // find the last occurence of "-" and replace that part with a ".0"
374 $t3version = substr($t3version, 0, strrpos($t3version, '-')) . '.0';
377 $versionRange = tx_em_Tools
::splitVersionRange($depV);
378 if ($versionRange[0] != '0.0.0' && version_compare($t3version, $versionRange[0], '<')) {
379 $msg[] = '<br />' . sprintf($GLOBALS['LANG']->getLL('checkDependencies_typo3_too_low'),
380 $t3version, $versionRange[0]);
381 $msg[] = ' <input type="checkbox" value="1" name="depsolver[ignore][' . $depK . ']" id="checkIgnore_' . $depK . '" />
382 <label for="checkIgnore_' . $depK . '">' . $GLOBALS['LANG']->getLL('checkDependencies_ignore_requirement') . '</label>';
385 } elseif ($versionRange[1] != '0.0.0' && version_compare($t3version, $versionRange[1], '>')) {
386 $msg[] = '<br />' . sprintf($GLOBALS['LANG']->getLL('checkDependencies_typo3_too_high'),
387 $t3version, $versionRange[1]);
388 $msg[] = ' <input type="checkbox" value="1" name="depsolver[ignore][' . $depK . ']" id="checkIgnore_' . $depK . '" />
389 <label for="checkIgnore_' . $depK . '">' . $GLOBALS['LANG']->getLL('checkDependencies_ignore_requirement') . '</label>';
393 } elseif (strlen($depK) && !t3lib_extMgm
::isLoaded($depK)) { // strlen check for braindead empty dependencies coming from extensions...
394 if (!isset($instExtInfo[$depK])) {
395 $msg[] = '<br />' . sprintf($GLOBALS['LANG']->getLL('checkDependencies_ext_not_available'),
397 $msg[] = ' ' . t3lib_iconWorks
::getSpriteIcon('actions-system-extension-import', array('title' => $GLOBALS['LANG']->getLL('checkDependencies_import_ext'))) . '
398 <a href="' . t3lib_div
::linkThisUrl($this->parentObject
->script
, array(
399 'CMD[importExt]' => $depK,
401 'CMD[standAlone]' => 1
402 )) . '" target="_blank">' . $GLOBALS['LANG']->getLL('checkDependencies_import_now') . '</a>';
403 $msg[] = ' <input type="checkbox" value="1" name="depsolver[ignore][' . $depK . ']" id="checkIgnore_' . $depK . '" />
404 <label for="checkIgnore_' . $depK . '">' . $GLOBALS['LANG']->getLL('checkDependencies_ignore_ext_requirement') . '</label>';
406 $msg[] = '<br />' . sprintf($GLOBALS['LANG']->getLL('checkDependencies_ext_not_installed'),
407 $depK, $instExtInfo[$depK]['EM_CONF']['title']);
408 $msg[] = ' ' . tx_em_Tools
::installButton() . '
409 <a href="' . t3lib_div
::linkThisUrl($this->parentObject
->script
, array(
410 'CMD[showExt]' => $depK,
413 'CMD[standAlone]' => 1,
414 'SET[singleDetails]' => 'info'
416 '" target="_blank">' . $GLOBALS['LANG']->getLL('checkDependencies_install_now') . '</a>';
417 $msg[] = ' <input type="checkbox" value="1" name="depsolver[ignore][' . $depK . ']" id="checkIgnore_' . $depK . '" />
418 <label for="checkIgnore_' . $depK . '">' . $GLOBALS['LANG']->getLL('checkDependencies_ignore_ext_requirement') . '</label>';
422 $versionRange = tx_em_Tools
::splitVersionRange($depV);
423 if ($versionRange[0] != '0.0.0' && version_compare($instExtInfo[$depK]['EM_CONF']['version'], $versionRange[0], '<')) {
424 $msg[] = '<br />' . sprintf($GLOBALS['LANG']->getLL('checkDependencies_ext_too_low'),
425 $depK, $instExtInfo[$depK]['EM_CONF']['version'], $versionRange[0]);
426 $msg[] = ' <input type="checkbox" value="1" name="depsolver[ignore][' . $depK . ']" id="checkIgnore_' . $depK . '" />
427 <label for="checkIgnore_' . $depK . '">' . $GLOBALS['LANG']->getLL('checkDependencies_ignore_requirement') . '</label>';
430 } elseif ($versionRange[1] != '0.0.0' && version_compare($instExtInfo[$depK]['EM_CONF']['version'], $versionRange[1], '>')) {
431 $msg[] = '<br />' . sprintf($GLOBALS['LANG']->getLL('checkDependencies_ext_too_high'),
432 $depK, $instExtInfo[$depK]['EM_CONF']['version'], $versionRange[1]);
433 $msg[] = ' <input type="checkbox" value="1" name="depsolver[ignore][' . $depK . ']" id="checkIgnore_' . $depK . '" />
434 <label for="checkIgnore_' . $depK . '">' . $GLOBALS['LANG']->getLL('checkDependencies_ignore_requirement') . '</label>';
442 if (($depError ||
$depIgnore) && $this->parentObject
instanceof SC_mod_tools_em_index
) {
443 $content .= $this->parentObject
->doc
->section(
444 $GLOBALS['LANG']->getLL('removeExtFromList_dependency_error'),
445 implode('<br />', $msg), 0, 1, 2
449 // Check conflicts with other extensions:
450 $conflictError = false;
451 $conflictIgnore = false;
454 if (isset($conf['constraints']['conflicts']) && is_array($conf['constraints']['conflicts'])) {
455 foreach ((array) $conf['constraints']['conflicts'] as $conflictK => $conflictV) {
456 if ($depsolver['ignore'][$conflictK]) {
457 $msg[] = '<br />' . sprintf($GLOBALS['LANG']->getLL('checkDependencies_conflict_ignored'),
459 <input type="hidden" value="1" name="depsolver[ignore][' . $conflictK . ']" />';
460 $conflictIgnore = true;
463 if (t3lib_extMgm
::isLoaded($conflictK)) {
464 $versionRange = tx_em_Tools
::splitVersionRange($conflictV);
465 if ($versionRange[0] != '0.0.0' && version_compare($instExtInfo[$conflictK]['EM_CONF']['version'], $versionRange[0], '<')) {
468 elseif ($versionRange[1] != '0.0.0' && version_compare($instExtInfo[$conflictK]['EM_CONF']['version'], $versionRange[1], '>')) {
471 $msg[] = sprintf($GLOBALS['LANG']->getLL('checkDependencies_conflict_remove'),
472 $extKey, $conflictK, $instExtInfo[$conflictK]['EM_CONF']['title'], $conflictK, $extKey);
473 $msg[] = ' ' . tx_em_Tools
::removeButton() . '
474 <a href="' . htmlspecialchars(t3lib_div
::linkThisScript(array(
475 'CMD[showExt]' => $conflictK,
478 'CMD[standAlone]' => 1,
479 'SET[singleDetails]' => 'info'
481 '" target="_blank">' . $GLOBALS['LANG']->getLL('checkDependencies_remove_now') . '</a>';
482 $msg[] = ' <input type="checkbox" value="1" name="depsolver[ignore][' . $conflictK . ']" id="checkIgnore_' . $conflictK . '" />
483 <label for="checkIgnore_' . $conflictK . '">' . $GLOBALS['LANG']->getLL('checkDependencies_ignore_conflict') . '</label>';
484 $conflictError = true;
488 if ($conflictError ||
$conflictIgnore) {
489 $content .= $this->parentObject
->doc
->section(
490 $GLOBALS['LANG']->getLL('checkDependencies_conflict_error'), implode('<br />', $msg), 0, 1, 2
494 // Check suggests on other extensions:
495 if (isset($conf['constraints']['suggests']) && is_array($conf['constraints']['suggests'])) {
497 $suggestionIgnore = false;
499 foreach ($conf['constraints']['suggests'] as $suggestK => $suggestV) {
500 if ($depsolver['ignore'][$suggestK]) {
501 $msg[] = '<br />' . sprintf($GLOBALS['LANG']->getLL('checkDependencies_suggestion_ignored'),
503 <input type="hidden" value="1" name="depsolver[ignore][' . $suggestK . ']" />';
504 $suggestionIgnore = true;
507 if (!t3lib_extMgm
::isLoaded($suggestK)) {
508 if (!isset($instExtInfo[$suggestK])) {
509 $msg[] = sprintf($GLOBALS['LANG']->getLL('checkDependencies_suggest_import'),
511 $msg[] = ' ' . t3lib_iconWorks
::getSpriteIcon('actions-system-extension-import', array('title' => $GLOBALS['LANG']->getLL('checkDependencies_import_ext'))) . '
512 <a href="' . t3lib_div
::linkThisScript(array(
513 'CMD[importExt]' => $suggestK,
515 'CMD[standAlone]' => 1
516 )) . '" target="_blank">' . $GLOBALS['LANG']->getLL('checkDependencies_import_now') . '</a>';
517 $msg[] = ' <input type="checkbox" value="1" name="depsolver[ignore][' . $suggestK . ']" id="checkIgnore_' . $suggestK . '" />
518 <label for="checkIgnore_' . $suggestK . '">' . $GLOBALS['LANG']->getLL('checkDependencies_ignore_suggestion') . '</label>';
520 $msg[] = sprintf($GLOBALS['LANG']->getLL('checkDependencies_suggest_installation'),
521 $suggestK, $instExtInfo[$suggestK]['EM_CONF']['title']);
522 $msg[] = ' ' . tx_em_Tools
::installButton() . '
523 <a href="' . htmlspecialchars(t3lib_div
::linkThisScript(array(
524 'CMD[showExt]' => $suggestK,
527 'CMD[standAlone]' => 1,
528 'SET[singleDetails]' => 'info'
530 '" target="_blank">' . $GLOBALS['LANG']->getLL('checkDependencies_install_now') . '</a>';
531 $msg[] = ' <input type="checkbox" value="1" name="depsolver[ignore][' . $suggestK . ']" id="checkIgnore_' . $suggestK . '" />
532 <label for="checkIgnore_' . $suggestK . '">' . $GLOBALS['LANG']->getLL('checkDependencies_ignore_suggestion') . '</label>';
537 if ($suggestion ||
$suggestionIgnore) {
538 $content .= $this->parentObject
->doc
->section(
539 sprintf($GLOBALS['LANG']->getLL('checkDependencies_exts_suggested_by_ext'), $extKey),
540 implode('<br />', $msg), 0, 1, 1
545 if ($depError ||
$conflictError ||
$suggestion) {
546 foreach ($this->parentObject
->CMD
as $k => $v) {
547 $content .= '<input type="hidden" name="CMD[' . $k . ']" value="' . $v . '" />';
549 $content .= '<br /><br /><input type="submit" value="' . $GLOBALS['LANG']->getLL('checkDependencies_try_again') . '" />';
552 'returnCode' => FALSE,
553 'html' => '<form action="' . $this->parentObject
->script
. '" method="post" name="depform">' . $content . '</form>');
563 * Delete extension from the file system
565 * @param string Extension key
566 * @param array Extension info array
567 * @return string Returns message string about the status of the operation
569 function extDelete($extKey, $extInfo, $command) {
570 $absPath = tx_em_Tools
::getExtPath($extKey, $extInfo['type']);
571 if (t3lib_extMgm
::isLoaded($extKey)) {
572 return $GLOBALS['LANG']->getLL('extDelete_ext_active');
573 } elseif (!tx_em_Tools
::deleteAsType($extInfo['type'])) {
574 return sprintf($GLOBALS['LANG']->getLL('extDelete_wrong_scope'),
575 $this->api
->typeLabels
[$extInfo['type']]
577 } elseif (t3lib_div
::inList('G,L', $extInfo['type'])) {
578 if ($command['doDelete'] && !strcmp($absPath, urldecode($command['absPath']))) {
579 $res = $this->removeExtDirectory($absPath);
581 if (!$this->silentMode
) {
582 $flashMessage = t3lib_div
::makeInstance(
583 't3lib_FlashMessage',
585 sprintf($GLOBALS['LANG']->getLL('extDelete_remove_dir_failed'), $absPath),
586 t3lib_FlashMessage
::ERROR
588 return $flashMessage->render();
592 if (!$this->silentMode
) {
593 $flashMessage = t3lib_div
::makeInstance(
594 't3lib_FlashMessage',
595 sprintf($GLOBALS['LANG']->getLL('extDelete_removed'), $absPath),
596 $GLOBALS['LANG']->getLL('extDelete_removed_header'),
597 t3lib_FlashMessage
::OK
599 return $flashMessage->render();
604 $areYouSure = $GLOBALS['LANG']->getLL('extDelete_sure');
605 $deleteFromServer = $GLOBALS['LANG']->getLL('extDelete_from_server');
606 $onClick = "if (confirm('$areYouSure')) {window.location.href='" . t3lib_div
::linkThisScript(array(
607 'CMD[showExt]' => $extKey,
608 'CMD[doDelete]' => 1,
609 'CMD[absPath]' => rawurlencode($absPath)
611 $content .= '<a class="t3-link" href="#" onclick="' . htmlspecialchars($onClick) .
612 ' return false;"><strong>' . $deleteFromServer . '</strong> ' .
613 sprintf($GLOBALS['LANG']->getLL('extDelete_from_location'),
614 $this->api
->typeLabels
[$extInfo['type']],
615 substr($absPath, strlen(PATH_site
))
617 $content .= '<br /><br />' . $GLOBALS['LANG']->getLL('extDelete_backup');
621 return $GLOBALS['LANG']->getLL('extDelete_neither_global_nor_local');
626 * Removes the extension directory (including content)
628 * @param string Extension directory to remove (with trailing slash)
629 * @param boolean If set, will leave the extension directory
630 * @return boolean False on success, otherwise error string.
632 function removeExtDirectory($removePath, $removeContentOnly = 0) {
634 if (@is_dir
($removePath) && substr($removePath, -1) == '/' && (
635 t3lib_div
::isFirstPartOfStr($removePath, tx_em_Tools
::typePath('G')) ||
636 t3lib_div
::isFirstPartOfStr($removePath, tx_em_Tools
::typePath('L')) ||
637 (t3lib_div
::isFirstPartOfStr($removePath, tx_em_Tools
::typePath('S')) && $this->systemInstall
) ||
638 t3lib_div
::isFirstPartOfStr($removePath, PATH_site
. $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] . '_temp_/')) // Playing-around directory...
641 // All files in extension directory:
642 $fileArr = t3lib_div
::getAllFilesAndFoldersInPath(array(), $removePath, '', 1);
643 if (is_array($fileArr)) {
645 // Remove files in dirs:
646 foreach ($fileArr as $removeFile) {
647 if (!@is_dir
($removeFile)) {
648 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!
649 @unlink
($removeFile);
651 if (@is_file
($removeFile)) {
652 $errors[] = sprintf($GLOBALS['LANG']->getLL('rmExtDir_could_not_be_deleted'),
657 $errors[] = sprintf($GLOBALS['LANG']->getLL('rmExtDir_error_file'),
658 $removeFile, $removePath
664 // Remove directories:
665 $remDirs = tx_em_Tools
::extractDirsFromFileList(t3lib_div
::removePrefixPathFromList($fileArr, $removePath));
666 $remDirs = array_reverse($remDirs); // Must delete outer directories first...
667 foreach ($remDirs as $removeRelDir) {
668 $removeDir = $removePath . $removeRelDir;
669 if (@is_dir
($removeDir)) {
672 if (@is_dir
($removeDir)) {
673 $errors[] = sprintf($GLOBALS['LANG']->getLL('rmExtDir_error_files_left'),
678 $errors[] = sprintf($GLOBALS['LANG']->getLL('rmExtDir_error_no_dir'),
684 // If extension dir should also be removed:
685 if (!$removeContentOnly) {
688 if (@is_dir
($removePath)) {
689 $errors[] = sprintf($GLOBALS['LANG']->getLL('rmExtDir_error_folders_left'),
695 $errors[] = $GLOBALS['LANG']->getLL('rmExtDir_error') . ' ' . $fileArr;
698 $errors[] = $GLOBALS['LANG']->getLL('rmExtDir_error_unallowed_path') . ' ' . $removePath;
701 // Return errors if any:
702 return implode(LF
, $errors);
706 * Validates the database according to extension requirements
707 * Prints form for changes if any. If none, returns blank. If an update is ordered, empty is returned as well.
708 * DBAL compliant (based on Install Tool code)
710 * @param string Extension key
711 * @param array Extension information array
712 * @param boolean If true, returns array with info.
713 * @return mixed If $infoOnly, returns array with information. Otherwise performs update.
715 function checkDBupdates($extKey, $extInfo, $infoOnly = 0) {
721 // Updating tables and fields?
722 if (is_array($extInfo['files']) && in_array('ext_tables.sql', $extInfo['files'])) {
723 $path = tx_em_Tools
::getExtPath($extKey, $extInfo['type']);
724 $fileContent = t3lib_div
::getUrl($path . 'ext_tables.sql');
726 $FDfile = $this->install
->getFieldDefinitions_fileContent($fileContent);
727 if (count($FDfile)) {
728 $FDdb = $this->install
->getFieldDefinitions_database(TYPO3_db
);
729 $diff = $this->install
->getDatabaseExtra($FDfile, $FDdb);
730 $update_statements = $this->install
->getUpdateSuggestions($diff);
732 $dbStatus['structure']['tables_fields'] = $FDfile;
733 $dbStatus['structure']['diff'] = $diff;
735 // Updating database...
736 if (!$infoOnly && is_array($this->install
->INSTALL
['database_update'])) {
737 $this->install
->performUpdateQueries($update_statements['add'], $this->install
->INSTALL
['database_update']);
738 $this->install
->performUpdateQueries($update_statements['change'], $this->install
->INSTALL
['database_update']);
739 $this->install
->performUpdateQueries($update_statements['create_table'], $this->install
->INSTALL
['database_update']);
741 $content .= $this->install
->generateUpdateDatabaseForm_checkboxes(
742 $update_statements['add'], $GLOBALS['LANG']->getLL('checkDBupdates_add_fields'));
743 $content .= $this->install
->generateUpdateDatabaseForm_checkboxes(
744 $update_statements['change'], $GLOBALS['LANG']->getLL('checkDBupdates_changing_fields'), 1, 0, $update_statements['change_currentValue']);
745 $content .= $this->install
->generateUpdateDatabaseForm_checkboxes(
746 $update_statements['create_table'], $GLOBALS['LANG']->getLL('checkDBupdates_add_tables'));
751 // Importing static tables?
752 if (is_array($extInfo['files']) && in_array('ext_tables_static+adt.sql', $extInfo['files'])) {
753 $fileContent = t3lib_div
::getUrl(tx_em_Tools
::getExtPath($extKey, $extInfo['type']) . 'ext_tables_static+adt.sql');
755 $statements = $this->install
->getStatementarray($fileContent, 1);
756 list($statements_table, $insertCount) = $this->install
->getCreateTables($statements, 1);
758 // Execute import of static table content:
759 if (!$infoOnly && is_array($this->install
->INSTALL
['database_import'])) {
761 // Traverse the tables
762 foreach ($this->install
->INSTALL
['database_import'] as $table => $md5str) {
763 if ($md5str == md5($statements_table[$table])) {
764 $GLOBALS['TYPO3_DB']->admin_query('DROP TABLE IF EXISTS ' . $table);
765 $GLOBALS['TYPO3_DB']->admin_query($statements_table[$table]);
767 if ($insertCount[$table]) {
768 $statements_insert = $this->install
->getTableInsertStatements($statements, $table);
770 foreach ($statements_insert as $v) {
771 $GLOBALS['TYPO3_DB']->admin_query($v);
777 $whichTables = $this->install
->getListOfTables();
778 if (count($statements_table)) {
780 foreach ($statements_table as $table => $definition) {
781 $exist = isset($whichTables[$table]);
783 $dbStatus['static'][$table]['exists'] = $exist;
784 $dbStatus['static'][$table]['count'] = $insertCount[$table];
787 <td><input type="checkbox" name="TYPO3_INSTALL[database_import][' . $table . ']" checked="checked" value="' . md5($definition) . '" /></td>
788 <td><strong>' . $table . '</strong></td>
789 <td><img src="clear.gif" width="10" height="1" alt="" /></td>
790 <td nowrap="nowrap">' .
791 ($insertCount[$table] ?
792 $GLOBALS['LANG']->getLL('checkDBupdates_rows') . ' ' . $insertCount[$table]
795 <td><img src="clear.gif" width="10" height="1" alt="" /></td>
796 <td nowrap="nowrap">' .
798 t3lib_iconWorks
::getSpriteIcon('status-dialog-warning') .
799 $GLOBALS['LANG']->getLL('checkDBupdates_table_exists')
806 <h3>' . $GLOBALS['LANG']->getLL('checkDBupdates_import_static_data') . '</h3>
807 <table border="0" cellpadding="0" cellspacing="0">' . $out . '</table>
813 // Return array of information if $infoOnly, otherwise content.
814 return $infoOnly ?
$dbStatus : $content;
818 * Removes the current extension of $type and creates the base folder for the new one (which is going to be imported)
820 * @param array Data for imported extension
821 * @param string Extension installation scope (L,G,S)
822 * @param boolean If set, nothing will be deleted (neither directory nor files)
823 * @return mixed Returns array on success (with extension directory), otherwise an error string.
825 function clearAndMakeExtensionDir($importedData, $type, $dontDelete = 0) {
826 if (!$importedData['extKey']) {
827 return $GLOBALS['LANG']->getLL('clearMakeExtDir_no_ext_key');
830 // Setting install path (L, G, S or fileadmin/_temp_/)
832 switch ((string) $type) {
835 $path = tx_em_Tools
::typePath($type);
838 // Creates the typo3conf/ext/ directory if it does NOT already exist:
839 if ((string) $type == 'L' && !@is_dir
($path)) {
840 t3lib_div
::mkdir($path);
844 if ($this->systemInstall
&& (string) $type == 'S') {
845 $path = tx_em_Tools
::typePath($type);
848 $path = PATH_site
. $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] . '_temp_/';
849 $suffix = '_' . date('dmy-His');
854 // If the install path is OK...
855 if ($path && @is_dir
($path)) {
857 // Set extension directory:
858 $extDirPath = $path . $importedData['extKey'] . $suffix . '/';
860 // Install dir was found, remove it then:
861 if (@is_dir
($extDirPath)) {
863 return array($extDirPath);
865 $res = $this->removeExtDirectory($extDirPath);
867 if (!$this->silentMode
) {
868 $flashMessage = t3lib_div
::makeInstance(
869 't3lib_FlashMessage',
871 sprintf($GLOBALS['LANG']->getLL('clearMakeExtDir_could_not_remove_dir'), $extDirPath),
872 t3lib_FlashMessage
::ERROR
874 return $flashMessage->render();
881 t3lib_div
::mkdir($extDirPath);
882 if (!is_dir($extDirPath)) {
883 return sprintf($GLOBALS['LANG']->getLL('clearMakeExtDir_could_not_create_dir'),
886 return array($extDirPath);
888 return sprintf($GLOBALS['LANG']->getLL('clearMakeExtDir_no_dir'),
894 /*******************************
896 * Extension analyzing (detailed information)
898 ******************************/
901 * Perform a detailed, technical analysis of the available extension on server!
902 * Includes all kinds of verifications
903 * Takes some time to process, therfore use with care, in particular in listings.
905 * @param string Extension key
906 * @param array Extension information
907 * @param boolean If set, checks for validity of classes etc.
908 * @return array Information in an array.
910 function makeDetailedExtensionAnalysis($extKey, $extInfo, $validity = 0) {
912 // Get absolute path of the extension
913 $absPath = tx_em_Tools
::getExtPath($extKey, $extInfo['type']);
914 $extensionDetails = t3lib_div
::makeInstance('tx_em_Extensions_Details', $this);
915 $infoArray = array();
917 $table_class_prefix = substr($extKey, 0, 5) == 'user_' ?
'user_' : 'tx_' . str_replace('_', '', $extKey) . '_';
918 $module_prefix = substr($extKey, 0, 5) == 'user_' ?
'u' : 'tx' . str_replace('_', '', $extKey);
921 $dbInfo = $this->checkDBupdates($extKey, $extInfo, 1);
923 // Database structure required:
924 if (is_array($dbInfo['structure']['tables_fields'])) {
925 $modify_tables = t3lib_div
::trimExplode(',', $extInfo['EM_CONF']['modify_tables'], 1);
926 $infoArray['dump_tf'] = array();
928 foreach ($dbInfo['structure']['tables_fields'] as $tN => $d) {
929 if (in_array($tN, $modify_tables)) {
930 $infoArray['fields'][] = $tN . ': <i>' .
931 (is_array($d['fields']) ?
implode(', ', array_keys($d['fields'])) : '') .
932 (is_array($d['keys']) ?
933 ' + ' . count($d['keys']) . ' ' . $GLOBALS['LANG']->getLL('detailedExtAnalysis_keys') : '') .
935 if (is_array($d['fields'])) {
936 foreach ($d['fields'] as $fN => $value) {
937 $infoArray['dump_tf'][] = $tN . '.' . $fN;
938 if (!t3lib_div
::isFirstPartOfStr($fN, $table_class_prefix)) {
939 $infoArray['NSerrors']['fields'][$fN] = $fN;
941 $infoArray['NSok']['fields'][$fN] = $fN;
945 if (is_array($d['keys'])) {
946 foreach ($d['keys'] as $fN => $value) {
947 $infoArray['dump_tf'][] = $tN . '.KEY:' . $fN;
951 $infoArray['dump_tf'][] = $tN;
952 $infoArray['tables'][] = $tN;
953 if (!t3lib_div
::isFirstPartOfStr($tN, $table_class_prefix)) {
954 $infoArray['NSerrors']['tables'][$tN] = $tN;
956 $infoArray['NSok']['tables'][$tN] = $tN;
960 if (count($dbInfo['structure']['diff']['diff']) ||
count($dbInfo['structure']['diff']['extra'])) {
962 if (count($dbInfo['structure']['diff']['diff'])) {
963 $msg[] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_tables_are_missing');
965 if (count($dbInfo['structure']['diff']['extra'])) {
966 $msg[] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_tables_are_of_wrong_type');
968 $infoArray['tables_error'] = 1;
969 if (t3lib_extMgm
::isLoaded($extKey)) {
970 $infoArray['errors'][] = sprintf($GLOBALS['LANG']->getLL('detailedExtAnalysis_tables_are'),
971 implode(' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:and') . ' ', $msg)
978 if (is_array($dbInfo['static'])) {
979 $infoArray['static'] = array_keys($dbInfo['static']);
981 foreach ($dbInfo['static'] as $tN => $d) {
983 $infoArray['static_error'] = 1;
984 if (t3lib_extMgm
::isLoaded($extKey)) {
985 $infoArray['errors'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_static_tables_missing');
987 if (!t3lib_div
::isFirstPartOfStr($tN, $table_class_prefix)) {
988 $infoArray['NSerrors']['tables'][$tN] = $tN;
990 $infoArray['NSok']['tables'][$tN] = $tN;
996 // Backend Module-check:
997 $knownModuleList = t3lib_div
::trimExplode(',', $extInfo['EM_CONF']['module'], 1);
998 foreach ($knownModuleList as $mod) {
999 if (@is_dir
($absPath . $mod)) {
1000 if (@is_file
($absPath . $mod . '/conf.php')) {
1001 $confFileInfo = $extensionDetails->modConfFileAnalysis($absPath . $mod . '/conf.php');
1002 if (is_array($confFileInfo['TYPO3_MOD_PATH'])) {
1003 $shouldBePath = tx_em_Tools
::typeRelPath($extInfo['type']) . $extKey . '/' . $mod . '/';
1004 if (strcmp($confFileInfo['TYPO3_MOD_PATH'][1][1], $shouldBePath)) {
1005 $infoArray['errors'][] = sprintf($GLOBALS['LANG']->getLL('detailedExtAnalysis_wrong_mod_path'),
1006 $confFileInfo['TYPO3_MOD_PATH'][1][1],
1011 // It seems like TYPO3_MOD_PATH and therefore also this warning is no longer needed.
1012 // $infoArray['errors'][] = 'No definition of TYPO3_MOD_PATH constant found inside!';
1014 if (is_array($confFileInfo['MCONF_name'])) {
1015 $mName = $confFileInfo['MCONF_name'][1][1];
1016 $mNameParts = explode('_', $mName);
1017 $infoArray['moduleNames'][] = $mName;
1018 if (!t3lib_div
::isFirstPartOfStr($mNameParts[0], $module_prefix) &&
1019 (!$mNameParts[1] ||
!t3lib_div
::isFirstPartOfStr($mNameParts[1], $module_prefix))) {
1020 $infoArray['NSerrors']['modname'][] = $mName;
1022 $infoArray['NSok']['modname'][] = $mName;
1025 $infoArray['errors'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_mconf_missing');
1028 $infoArray['errors'][] = sprintf($GLOBALS['LANG']->getLL('detailedExtAnalysis_be_module_conf_missing'),
1033 $infoArray['errors'][] = sprintf($GLOBALS['LANG']->getLL('detailedExtAnalysis_module_folder_missing'),
1038 $dirs = t3lib_div
::get_dirs($absPath);
1039 if (is_array($dirs)) {
1041 while (list(, $mod) = each($dirs)) {
1042 if (!in_array($mod, $knownModuleList) && @is_file
($absPath . $mod . '/conf.php')) {
1043 $confFileInfo = $extensionDetails->modConfFileAnalysis($absPath . $mod . '/conf.php');
1044 if (is_array($confFileInfo)) {
1045 $infoArray['errors'][] = sprintf($GLOBALS['LANG']->getLL('detailedExtAnalysis_unconfigured_module'),
1054 if (@is_file
($absPath . 'ext_tables.php')) {
1055 $content = t3lib_div
::getUrl($absPath . 'ext_tables.php');
1056 if (stristr($content, 't3lib_extMgm::addModule')) {
1057 $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_module');
1059 if (stristr($content, 't3lib_extMgm::insertModuleFunction')) {
1060 $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_module_and_more');
1062 if (stristr($content, 't3lib_div::loadTCA')) {
1063 $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_loadTCA');
1065 if (stristr($content, '$TCA[')) {
1066 $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_TCA');
1068 if (stristr($content, 't3lib_extMgm::addPlugin')) {
1069 $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_plugin');
1073 // ext_localconf.php:
1074 if (@is_file
($absPath . 'ext_localconf.php')) {
1075 $content = t3lib_div
::getUrl($absPath . 'ext_localconf.php');
1076 if (stristr($content, 't3lib_extMgm::addPItoST43')) {
1077 $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_plugin_st43');
1079 if (stristr($content, 't3lib_extMgm::addPageTSConfig')) {
1080 $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_page_ts');
1082 if (stristr($content, 't3lib_extMgm::addUserTSConfig')) {
1083 $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_user_ts');
1085 if (stristr($content, 't3lib_extMgm::addTypoScriptSetup')) {
1086 $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_ts_setup');
1088 if (stristr($content, 't3lib_extMgm::addTypoScriptConstants')) {
1089 $infoArray['flags'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_ts_constants');
1093 if (@is_file
($absPath . 'ext_typoscript_constants.txt')) {
1094 $infoArray['TSfiles'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_constants');
1096 if (@is_file
($absPath . 'ext_typoscript_setup.txt')) {
1097 $infoArray['TSfiles'][] = $GLOBALS['LANG']->getLL('detailedExtAnalysis_setup');
1099 if (@is_file
($absPath . 'ext_conf_template.txt')) {
1100 $infoArray['conf'] = 1;
1105 $filesInside = tx_em_Tools
::getClassIndexLocallangFiles($absPath, $table_class_prefix, $extKey);
1106 if (is_array($filesInside['errors'])) {
1107 $infoArray['errors'] = array_merge((array) $infoArray['errors'], $filesInside['errors']);
1109 if (is_array($filesInside['NSerrors'])) {
1110 $infoArray['NSerrors'] = array_merge((array) $infoArray['NSerrors'], $filesInside['NSerrors']);
1112 if (is_array($filesInside['NSok'])) {
1113 $infoArray['NSok'] = array_merge((array) $infoArray['NSok'], $filesInside['NSok']);
1115 $infoArray['locallang'] = $filesInside['locallang'];
1116 $infoArray['classes'] = $filesInside['classes'];
1120 if ($extInfo['EM_CONF']['uploadfolder']) {
1121 $infoArray['uploadfolder'] = tx_em_Tools
::uploadFolder($extKey);
1122 if (!@is_dir
(PATH_site
. $infoArray['uploadfolder'])) {
1123 $infoArray['errors'][] = sprintf($GLOBALS['LANG']->getLL('detailedExtAnalysis_no_upload_folder'),
1124 $infoArray['uploadfolder']
1126 $infoArray['uploadfolder'] = '';
1130 // Create directories:
1131 if ($extInfo['EM_CONF']['createDirs']) {
1132 $infoArray['createDirs'] = array_unique(t3lib_div
::trimExplode(',', $extInfo['EM_CONF']['createDirs'], 1));
1133 foreach ($infoArray['createDirs'] as $crDir) {
1134 if (!@is_dir
(PATH_site
. $crDir)) {
1135 $infoArray['errors'][] = sprintf($GLOBALS['LANG']->getLL('detailedExtAnalysis_no_upload_folder'),
1142 // Return result array:
1148 * Produces the config form for an extension (if any template file, ext_conf_template.txt is found)
1150 * @param string Extension key
1151 * @param array Extension information array
1152 * @param boolean If true, the form HTML content is returned, otherwise the content is set in $this->content.
1153 * @param string Submit-to URL (supposedly)
1154 * @param string Additional form fields to include.
1155 * @return string Depending on $output. Can return the whole form.
1157 function tsStyleConfigForm($extKey, $extInfo, $output = 0, $script = '', $addFields = '') {
1158 global $TYPO3_CONF_VARS;
1161 $absPath = tx_em_Tools
::getExtPath($extKey, $extInfo['type']);
1162 $relPath = tx_em_Tools
::typeRelPath($extInfo['type']) . $extKey . '/';
1166 // Look for template file for form:
1167 if (t3lib_extMgm
::isLoaded($extKey) && @is_file
($absPath . 'ext_conf_template.txt')) {
1169 // Load tsStyleConfig class and parse configuration template:
1170 $tsStyleConfig = t3lib_div
::makeInstance('t3lib_tsStyleConfig');
1171 $tsStyleConfig->doNotSortCategoriesBeforeMakingForm
= TRUE;
1172 $theConstants = $tsStyleConfig->ext_initTSstyleConfig(
1173 t3lib_div
::getUrl($absPath . 'ext_conf_template.txt'),
1176 $GLOBALS['BACK_PATH']
1179 // Load the list of resources.
1180 $tsStyleConfig->ext_loadResources($absPath . 'res/');
1182 // Load current value:
1183 $arr = unserialize($TYPO3_CONF_VARS['EXT']['extConf'][$extKey]);
1184 $arr = is_array($arr) ?
$arr : array();
1186 // Call processing function for constants config and data before write and form rendering:
1187 if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/mod/tools/em/index.php']['tsStyleConfigForm'])) {
1188 $_params = array('fields' => &$theConstants, 'data' => &$arr, 'extKey' => $extKey);
1189 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/mod/tools/em/index.php']['tsStyleConfigForm'] as $_funcRef) {
1190 t3lib_div
::callUserFunction($_funcRef, $_params, $this);
1195 // If saving operation is done:
1196 if (t3lib_div
::_POST('submit')) {
1197 $tsStyleConfig->ext_procesInput(t3lib_div
::_POST(), array(), $theConstants, array());
1198 $arr = $tsStyleConfig->ext_mergeIncomingWithExisting($arr);
1199 $this->writeTsStyleConfig($extKey, $arr);
1202 // Setting value array
1203 $tsStyleConfig->ext_setValuearray($theConstants, $arr);
1205 // Getting session data:
1206 $MOD_MENU = array();
1207 $MOD_MENU['constant_editor_cat'] = $tsStyleConfig->ext_getCategoriesForModMenu();
1208 $MOD_SETTINGS = t3lib_BEfunc
::getModuleData($MOD_MENU, t3lib_div
::_GP('SET'), 'xMod_test');
1210 // Resetting the menu (stop)
1211 if (count($MOD_MENU['constant_editor_cat']) > 1) {
1212 $menu = $GLOBALS['LANG']->getLL('extInfoArray_category') . ' ' .
1213 t3lib_BEfunc
::getFuncMenu(0, 'SET[constant_editor_cat]', $MOD_SETTINGS['constant_editor_cat'], $MOD_MENU['constant_editor_cat'], '', '&CMD[showExt]=' . $extKey);
1214 // add class to select
1215 $menu = str_replace('<select', '<select class="mod-menu-template-select"', $menu);
1216 $menu = str_replace('jumpToUrl', 'abc', $menu);
1218 if ($this->parentObject
instanceof SC_mod_tools_em_index
) {
1219 $this->parentObject
->content
.= $this->parentObject
->doc
->section('', '<span class="nobr">' . $menu . '</span>');
1220 $this->parentObject
->content
.= $this->parentObject
->doc
->spacer(10);
1222 $form .= '<h3>' . '<span class="nobr">' . $menu . '</span></h3>';
1226 // Category and constant editor config:
1228 <table border="0" cellpadding="0" cellspacing="0" width="600">
1230 <td>' . $tsStyleConfig->ext_getForm($MOD_SETTINGS['constant_editor_cat'], $theConstants, $script, $addFields, $extKey) . '</form></td>
1234 if (!$this->silentMode
) {
1235 $flashMessage = t3lib_div
::makeInstance(
1236 't3lib_FlashMessage',
1237 $GLOBALS['LANG']->getLL('tsStyleConfigForm_additional_config'),
1239 t3lib_FlashMessage
::INFO
1243 <table border="0" cellpadding="0" cellspacing="0" width="600">
1246 <form action="' . htmlspecialchars($script) . '" method="post">' .
1248 ($this->silentMode ?
'' : $flashMessage->render()) .
1249 '<br /><input type="submit" id="configuration-submit-' . $extKey . '" name="write" value="' . $GLOBALS['LANG']->getLL('updatesForm_make_updates') . '" />
1259 # $this->content.=$this->doc->section('', $form);
1266 * Writes the TSstyleconf values to "localconf.php"
1267 * Removes the temp_CACHED* files before return.
1269 * @param string Extension key
1270 * @param array Configuration array to write back
1273 function writeTsStyleConfig($extKey, $arr) {
1275 // Instance of install tool
1276 $instObj = new t3lib_install
;
1277 $instObj->allowUpdateLocalConf
= 1;
1278 $instObj->updateIdentity
= 'TYPO3 Extension Manager';
1280 // Get lines from localconf file
1281 $lines = $instObj->writeToLocalconf_control();
1282 $instObj->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'EXT\'][\'extConf\'][\'' . $extKey . '\']', serialize($arr)); // This will be saved only if there are no linebreaks in it !
1283 $instObj->writeToLocalconf_control($lines);
1285 t3lib_extMgm
::removeCacheFiles();
1290 * Creates a form for an extension which contains all options for configuration, updates of database, clearing of cache etc.
1292 * @param string $extKey Extension key
1293 * @param array $extInfo Extension information array
1294 * @param boolean $notSilent If set, the form will ONLY show if fields/tables should be updated (suppressing forms like general configuration and cache clearing).
1295 * @param string $script Alternative action=""-script
1296 * @param string $addFields Additional form fields
1297 * @param boolean $addFormTags TRUE if it shopuld be wrapped with form tag
1298 * @param boolean $excludeDatabaseCheck TRUE if no database check should be done
1301 function updatesForm($extKey, $extInfo, $notSilent = FALSE, $script = '', $addFields = '', $addFormTag = TRUE, $excludeDatabaseCheck = FALSE) {
1302 $script = $script ?
$script : t3lib_div
::linkThisScript();
1304 $formWrap = array('<form action="' . htmlspecialchars($script) . '" method="POST">', '</form>');
1306 $formWrap = array('', '');
1308 $extensionDetails = t3lib_div
::makeInstance('tx_em_Extensions_Details', $this);
1311 if (!$excludeDatabaseCheck) {
1312 $updates .= $this->checkDBupdates($extKey, $extInfo);
1315 $uCache = $this->checkClearCache($extInfo);
1317 $updates .= $uCache;
1319 $updates .= $extensionDetails->checkUploadFolder($extKey, $extInfo);
1321 $absPath = tx_em_Tools
::getExtPath($extKey, $extInfo['type']);
1322 if ($notSilent && @is_file
($absPath . 'ext_conf_template.txt')) {
1323 $configForm = $this->tsStyleConfigForm($extKey, $extInfo, 1, $script, $updates . $addFields . '<br />');
1326 if ($updates ||
$configForm) {
1328 $updates = $configForm;
1330 $updates = $formWrap[0] . $updates . $addFields . '
1331 <br /><input type="submit" name="write" id="update-submit-' . $extKey . '" value="' . $GLOBALS['LANG']->getLL('updatesForm_make_updates') . '" />
1341 * Check if clear-cache should be performed, otherwise show form (for installation of extension)
1342 * Shown only if the extension has the clearCacheOnLoad flag set.
1344 * @param string Extension key
1345 * @param array Extension information array
1346 * @return string HTML output (if form is shown)
1348 function checkClearCache($extInfo) {
1349 if ($extInfo['EM_CONF']['clearCacheOnLoad']) {
1350 if (t3lib_div
::_POST('_clear_all_cache')) { // Action: Clearing the cache
1351 $tce = t3lib_div
::makeInstance('t3lib_TCEmain');
1352 $tce->stripslashes_values
= 0;
1353 $tce->start(array(), array());
1354 $tce->clear_cacheCmd('all');
1355 } else { // Show checkbox for clearing cache:
1358 <h3>' . $GLOBALS['LANG']->getLL('checkUploadFolder_clear_cache') . '</h3>
1359 <p>' . $GLOBALS['LANG']->getLL('checkUploadFolder_clear_cache_requested') . '<br />
1360 <label for="check_clear_all_cache">' . $GLOBALS['LANG']->getLL('checkUploadFolder_clear_all_cache') . '</label>
1361 <input type="checkbox" name="_clear_all_cache" id="check_clear_all_cache" checked="checked" value="1" /><br />
1370 * Writes the extension list to "localconf.php" file
1371 * Removes the temp_CACHED* files before return.
1373 * @param string List of extensions
1376 function writeNewExtensionList($newExtList) {
1377 $strippedExtensionList = $this->stripNonFrontendExtensions($newExtList);
1379 // Instance of install tool
1380 $instObj = new t3lib_install
;
1381 $instObj->allowUpdateLocalConf
= 1;
1382 $instObj->updateIdentity
= 'TYPO3 Extension Manager';
1384 // Get lines from localconf file
1385 $lines = $instObj->writeToLocalconf_control();
1386 $instObj->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'EXT\'][\'extList\']', $newExtList);
1387 $instObj->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'EXT\'][\'extList_FE\']', $strippedExtensionList);
1388 $instObj->writeToLocalconf_control($lines);
1390 $GLOBALS['TYPO3_CONF_VARS']['EXT']['extList'] = $newExtList;
1391 $GLOBALS['TYPO3_CONF_VARS']['EXT']['extList_FE'] = $strippedExtensionList;
1392 t3lib_extMgm
::removeCacheFiles();
1396 * Removes unneeded extensions from the frontend based on
1397 * EMCONF doNotLoadInFE = 1
1399 * @param string $extList
1402 function stripNonFrontendExtensions($extList) {
1403 $fullExtList = $this->parentObject
->extensionList
->getInstalledExtensions();
1404 $extListArray = t3lib_div
::trimExplode(',', $extList);
1405 foreach ($extListArray as $arrayKey => $extKey) {
1406 if ($fullExtList[0][$extKey]['EM_CONF']['doNotLoadInFE'] == 1) {
1407 unset($extListArray[$arrayKey]);
1410 $nonFEList = implode(',', $extListArray);
1415 * Updates the database according to extension requirements
1416 * DBAL compliant (based on Install Tool code)
1418 * @param string Extension key
1419 * @param array Extension information array
1422 function forceDBupdates($extKey, $extInfo) {
1423 $instObj = new t3lib_install
;
1425 // Updating tables and fields?
1426 if (is_array($extInfo['files']) && in_array('ext_tables.sql', $extInfo['files'])) {
1427 $fileContent = t3lib_div
::getUrl(tx_em_Tools
::getExtPath($extKey, $extInfo['type']) . 'ext_tables.sql');
1429 $FDfile = $instObj->getFieldDefinitions_fileContent($fileContent);
1430 if (count($FDfile)) {
1431 $FDdb = $instObj->getFieldDefinitions_database(TYPO3_db
);
1432 $diff = $instObj->getDatabaseExtra($FDfile, $FDdb);
1433 $update_statements = $instObj->getUpdateSuggestions($diff);
1435 foreach ((array) $update_statements['add'] as $string) {
1436 $GLOBALS['TYPO3_DB']->admin_query($string);
1438 foreach ((array) $update_statements['change'] as $string) {
1439 $GLOBALS['TYPO3_DB']->admin_query($string);
1441 foreach ((array) $update_statements['create_table'] as $string) {
1442 $GLOBALS['TYPO3_DB']->admin_query($string);
1447 // Importing static tables?
1448 if (is_array($extInfo['files']) && in_array('ext_tables_static+adt.sql', $extInfo['files'])) {
1449 $fileContent = t3lib_div
::getUrl(tx_em_Tools
::getExtPath($extKey, $extInfo['type']) . 'ext_tables_static+adt.sql');
1451 $statements = $instObj->getStatementarray($fileContent, 1);
1452 list($statements_table, $insertCount) = $instObj->getCreateTables($statements, 1);
1454 // Traverse the tables
1455 foreach ($statements_table as $table => $query) {
1456 $GLOBALS['TYPO3_DB']->admin_query('DROP TABLE IF EXISTS ' . $table);
1457 $GLOBALS['TYPO3_DB']->admin_query($query);
1459 if ($insertCount[$table]) {
1460 $statements_insert = $instObj->getTableInsertStatements($statements, $table);
1462 foreach ($statements_insert as $v) {
1463 $GLOBALS['TYPO3_DB']->admin_query($v);
1472 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE
]['XCLASS']['typo3/sysext/em/classes/install/class.tx_em_install.php'])) {
1473 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE
]['XCLASS']['typo3/sysext/em/classes/install/class.tx_em_install.php']);