Fixed bug #10004: Extend UpdateWizard for install systemextensions
[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 public $newSystemExtensions = array('about', 'cshmanual', 'feedit', '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
80 $content = '<strong>Install the following SystemExtensions</strong>:<br />
81 <input type="checkbox" id="about" name="' . $inputPrefix . '[sysext][about]" value="1" checked="checked" /><label for="about">Help&gt;About [about]</label><br />
82 <input type="checkbox" id="cshmanual" name="' . $inputPrefix . '[sysext][cshmanual]" value="1" checked="checked" /><label for="cshmanual">Help&gt;TYPO3 Manual [cshmanual]</label><br />
83 <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 />
84 <input type="checkbox" id="simulatestatic" name="' . $inputPrefix . '[sysext][simulatestatic]" value="1" checked="checked" /><label for="simulatestatic">Simulate Static URLs [simulatestatic]</label><br />';
85
86 return $content;
87 }
88
89 /**
90 * Adds the extensions "about", "cshmanual" and "simulatestatic" to the extList in TYPO3_CONF_VARS
91 *
92 * @param array &$dbQueries: queries done in this update
93 * @param mixed &$customMessages: custom messages
94 * @return boolean whether it worked (true) or not (false)
95 */
96 public function performUpdate(&$dbQueries, &$customMessages) {
97 $result = false;
98 $extArray = (array) array_keys($this->pObj->INSTALL['update']['installSystemExtensions']['sysext']);
99
100 $extList = $this->addExtToList($extArray);
101 if ($extList) {
102 $this->writeNewExtensionList($extList);
103 $result = true;
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 $listArr = array_keys($GLOBALS['TYPO3_LOADED_EXT']);
119 $listArr = array_merge($listArr, $extKeys);
120
121 // Implode unique list of extensions to load and return:
122 return implode(',', array_unique($listArr));
123 }
124
125
126 /**
127 * Writes the extension list to "localconf.php" file
128 * Removes the temp_CACHED* files before return.
129 *
130 * @param string List of extensions
131 * @return void
132 */
133 protected function writeNewExtensionList($newExtList) {
134 // Instance of install tool
135 $instObj = new t3lib_install;
136 $instObj->allowUpdateLocalConf = 1;
137 $instObj->updateIdentity = 'TYPO3 Core Update Manager';
138
139 // Get lines from localconf file
140 $lines = $instObj->writeToLocalconf_control();
141 $instObj->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'EXT\'][\'extList\']', $newExtList);
142 $instObj->writeToLocalconf_control($lines);
143
144 $GLOBALS['TYPO3_CONF_VARS']['EXT']['extList'] = $newExtList;
145 t3lib_extMgm::removeCacheFiles();
146 }
147 }
148 ?>