|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2008-2011 Steffen Kamper <info@sk-typo3.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 merging advanced and normal pagetype. 00030 * 00031 * @author Steffen Kamper <info@sk-typo3.de> 00032 * @version 00033 */ 00034 class tx_coreupdates_imagecols extends Tx_Install_Updates_Base { 00035 protected $title = 'Update Existing Text with Image Content Elements'; 00036 00037 00038 /** 00039 * Checks if an update is needed 00040 * 00041 * @param string &$description: The description for the update 00042 * @return boolean whether an update is needed (true) or not (false) 00043 */ 00044 public function checkForUpdate(&$description) { 00045 $result = false; 00046 $description = 'Sets tt_content.imagecols = 1 to all entries having "0". This is needed to have a valid value for imagecols.'; 00047 00048 if ($this->versionNumber >= 4003000) { 00049 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'tt_content', 'CTYPE IN (\'textpic\', \'image\') AND imagecols=0', '', '', '1'); 00050 if($GLOBALS['TYPO3_DB']->sql_num_rows($res)) { 00051 $result = true; 00052 } 00053 $GLOBALS['TYPO3_DB']->sql_free_result($res); 00054 } 00055 return $result; 00056 } 00057 00058 00059 /** 00060 * Performs the database update. Changes the doktype from 2 (advanced) to 1 (standard) 00061 * 00062 * @param array &$dbQueries: queries done in this update 00063 * @param mixed &$customMessages: custom messages 00064 * @return boolean whether it worked (true) or not (false) 00065 */ 00066 public function performUpdate(&$dbQueries, &$customMessages) { 00067 $result = false; 00068 if($this->versionNumber >= 4003000) { 00069 $updateArray = array( 00070 'imagecols' => 1, 00071 ); 00072 00073 $res = $GLOBALS['TYPO3_DB']->exec_UPDATEquery('tt_content', 'CTYPE IN (\'textpic\', \'image\') AND imagecols=0', $updateArray); 00074 $dbQueries[] = str_replace(chr(10), ' ', $GLOBALS['TYPO3_DB']->debug_lastBuiltQuery); 00075 00076 if ($GLOBALS['TYPO3_DB']->sql_error()) { 00077 $customMessages = 'SQL-ERROR: ' . htmlspecialchars($GLOBALS['TYPO3_DB']->sql_error()); 00078 } else { 00079 $result = true; 00080 } 00081 } 00082 return $result; 00083 } 00084 } 00085 ?>
1.8.0