[TASK] Remove trailing newlines from EOF
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / updates / class.tx_coreupdates_charsetdefaults.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2010-2011 Michael Stucki <michael@typo3.org>, 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 * Displays warnings and information about the database character set
30 */
31 class tx_coreupdates_charsetDefaults extends Tx_Install_Updates_Base {
32 protected $title = 'Database Character Set';
33
34 /**
35 * Checks if the configuration is relying on old default values or not.
36 * If needed, this updater will fix the configuration appropriately.
37 *
38 * @param string &$description: The description for the update
39 * @param string &$showUpdate: 0=dont show update; 1=show update and next button; 2=only show description
40 * @return boolean whether an update is needed (true) or not (false)
41 */
42 public function checkForUpdate(&$description, &$showUpdate = FALSE) {
43 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] === '-1' ||
44 $GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit'] === '-1') {
45
46 $description = 'The configuration variables $TYPO3_CONF_VARS[\'SYS\'][\'setDBinit\'] and/or
47 $TYPO3_CONF_VARS[\'BE\'][\'forceCharset\'] are relying on empty default values.<br />
48 However, the defaults for both values have changed in TYPO3 4.5.<br /><br />
49 Please click "Next" to write the former default settings to your localconf.php,
50 so that your setup will continue to work like before.';
51 $showUpdate = 1;
52 }
53 }
54
55
56 /**
57 * Write the current configuration to localconf.php
58 * This is needed for any sites that were relying on the former default
59 * values which are going to change in TYPO3 4.5.
60 *
61 * @param array &$dbQueries: queries done in this update
62 * @param mixed &$customMessages: custom messages
63 * @return boolean whether the updated was made or not
64 */
65 public function performUpdate(array &$dbQueries, &$customMessages) {
66 $localconf = $this->pObj->writeToLocalconf_control();
67
68 // Update "setDBinit" setting
69 if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit'] === '-1') {
70 $this->pObj->setValueInLocalconfFile($localconf, '$TYPO3_CONF_VARS[\'SYS\'][\'setDBinit\']', '');
71 }
72
73 // Update the "forceCharset" setting
74 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] === '-1') {
75 $this->pObj->setValueInLocalconfFile($localconf, '$TYPO3_CONF_VARS[\'BE\'][\'forceCharset\']', '');
76 }
77
78 $message = $this->pObj->writeToLocalconf_control($localconf);
79 if ($message == 'continue') {
80 $customMessages[] = 'The configuration was successfully updated.';
81 return TRUE;
82 } else {
83 return FALSE; // something went wrong
84 }
85 }
86 }
87
88 ?>