|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2010-2011 Benjamin Mack <benni@typo3.org> 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 /** 00030 * Generic class that every update wizard class inherits from. 00031 * Used by the update wizard in the install tool. 00032 * 00033 * @author Benjamin Mack <benni@typo3.org> 00034 * @version $Id: Base.php 10318 2011-01-26 01:16:25Z baschny $ 00035 */ 00036 abstract class Tx_Install_Updates_Base { 00037 00038 /** 00039 * the human-readable title of the upgrade wizard 00040 */ 00041 protected $title; 00042 00043 /** 00044 * parent object 00045 * @var tx_install 00046 */ 00047 public $pObj; 00048 00049 /** 00050 * user input, set from outside 00051 */ 00052 public $userInput; 00053 00054 /** 00055 * current TYPO3 version number, set from outside 00056 * version number coming from t3lib_div::int_from_ver() 00057 */ 00058 public $versionNumber; 00059 00060 00061 00062 /** 00063 * 00064 * API functions 00065 * 00066 **/ 00067 00068 /** 00069 * The first function in the update wizard steps 00070 * 00071 * it works like this: 00072 * @param $explanation string HTML that is outputted on the first 00073 * @param $showUpdate int that informs you whether to show this update wizard or not. Possible values that checkForUpdate() should set: 00074 * 0 = don't show this update wizard at all (because it's not needed) 00075 * 1 = show the update wizard (explanation + next step button) 00076 * 2 = show the update wizard (explanation but not the "next step" button), useful for showing a status of a wizard 00077 * @return deprecated since TYPO3 4.5, in previous versions it was used to determine whether the update wizards should be shown, now, the $showUpdate parameter is used for that 00078 */ 00079 // public abstract function checkForUpdate(&$explanation, &$showUpdate); 00080 00081 00082 /** 00083 * second step: get user input if needed 00084 * 00085 * @param string input prefix, all names of form fields have to start with this. Append custom name in [ ... ] 00086 * @return string HTML output 00087 */ 00088 // public abstract function getUserInput($inputPrefix); 00089 00090 00091 /** 00092 * third step: do the updates 00093 * 00094 * @param array &$dbQueries: queries done in this update 00095 * @param mixed &$customMessages: custom messages 00096 * @return boolean whether it worked (true) or not (false) 00097 */ 00098 // public abstract function performUpdate(&$dbQueries, &$customMessages); 00099 00100 /** 00101 * Checks if user input is valid 00102 * 00103 * @param string pointer to output custom messages 00104 * @return boolean true if user input is correct, then the update is performed. When false, return to getUserInput 00105 */ 00106 // public abstract function checkUserInput(&$customMessages); 00107 00108 00109 00110 00111 00112 /** 00113 * 00114 * Helper functions, getters and setters 00115 * 00116 **/ 00117 00118 /** 00119 * returns the title attribute 00120 * 00121 * @return the title of this update wizard 00122 **/ 00123 public function getTitle() { 00124 if ($this->title) { 00125 return $this->title; 00126 } else { 00127 return $this->identifier; 00128 } 00129 } 00130 00131 /** 00132 * sets the title attribute 00133 * 00134 * @param $title the title of this update wizard 00135 * @return void 00136 **/ 00137 public function setTitle($title) { 00138 $this->title = $title; 00139 } 00140 00141 00142 /** 00143 * returns the identifier of this class 00144 * 00145 * @return the identifier of this update wizard 00146 **/ 00147 public function getIdentifier() { 00148 return $this->identifier; 00149 } 00150 00151 /** 00152 * sets the identifier attribute 00153 * 00154 * @param $identifier the identifier of this update wizard 00155 * @return void 00156 **/ 00157 public function setIdentifier($identifier) { 00158 $this->identifier = $identifier; 00159 } 00160 00161 /** 00162 * simple wrapper function that helps dealing with the compatibility 00163 * layer that some update wizards don't have a second parameter 00164 * thus, it evaluates everything already 00165 * 00166 * @return boolean if the wizard should be shown at all on the overview page 00167 * @see checkForUpdate() 00168 */ 00169 public function shouldRenderWizard() { 00170 $showUpdate = 0; 00171 $explanation = ''; 00172 $res = $this->checkForUpdate($explanation, $showUpdate); 00173 return ($showUpdate > 0 || $res == TRUE); 00174 } 00175 00176 /** 00177 * simple wrapper function that helps to check whether (if) 00178 * this feature is cool if you want to tell the user that the update wizard 00179 * is working fine, just as output (useful for the character set / utf8 wizard) 00180 * 00181 * @return boolean if the wizard should render the Next() button on the overview page 00182 * @see checkForUpdate() 00183 */ 00184 public function shouldRenderNextButton() { 00185 $showUpdate = 0; 00186 $explanation = ''; 00187 $res = $this->checkForUpdate($explanation, $showUpdate); 00188 return ($showUpdate != 2 || $res == TRUE); 00189 } 00190 00191 /** 00192 * This method creates an instance of a connection to the Extension Manager 00193 * and returns it. This is used when installing an extension. 00194 * 00195 * @return tx_em_Connection_ExtDirectServer EM connection instance 00196 */ 00197 public function getExtensionManagerConnection() { 00198 // Create an instance of language, if necessary. 00199 // Needed in order to make the em_index work 00200 if (!isset($GLOBALS['LANG'])) { 00201 $GLOBALS['LANG'] = t3lib_div::makeInstance('language'); 00202 $GLOBALS['LANG']->csConvObj = t3lib_div::makeInstance('t3lib_cs'); 00203 } 00204 // Create an instance of a connection class to the EM 00205 $extensionManagerConnection = t3lib_div::makeInstance('tx_em_Connection_ExtDirectServer', FALSE); 00206 return $extensionManagerConnection; 00207 } 00208 00209 /** 00210 * This method can be called to install extensions following all proper processes 00211 * (e.g. installing in both extList and extList_FE, respecting priority, etc.) 00212 * 00213 * @param array $extensionKeys List of keys of extensions to install 00214 * @return void 00215 */ 00216 protected function installExtensions($extensionKeys) { 00217 $extensionManagerConnection = $this->getExtensionManagerConnection(); 00218 foreach ($extensionKeys as $extension) { 00219 $extensionManagerConnection->enableExtension($extension); 00220 } 00221 } 00222 00223 /** 00224 * Marks some wizard as being "seen" so that it not shown again. 00225 * 00226 * Writes the info in localconf.php 00227 * 00228 * @return void 00229 */ 00230 protected function markWizardAsDone() { 00231 /** @var t3lib_install $install */ 00232 $install = t3lib_div::makeInstance('t3lib_install'); 00233 $install->allowUpdateLocalConf = 1; 00234 $install->updateIdentity = 'TYPO3 Upgrade Wizard'; 00235 // Get lines from localconf file 00236 $lines = $install->writeToLocalconf_control(); 00237 $wizardClassName = get_class($this); 00238 $install->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'INSTALL\'][\'wizardDone\'][\'' . $wizardClassName . '\']', 1); 00239 $install->writeToLocalconf_control($lines); 00240 } 00241 00242 /** 00243 * Checks if this wizard has been "done" before 00244 * 00245 * @return boolean TRUE if wizard has been done before, FALSE otherwise 00246 */ 00247 protected function isWizardDone() { 00248 $wizardClassName = get_class($this); 00249 $done = FALSE; 00250 if (isset($GLOBALS['TYPO3_CONF_VARS']['INSTALL']['wizardDone'][$wizardClassName]) && 00251 $GLOBALS['TYPO3_CONF_VARS']['INSTALL']['wizardDone'][$wizardClassName]) { 00252 $done = TRUE; 00253 } 00254 return $done; 00255 } 00256 } 00257 ?>
1.8.0