[TASK] Move and Namespace classes
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / CoreUpdates / InstallSysExtsUpdate.php
1 <?php
2 namespace TYPO3\CMS\Install\CoreUpdates;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2008-2011 Benjamin Mack <benni@typo3.org>
8 * (c) 2008-2011 Steffen Kamper <info@sk-typo3.de>
9 * All rights reserved
10 *
11 * This script is part of the TYPO3 project. The TYPO3 project is
12 * free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * The GNU General Public License can be found at
18 * http://www.gnu.org/copyleft/gpl.html.
19 * A copy is found in the textfile GPL.txt and important notices to the license
20 * from the author is found in LICENSE.txt distributed with these scripts.
21 *
22 *
23 * This script is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * This copyright notice MUST APPEAR in all copies of the script!
29 ***************************************************************/
30 /**
31 * Contains the update class for adding outsourced system extensions.
32 *
33 * @author Benjamin Mack <benni@typo3.org>
34 * @author Steffen Kamper <info@sk-typo3.de>
35 */
36 class InstallSysExtsUpdate extends \TYPO3\CMS\Install\Updates\AbstractUpdate {
37
38 protected $title = 'Install Outsourced System Extensions';
39
40 protected $outsourcedSystemExtensions = array('info', 'perm', 'func', 'filelist', 'about', 'cshmanual', 'feedit', 'opendocs');
41
42 /**
43 * Checks if an update is needed
44 *
45 * @param string &$description: The description for the update
46 * @return boolean whether an update is needed (TRUE) or not (FALSE)
47 */
48 public function checkForUpdate(&$description) {
49 $result = FALSE;
50 $description = '
51 <ul>
52 ';
53 foreach ($this->outsourcedSystemExtensions as $_EXTKEY) {
54 if (!\TYPO3\CMS\Core\Extension\ExtensionManager::isLoaded($_EXTKEY)) {
55 $EM_CONF = FALSE;
56 // extension may not been loaded at this point, so we can't use an API function from t3lib_extmgm
57 require_once ((PATH_site . 'typo3/sysext/') . $_EXTKEY) . '/ext_emconf.php';
58 $description .= ((((('
59 <li>
60 <strong>
61 ' . htmlspecialchars($EM_CONF[$_EXTKEY]['title'])) . ' [') . $_EXTKEY) . ']
62 </strong>
63 <br />
64 ') . htmlspecialchars($EM_CONF[$_EXTKEY]['description'])) . '
65 </li>
66 ';
67 $result = TRUE;
68 }
69 }
70 $description .= '
71 </ul>
72 ';
73 if ($this->isWizardDone()) {
74 $result = FALSE;
75 }
76 return $result;
77 }
78
79 /**
80 * second step: get user input for installing sysextensions
81 *
82 * @param string $inputPrefix input prefix, all names of form fields have to start with this. Append custom name in [ ... ]
83 * @return string HTML output
84 */
85 public function getUserInput($inputPrefix) {
86 $content = '
87 <p>
88 <strong>
89 Install the following SystemExtensions:
90 </strong>
91 </p>
92 ';
93 $content .= '
94 <fieldset>
95 <ol>
96 ';
97 foreach ($this->outsourcedSystemExtensions as $_EXTKEY) {
98 if (!\TYPO3\CMS\Core\Extension\ExtensionManager::isLoaded($_EXTKEY)) {
99 $EM_CONF = FALSE;
100 // extension may not been loaded at this point, so we can't use an API function from t3lib_extmgm
101 require_once ((PATH_site . 'typo3/sysext/') . $_EXTKEY) . '/ext_emconf.php';
102 $content .= ((((((((((('
103 <li class="labelAfter">
104 <input type="checkbox" id="' . $_EXTKEY) . '" name="') . $inputPrefix) . '[sysext][') . $_EXTKEY) . ']" value="1" checked="checked" />
105 <label for="') . $_EXTKEY) . '">') . $EM_CONF[$_EXTKEY]['title']) . ' [') . $_EXTKEY) . ']</label>
106 </li>
107 ';
108 }
109 }
110 $content .= '
111 </ol>
112 </fieldset>
113 ';
114 return $content;
115 }
116
117 /**
118 * Adds the outsourced extensions to the extList in TYPO3_CONF_VARS
119 *
120 * @param array &$dbQueries: queries done in this update
121 * @param mixed &$customMessages: custom messages
122 * @return boolean whether it worked (TRUE) or not (FALSE)
123 */
124 public function performUpdate(array &$dbQueries, &$customMessages) {
125 // Get extension keys that were submitted by the user to be installed and that are valid for this update wizard
126 if (is_array($this->pObj->INSTALL['update']['installSystemExtensions']['sysext'])) {
127 $extArray = array_intersect($this->outsourcedSystemExtensions, array_keys($this->pObj->INSTALL['update']['installSystemExtensions']['sysext']));
128 $this->installExtensions($extArray);
129 }
130 // Never show this wizard again
131 $this->markWizardAsDone();
132 return TRUE;
133 }
134
135 }
136
137
138 ?>