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