Fixed bug #14752: Add Update Wizards for Skinning Changes (Thanks to Jigal van Hemert)
authorSteffen Kamper <info@sk-typo3.de>
Mon, 21 Jun 2010 18:16:16 +0000 (18:16 +0000)
committerSteffen Kamper <info@sk-typo3.de>
Mon, 21 Jun 2010 18:16:16 +0000 (18:16 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@8016 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/install/updates/class.tx_coreupdates_t3skin.php

index 1665f66..887c352 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -20,6 +20,7 @@
 
 2010-06-21  Steffen Kamper  <info@sk-typo3.de>
 
+       * Fixed bug #14752: Add Update Wizards for Skinning Changes (Thanks to Jigal van Hemert)
        * Fixed bug #14800: JS errors prevent JS pased popups from working in IE (Thanks to Jo Hasenau)
        * Fixed bug #14808 tceforms.js slows down performance of IE dramatically (Thanks to Jo Hasenau)
        * Fixed bug #14721: Flexform sections are unstyled and look weird
index 1a50ca0..44babc8 100644 (file)
@@ -42,13 +42,14 @@ class tx_coreupdates_t3skin {
         * @return      boolean         whether an update is needed (true) or not (false)
         */
        public function checkForUpdate(&$description) {
+               $result = FALSE;
                $description = '<strong>The backend skin "t3skin" is not loaded.</strong>
                TYPO3 4.4 introduced many changes in backend skinning and old backend skins are now incompatible.
                <strong>Without "t3skin" the backend may be unusable.</strong> Install extension "t3skin".';
                if (!t3lib_extMgm::isLoaded('t3skin')) {
-                       return TRUE;
+                       $result = TRUE;
                }
-               return FALSE;
+               return $result;
        }
 
        /**
@@ -71,21 +72,68 @@ class tx_coreupdates_t3skin {
         * @return      bool            whether everything went smoothly or not
         */
        public function performUpdate(array &$dbQueries, &$customMessages) {
+               $result = FALSE;
                if ($this->versionNumber >= 4004000 && !t3lib_extMgm::isLoaded('t3skin')) {
                        // check wether the table can be truncated or if sysext with tca has to be installed
                        if ($this->checkForUpdate($customMessages[])) {
-                               $localconf = $this->pObj->writeToLocalconf_control();
-                               $this->pObj->setValueInLocalconfFile($localconf, '$TYPO3_CONF_VARS[\'EXT\'][\'extList\']', $GLOBALS['TYPO3_CONF_VARS']['EXT']['extList'] . ',t3skin');
-                               $message = $this->pObj->writeToLocalconf_control($localconf);
+                               $extList = $this->addExtToList(array('t3skin'));
+                               if ($extList) {
+                                       $message = $this->writeNewExtensionList($extList);
+                               }
+
                                if ($message == 'continue') {
                                        $customMessages = 'The system extension "t3skin" was succesfully loaded.';
-                                       return TRUE;
-                               } else { 
-                                       return FALSE;   // something went wrong
+                                       $result = TRUE;
+                               }
                                }
                        }
-                       return TRUE;
+               return $result;
+       }
+
+       /**
+        * Adds extension to extension list and returns new list. If -1 is returned, an error happend.
+        * Does NOT check dependencies yet.
+        *
+        * @param       array           Extension keys to add
+        * @return      string          New list of installed extensions or -1 if error
+        */
+       protected function addExtToList(array $extKeys) {
+                       // Get list of installed extensions and add this one.
+               $tmpLoadedExt = $GLOBALS['TYPO3_LOADED_EXT'];
+               if (isset($tmpLoadedExt['_CACHEFILE'])) {
+                       unset($tmpLoadedExt['_CACHEFILE']);
                }
+
+               $listArr = array_keys($tmpLoadedExt);
+               $listArr = array_merge($listArr, $extKeys);
+
+                       // Implode unique list of extensions to load and return:
+               return implode(',', array_unique($listArr));
+               }
+
+
+       /**
+        * Writes the extension list to "localconf.php" file
+        * Removes the temp_CACHED* files before return.
+        *
+        * @param       string          List of extensions
+        * @return      string          Result of writeToLocalconf_control()
+        */
+       protected function writeNewExtensionList($newExtList)   {
+                       // Instance of install tool
+               $instObj = new t3lib_install;
+               $instObj->allowUpdateLocalConf = 1;
+               $instObj->updateIdentity = 'TYPO3 Core Update Manager';
+
+                       // Get lines from localconf file
+               $lines = $instObj->writeToLocalconf_control();
+               $instObj->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'EXT\'][\'extList\']', $newExtList);
+               $result = $instObj->writeToLocalconf_control($lines);
+
+               $GLOBALS['TYPO3_CONF_VARS']['EXT']['extList'] = $newExtList;
+               t3lib_extMgm::removeCacheFiles();
+
+               return $result;
        }
 }
 ?>
\ No newline at end of file