Follow-up to bugfix #10004: Tweak corrections to update wizard for installing new...
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / updates / class.tx_coreupdates_installsysexts.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2008 Benjamin Mack <benni@typo3.org>
6 * (c) 2008 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 Benjamin Mack <benni@typo3.org>
35 * @author Steffen Kamper <info@sk-typo3.de>
36 */
37 class tx_coreupdates_installsysexts {
38 public $versionNumber; // version number coming from t3lib_div::int_from_ver()
39 protected $newSystemExtensions = array('about', 'cshmanual', 'fe_edit', 'simulatestatic');
40
41 /**
42 * parent object
43 *
44 * @var tx_install
45 */
46 public $pObj;
47 public $userInput; // user input
48
49
50 /**
51 * Checks if an update is needed
52 *
53 * @param string &$description: The description for the update
54 * @return boolean whether an update is needed (true) or not (false)
55 */
56 public function checkForUpdate(&$description) {
57 $result = false;
58 $description = 'Install the following system extensions as their functionality is moved out of the TYPO3 base installation and now optional:<br />
59 <strong>Help&gt;About [about]</strong><br />Shows info about TYPO3 and installed extensions.<br />
60 <strong>Help&gt;TYPO3 Manual [cshmanual]</strong><br />Shows TYPO3 inline user manual.<br />
61 <strong>Frontend Editing [fe_edit]</strong><br />This module enables FE-editing, configuration is done by Typoscript<br />
62 <strong>Simulate Static URLs [simulatestatic]</strong><br />If you do not want to use RealURL or CoolURI but still want the Speaking URL feature. If you used "config.simulateStaticDocuments = 1" in this installation before, you should install this system extension. Be sure to read the manual of "simulatestatic".</label>';
63
64 foreach($this->newSystemExtensions as $ext) {
65 if (!t3lib_extMgm::isLoaded($ext)) {
66 $result = true;
67 }
68 }
69 return $result;
70 }
71
72 /**
73 * second step: get user input for installing sysextensions
74 *
75 * @param string input prefix, all names of form fields have to start with this. Append custom name in [ ... ]
76 * @return string HTML output
77 */
78 public function getUserInput($inputPrefix) {
79 $content = '<strong>Install the following SystemExtensions</strong>:<br />
80 <input type="checkbox" id="about" name="' . $inputPrefix . '[sysext][about]" value="1" checked="checked" /><label for="about">Help&gt;About [about]</label><br />
81 <input type="checkbox" id="cshmanual" name="' . $inputPrefix . '[sysext][cshmanual]" value="1" checked="checked" /><label for="cshmanual">Help&gt;TYPO3 Manual [cshmanual]</label><br />
82 <input type="checkbox" id="fe_edit" name="' . $inputPrefix . '[sysext][fe_edit]" value="1" checked="checked" /><label for="fe_edit">Frontend Editing [fe_edit]</label><br />
83 <input type="checkbox" id="simulatestatic" name="' . $inputPrefix . '[sysext][simulatestatic]" value="1" checked="checked" /><label for="simulatestatic">Simulate Static URLs [simulatestatic]</label><br />';
84
85 return $content;
86 }
87
88 /**
89 * Adds the extensions "about", "cshmanual" and "simulatestatic" to the extList in TYPO3_CONF_VARS
90 *
91 * @param array &$dbQueries: queries done in this update
92 * @param mixed &$customMessages: custom messages
93 * @return boolean whether it worked (true) or not (false)
94 */
95 public function performUpdate(&$dbQueries, &$customMessages) {
96 $result = false;
97
98 // Get extension keys that were submitted by the used to be installed and that are valid for this update wizard:
99 if (is_array($this->pObj->INSTALL['update']['installSystemExtensions']['sysext'])) {
100 $extArray = array_intersect(
101 $this->newSystemExtensions,
102 array_keys($this->pObj->INSTALL['update']['installSystemExtensions']['sysext'])
103 );
104 $extList = $this->addExtToList($extArray);
105 if ($extList) {
106 $this->writeNewExtensionList($extList);
107 $result = true;
108 }
109 }
110
111 return $result;
112 }
113
114
115 /**
116 * Adds extension to extension list and returns new list. If -1 is returned, an error happend.
117 * Does NOT check dependencies yet.
118 *
119 * @param array Extension keys to add
120 * @return string New list of installed extensions or -1 if error
121 */
122 function addExtToList(array $extKeys) {
123 // Get list of installed extensions and add this one.
124 $listArr = array_keys($GLOBALS['TYPO3_LOADED_EXT']);
125 $listArr = array_merge($listArr, $extKeys);
126
127 // Implode unique list of extensions to load and return:
128 return implode(',', array_unique($listArr));
129 }
130
131
132 /**
133 * Writes the extension list to "localconf.php" file
134 * Removes the temp_CACHED* files before return.
135 *
136 * @param string List of extensions
137 * @return void
138 */
139 protected function writeNewExtensionList($newExtList) {
140 // Instance of install tool
141 $instObj = new t3lib_install;
142 $instObj->allowUpdateLocalConf = 1;
143 $instObj->updateIdentity = 'TYPO3 Core Update Manager';
144
145 // Get lines from localconf file
146 $lines = $instObj->writeToLocalconf_control();
147 $instObj->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'EXT\'][\'extList\']', $newExtList);
148 $instObj->writeToLocalconf_control($lines);
149
150 $GLOBALS['TYPO3_CONF_VARS']['EXT']['extList'] = $newExtList;
151 t3lib_extMgm::removeCacheFiles();
152 }
153 }
154 ?>