|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2010-2011 Ernesto Baschny <ernst@cron-it.de> 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 * Contains the update class for transitioning from ".gif" flags to sprites 00030 * 00031 * @author Ernesto Baschny <ernst@cron-it.de> 00032 * @version $Id$ 00033 */ 00034 class tx_coreupdates_flagsfromsprite extends Tx_Install_Updates_Base { 00035 protected $title = 'Update Graphics, Using Sprites for sys_language Records'; 00036 00037 /** 00038 * Checks if an update is needed 00039 * 00040 * @param string &$description: The description for the update 00041 * @return boolean whether an update is needed (true) or not (false) 00042 */ 00043 public function checkForUpdate(&$description) { 00044 $result = FALSE; 00045 $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.'; 00046 00047 if ($this->versionNumber >= 4005000) { 00048 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'sys_language', 'flag LIKE \'%.gif\'', '', '', '1'); 00049 if($GLOBALS['TYPO3_DB']->sql_num_rows($res)) { 00050 $result = TRUE; 00051 } 00052 $GLOBALS['TYPO3_DB']->sql_free_result($res); 00053 } 00054 return $result; 00055 } 00056 00057 00058 /** 00059 * Performs the database update. Changes the flags from ".gif" to flag without suffix 00060 * 00061 * @param array &$dbQueries: queries done in this update 00062 * @param mixed &$customMessages: custom messages 00063 * @return boolean whether it worked (true) or not (false) 00064 */ 00065 public function performUpdate(&$dbQueries, &$customMessages) { 00066 $result = FALSE; 00067 if ($this->versionNumber >= 4005000) { 00068 $sql = 'UPDATE sys_language SET flag=REPLACE(flag, \'.gif\', \'\') WHERE flag LIKE \'%.gif\''; 00069 $res = $GLOBALS['TYPO3_DB']->sql_query($sql); 00070 $dbQueries[] = $sql; 00071 if ($GLOBALS['TYPO3_DB']->sql_error()) { 00072 $customMessages = 'SQL-ERROR: ' . htmlspecialchars($GLOBALS['TYPO3_DB']->sql_error()); 00073 } else { 00074 $result = TRUE; 00075 } 00076 00077 $sql = 'UPDATE sys_language SET flag=\'multiple\' WHERE flag=\'multi-language\''; 00078 $res = $GLOBALS['TYPO3_DB']->sql_query($sql); 00079 $dbQueries[] = $sql; 00080 if ($GLOBALS['TYPO3_DB']->sql_error()) { 00081 $customMessages = 'SQL-ERROR: ' . htmlspecialchars($GLOBALS['TYPO3_DB']->sql_error()); 00082 } else { 00083 $result = TRUE; 00084 } 00085 } 00086 return $result; 00087 } 00088 } 00089 ?>
1.8.0