Cleanup: Updated copyright comments
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / updates / class.tx_coreupdates_installsysexts.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 Benjamin Mack <benni@typo3.org>
35 * @author Steffen Kamper <info@sk-typo3.de>
36 */
37 class tx_coreupdates_installsysexts extends Tx_Install_Updates_Base {
38 protected $title = 'Install Outsourced System Extensions';
39 protected $newSystemExtensions = array('info', 'perm', 'func', 'filelist', 'about', 'cshmanual', 'feedit', 'opendocs', 'simulatestatic');
40
41 /**
42 * Checks if an update is needed
43 *
44 * @param string &$description: The description for the update
45 * @return boolean whether an update is needed (true) or not (false)
46 */
47 public function checkForUpdate(&$description) {
48 $result = false;
49 $description = '
50 <p>
51 Install the following system extensions as their functionality
52 is moved out of the TYPO3 base installation and now optional:
53 </p>
54 <ul>
55 <li>
56 <strong>Web&gt;Info [info]</strong>
57 <br />
58 Shows page related information, eg. hit statistics, change log, record counts.
59 </li>
60 <li>
61 <strong>Web&gt;Access [perm]</strong>
62 <br />
63 Sets page editing permissions.
64 </li>
65 <li>
66 <strong>Web&gt;Functions [func]</strong>
67 <br />
68 Advanced functions like wizards for page sorting and batch creating.
69 </li>
70 <li>
71 <strong>File&gt;Filelist [filelist]</strong>
72 <br />
73 Listing of files in the directory.
74 </li>
75 <li>
76 <strong>Help&gt;About [about]</strong>
77 <br />
78 Shows info about TYPO3 and installed extensions.
79 </li>
80 <li>
81 <strong>Help&gt;TYPO3 Manual [cshmanual]</strong>
82 <br />
83 Shows TYPO3 inline user manual.
84 </li>
85 <li>
86 <strong>Frontend Editing [feedit]</strong>
87 <br />
88 This module enables FE-editing, configuration is done by
89 Typoscript.
90 </li>
91 <li>
92 <strong>User&gt;Open Documents [opendocs]</strong>
93 <br />
94 Handles the list of opened documents in TYPO3 backend.
95 </li>
96 <li>
97 <strong>Simulate Static URLs [simulatestatic]</strong>
98 <br />
99 If you do not want to use RealURL or CoolURI but still want
100 the Speaking URL feature. If you used
101 "config.simulateStaticDocuments = 1" in this installation
102 before, you should install this system extension. Be sure to
103 read the manual of "simulatestatic".
104 </li>
105 </ul>
106 ';
107
108 foreach($this->newSystemExtensions as $ext) {
109 if (!t3lib_extMgm::isLoaded($ext)) {
110 $result = true;
111 }
112 }
113 return $result;
114 }
115
116 /**
117 * second step: get user input for installing sysextensions
118 *
119 * @param string input prefix, all names of form fields have to start with this. Append custom name in [ ... ]
120 * @return string HTML output
121 */
122 public function getUserInput($inputPrefix) {
123 $content = '
124 <p>
125 <strong>
126 Install the following SystemExtensions
127 </strong>:
128 </p>
129 <fieldset>
130 <ol>
131 <li class="labelAfter">
132 <input type="checkbox" id="info" name="' . $inputPrefix . '[sysext][info]" value="1" checked="checked" />
133 <label for="info">Web&gt;Info [info]</label>
134 </li>
135 <li class="labelAfter">
136 <input type="checkbox" id="perm" name="' . $inputPrefix . '[sysext][perm]" value="1" checked="checked" />
137 <label for="perm">Web&gt;Access [perm]</label>
138 </li>
139 <li class="labelAfter">
140 <input type="checkbox" id="func" name="' . $inputPrefix . '[sysext][func]" value="1" checked="checked" />
141 <label for="func">Web&gt;Functions [func]</label>
142 </li>
143 <li class="labelAfter">
144 <input type="checkbox" id="filelist" name="' . $inputPrefix . '[sysext][filelist]" value="1" checked="checked" />
145 <label for="filelist">File&gt;Filelist [filelist]</label>
146 </li>
147 <li class="labelAfter">
148 <input type="checkbox" id="about" name="' . $inputPrefix . '[sysext][about]" value="1" checked="checked" />
149 <label for="about">Help&gt;About [about]</label>
150 </li>
151 <li class="labelAfter">
152 <input type="checkbox" id="cshmanual" name="' . $inputPrefix . '[sysext][cshmanual]" value="1" checked="checked" />
153 <label for="cshmanual">Help&gt;TYPO3 Manual [cshmanual]</label>
154 </li>
155 <li class="labelAfter">
156 <input type="checkbox" id="feedit" name="' . $inputPrefix . '[sysext][feedit]" value="1" checked="checked" />
157 <label for="feedit">Frontend Editing [feedit]</label>
158 </li>
159 <li class="labelAfter">
160 <input type="checkbox" id="opendocs" name="' . $inputPrefix . '[sysext][opendocs]" value="1" checked="checked" />
161 <label for="opendocs">User&gt;Open Documents [opendocs]</label>
162 </li>
163 <li class="labelAfter">
164 <input type="checkbox" id="simulatestatic" name="' . $inputPrefix . '[sysext][simulatestatic]" value="1" checked="checked" />
165 <label for="simulatestatic">Simulate Static URLs [simulatestatic]</label>
166 </li>
167 </ol>
168 </fieldset>
169 ';
170
171 return $content;
172 }
173
174 /**
175 * Adds the extensions "about", "cshmanual" and "simulatestatic" to the extList in TYPO3_CONF_VARS
176 *
177 * @param array &$dbQueries: queries done in this update
178 * @param mixed &$customMessages: custom messages
179 * @return boolean whether it worked (true) or not (false)
180 */
181 public function performUpdate(&$dbQueries, &$customMessages) {
182 $result = false;
183
184 // Get extension keys that were submitted by the used to be installed and that are valid for this update wizard:
185 if (is_array($this->pObj->INSTALL['update']['installSystemExtensions']['sysext'])) {
186 $extArray = array_intersect(
187 $this->newSystemExtensions,
188 array_keys($this->pObj->INSTALL['update']['installSystemExtensions']['sysext'])
189 );
190 $extList = $this->addExtToList($extArray);
191 if ($extList) {
192 $this->writeNewExtensionList($extList);
193 $result = true;
194 }
195 }
196
197 return $result;
198 }
199
200
201 /**
202 * Adds extension to extension list and returns new list. If -1 is returned, an error happend.
203 * Does NOT check dependencies yet.
204 *
205 * @param array Extension keys to add
206 * @return string New list of installed extensions or -1 if error
207 */
208 function addExtToList(array $extKeys) {
209 // Get list of installed extensions and add this one.
210 $tmpLoadedExt = $GLOBALS['TYPO3_LOADED_EXT'];
211 if (isset($tmpLoadedExt['_CACHEFILE'])) {
212 unset($tmpLoadedExt['_CACHEFILE']);
213 }
214
215 $listArr = array_keys($tmpLoadedExt);
216 $listArr = array_merge($listArr, $extKeys);
217
218 // Implode unique list of extensions to load and return:
219 return implode(',', array_unique($listArr));
220 }
221
222
223 /**
224 * Writes the extension list to "localconf.php" file
225 * Removes the temp_CACHED* files before return.
226 *
227 * @param string List of extensions
228 * @return void
229 */
230 protected function writeNewExtensionList($newExtList) {
231 // Instance of install tool
232 $instObj = new t3lib_install;
233 $instObj->allowUpdateLocalConf = 1;
234 $instObj->updateIdentity = 'TYPO3 Core Update Manager';
235
236 // Get lines from localconf file
237 $lines = $instObj->writeToLocalconf_control();
238 $instObj->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'EXT\'][\'extList\']', $newExtList);
239 $instObj->writeToLocalconf_control($lines);
240
241 $GLOBALS['TYPO3_CONF_VARS']['EXT']['extList'] = $newExtList;
242 t3lib_extMgm::removeCacheFiles();
243 }
244 }
245 ?>