[BUGFIX] Do not try to download extensions in composer mode
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Updates / FuncExtractionUpdate.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:func
21 */
22 class FuncExtractionUpdate extends AbstractDownloadExtensionUpdate
23 {
24 /**
25 * @var string
26 */
27 protected $title = 'Install extension "func" from TER';
28
29 /**
30 * @var string
31 */
32 protected $extensionKey = 'func';
33
34 /**
35 * @var array
36 */
37 protected $extensionDetails = [
38 'func' => [
39 'title' => 'Web->Functions module',
40 'description' => 'Provides Web->Functions BE module used in previous TYPO3 versions for extensions that still rely on it.',
41 'versionString' => '9.0.1',
42 'composerName' => 'friendsoftypo3/cms-func',
43 ],
44 ];
45
46 /**
47 * Checks if an update is needed
48 *
49 * @param string $description The description for the update
50 * @return bool Whether an update is needed (true) or not (false)
51 */
52 public function checkForUpdate(&$description)
53 {
54 $description = 'The extension "func" that brings the "Web->Functions" backend module has been extracted to'
55 . ' the TYPO3 Extension Repository. This update downloads the TYPO3 extension func from the TER.'
56 . ' Use this if you\'re dealing with extensions in the instance that rely on "Web->Functions" and bring own'
57 . ' modules.';
58
59 $updateNeeded = false;
60
61 if (!$this->isWizardDone()) {
62 $updateNeeded = true;
63 }
64
65 return $updateNeeded;
66 }
67
68 /**
69 * Second step: Ask user to install the extension
70 *
71 * @param string $inputPrefix input prefix, all names of form fields have to start with this. Append custom name in [ ... ]
72 * @return string HTML output
73 */
74 public function getUserInput($inputPrefix)
75 {
76 return '
77 <div class="panel panel-danger">
78 <div class="panel-heading">Are you really sure?</div>
79 <div class="panel-body">
80 <p>You should install EXT:func only if you really need it.</p>
81 <p>This update wizard cannot check if the extension was installed before the update.</p>
82 <p>Are you really sure, you want to install EXT:func?</p>
83 <div class="btn-group clearfix" data-toggle="buttons">
84 <label class="btn btn-default active">
85 <input type="radio" name="' . $inputPrefix . '[install]" value="0" checked="checked" /> no, don\'t install
86 </label>
87 <label class="btn btn-default">
88 <input type="radio" name="' . $inputPrefix . '[install]" value="1" /> yes, please install
89 </label>
90 </div>
91 </div>
92 </div>
93 ';
94 }
95
96 /**
97 * Performs the update if EXT:func should be installed.
98 *
99 * @param array $databaseQueries Queries done in this update
100 * @param string $customMessage Custom message
101 * @return bool
102 */
103 public function performUpdate(array &$databaseQueries, &$customMessage)
104 {
105 $requestParams = GeneralUtility::_GP('install');
106 if (!isset($requestParams['values']['funcExtension']['install'])) {
107 return false;
108 }
109 $install = (int)$requestParams['values']['funcExtension']['install'];
110
111 if ($install === 1) {
112 // user decided to install extension, install and mark wizard as done
113 $updateSuccessful = $this->installExtension($this->extensionKey, $customMessage);
114 if ($updateSuccessful) {
115 $this->markWizardAsDone();
116 return true;
117 }
118 } else {
119 // user decided to not install extension, mark wizard as done
120 $this->markWizardAsDone();
121 return true;
122 }
123 return $updateSuccessful;
124 }
125 }