TYPO3 API  SVNRelease
class.tx_coreupdates_installsysexts.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 2008-2011 Benjamin Mack <benni@typo3.org>
00006 *  (c) 2008-2011 Steffen Kamper <info@sk-typo3.de>
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 /**
00030  * Contains the update class for adding the system extension "simulate static".
00031  *
00032  * $Id: class.tx_coreupdates_installsysexts.php 10318 2011-01-26 01:16:25Z baschny $
00033  *
00034  * @author  Benjamin Mack <benni@typo3.org>
00035  * @author  Steffen Kamper <info@sk-typo3.de>
00036  */
00037 class tx_coreupdates_installsysexts extends Tx_Install_Updates_Base {
00038     protected $title = 'Install Outsourced System Extensions';
00039     protected $newSystemExtensions = array('info', 'perm', 'func', 'filelist', 'about', 'cshmanual', 'feedit', 'opendocs', 'simulatestatic');
00040 
00041     /**
00042      * Checks if an update is needed
00043      *
00044      * @param   string      &$description: The description for the update
00045      * @return  boolean     whether an update is needed (true) or not (false)
00046      */
00047     public function checkForUpdate(&$description) {
00048         $result = FALSE;
00049         $description = '
00050             <p>
00051                 Install the following system extensions as their functionality
00052                 is moved out of the TYPO3 base installation and now optional:
00053             </p>
00054             <ul>
00055                 <li>
00056                     <strong>Web&gt;Info [info]</strong>
00057                     <br />
00058                     Shows page related information, eg. hit statistics, change log, record counts.
00059                 </li>
00060                 <li>
00061                     <strong>Web&gt;Access [perm]</strong>
00062                     <br />
00063                     Sets page editing permissions.
00064                 </li>
00065                 <li>
00066                     <strong>Web&gt;Functions [func]</strong>
00067                     <br />
00068                     Advanced functions like wizards for page sorting and batch creating.
00069                 </li>
00070                 <li>
00071                     <strong>File&gt;Filelist [filelist]</strong>
00072                     <br />
00073                      Listing of files in the directory.
00074                 </li>
00075                 <li>
00076                     <strong>Help&gt;About [about]</strong>
00077                     <br />
00078                     Shows info about TYPO3 and installed extensions.
00079                 </li>
00080                 <li>
00081                     <strong>Help&gt;TYPO3 Manual [cshmanual]</strong>
00082                     <br />
00083                     Shows TYPO3 inline user manual.
00084                 </li>
00085                 <li>
00086                     <strong>Frontend Editing [feedit]</strong>
00087                     <br />
00088                     This module enables FE-editing, configuration is done by
00089                     Typoscript.
00090                 </li>
00091                 <li>
00092                     <strong>User&gt;Open Documents [opendocs]</strong>
00093                     <br />
00094                     Handles the list of opened documents in TYPO3 backend.
00095                 </li>
00096                 <li>
00097                     <strong>Simulate Static URLs [simulatestatic]</strong>
00098                     <br />
00099                     If you do not want to use RealURL or CoolURI but still want
00100                     the Speaking URL feature. If you used
00101                     "config.simulateStaticDocuments = 1" in this installation
00102                     before, you should install this system extension. Be sure to
00103                     read the manual of "simulatestatic".
00104                 </li>
00105             </ul>
00106         ';
00107 
00108         foreach($this->newSystemExtensions as $ext) {
00109             if (!t3lib_extMgm::isLoaded($ext)) {
00110                 $result = TRUE;
00111             }
00112         }
00113         if ($this->isWizardDone()) {
00114             $result = FALSE;
00115         }
00116         return $result;
00117     }
00118 
00119     /**
00120      * second step: get user input for installing sysextensions
00121      *
00122      * @param   string      input prefix, all names of form fields have to start with this. Append custom name in [ ... ]
00123      * @return  string      HTML output
00124      */
00125     public function getUserInput($inputPrefix) {
00126         $content = '
00127             <p>
00128                 <strong>
00129                     Install the following SystemExtensions
00130                 </strong>:
00131             </p>
00132             <fieldset>
00133                 <ol>
00134                     <li class="labelAfter">
00135                         <input type="checkbox" id="info" name="' . $inputPrefix . '[sysext][info]" value="1" checked="checked" />
00136                         <label for="info">Web&gt;Info [info]</label>
00137                     </li>
00138                     <li class="labelAfter">
00139                         <input type="checkbox" id="perm" name="' . $inputPrefix . '[sysext][perm]" value="1" checked="checked" />
00140                         <label for="perm">Web&gt;Access [perm]</label>
00141                     </li>
00142                     <li class="labelAfter">
00143                         <input type="checkbox" id="func" name="' . $inputPrefix . '[sysext][func]" value="1" checked="checked" />
00144                         <label for="func">Web&gt;Functions [func]</label>
00145                     </li>
00146                     <li class="labelAfter">
00147                         <input type="checkbox" id="filelist" name="' . $inputPrefix . '[sysext][filelist]" value="1" checked="checked" />
00148                         <label for="filelist">File&gt;Filelist [filelist]</label>
00149                     </li>
00150                     <li class="labelAfter">
00151                         <input type="checkbox" id="about" name="' . $inputPrefix . '[sysext][about]" value="1" checked="checked" />
00152                         <label for="about">Help&gt;About [about]</label>
00153                     </li>
00154                     <li class="labelAfter">
00155                         <input type="checkbox" id="cshmanual" name="' . $inputPrefix . '[sysext][cshmanual]" value="1" checked="checked" />
00156                         <label for="cshmanual">Help&gt;TYPO3 Manual [cshmanual]</label>
00157                     </li>
00158                     <li class="labelAfter">
00159                         <input type="checkbox" id="feedit" name="' . $inputPrefix . '[sysext][feedit]" value="1" checked="checked" />
00160                         <label for="feedit">Frontend Editing [feedit]</label>
00161                     </li>
00162                     <li class="labelAfter">
00163                         <input type="checkbox" id="opendocs" name="' . $inputPrefix . '[sysext][opendocs]" value="1" checked="checked" />
00164                         <label for="opendocs">User&gt;Open Documents [opendocs]</label>
00165                     </li>
00166                     <li class="labelAfter">
00167                         <input type="checkbox" id="simulatestatic" name="' . $inputPrefix . '[sysext][simulatestatic]" value="1" checked="checked" />
00168                         <label for="simulatestatic">Simulate Static URLs [simulatestatic]</label>
00169                     </li>
00170                 </ol>
00171             </fieldset>
00172         ';
00173 
00174         return $content;
00175     }
00176 
00177     /**
00178      * Adds the extensions "about", "cshmanual" and "simulatestatic" to the extList in TYPO3_CONF_VARS
00179      *
00180      * @param   array       &$dbQueries: queries done in this update
00181      * @param   mixed       &$customMessages: custom messages
00182      * @return  boolean     whether it worked (true) or not (false)
00183      */
00184     public function performUpdate(&$dbQueries, &$customMessages) {
00185 
00186             // Get extension keys that were submitted by the user to be installed and that are valid for this update wizard
00187         if (is_array($this->pObj->INSTALL['update']['installSystemExtensions']['sysext'])) {
00188             $extArray = array_intersect(
00189                 $this->newSystemExtensions,
00190                 array_keys($this->pObj->INSTALL['update']['installSystemExtensions']['sysext'])
00191             );
00192             $this->installExtensions($extArray);
00193         }
00194 
00195             // Never show this wizard again
00196         $this->markWizardAsDone();
00197 
00198         return TRUE;
00199     }
00200 
00201     /**
00202      * Adds extension to extension list and returns new list. If -1 is returned, an error happend.
00203      * Does NOT check dependencies yet.
00204      *
00205      * @param   array       Extension keys to add
00206      * @return  string      New list of installed extensions or -1 if error
00207      * @deprecated since TYPO3 4.5, will be removed in TYPO3 4.7 - Should not be needed anymore. Extensions should be installed directly by calling Tx_Install_Updates_Base::installExtensions()
00208      */
00209     function addExtToList(array $extKeys) {
00210         t3lib_div::logDeprecatedFunction();
00211             // Get list of installed extensions and add this one.
00212         $tmpLoadedExt = $GLOBALS['TYPO3_LOADED_EXT'];
00213         if (isset($tmpLoadedExt['_CACHEFILE'])) {
00214             unset($tmpLoadedExt['_CACHEFILE']);
00215         }
00216 
00217         $listArr = array_keys($tmpLoadedExt);
00218         $listArr = array_merge($listArr, $extKeys);
00219 
00220             // Implode unique list of extensions to load and return:
00221         return implode(',', array_unique($listArr));
00222     }
00223 
00224 
00225     /**
00226      * Writes the extension list to "localconf.php" file
00227      * Removes the temp_CACHED* files before return.
00228      *
00229      * @param   string      List of extensions
00230      * @return  void
00231      * @deprecated since TYPO3 4.5, will be removed in TYPO3 4.7 - Use Tx_Install_Updates_Base::installExtensions() instead
00232      */
00233     protected function writeNewExtensionList($newExtList) {
00234         t3lib_div::logDeprecatedFunction();
00235             // Instance of install tool
00236         $instObj = new t3lib_install;
00237         $instObj->allowUpdateLocalConf = 1;
00238         $instObj->updateIdentity = 'TYPO3 Core Update Manager';
00239 
00240             // Get lines from localconf file
00241         $lines = $instObj->writeToLocalconf_control();
00242         $instObj->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'EXT\'][\'extList\']', $newExtList);
00243         $instObj->writeToLocalconf_control($lines);
00244 
00245         $GLOBALS['TYPO3_CONF_VARS']['EXT']['extList'] = $newExtList;
00246         t3lib_extMgm::removeCacheFiles();
00247     }
00248 }
00249 ?>