TYPO3 API  SVNRelease
class.tx_coreupdates_statictemplates.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 2008-2011  Steffen Ritter (info@rs-websystems.de)
00006 *           2009  Benjamin Mack (benni@typo3.org)
00007 *  All rights reserved
00008 *
00009 *  This script is part of the TYPO3 project. The TYPO3 project is
00010 *  free software; you can redistribute it and/or modify
00011 *  it under the terms of the GNU General Public License as published by
00012 *  the Free Software Foundation; either version 2 of the License, or
00013 *  (at your option) any later version.
00014 *
00015 *  The GNU General Public License can be found at
00016 *  http://www.gnu.org/copyleft/gpl.html.
00017 *  A copy is found in the textfile GPL.txt and important notices to the license
00018 *  from the author is found in LICENSE.txt distributed with these scripts.
00019 *
00020 *
00021 *  This script is distributed in the hope that it will be useful,
00022 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00023 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00024 *  GNU General Public License for more details.
00025 *
00026 *  This copyright notice MUST APPEAR in all copies of the script!
00027 ***************************************************************/
00028 /**
00029  * Contains the update class for old static templates. Used by the update wizard in the install tool.
00030  *
00031  * @author  Steffen Ritter <info@rs-websystems.de>
00032  * @author      Benjamin Mack <benni@typo3.org>
00033  */
00034 class tx_coreupdates_statictemplates extends Tx_Install_Updates_Base {
00035     protected $title = 'Install Outsourced Static Templates (now in System Extension)';
00036 
00037 
00038     /**
00039      * Checks if there are any references to static_templates and 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         $description = '<strong>Check dependencies / references to old TypoScript templates in table static_template.</strong><br />
00046         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 />';
00047         if ($this->versionNumber >= 4004000 && !t3lib_extMgm::isLoaded('statictemplates')) {
00048             $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
00049                 '*',
00050                 'sys_refindex',
00051                 'ref_table = "static_template" AND tablename != "static_template" AND deleted=0'
00052             );
00053             if ($count) {
00054                 $description .= '<strong style="color:#f00">Dependencies found! You MUST install the extenion "statictemplates"!</strong>';
00055                 return TRUE;
00056             }
00057             else {
00058                 $description .= 'No Dependencies found! You may use the COMPARE - Tool to delete the static_template table.';
00059             }
00060         }
00061         return FALSE;
00062     }
00063 
00064     /**
00065      * second step: get user info
00066      *
00067      * @param   string      input prefix, all names of form fields have to start with this. Append custom name in [ ... ]
00068      * @return  string      HTML output
00069      */
00070     public function getUserInput($inputPrefix) {
00071         $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.';
00072 
00073         return $content;
00074     }
00075 
00076     /**
00077      * performs the action of the UpdateManager
00078      *
00079      * @param   array       &$dbQueries: queries done in this update
00080      * @param   mixed       &$customMessages: custom messages
00081      * @return  bool        whether everything went smoothly or not
00082      */
00083     public function performUpdate(array &$dbQueries, &$customMessages) {
00084         if ($this->versionNumber >= 4004000 && !t3lib_extMgm::isLoaded('statictemplates')) {
00085             // check wether the table can be truncated or if sysext with tca has to be installed
00086             if ($this->checkForUpdate($customMessages[])) {
00087                 $localconf = $this->pObj->writeToLocalconf_control();
00088                 $this->pObj->setValueInLocalconfFile($localconf, '$TYPO3_CONF_VARS[\'EXT\'][\'extList\']', $GLOBALS['TYPO3_CONF_VARS']['EXT']['extList'] . ',statictemplates');
00089                 $message = $this->pObj->writeToLocalconf_control($localconf);
00090                 if ($message == 'continue') {
00091                     $customMessages[] = 'System Extension "statictemplates" was succesfully loaded, static templates are now supported.';
00092                     return TRUE;
00093                 } else {
00094                     return FALSE;   // something went wrong
00095                 }
00096             }
00097             return TRUE;
00098         }
00099     }
00100 }
00101 ?>