|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2011 Sebastian Kurfürst <sebastian@garbage-group.de> 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * A copy is found in the textfile GPL.txt and important notices to the license 00017 * from the author is found in LICENSE.txt distributed with these scripts. 00018 * 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00027 00028 /** 00029 * Contains the update class for the compatibility version. Used by the update wizard in the install tool. 00030 * 00031 * @author Sebastian Kurfürst <sebastian@garbage-group.de 00032 * @version $Id: class.tx_coreupdates_compatversion.php 10120 2011-01-18 20:03:36Z ohader $ 00033 */ 00034 class tx_coreupdates_compatversion extends Tx_Install_Updates_Base { 00035 protected $title = 'Version Compatibility'; 00036 00037 /** 00038 * Function which checks if update is needed. Called in the beginning of an update process. 00039 * 00040 * @param string pointer to description for the update 00041 * @return boolean true if update is needs to be performed, false otherwise. 00042 */ 00043 function checkForUpdate(&$description) { 00044 global $TYPO3_CONF_VARS; 00045 00046 if ($this->compatVersionIsCurrent()) { 00047 $description = ' 00048 <p> 00049 <strong>Up to date!</strong> 00050 <br /> 00051 If you do not use the wizard, your current TYPO3 00052 installation is configured to use all the features included 00053 in the current release ' . TYPO3_version . '. 00054 <br /> 00055 There are two possibilities that you see this screen: 00056 </p> 00057 <ol> 00058 <li> 00059 <strong>You just updated from a previous version of 00060 TYPO3:</strong> 00061 Because of some new features, the frontend output of 00062 your site might have changed. To emulate the "old" 00063 frontend behavior, change the compatibility version 00064 by continuing to step 2. 00065 This is <strong>recommended</strong> after every update 00066 to make sure the frontend output is not altered. When 00067 re-running the wizard, you will see the changes needed 00068 for using the new features. 00069 <em>Please continue to step two.</em> 00070 </li> 00071 <li> 00072 <strong>You just made a fresh install of TYPO3:</strong> 00073 Perfect! All new features will be used. 00074 <em>You can stop here and do not need this wizard now.</em> 00075 </li> 00076 </ol> 00077 '; 00078 00079 if (!$TYPO3_CONF_VARS['SYS']['compat_version']) { 00080 $description .= ' 00081 <p> 00082 The compatibility version has been set to the current 00083 TYPO3 version. This is a stamp and has no impact for 00084 your installation. 00085 </p> 00086 '; 00087 } 00088 } else { 00089 $description = ' 00090 <p> 00091 Your current TYPO3 installation is configured to 00092 <strong>behave like version 00093 ' . htmlspecialchars($TYPO3_CONF_VARS['SYS']['compat_version']) . ' 00094 </strong> of TYPO3. If you just upgraded from this version, 00095 you most likely want to <strong>use new features</strong> as 00096 well. 00097 </p> 00098 <p> 00099 In the next step, you will see the things that need to be 00100 adjusted to make your installation compatible with the new 00101 features. 00102 </p> 00103 '; 00104 } 00105 00106 return 1; // Return 1 in any case so user has possibility to switch back to a previous compat_version. 00107 } 00108 00109 /** 00110 * second step: get user input if needed 00111 * 00112 * @param string input prefix, all names of form fields have to start with this. Append custom name in [ ... ] 00113 * @return string HTML output 00114 */ 00115 function getUserInput($inputPrefix) { 00116 global $TYPO3_CONF_VARS; 00117 if ($this->compatVersionIsCurrent()) { 00118 $content = ' 00119 <fieldset> 00120 <ol> 00121 <li> 00122 <strong>You updated from an older version of TYPO3</strong>: 00123 </li> 00124 <li> 00125 <label for="version">Select the version where you have upgraded from:</label> 00126 <select name="' . $inputPrefix . '[version]" id="version"> 00127 '; 00128 $versions = array( 00129 '3.8' => '<= 3.8', 00130 '4.1' => '<= 4.1', 00131 '4.2' => '<= 4.2', 00132 '4.3' => '<= 4.3', 00133 '4.4' => '<= 4.4' 00134 ); 00135 foreach ($versions as $singleVersion => $caption) { 00136 $content .= ' 00137 <option value="'.$singleVersion.'">'.$caption.'</option> 00138 '; 00139 } 00140 $content .= ' 00141 </select> 00142 </li> 00143 </ol> 00144 </fieldset> 00145 '; 00146 } else { 00147 $content = ' 00148 <p> 00149 TYPO3 output is currently compatible to version ' . htmlspecialchars($TYPO3_CONF_VARS['SYS']['compat_version']) . '. 00150 To use all the new features in the current TYPO3 version, 00151 make sure you follow the guidelines below to upgrade without 00152 problems. 00153 </p> 00154 <p> 00155 <strong> 00156 Follow the steps below carefully and confirm every step! 00157 </strong> 00158 <br /> 00159 You will see this list again after you performed the update. 00160 </p> 00161 '; 00162 00163 $content .= $this->showChangesNeeded($inputPrefix); 00164 00165 $content.= ' 00166 <fieldset> 00167 <ol> 00168 <li class="labelAfter"> 00169 <input type="checkbox" name="' . $inputPrefix . '[compatVersion][all]" id="compatVersionAll" value="1" /> 00170 <label for="compatVersionAll">Check all (ignore selection above)</label> 00171 </li> 00172 <li> 00173 WARNING: this might break the output of your website. 00174 </li> 00175 </ol> 00176 </fieldset> 00177 '; 00178 } 00179 return $content; 00180 } 00181 00182 /** 00183 * Checks if user input is valid 00184 * 00185 * @param string pointer to output custom messages 00186 * @return boolean true if user input is correct, then the update is performed. When false, return to getUserInput 00187 */ 00188 function checkUserInput(&$customMessages) { 00189 global $TYPO3_CONF_VARS; 00190 00191 if ($this->compatVersionIsCurrent()) { 00192 return 1; 00193 } else { 00194 if ($this->userInput['compatVersion']['all']) { 00195 return 1; 00196 } else { 00197 $performUpdate = 1; 00198 $oldVersion = t3lib_div::int_from_ver($TYPO3_CONF_VARS['SYS']['compat_version']); 00199 $currentVersion = t3lib_div::int_from_ver(TYPO3_branch); 00200 00201 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['ext/install']['compat_version'] as $internalName => $details) { 00202 if ($details['version'] > $oldVersion && $details['version'] <= $currentVersion) { 00203 if (!$this->userInput['compatVersion'][$internalName]) { 00204 $performUpdate = 0; 00205 $customMessages = 'If you want to update the compatibility version, you need to confirm all checkboxes on the previous page.'; 00206 break; 00207 } 00208 } 00209 } 00210 return $performUpdate; 00211 } 00212 } 00213 } 00214 00215 /** 00216 * Performs the update itself 00217 * 00218 * @param array pointer where to insert all DB queries made, so they can be shown to the user if wanted 00219 * @param string pointer to output custom messages 00220 * @return boolean true if update succeeded, false otherwise 00221 */ 00222 function performUpdate(&$dbQueries, &$customMessages) { 00223 $customMessages = ''; 00224 00225 // if we just set it to an older version 00226 if ($this->userInput['version']) { 00227 $customMessages .= 'If you want to see what you need to do to use the new features, run the update wizard again!'; 00228 } 00229 00230 $linesArr = $this->pObj->writeToLocalconf_control(); 00231 $version = $this->userInput['version'] ? $this->userInput['version'] : TYPO3_branch; 00232 $this->pObj->setValueInLocalconfFile($linesArr, '$TYPO3_CONF_VARS[\'SYS\'][\'compat_version\']', $version); 00233 $this->pObj->writeToLocalconf_control($linesArr,0); 00234 $customMessages.= '<br />The compatibility version has been set to '.$version.'.'; 00235 00236 return 1; 00237 } 00238 00239 00240 /********************** 00241 * 00242 * HELPER FUNCTIONS - just used in this update method 00243 * 00244 **********************/ 00245 /** 00246 * checks if compatibility version is set to current version 00247 * 00248 * @return boolean true if compat version is equal the current version 00249 */ 00250 function compatVersionIsCurrent() { 00251 global $TYPO3_CONF_VARS; 00252 if (TYPO3_branch != $TYPO3_CONF_VARS['SYS']['compat_version']) { 00253 return 0; 00254 } else { 00255 return 1; 00256 } 00257 } 00258 00259 /** 00260 * show changes needed 00261 * 00262 * @param string input prefix to prepend all form fields with. 00263 * @return string HTML output 00264 */ 00265 function showChangesNeeded($inputPrefix = '') { 00266 global $TYPO3_CONF_VARS; 00267 $oldVersion = t3lib_div::int_from_ver($TYPO3_CONF_VARS['SYS']['compat_version']); 00268 $currentVersion = t3lib_div::int_from_ver(TYPO3_branch); 00269 00270 $tableContents = ''; 00271 00272 if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['ext/install']['compat_version'])) { 00273 $updateWizardBoxes = ''; 00274 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['ext/install']['compat_version'] as $internalName => $details) { 00275 if ($details['version'] > $oldVersion && $details['version'] <= $currentVersion) { 00276 $description = str_replace(chr(10),'<br />',$details['description']); 00277 $description_acknowledge = (isset($details['description_acknowledge']) ? str_replace(chr(10),'<br />',$details['description_acknowledge']) : ''); 00278 00279 $updateWizardBoxes.= ' 00280 <div style="border: 1px solid; padding: 10px; margin: 10px; padding-top: 0px; width: 500px;"> 00281 <h3>'.(isset($details['title'])?$details['title']:$internalName).'</h3> 00282 ' . $description . 00283 (strlen($description_acknowledge) ? '<p>'.$description_acknowledge.'</p>' : ''). 00284 (strlen($inputPrefix) ? ' 00285 <fieldset> 00286 <ol> 00287 <li class="labelAfter"> 00288 <input type="checkbox" name="' . $inputPrefix . '[compatVersion][' . $internalName . ']" id="compatVersion' . $internalName . '" value="1" /> 00289 <label for="compatVersion' . $internalName . '">Acknowledged</label> 00290 </li> 00291 </ol> 00292 </fieldset> 00293 ' : '').' 00294 </div>'; 00295 } 00296 } 00297 } 00298 if (strlen($updateWizardBoxes)) { 00299 return $updateWizardBoxes; 00300 } 00301 return ''; 00302 } 00303 } 00304 ?>
1.8.0