Cleanup: Updated copyright comments
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / updates / class.tx_coreupdates_t3skin.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2010-2011 Steffen Ritter (info@rs-websystems.de)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Contains the update class for not installed t3skin. Used by the update wizard in the install tool.
29 *
30 * @author Steffen Ritter <info@rs-websystems.de>
31 */
32 class tx_coreupdates_t3skin extends Tx_Install_Updates_Base {
33 protected $title = 'Install the new TYPO3 Skin "t3skin"';
34
35
36 /**
37 * Checks if t3skin is not installed.
38 *
39 * @param string &$description: The description for the update
40 * @return boolean whether an update is needed (true) or not (false)
41 */
42 public function checkForUpdate(&$description) {
43 $result = FALSE;
44 $description = '<strong>The backend skin "t3skin" is not loaded.</strong>
45 TYPO3 4.4 introduced many changes in backend skinning and old backend skins are now incompatible.
46 <strong>Without "t3skin" the backend may be unusable.</strong> Install extension "t3skin".';
47 if (!t3lib_extMgm::isLoaded('t3skin')) {
48 $result = TRUE;
49 }
50 return $result;
51 }
52
53 /**
54 * second step: get user info
55 *
56 * @param string input prefix, all names of form fields have to start with this. Append custom name in [ ... ]
57 * @return string HTML output
58 */
59 public function getUserInput($inputPrefix) {
60 $content = '<strong>Install the system extension</strong><br />You are about to install the extension "t3skin".';
61
62 return $content;
63 }
64
65 /**
66 * performs the action of the UpdateManager
67 *
68 * @param array &$dbQueries: queries done in this update
69 * @param mixed &$customMessages: custom messages
70 * @return bool whether everything went smoothly or not
71 */
72 public function performUpdate(array &$dbQueries, &$customMessages) {
73 $result = FALSE;
74 if ($this->versionNumber >= 4004000 && !t3lib_extMgm::isLoaded('t3skin')) {
75 // check wether the table can be truncated or if sysext with tca has to be installed
76 if ($this->checkForUpdate($customMessages[])) {
77 $extList = $this->addExtToList(array('t3skin'));
78 if ($extList) {
79 $message = $this->writeNewExtensionList($extList);
80 }
81
82 if ($message == 'continue') {
83 $customMessages = 'The system extension "t3skin" was succesfully loaded.';
84 $result = TRUE;
85 }
86 }
87 }
88 return $result;
89 }
90
91 /**
92 * Adds extension to extension list and returns new list. If -1 is returned, an error happend.
93 * Does NOT check dependencies yet.
94 *
95 * @param array Extension keys to add
96 * @return string New list of installed extensions or -1 if error
97 */
98 protected function addExtToList(array $extKeys) {
99 // Get list of installed extensions and add this one.
100 $tmpLoadedExt = $GLOBALS['TYPO3_LOADED_EXT'];
101 if (isset($tmpLoadedExt['_CACHEFILE'])) {
102 unset($tmpLoadedExt['_CACHEFILE']);
103 }
104
105 $listArr = array_keys($tmpLoadedExt);
106 $listArr = array_merge($listArr, $extKeys);
107
108 // Implode unique list of extensions to load and return:
109 return implode(',', array_unique($listArr));
110 }
111
112
113 /**
114 * Writes the extension list to "localconf.php" file
115 * Removes the temp_CACHED* files before return.
116 *
117 * @param string List of extensions
118 * @return string Result of writeToLocalconf_control()
119 */
120 protected function writeNewExtensionList($newExtList) {
121 // Instance of install tool
122 $instObj = new t3lib_install;
123 $instObj->allowUpdateLocalConf = 1;
124 $instObj->updateIdentity = 'TYPO3 Core Update Manager';
125
126 // Get lines from localconf file
127 $lines = $instObj->writeToLocalconf_control();
128 $instObj->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'EXT\'][\'extList\']', $newExtList);
129 $result = $instObj->writeToLocalconf_control($lines);
130
131 $GLOBALS['TYPO3_CONF_VARS']['EXT']['extList'] = $newExtList;
132 t3lib_extMgm::removeCacheFiles();
133
134 return $result;
135 }
136 }
137 ?>