Convert DOS to Unix linebreaks throughout TYPO3core (text files only) except contrib...
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / updates / class.tx_coreupdates_imagescols.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2008-2009 Steffen Kamper <info@sk-typo3.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 merging advanced and normal pagetype.
30 *
31 * @author Steffen Kamper <info@sk-typo3.de>
32 * @version
33 */
34 class tx_coreupdates_imagecols {
35 var $versionNumber; // version number coming from t3lib_div::int_from_ver()
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 an update is needed
48 *
49 * @param string &$description: The description for the update
50 * @return boolean whether an update is needed (true) or not (false)
51 */
52 public function checkForUpdate(&$description) {
53 $result = false;
54 $description = 'Sets tt_content.imagecols = 1 to all entries having "0". This is needed to have a valid value for imagecols.';
55
56 if ($this->versionNumber >= 4003000) {
57 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'tt_content', 'CTYPE IN (\'textpic\', \'image\') AND imagecols=0', '', '', '1');
58 if($GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
59 $result = true;
60 }
61 $GLOBALS['TYPO3_DB']->sql_free_result($res);
62 }
63 return $result;
64 }
65
66
67 /**
68 * Performs the database update. Changes the doktype from 2 (advanced) to 1 (standard)
69 *
70 * @param array &$dbQueries: queries done in this update
71 * @param mixed &$customMessages: custom messages
72 * @return boolean whether it worked (true) or not (false)
73 */
74 public function performUpdate(&$dbQueries, &$customMessages) {
75 $result = false;
76 if($this->versionNumber >= 4003000) {
77 $updateArray = array(
78 'imagecols' => 1,
79 );
80
81 $res = $GLOBALS['TYPO3_DB']->exec_UPDATEquery('tt_content', 'CTYPE IN (\'textpic\', \'image\') AND imagecols=0', $updateArray);
82 $dbQueries[] = str_replace(chr(10), ' ', $GLOBALS['TYPO3_DB']->debug_lastBuiltQuery);
83
84 if ($GLOBALS['TYPO3_DB']->sql_error()) {
85 $customMessages = 'SQL-ERROR: ' . htmlspecialchars($GLOBALS['TYPO3_DB']->sql_error());
86 } else {
87 $result = true;
88 }
89 }
90 return $result;
91 }
92 }
93 ?>