0827e0a902fa88246bfe0b0818175cd760ba979e
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Updates / Base.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2010 Benjamin Mack <benni@typo3.org>
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27
28
29 /**
30 * Generic class that every update wizard class inherits from.
31 * Used by the update wizard in the install tool.
32 *
33 * @author Benjamin Mack <benni@typo3.org>
34 * @version $Id:
35 */
36 abstract class Tx_Install_Updates_Base {
37
38 /**
39 * the human-readable title of the upgrade wizard
40 */
41 protected $title;
42
43 /**
44 * parent object
45 * @var tx_install
46 */
47 public $pObj;
48
49 /**
50 * user input, set from outside
51 */
52 public $userInput;
53
54 /**
55 * current TYPO3 version number, set from outside
56 * version number coming from t3lib_div::int_from_ver()
57 */
58 public $versionNumber;
59
60
61
62 /**
63 *
64 * API functions
65 *
66 **/
67
68 /**
69 * The first function in the update wizard steps
70 *
71 * it works like this:
72 * @param $explanation string HTML that is outputted on the first
73 * @param $showUpdate int that informs you whether to show this update wizard or not. Possible values that checkForUpdate() should set:
74 * 0 = don't show this update wizard at all (because it's not needed)
75 * 1 = show the update wizard (explanation + next step button)
76 * 2 = show the update wizard (explanation but not the "next step" button), useful for showing a status of a wizard
77 * @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
78 */
79 // public abstract function checkForUpdate(&$explanation, &$showUpdate);
80
81
82 /**
83 * second step: get user input if needed
84 *
85 * @param string input prefix, all names of form fields have to start with this. Append custom name in [ ... ]
86 * @return string HTML output
87 */
88 // public abstract function getUserInput($inputPrefix);
89
90
91 /**
92 * third step: do the updates
93 *
94 * @param array &$dbQueries: queries done in this update
95 * @param mixed &$customMessages: custom messages
96 * @return boolean whether it worked (true) or not (false)
97 */
98 // public abstract function performUpdate(&$dbQueries, &$customMessages);
99
100 /**
101 * Checks if user input is valid
102 *
103 * @param string pointer to output custom messages
104 * @return boolean true if user input is correct, then the update is performed. When false, return to getUserInput
105 */
106 // public abstract function checkUserInput(&$customMessages);
107
108
109
110
111
112 /**
113 *
114 * Helper functions, getters and setters
115 *
116 **/
117
118 /**
119 * returns the title attribute
120 *
121 * @return the title of this update wizard
122 **/
123 public function getTitle() {
124 if ($this->title) {
125 return $this->title;
126 } else {
127 return $this->identifier;
128 }
129 }
130
131 /**
132 * sets the title attribute
133 *
134 * @param $title the title of this update wizard
135 * @return void
136 **/
137 public function setTitle($title) {
138 $this->title = $title;
139 }
140
141
142 /**
143 * returns the identifier of this class
144 *
145 * @return the identifier of this update wizard
146 **/
147 public function getIdentifier() {
148 return $this->identifier;
149 }
150
151 /**
152 * sets the identifier attribute
153 *
154 * @param $identifier the identifier of this update wizard
155 * @return void
156 **/
157 public function setIdentifier($identifier) {
158 $this->identifier = $identifier;
159 }
160
161 /**
162 * simple wrapper function that helps dealing with the compatibility
163 * layer that some update wizards don't have a second parameter
164 * thus, it evaluates everything already
165 *
166 * @return boolean if the wizard should be shown at all on the overview page
167 * @see checkForUpdate()
168 */
169 public function shouldRenderWizard() {
170 $showUpdate = 0;
171 $explanation = '';
172 $res = $this->checkForUpdate($explanation, $showUpdate);
173 return ($showUpdate > 0 || $res == TRUE);
174 }
175
176 /**
177 * simple wrapper function that helps to check whether (if)
178 * this feature is cool if you want to tell the user that the update wizard
179 * is working fine, just as output (useful for the character set / utf8 wizard)
180 *
181 * @return boolean if the wizard should render the Next() button on the overview page
182 * @see checkForUpdate()
183 */
184 public function shouldRenderNextButton() {
185 $showUpdate = 0;
186 $explanation = '';
187 $res = $this->checkForUpdate($explanation, $showUpdate);
188 return ($showUpdate != 2 || $res == TRUE);
189 }
190
191
192 }
193
194 ?>