"TYPO3 4.0.1: typo3_src-4.0.1/typo3/sysext/install/updates/class.tx_coreupdates_compatversion.php Source File", "datetime" => "Sat Dec 2 19:22:34 2006", "date" => "2 Dec 2006", "doxygenversion" => "1.4.6", "projectname" => "TYPO3 4.0.1", "projectnumber" => "4.0.1" ); get_header($doxygen_vars); ?>

class.tx_coreupdates_compatversion.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2006 Sebastian Kurfuerst (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 ***************************************************************/
00032 class tx_coreupdates_compatversion {
00033         var $versionNumber;     // version number coming from t3lib_div::int_from_ver()
00034         var $pObj;      // parent object (tx_install)
00035         var $userInput; // user input
00036 
00043         function checkForUpdate(&$description)  {
00044                 global $TYPO3_CONF_VARS;
00045 
00046                 if ($this->compatVersionIsCurrent())    {
00047                         $description = '<strong>Up to date!</strong><br />If you do not use the wizard, your current TYPO3 installation is configured to use all the features included in the current release '.TYPO3_version.'.<br />
00048                         There are two possibilities that you see this screen:<ol><li><b>You just updated from a previous version of TYPO3:</b>
00049                         Because of some new features, the frontend output of your site might have changed. To emulate the "old" frontend behavior, change the compatibility version by continuing to step 2.
00050                         This is <b>recommended</b> after every update to make sure the frontend output is not altered. When re-running the wizard, you will see the changes needed for using the new features.
00051                         <i>Please continue to step two.</i></li>
00052                         <li><b>You just made a fresh install of TYPO3:</b>
00053                         Perfect! All new features will be used.
00054                         <i>You can stop here and do not need this wizard now.</i></li></ol>';
00055 
00056                         if (!$TYPO3_CONF_VARS['SYS']['compat_version']) {
00057                                 $description .= '
00058                                 The compatibility version has been set to the current TYPO3 version. This is a stamp and has no impact for your installation.';
00059                         }
00060                 } else {
00061                         $description = 'Your current TYPO3 installation is configured to <b>behave like version '.$TYPO3_CONF_VARS['SYS']['compat_version'].'</b> of TYPO3. If you just upgraded from this version, you most likely want to <b>use new features</b> as well.</p><p>In the next step, you will see the things that need to be adjusted to make your installation compatible with the new features.';
00062                 }
00063 
00064                 return 1;       // Return 1 in any case so user has possibility to switch back to a previous compat_version.
00065         }
00066 
00073         function getUserInput($inputPrefix)     {
00074                 global $TYPO3_CONF_VARS;
00075                 if ($this->compatVersionIsCurrent())    {
00076                         $content = '<strong>You updated from an older version of TYPO3</strong>:<br />
00077                         <label for="'.$inputPrefix.'[version]">Select the version where you have upgraded from:</label> <select name="'.$inputPrefix.'[version]" id="'.$inputPrefix.'[version]">';
00078                         $versions = array(
00079                                 '3.8' => '<= 3.8'
00080                         );
00081                         foreach ($versions as $singleVersion => $caption)       {
00082                                 $content .= '<option value="'.$singleVersion.'">'.$caption.'</option>';
00083                         }
00084                         $content .= '</select>';
00085                 } else {
00086                         $content = 'TYPO3 output is currently compatible to version '.$TYPO3_CONF_VARS['SYS']['compat_version'].'. To use all the new features in the current TYPO3 version, make sure you follow the guidelines below to upgrade without problems.<br />
00087                         <p><strong>Follow the steps below carefully and confirm every step!</strong><br />You will see this list again after you performed the update.</p>';
00088 
00089                         $content .= $this->showChangesNeeded($inputPrefix);
00090 
00091                         $content.= '<p><input type="checkbox" name="'.$inputPrefix.'[compatVersion][all]" id="'.$inputPrefix.'[compatVersion][all]" value="1">&nbsp;<strong><label for="'.$inputPrefix.'[compatVersion][all]">Check all (ignore selection above)<br />WARNING: this might break the output of your website.</label></strong></p><hr />';
00092                 }
00093                 return $content;
00094         }
00095 
00102         function checkUserInput(&$customMessages)       {
00103                 global $TYPO3_CONF_VARS;
00104 
00105                 if ($this->compatVersionIsCurrent())    {
00106                         return 1;
00107                 } else {
00108                         if ($this->userInput['compatVersion']['all'])   {
00109                                 return 1;
00110                         } else {
00111                                 $performUpdate = 1;
00112                                 $oldVersion = t3lib_div::int_from_ver($TYPO3_CONF_VARS['SYS']['compat_version']);
00113                                 $currentVersion = t3lib_div::int_from_ver(TYPO3_branch);
00114 
00115                                 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['ext/install']['compat_version'] as $internalName => $details)  {
00116                                         if ($details['version'] > $oldVersion && $details['version'] <= $currentVersion)        {
00117                                                 if (!$this->userInput['compatVersion'][$internalName])  {
00118                                                         $performUpdate = 0;
00119                                                         $customMessages = 'If you want to update the compatibility version, you need to confirm all checkboxes on the previous page.';
00120                                                         break;
00121                                                 }
00122                                         }
00123                                 }
00124                                 return $performUpdate;
00125                         }
00126                 }
00127         }
00128 
00136         function performUpdate(&$dbQueries, &$customMessages)   {
00137                 $customMessages = '';
00138 
00139                         // if we just set it to an older version
00140                 if ($this->userInput['version'])        {
00141                          $customMessages .= 'If you want to see what you need to do to use the new features, run the update wizard again!';
00142                 }
00143 
00144                 $linesArr = $this->pObj->writeToLocalconf_control();
00145                 $version = $this->userInput['version'] ? $this->userInput['version'] : TYPO3_branch;
00146                 $this->pObj->setValueInLocalconfFile($linesArr, '$TYPO3_CONF_VARS["SYS"]["compat_version"]', $version);
00147                 $this->pObj->writeToLocalconf_control($linesArr,0);
00148                 $customMessages.= '<br />The compatibility version has been set to '.$version.'.';
00149 
00150                 return 1;
00151         }
00152 
00153 
00154         /**********************
00155          *
00156          * HELPER FUNCTIONS - just used in this update method
00157          *
00158          **********************/
00164         function compatVersionIsCurrent()       {
00165                 global $TYPO3_CONF_VARS;
00166                 if (TYPO3_branch != $TYPO3_CONF_VARS['SYS']['compat_version'])  {
00167                         return 0;
00168                 } else {
00169                         return 1;
00170                 }
00171         }
00172 
00179         function showChangesNeeded($inputPrefix = '')   {
00180                 global $TYPO3_CONF_VARS;
00181                 $oldVersion = t3lib_div::int_from_ver($TYPO3_CONF_VARS['SYS']['compat_version']);
00182                 $currentVersion = t3lib_div::int_from_ver(TYPO3_branch);
00183 
00184                 $tableContents = '';
00185 
00186                 if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['ext/install']['compat_version'])) {
00187                         $updateWizardBoxes = '';
00188                         foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['ext/install']['compat_version'] as $internalName => $details)  {
00189                                 if ($details['version'] > $oldVersion && $details['version'] <= $currentVersion)        {
00190                                         $description = str_replace(chr(10),'<br />',$details['description']);
00191                                         $description_acknowledge = (isset($details['description_acknowledge']) ? str_replace(chr(10),'<br />',$details['description_acknowledge']) : '');
00192 
00193                                         $updateWizardBoxes.= '
00194                                                 <div style="border: 1px solid; padding: 10px; margin: 10px; padding-top: 0px; width: 500px;">
00195                                                         <h3>'.(isset($details['title'])?$details['title']:$internalName).'</h3>
00196                                                         <p>'.$description.'</p>'.
00197                                                         (strlen($description_acknowledge) ? '<p>'.$description_acknowledge.'</p>' : '').
00198                                                         (strlen($inputPrefix) ? '<p><input type="checkbox" name="'.$inputPrefix.'[compatVersion]['.$internalName.']" id="'.$inputPrefix.'[compatVersion]['.$internalName.']" value="1">&nbsp;<strong><label for="'.$inputPrefix.'[compatVersion]['.$internalName.']">Acknowledged</label></strong></p>' : '').'
00199                                                 </div>';
00200                                 }
00201                         }
00202                 }
00203                 if (strlen($updateWizardBoxes)) {
00204                         return '<table><tr><td>'.$updateWizardBoxes.'</td></tr></table>';
00205                 }
00206                 return '';
00207         }
00208 }
00209 ?>