Added feature #15666: sys_language table icon should be the flag you selected, using...
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / updates / class.tx_coreupdates_flagsfromsprite.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2010 Ernesto Baschny <ernst@cron-it.de>
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 * Contains the update class for transitioning from ".gif" flags to sprites
30 *
31 * @author Ernesto Baschny <ernst@cron-it.de>
32 * @version $Id$
33 */
34 class tx_coreupdates_flagsfromsprite {
35 public $versionNumber; // version number coming from t3lib_div::int_from_ver()
36
37 /**
38 * Checks if an update is needed
39 *
40 * @param string &$description: The description for the update
41 * @return boolean whether an update is needed (true) or not (false)
42 */
43 public function checkForUpdate(&$description) {
44 $result = FALSE;
45 $description = 'Removes the ".gif" suffix from entries in sys_language, because flags now come from a sprite provided by t3skin and not individual .gif files.';
46
47 if ($this->versionNumber >= 4005000) {
48 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'sys_language', 'flag LIKE \'%.gif\'', '', '', '1');
49 if($GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
50 $result = TRUE;
51 }
52 $GLOBALS['TYPO3_DB']->sql_free_result($res);
53 }
54 return $result;
55 }
56
57
58 /**
59 * Performs the database update. Changes the flags from ".gif" to flag without suffix
60 *
61 * @param array &$dbQueries: queries done in this update
62 * @param mixed &$customMessages: custom messages
63 * @return boolean whether it worked (true) or not (false)
64 */
65 public function performUpdate(&$dbQueries, &$customMessages) {
66 $result = FALSE;
67 if ($this->versionNumber >= 4005000) {
68 $sql = 'UPDATE sys_language SET flag=REPLACE(flag, \'.gif\', \'\') WHERE flag LIKE \'%.gif\'';
69 $res = $GLOBALS['TYPO3_DB']->sql_query($sql);
70 $dbQueries[] = $sql;
71
72 if ($GLOBALS['TYPO3_DB']->sql_error()) {
73 $customMessages = 'SQL-ERROR: ' . htmlspecialchars($GLOBALS['TYPO3_DB']->sql_error());
74 } else {
75 $result = TRUE;
76 }
77 }
78 return $result;
79 }
80 }
81 ?>