|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2009-2011 Kasper Skårhøj (kasperYYYY@typo3.com) 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * A copy is found in the textfile GPL.txt and important notices to the license 00017 * from the author is found in LICENSE.txt distributed with these scripts. 00018 * 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00027 /** 00028 * Core functions for admin 00029 * 00030 * $Id: class.tx_lowlevel_admin_core.php 10120 2011-01-18 20:03:36Z ohader $ 00031 * 00032 * @author Kasper Skårhøj <kasperYYYY@typo3.com> 00033 */ 00034 /** 00035 * [CLASS/FUNCTION INDEX of SCRIPT] 00036 * 00037 */ 00038 /** 00039 * Core functions for administration 00040 * 00041 * @author Kasper Skårhøj <kasperYYYY@typo3.com> 00042 * @package TYPO3 00043 * @subpackage tx_lowlevel 00044 */ 00045 class tx_lowlevel_admin_core extends t3lib_cli { 00046 00047 var $adminModules = array( 00048 'setBElock' => 'Set the Backend Lock', 00049 'clearBElock' => 'Clears the Backend Lock', 00050 'msg' => 1 00051 ); 00052 00053 /** 00054 * Constructor 00055 * 00056 * @return void 00057 */ 00058 function tx_lowlevel_admin_core() { 00059 00060 // Running parent class constructor 00061 parent::t3lib_cli(); 00062 00063 // Adding options to help archive: 00064 $this->cli_options[] = array('--redirect=[URL]', 'For toolkey "setBElock": The URL to which the redirection will occur.'); 00065 00066 // Setting help texts: 00067 $this->cli_help['name'] = 'lowlevel_admin -- Various functions for administration and maintenance of TYPO3 from the command line'; 00068 $this->cli_help['synopsis'] = 'toolkey ###OPTIONS###'; 00069 $this->cli_help['description'] = "The 'toolkey' keywords are:\n\n ".implode("\n ",array_keys($this->adminModules)); 00070 $this->cli_help['examples'] = "/.../cli_dispatch.phpsh lowlevel_admin setBElock --redirect=http://url_which_explains_why.com/"; 00071 $this->cli_help['author'] = "Kasper Skaarhoej, (c) 2009"; 00072 } 00073 00074 00075 00076 00077 00078 00079 00080 00081 00082 /************************** 00083 * 00084 * CLI functionality 00085 * 00086 *************************/ 00087 00088 /** 00089 * CLI engine 00090 * 00091 * @param array Command line arguments 00092 * @return string 00093 */ 00094 function cli_main($argv) { 00095 00096 // Force user to admin state and set workspace to "Live": 00097 $GLOBALS['BE_USER']->user['admin'] = 1; 00098 $GLOBALS['BE_USER']->setWorkspace(0); 00099 00100 // Print help 00101 $analysisType = (string)$this->cli_args['_DEFAULT'][1]; 00102 if (!$analysisType) { 00103 $this->cli_validateArgs(); 00104 $this->cli_help(); 00105 exit; 00106 } 00107 00108 // Analysis type: 00109 switch((string)$analysisType) { 00110 case 'setBElock': 00111 if (@is_file(PATH_typo3conf.'LOCK_BACKEND')) { 00112 $this->cli_echo("A lockfile already exists. Overwriting it... \n"); 00113 } 00114 $lockFileContent = $this->cli_argValue('--redirect'); 00115 t3lib_div::writeFile(PATH_typo3conf.'LOCK_BACKEND', $lockFileContent); 00116 $this->cli_echo("Wrote lock-file to '".PATH_typo3conf."LOCK_BACKEND' with content '".$lockFileContent."'"); 00117 break; 00118 case 'clearBElock': 00119 if (@is_file(PATH_typo3conf.'LOCK_BACKEND')) { 00120 unlink(PATH_typo3conf.'LOCK_BACKEND'); 00121 if (@is_file(PATH_typo3conf.'LOCK_BACKEND') ) { 00122 $this->cli_echo("ERROR: Could not remove lock file '".PATH_typo3conf."LOCK_BACKEND'!!\n",1); 00123 } else { 00124 $this->cli_echo("Removed lock file '".PATH_typo3conf."LOCK_BACKEND'\n"); 00125 } 00126 } else { 00127 $this->cli_echo("No lock file '".PATH_typo3conf."LOCK_BACKEND' was found; hence no lock can be removed.'\n"); 00128 } 00129 break; 00130 default: 00131 $this->cli_echo("Unknown toolkey, '".$analysisType."'"); 00132 break; 00133 } 00134 $this->cli_echo(LF); 00135 } 00136 00137 00138 } 00139 00140 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/lowlevel/class.tx_lowlevel_admin.php'])) { 00141 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/lowlevel/class.tx_lowlevel_admin.php']); 00142 } 00143 00144 ?>
1.8.0