[BUGFIX] Allow proper method override in tx_coreupdates_installsysexts
[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 outsourced system extensions.
31 *
32 * @author Benjamin Mack <benni@typo3.org>
33 * @author Steffen Kamper <info@sk-typo3.de>
34 */
35 class tx_coreupdates_installsysexts extends Tx_Install_Updates_Base {
36 protected $title = 'Install Outsourced System Extensions';
37 protected $outsourcedSystemExtensions = array('info', 'perm', 'func', 'filelist', 'about', 'cshmanual', 'feedit', 'opendocs', 'simulatestatic');
38
39 /**
40 * Checks if an update is needed
41 *
42 * @param string &$description: The description for the update
43 * @return boolean whether an update is needed (TRUE) or not (FALSE)
44 */
45 public function checkForUpdate(&$description) {
46 $result = FALSE;
47
48 $description = '
49 <ul>
50 ';
51
52 foreach($this->outsourcedSystemExtensions as $_EXTKEY) {
53 if (!t3lib_extMgm::isLoaded($_EXTKEY)) {
54 $EM_CONF = FALSE;
55 // extension may not been loaded at this point, so we can't use an API function from t3lib_extmgm
56 require_once(PATH_site . 'typo3/sysext/' . $_EXTKEY . '/ext_emconf.php');
57 $description .= '
58 <li>
59 <strong>
60 ' . htmlspecialchars($EM_CONF[$_EXTKEY]['title']) . ' [' . $_EXTKEY . ']
61 </strong>
62 <br />
63 ' . htmlspecialchars($EM_CONF[$_EXTKEY]['description']) . '
64 </li>
65 ';
66
67 $result = TRUE;
68 }
69 }
70
71 $description .= '
72 </ul>
73 ';
74 if ($this->isWizardDone()) {
75 $result = FALSE;
76 }
77
78 return $result;
79 }
80
81 /**
82 * second step: get user input for installing sysextensions
83 *
84 * @param string $inputPrefix input prefix, all names of form fields have to start with this. Append custom name in [ ... ]
85 * @return string HTML output
86 */
87 public function getUserInput($inputPrefix) {
88 $content = '
89 <p>
90 <strong>
91 Install the following SystemExtensions:
92 </strong>
93 </p>
94 ';
95
96 $content .= '
97 <fieldset>
98 <ol>
99 ';
100
101 foreach($this->outsourcedSystemExtensions as $_EXTKEY) {
102 if (!t3lib_extMgm::isLoaded($_EXTKEY)) {
103 $EM_CONF = FALSE;
104 // extension may not been loaded at this point, so we can't use an API function from t3lib_extmgm
105 require_once(PATH_site . 'typo3/sysext/' . $_EXTKEY . '/ext_emconf.php');
106 $content .= '
107 <li class="labelAfter">
108 <input type="checkbox" id="' . $_EXTKEY . '" name="' . $inputPrefix . '[sysext][' . $_EXTKEY . ']" value="1" checked="checked" />
109 <label for="' . $_EXTKEY . '">' . $EM_CONF[$_EXTKEY]['title'] . ' [' . $_EXTKEY . ']</label>
110 </li>
111 ';
112 }
113 }
114
115 $content .= '
116 </ol>
117 </fieldset>
118 ';
119
120 return $content;
121 }
122
123 /**
124 * Adds the outsourced extensions to the extList in TYPO3_CONF_VARS
125 *
126 * @param array &$dbQueries: queries done in this update
127 * @param mixed &$customMessages: custom messages
128 * @return boolean whether it worked (TRUE) or not (FALSE)
129 */
130 public function performUpdate(array &$dbQueries, &$customMessages) {
131
132 // Get extension keys that were submitted by the user to be installed and that are valid for this update wizard
133 if (is_array($this->pObj->INSTALL['update']['installSystemExtensions']['sysext'])) {
134 $extArray = array_intersect(
135 $this->outsourcedSystemExtensions,
136 array_keys($this->pObj->INSTALL['update']['installSystemExtensions']['sysext'])
137 );
138 $this->installExtensions($extArray);
139 }
140
141 // Never show this wizard again
142 $this->markWizardAsDone();
143
144 return TRUE;
145 }
146
147 /**
148 * Adds extension to extension list and returns new list. If -1 is returned, an error happend.
149 * Does NOT check dependencies yet.
150 *
151 * @param array $extKeys Extension keys to add
152 * @return string New list of installed extensions or -1 if error
153 * @deprecated since TYPO3 4.5, will be removed in TYPO3 4.7 - Should not be needed anymore. Extensions should be installed directly by calling Tx_Install_Updates_Base::installExtensions()
154 */
155 function addExtToList(array $extKeys) {
156 t3lib_div::logDeprecatedFunction();
157 // Get list of installed extensions and add this one.
158 $tmpLoadedExt = $GLOBALS['TYPO3_LOADED_EXT'];
159 if (isset($tmpLoadedExt['_CACHEFILE'])) {
160 unset($tmpLoadedExt['_CACHEFILE']);
161 }
162
163 $listArr = array_keys($tmpLoadedExt);
164 $listArr = array_merge($listArr, $extKeys);
165
166 // Implode unique list of extensions to load and return:
167 return implode(',', array_unique($listArr));
168 }
169
170 /**
171 * Writes the extension list to "localconf.php" file
172 * Removes the temp_CACHED* files before return.
173 *
174 * @param string $newExtList List of extensions
175 * @return void
176 * @deprecated since TYPO3 4.5, will be removed in TYPO3 4.7 - Use Tx_Install_Updates_Base::installExtensions() instead
177 */
178 protected function writeNewExtensionList($newExtList) {
179 t3lib_div::logDeprecatedFunction();
180 // Instance of install tool
181 $instObj = new t3lib_install;
182 $instObj->allowUpdateLocalConf = 1;
183 $instObj->updateIdentity = 'TYPO3 Core Update Manager';
184
185 // Get lines from localconf file
186 $lines = $instObj->writeToLocalconf_control();
187 $instObj->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'EXT\'][\'extList\']', $newExtList);
188 $instObj->writeToLocalconf_control($lines);
189
190 $GLOBALS['TYPO3_CONF_VARS']['EXT']['extList'] = $newExtList;
191 t3lib_extMgm::removeCacheFiles();
192 }
193 }
194 ?>