Cleanup: Updated copyright comments
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / updates / class.tx_coreupdates_statictemplates.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2008-2011 Steffen Ritter (info@rs-websystems.de)
6 * 2009 Benjamin Mack (benni@typo3.org)
7 * All rights reserved
8 *
9 * This script is part of the TYPO3 project. The TYPO3 project is
10 * free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * The GNU General Public License can be found at
16 * http://www.gnu.org/copyleft/gpl.html.
17 * A copy is found in the textfile GPL.txt and important notices to the license
18 * from the author is found in LICENSE.txt distributed with these scripts.
19 *
20 *
21 * This script is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * This copyright notice MUST APPEAR in all copies of the script!
27 ***************************************************************/
28 /**
29 * Contains the update class for old static templates. Used by the update wizard in the install tool.
30 *
31 * @author Steffen Ritter <info@rs-websystems.de>
32 * @author Benjamin Mack <benni@typo3.org>
33 */
34 class tx_coreupdates_statictemplates extends Tx_Install_Updates_Base {
35 protected $title = 'Install Outsourced Static Templates (now in System Extension)';
36
37
38 /**
39 * Checks if there are any references to static_templates and an update is needed.
40 *
41 * @param string &$description: The description for the update
42 * @return boolean whether an update is needed (true) or not (false)
43 */
44 public function checkForUpdate(&$description) {
45 $description = '<strong>Check dependencies / references to old TypoScript templates in table static_template.</strong><br />
46 This updater checks if you are using the old TypoScript static templates. These are extracted into its own extension "statictemplates". If you need them, this updater will install this extension.<br /><br />';
47 if ($this->versionNumber >= 4004000 && !t3lib_extMgm::isLoaded('statictemplates')) {
48 $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
49 '*',
50 'sys_refindex',
51 'ref_table = "static_template" AND tablename != "static_template" AND deleted=0'
52 );
53 if ($count) {
54 $description .= '<strong style="color:#f00">Dependencies found! You MUST install the extenion "statictemplates"!</strong>';
55 return TRUE;
56 }
57 else {
58 $description .= 'No Dependencies found! You may use the COMPARE - Tool to delete the static_template table.';
59 }
60 }
61 return FALSE;
62 }
63
64 /**
65 * second step: get user info
66 *
67 * @param string input prefix, all names of form fields have to start with this. Append custom name in [ ... ]
68 * @return string HTML output
69 */
70 public function getUserInput($inputPrefix) {
71 $content = '<strong>Install the system extension</strong><br />You are about to install the extension "statictemplates". Make sure it is available in the TYPO3 source.';
72
73 return $content;
74 }
75
76 /**
77 * performs the action of the UpdateManager
78 *
79 * @param array &$dbQueries: queries done in this update
80 * @param mixed &$customMessages: custom messages
81 * @return bool whether everything went smoothly or not
82 */
83 public function performUpdate(array &$dbQueries, &$customMessages) {
84 if ($this->versionNumber >= 4004000 && !t3lib_extMgm::isLoaded('statictemplates')) {
85 // check wether the table can be truncated or if sysext with tca has to be installed
86 if ($this->checkForUpdate($customMessages[])) {
87 $localconf = $this->pObj->writeToLocalconf_control();
88 $this->pObj->setValueInLocalconfFile($localconf, '$TYPO3_CONF_VARS[\'EXT\'][\'extList\']', $GLOBALS['TYPO3_CONF_VARS']['EXT']['extList'] . ',statictemplates');
89 $message = $this->pObj->writeToLocalconf_control($localconf);
90 if ($message == 'continue') {
91 $customMessages[] = 'System Extension "statictemplates" was succesfully loaded, static templates are now supported.';
92 return TRUE;
93 } else {
94 return FALSE; // something went wrong
95 }
96 }
97 return TRUE;
98 }
99 }
100 }
101 ?>