Documentation TYPO3 par Ameos

class.tx_coreupdates_compatversion.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2005 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                 if ($this->compatVersionIsCurrent())    {
00046                         $description = '<b>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.'.</b>
00047                         There are two possibilities that you see this screen:<ol><li><b>You just updated from a previous version of TYPO3:</b>
00048                         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.
00049                         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.
00050                         <i>Please continue to step two.</i></li>
00051                         <li><b>You just made a fresh install of TYPO3:</b>
00052                         Perfect! All new features will be used.
00053                         <i>You can stop here and do not need this wizard now.</i></li></ol>';
00054 
00055                         if (!$TYPO3_CONF_VARS['SYS']['compat_version']) {
00056                                 $description .= '
00057                                 The compatibility version has been set to the current TYPO3 version. This is a stamp and has no impact for your installation.';
00058                         }
00059                 } else {
00060                         $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. In the next step, you will see the things that need to be adjusted to make your installation compatible with the new features.';
00061                 }
00062 
00063                 return 1;
00064         }
00065 
00072         function getUserInput($inputPrefix)     {
00073                 global $TYPO3_CONF_VARS;
00074                 if ($this->compatVersionIsCurrent())    {
00075                         $content = '<b>You updated from an older version of TYPO3</b>:<br>
00076                         <label for="'.$inputPrefix.'[version]">Select the version where you have upgraded from:</label> <select name="'.$inputPrefix.'[version]" id="'.$inputPrefix.'[version]">';
00077                         $versions = array(
00078                                 '3.8' => '<= 3.8'
00079                         );
00080                         foreach ($versions as $singleVersion => $caption)       {
00081                                 $content .= '<option value="'.$singleVersion.'">'.$caption.'</option>';
00082                         }
00083                         $content .= '</select>';
00084                 } else {
00085                         $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 />
00086                         <b>Follow the steps below carefully and confirm every step!</b> You will see this list again after you performed the update.';
00087 
00088                         $content .= $this->showChangesNeeded($inputPrefix);
00089 
00090                         $content .= '<br /><input type="checkbox" name="'.$inputPrefix.'[compatVersion][all]" id="'.$inputPrefix.'[compatVersion][all]" value="1"> <b><label for="'.$inputPrefix.'[compatVersion][all]">ignore selection above - WARNING: this might break the output of your website.</label></b>';
00091                 }
00092                 return $content;
00093         }
00094 
00101         function checkUserInput(&$customMessages)       {
00102                 global $TYPO3_CONF_VARS;
00103                 if ($this->compatVersionIsCurrent())    {
00104                         return 1;
00105                 } else {
00106                         if ($this->userInput['compatVersion']['all'])   {
00107                                 return 1;
00108                         } else {
00109                                 $performUpdate = 1;
00110                                 $oldVersion = t3lib_div::int_from_ver($TYPO3_CONF_VARS['SYS']['compat_version']);
00111                                 $currentVersion = t3lib_div::int_from_ver(TYPO3_version);
00112                                 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['ext/install']['compat_version'] as $internalName => $details)  {
00113                                         if ($details['version'] > $oldVersion && $details['version'] <= $currentVersion)        {
00114                                                 if (!$this->userInput['compatVersion'][$internalName])  {
00115                                                         $performUpdate = 0;
00116                                                         $customMessages = 'If you want to update the compatibility version, you need to confirm all checkboxes on the previous page.';
00117                                                         break;
00118                                                 }
00119                                         }
00120                                 }
00121                                 return $performUpdate;
00122                         }
00123                 }
00124         }
00125 
00133         function performUpdate(&$dbQueries, &$customMessages)   {
00134                 $customMessages = '';
00135 
00136                         // if we just set it to an older version
00137                 if ($this->userInput['version'])        {
00138                          $customMessages .= 'If you want to see what you need to do to use the new features, run the update wizard again!';
00139                 }
00140 
00141                 $linesArr = $this->pObj->writeToLocalconf_control();
00142                 $version = $this->userInput['version']?$this->userInput['version']:TYPO3_version;
00143                 $this->pObj->setValueInLocalconfFile($linesArr, '$TYPO3_CONF_VARS["SYS"]["compat_version"]', $version);
00144                 $this->pObj->writeToLocalconf_control($linesArr,0);
00145                 $customMessages .= '
00146                 The compatibility version has been set to '.$version.'.';
00147                 $customMessages .= $this->showChangesNeeded();
00148 
00149                 return 1;
00150         }
00151 
00152 
00153         /**********************
00154          *
00155          * HELPER FUNCTIONS - just used in this update method
00156          *
00157          **********************/
00163         function compatVersionIsCurrent()       {
00164                 global $TYPO3_CONF_VARS;
00165                 if ($TYPO3_CONF_VARS['SYS']['compat_version'] && t3lib_div::int_from_ver(TYPO3_version) != t3lib_div::int_from_ver($TYPO3_CONF_VARS['SYS']['compat_version']))  {
00166                         return 0;
00167                 } else {
00168                         return 1;
00169                 }
00170         }
00171 
00178         function showChangesNeeded($inputPrefix = '')   {
00179                 global $TYPO3_CONF_VARS;
00180                 $oldVersion = t3lib_div::int_from_ver($TYPO3_CONF_VARS['SYS']['compat_version']);
00181                 $currentVersion = t3lib_div::int_from_ver(TYPO3_version);
00182 
00183                 $tableContents = '';
00184                 if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['ext/install']['compat_version'])) {
00185                         foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['ext/install']['compat_version'] as $internalName => $details)  {
00186                                 if ($details['version'] > $oldVersion && $details['version'] <= $currentVersion)        {
00187                                         $tableContents .= '<tr><td colspan="2"><hr /></td></tr>
00188                                         <tr><td valign="bottom">'.($inputPrefix?'<input type="checkbox" name="'.$inputPrefix.'[compatVersion]['.$internalName.']" id="'.$inputPrefix.'[compatVersion]['.$internalName.']" value="1">':'&nbsp;').'</td><td>'.str_replace(chr(10),'<br />',$details['description']).($inputPrefix?'<br /><b><label for="'.$inputPrefix.'[compatVersion]['.$internalName.']">'.$details['description_acknowledge'].'</label></b>':'').'</td></tr>';
00189                                 }
00190                         }
00191                 }
00192                 if (strlen($tableContents))     {
00193                         return '<table>'.$tableContents.'</table>';
00194                 }
00195                 return '';
00196         }
00197 }
00198 ?>


Généré par Les spécialistes TYPO3 avec  doxygen 1.4.6