TYPO3 CMS  TYPO3_8-7
FormLegacyExtractionUpdate.php
Go to the documentation of this file.
1 <?php
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 
21 
26 {
30  protected $title = 'Install extension "form_legacy" from TER';
31 
35  protected $extensionKey = 'form_legacy';
36 
40  protected $extensionDetails = [
41  'form_legacy' => [
42  'title' => 'Legacy form extension for TYPO3 v7 compatibility',
43  'description' => 'Provides an additional backwards-compatibility layer with legacy functionality for sites that used the form extension in TYPO3 v7.',
44  'versionString' => '8.7.0',
45  'composerName' => 'friendsoftypo3/form-legacy',
46  ],
47  ];
48 
55  public function checkForUpdate(&$description)
56  {
57  $description = 'The extension "form" was rewritten in TYPO3 v8 and follows a new approach.'
58  . 'This update downloads the old implementation of the form extension as known from TYPO3 v7 from the TER.';
59 
60  $updateNeeded = false;
61 
62  if (!$this->isWizardDone() && !ExtensionManagementUtility::isLoaded('form_legacy')) {
63  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tt_content');
64  $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class));
65  $count = $queryBuilder
66  ->count('*')
67  ->from('tt_content')
68  ->where($queryBuilder->expr()->eq('CType', $queryBuilder->createNamedParameter('mailform')))
69  ->execute()
70  ->fetchColumn(0);
71  if ($count > 0) {
72  $updateNeeded = true;
73  }
74  }
75 
76  return $updateNeeded;
77  }
78 
85  public function getUserInput($inputPrefix)
86  {
87  return '
88  <div class="panel panel-danger">
89  <div class="panel-heading">Are you really sure?</div>
90  <div class="panel-body">
91  <p>You should install EXT:form_legacy only if you really need it.</p>
92  <p>This update wizard checked all content elements and found at least one not deleted element based
93  on the old form module. It is advised to manually convert those elements from the old form implementation
94  to the new implementation of EXT:form. EXT:form_legacy should be unloaded and removed afterwards.</p>
95  <p>Are you really sure, you want to install EXT:form_legacy?</p>
96  <div class="btn-group clearfix" data-toggle="buttons">
97  <label class="btn btn-default active">
98  <input type="radio" name="' . $inputPrefix . '[install]" value="0" checked="checked" /> no, don\'t install
99  </label>
100  <label class="btn btn-default">
101  <input type="radio" name="' . $inputPrefix . '[install]" value="1" /> yes, please install
102  </label>
103  </div>
104  </div>
105  </div>
106  ';
107  }
108 
116  public function performUpdate(array &$databaseQueries, &$customMessage)
117  {
118  $requestParams = GeneralUtility::_GP('install');
119  if (!isset($requestParams['values']['formLegacyExtractionUpdate']['install'])) {
120  return false;
121  }
122  $install = (int)$requestParams['values']['formLegacyExtractionUpdate']['install'];
123 
124  if ($install === 1) {
125  // user decided to install extension, install and mark wizard as done
126  $updateSuccessful = $this->installExtension($this->extensionKey, $customMessage);
127  if ($updateSuccessful) {
128  $this->markWizardAsDone();
129  return true;
130  }
131  } else {
132  // user decided to not install extension, mark wizard as done
133  $this->markWizardAsDone();
134  return true;
135  }
136  return $updateSuccessful;
137  }
138 }
static makeInstance($className,... $constructorArguments)
performUpdate(array &$databaseQueries, &$customMessage)