Cleanup: Updated copyright comments
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / updates / class.tx_coreupdates_installversioning.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2008-2011 Benjamin Mack <benni@typo3.org>
6 * (c) 2008-2011 Steffen Kamper <info@sk-typo3.de>
7 * All rights reserved
8 *
9 * This script is part of the TYPO3 project. The TYPO3 project is
10 * free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * The GNU General Public License can be found at
16 * http://www.gnu.org/copyleft/gpl.html.
17 * A copy is found in the textfile GPL.txt and important notices to the license
18 * from the author is found in LICENSE.txt distributed with these scripts.
19 *
20 *
21 * This script is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * This copyright notice MUST APPEAR in all copies of the script!
27 ***************************************************************/
28
29 /**
30 * Contains the update class for adding the system extension "simulate static".
31 *
32 * $Id$
33 *
34 * @author Rupert Germann
35 */
36 class tx_coreupdates_installversioning extends Tx_Install_Updates_Base {
37 protected $title = 'Versioning and Workspaces: Install System Extension';
38 protected $newSystemExtensions = array('version');
39
40 /**
41 * Checks if an update is needed
42 *
43 * @param string &$description: The description for the update
44 * @return boolean whether an update is needed (true) or not (false)
45 */
46 public function checkForUpdate(&$description) {
47 $result = false;
48 $description = '<strong>The extension "version" is not loaded.</strong>
49 Since TYPO3 4.3 the extension "version" is no longer required. Therefore it is not enabled by default if you update an existing TYPO3 installation.
50 If you use versioning and workspaces in your installation you might install the extension "version" directly from here - in case you don\'t need versioning and workspaces leave "version" disabled because it needs quite a lot performance.
51
52 <strong>Enable versioning and workspaces</strong>
53 Install extension "version"';
54
55 foreach($this->newSystemExtensions as $ext) {
56 if (!t3lib_extMgm::isLoaded($ext)) {
57 $result = true;
58 }
59 }
60 return $result;
61 }
62
63 /**
64 * second step: get user input for installing sysextensions
65 *
66 * @param string input prefix, all names of form fields have to start with this. Append custom name in [ ... ]
67 * @return string HTML output
68 */
69 public function getUserInput($inputPrefix) {
70 $content = '
71 Enable versioning and workspaces:
72
73 <input type="checkbox" id="version" name="' . $inputPrefix . '[sysext][version]" value="1" checked="checked" /><label for="version">Install versioning extension [version]</label><br />
74
75 ';
76
77 return $content;
78 }
79
80 /**
81 * Adds the extensions "about", "cshmanual" and "simulatestatic" to the extList in TYPO3_CONF_VARS
82 *
83 * @param array &$dbQueries: queries done in this update
84 * @param mixed &$customMessages: custom messages
85 * @return boolean whether it worked (true) or not (false)
86 */
87 public function performUpdate($dbQueries, $customMessages) {
88 $result = false;
89
90 // Get extension keys that were submitted by the used to be installed and that are valid for this update wizard:
91 if (is_array($this->pObj->INSTALL['update']['installVersioning']['sysext'])) {
92 $extArray = array_intersect(
93 $this->newSystemExtensions,
94 array_keys($this->pObj->INSTALL['update']['installVersioning']['sysext'])
95 );
96
97 $extList = $this->addExtToList($extArray);
98
99 if ($extList) {
100 $this->writeNewExtensionList($extList);
101 $result = true;
102 }
103 }
104
105 return $result;
106 }
107
108
109 /**
110 * Adds extension to extension list and returns new list. If -1 is returned, an error happend.
111 * Does NOT check dependencies yet.
112 *
113 * @param array Extension keys to add
114 * @return string New list of installed extensions or -1 if error
115 */
116 function addExtToList(array $extKeys) {
117 // Get list of installed extensions and add this one.
118 $tmpLoadedExt = $GLOBALS['TYPO3_LOADED_EXT'];
119 if (isset($tmpLoadedExt['_CACHEFILE'])) {
120 unset($tmpLoadedExt['_CACHEFILE']);
121 }
122
123 $listArr = array_keys($tmpLoadedExt);
124 $listArr = array_merge($listArr, $extKeys);
125
126 // Implode unique list of extensions to load and return:
127 return implode(',', array_unique($listArr));
128 }
129
130
131 /**
132 * Writes the extension list to "localconf.php" file
133 * Removes the temp_CACHED* files before return.
134 *
135 * @param string List of extensions
136 * @return void
137 */
138 protected function writeNewExtensionList($newExtList) {
139
140
141 // Instance of install tool
142 $instObj = new t3lib_install;
143 $instObj->allowUpdateLocalConf = 1;
144 $instObj->updateIdentity = 'TYPO3 Core Update Manager';
145
146 // Get lines from localconf file
147 $lines = $instObj->writeToLocalconf_control();
148 $instObj->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'EXT\'][\'extList\']', $newExtList);
149 $instObj->writeToLocalconf_control($lines);
150
151 $GLOBALS['TYPO3_CONF_VARS']['EXT']['extList'] = $newExtList;
152 t3lib_extMgm::removeCacheFiles();
153 }
154 }
155 ?>