* Added feature #7942: Enable UTF-8 by default (Thanks to Benni Mack and Christian...
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / updates / class.tx_coreupdates_charsetdefaults.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2010 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 * @version $Id$
32 */
33 class tx_coreupdates_charsetDefaults {
34 var $versionNumber; // version number coming from t3lib_div::int_from_ver()
35 var $needsExternalHelp = FALSE;
36
37 /**
38 * parent object
39 *
40 * @var tx_install
41 */
42 var $pObj;
43 var $userInput; // user input
44
45
46 /**
47 * Checks if the configuration is relying on old default values or not.
48 * If needed, this updater will fix the configuration appropriately.
49 *
50 * @param string &$description: The description for the update
51 * @param string &$showUpdate: 0=dont show update; 1=show update and next button; 2=only show description
52 * @return boolean whether an update is needed (true) or not (false)
53 */
54 public function checkForUpdate(&$description, &$showUpdate = FALSE) {
55 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] === '-1' ||
56 $GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit'] === '-1') {
57
58 $description = 'The configuration variables $TYPO3_CONF_VARS[\'SYS\'][\'setDBinit\'] and/or
59 $TYPO3_CONF_VARS[\'BE\'][\'forceCharset\'] are relying on empty default values.<br />
60 However, the defaults for both values have changed in TYPO3 4.5.<br /><br />
61 Please click "Next" to write the former default settings to your localconf.php,
62 so that your setup will continue to work like before.';
63 $showUpdate = 1;
64 }
65 }
66
67
68 /**
69 * Write the current configuration to localconf.php
70 * This is needed for any sites that were relying on the former default
71 * values which are going to change in TYPO3 4.5.
72 *
73 * @param array &$dbQueries: queries done in this update
74 * @param mixed &$customMessages: custom messages
75 * @return boolean whether the updated was made or not
76 */
77 public function performUpdate(array &$dbQueries, &$customMessages) {
78 $localconf = $this->pObj->writeToLocalconf_control();
79
80 // Update "setDBinit" setting
81 if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit'] === '-1') {
82 $this->pObj->setValueInLocalconfFile($localconf, '$TYPO3_CONF_VARS[\'SYS\'][\'setDBinit\']', '');
83 }
84
85 // Update the "forceCharset" setting
86 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] === '-1') {
87 $this->pObj->setValueInLocalconfFile($localconf, '$TYPO3_CONF_VARS[\'BE\'][\'forceCharset\']', '');
88 }
89
90 $message = $this->pObj->writeToLocalconf_control($localconf);
91 if ($message == 'continue') {
92 $customMessages[] = 'The configuration was successfully updated.';
93 return TRUE;
94 } else {
95 return FALSE; // something went wrong
96 }
97 }
98 }
99
100 ?>