[!!!][TASK] Drop ext:typo3db_legacy
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Updates / Typo3DbExtractionUpdate.php
1 <?php
2 namespace TYPO3\CMS\Install\Updates;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Core\Utility\GeneralUtility;
18
19 /**
20 * Installs and downloads EXT:typo3db_legacy
21 */
22 class Typo3DbExtractionUpdate extends AbstractDownloadExtensionUpdate
23 {
24 /**
25 * @var string
26 */
27 protected $title = 'Install extension "typo3db_legacy" from TER';
28
29 /**
30 * @var string
31 */
32 protected $extensionKey = 'typo3db_legacy';
33
34 /**
35 * @var array
36 */
37 protected $extensionDetails = [
38 'typo3db_legacy' => [
39 'title' => '$GLOBALS[\'TYPO3_DB\'] compatibility layer',
40 'description' => 'Provides the well-known database API $GLOBALS[\'TYPO3_DB\'] used in previous TYPO3 versions for extensions that still rely on it.',
41 'versionString' => '1.0.1',
42 ]
43 ];
44
45 /**
46 * Checks if an update is needed
47 *
48 * @param string $description The description for the update
49 * @return bool Whether an update is needed (true) or not (false)
50 */
51 public function checkForUpdate(&$description)
52 {
53 $description = 'The old database API populated as $GLOBALS[\'TYPO3_DB\'] has been extracted into'
54 . ' the TYPO3 Extension Repository. This update downloads the TYPO3 extension typo3db_legacy from the TER.'
55 . ' Use this if you\'re dealing with extensions in the instance that still rely on the old database API.';
56
57 $updateNeeded = false;
58
59 if (!$this->isWizardDone()) {
60 $updateNeeded = true;
61 }
62
63 return $updateNeeded;
64 }
65
66 /**
67 * Second step: Ask user to install the extension
68 *
69 * @param string $inputPrefix input prefix, all names of form fields have to start with this. Append custom name in [ ... ]
70 * @return string HTML output
71 */
72 public function getUserInput($inputPrefix)
73 {
74 return '
75 <div class="panel panel-danger">
76 <div class="panel-heading">Are you really sure?</div>
77 <div class="panel-body">
78 <p>You should install EXT:typo3db_legacy only if you really need it.</p>
79 <p>This update wizard cannot check if the extension was installed before the update.</p>
80 <p>Are you really sure, you want to install EXT:typo3db_legacy?</p>
81 <div class="btn-group clearfix" data-toggle="buttons">
82 <label class="btn btn-default active">
83 <input type="radio" name="' . $inputPrefix . '[install]" value="0" checked="checked" /> no, don\'t install
84 </label>
85 <label class="btn btn-default">
86 <input type="radio" name="' . $inputPrefix . '[install]" value="1" /> yes, please install
87 </label>
88 </div>
89 </div>
90 </div>
91 ';
92 }
93
94 /**
95 * Performs the update if EXT:typo3db_legacy should be installed.
96 *
97 * @param array $databaseQueries Queries done in this update
98 * @param string $customMessage Custom message
99 * @return bool
100 */
101 public function performUpdate(array &$databaseQueries, &$customMessage)
102 {
103 $requestParams = GeneralUtility::_GP('install');
104 if (!isset($requestParams['values']['typo3DbLegacyExtension']['install'])) {
105 return false;
106 }
107 $install = (int)$requestParams['values']['typo3DbLegacyExtension']['install'];
108
109 if ($install === 1) {
110 // user decided to install extension, install and mark wizard as done
111 $updateSuccessful = $this->installExtension($this->extensionKey, $customMessage);
112 if ($updateSuccessful) {
113 $this->markWizardAsDone();
114 return true;
115 }
116 } else {
117 // user decided to not install extension, mark wizard as done
118 $this->markWizardAsDone();
119 return true;
120 }
121 return $updateSuccessful;
122 }
123 }