TYPO3 CMS  TYPO3_6-2
CompatVersionUpdate.php
Go to the documentation of this file.
1 <?php
3 
24 
28  protected $title = 'Version Compatibility';
29 
36  public function checkForUpdate(&$description) {
37  if (!$this->compatVersionIsCurrent()) {
38  $description = '
39  <p>
40  Your current TYPO3 installation is configured to
41  <strong>behave like version
42  ' . htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['compat_version']) . '
43  </strong> of TYPO3. If you just upgraded from this version,
44  you most likely want to <strong>use new features</strong> as
45  well.
46  </p>
47  <p>
48  In the next step, you will see the things that need to be
49  adjusted to make your installation compatible with the new
50  features.
51  </p>
52  ';
53  return TRUE;
54  }
55  return FALSE;
56  }
57 
64  public function getUserInput($inputPrefix) {
65  if ($this->compatVersionIsCurrent()) {
66  $content = '
67  <fieldset>
68  <ol>
69  <li>
70  <strong>You updated from an older version of TYPO3</strong>:
71  </li>
72  <li>
73  <label for="version">Select the version where you have upgraded from:</label>
74  <select name="' . $inputPrefix . '[version]" id="version">
75  ';
76  $versions = array(
77  '3.8' => '<= 3.8',
78  '4.1' => '<= 4.1',
79  '4.2' => '<= 4.2',
80  '4.3' => '<= 4.3',
81  '4.4' => '<= 4.4',
82  '4.5' => '<= 4.5'
83  );
84  foreach ($versions as $singleVersion => $caption) {
85  $content .= '
86  <option value="' . $singleVersion . '">' . $caption . '</option>
87  ';
88  }
89  $content .= '
90  </select>
91  </li>
92  </ol>
93  </fieldset>
94  ';
95  } else {
96  $content = '
97  <p>
98  TYPO3 output is currently compatible to version ' . htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['compat_version']) . '.
99  To use all the new features in the current TYPO3 version,
100  make sure you follow the guidelines below to upgrade without
101  problems.
102  </p>
103  <p>
104  <strong>
105  Follow the steps below carefully and confirm every step!
106  </strong>
107  <br />
108  You will see this list again after you performed the update.
109  </p>
110  ';
111  $content .= $this->showChangesNeeded($inputPrefix);
112  $content .= '
113  <fieldset>
114  <ol>
115  <li class="labelAfter">
116  <input type="checkbox" name="' . $inputPrefix . '[compatVersion][all]" id="compatVersionAll" value="1" />
117  <label for="compatVersionAll">Check all (ignore selection above)</label>
118  </li>
119  <li>
120  WARNING: this might break the output of your website.
121  </li>
122  </ol>
123  </fieldset>
124  ';
125  }
126  return $content;
127  }
128 
135  public function checkUserInput(&$customMessages) {
136  if ($this->compatVersionIsCurrent()) {
137  return TRUE;
138  } else {
139  if ($this->userInput['compatVersion']['all']) {
140  return TRUE;
141  } else {
142  $performUpdate = TRUE;
143  $oldVersion = \TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger($GLOBALS['TYPO3_CONF_VARS']['SYS']['compat_version']);
145  foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['compat_version'] as $internalName => $details) {
146  if ($details['version'] > $oldVersion && $details['version'] <= $currentVersion) {
147  if (!$this->userInput['compatVersion'][$internalName]) {
148  $performUpdate = FALSE;
149  $customMessages = 'If you want to update the compatibility version, you need to confirm all checkboxes on the previous page.';
150  break;
151  }
152  }
153  }
154  return $performUpdate;
155  }
156  }
157  }
158 
166  public function performUpdate(array &$dbQueries, &$customMessages) {
167  $customMessages = '';
168  // If we just set it to an older version
169  if ($this->userInput['version']) {
170  $customMessages .= 'If you want to see what you need to do to use the new features, run the update wizard again!';
171  }
172  $version = $this->userInput['version'] ? $this->userInput['version'] : TYPO3_branch;
173  \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager')->setLocalConfigurationValueByPath('SYS/compat_version', $version);
174  $customMessages .= '<br />The compatibility version has been set to ' . $version . '.';
175  return TRUE;
176  }
177 
183  protected function compatVersionIsCurrent() {
184  if (TYPO3_branch != $GLOBALS['TYPO3_CONF_VARS']['SYS']['compat_version']) {
185  return FALSE;
186  } else {
187  return TRUE;
188  }
189  }
190 
197  protected function showChangesNeeded($inputPrefix = '') {
198  $oldVersion = \TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger($GLOBALS['TYPO3_CONF_VARS']['SYS']['compat_version']);
200  $tableContents = '';
201  if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['compat_version'])) {
202  $upgradeWizardBoxes = '';
203  foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['compat_version'] as $internalName => $details) {
204  if ($details['version'] > $oldVersion && $details['version'] <= $currentVersion) {
205  $description = str_replace(chr(10), '<br />', $details['description']);
206  $description_acknowledge = isset($details['description_acknowledge']) ? str_replace(chr(10), '<br />', $details['description_acknowledge']) : '';
207  $upgradeWizardBoxes .= '
208  <div style="border: 1px solid; padding: 10px; margin: 10px; padding-top: 0px; width: 500px;">
209  <h3>' . (isset($details['title']) ? $details['title'] : $internalName) . '</h3>
210  ' . $description . (strlen($description_acknowledge) ? '<p>' . $description_acknowledge . '</p>' : '') . (strlen($inputPrefix) ? '
211  <fieldset>
212  <ol>
213  <li class="labelAfter">
214  <input type="checkbox" name="' . $inputPrefix . '[compatVersion][' . $internalName . ']" id="compatVersion' . $internalName . '" value="1" />
215  <label for="compatVersion' . $internalName . '">Acknowledged</label>
216  </li>
217  </ol>
218  </fieldset>
219  ' : '') . '
220  </div>';
221  }
222  }
223  }
224  if (strlen($upgradeWizardBoxes)) {
225  return $upgradeWizardBoxes;
226  }
227  return '';
228  }
229 
230 }
performUpdate(array &$dbQueries, &$customMessages)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]