[FEATURE] Add XLIFF translation support (l10n)
[Packages/TYPO3.CMS.git] / typo3 / sysext / lowlevel / class.tx_lowlevel_admin_core.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2009-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Core functions for admin
29 *
30 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
31 */
32 /**
33 * [CLASS/FUNCTION INDEX of SCRIPT]
34 *
35 */
36 /**
37 * Core functions for administration
38 *
39 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
40 * @package TYPO3
41 * @subpackage tx_lowlevel
42 */
43 class tx_lowlevel_admin_core extends t3lib_cli {
44
45 var $adminModules = array(
46 'setBElock' => 'Set the Backend Lock',
47 'clearBElock' => 'Clears the Backend Lock',
48 'msg' => 1
49 );
50
51 /**
52 * Constructor
53 *
54 * @return void
55 */
56 function __construct() {
57
58 // Running parent class constructor
59 parent::__construct();
60
61 // Adding options to help archive:
62 $this->cli_options[] = array('--redirect=[URL]', 'For toolkey "setBElock": The URL to which the redirection will occur.');
63
64 // Setting help texts:
65 $this->cli_help['name'] = 'lowlevel_admin -- Various functions for administration and maintenance of TYPO3 from the command line';
66 $this->cli_help['synopsis'] = 'toolkey ###OPTIONS###';
67 $this->cli_help['description'] = "The 'toolkey' keywords are:\n\n ".implode("\n ",array_keys($this->adminModules));
68 $this->cli_help['examples'] = "/.../cli_dispatch.phpsh lowlevel_admin setBElock --redirect=http://url_which_explains_why.com/";
69 $this->cli_help['author'] = "Kasper Skaarhoej, (c) 2009";
70 }
71
72
73
74
75
76
77
78
79
80 /**************************
81 *
82 * CLI functionality
83 *
84 *************************/
85
86 /**
87 * CLI engine
88 *
89 * @param array Command line arguments
90 * @return string
91 */
92 function cli_main($argv) {
93
94 // Force user to admin state and set workspace to "Live":
95 $GLOBALS['BE_USER']->user['admin'] = 1;
96 $GLOBALS['BE_USER']->setWorkspace(0);
97
98 // Print help
99 $analysisType = (string)$this->cli_args['_DEFAULT'][1];
100 if (!$analysisType) {
101 $this->cli_validateArgs();
102 $this->cli_help();
103 exit;
104 }
105
106 // Analysis type:
107 switch((string)$analysisType) {
108 case 'setBElock':
109 if (@is_file(PATH_typo3conf.'LOCK_BACKEND')) {
110 $this->cli_echo("A lockfile already exists. Overwriting it... \n");
111 }
112 $lockFileContent = $this->cli_argValue('--redirect');
113 t3lib_div::writeFile(PATH_typo3conf.'LOCK_BACKEND', $lockFileContent);
114 $this->cli_echo("Wrote lock-file to '".PATH_typo3conf."LOCK_BACKEND' with content '".$lockFileContent."'");
115 break;
116 case 'clearBElock':
117 if (@is_file(PATH_typo3conf.'LOCK_BACKEND')) {
118 unlink(PATH_typo3conf.'LOCK_BACKEND');
119 if (@is_file(PATH_typo3conf.'LOCK_BACKEND') ) {
120 $this->cli_echo("ERROR: Could not remove lock file '".PATH_typo3conf."LOCK_BACKEND'!!\n",1);
121 } else {
122 $this->cli_echo("Removed lock file '".PATH_typo3conf."LOCK_BACKEND'\n");
123 }
124 } else {
125 $this->cli_echo("No lock file '".PATH_typo3conf."LOCK_BACKEND' was found; hence no lock can be removed.'\n");
126 }
127 break;
128 default:
129 $this->cli_echo("Unknown toolkey, '".$analysisType."'");
130 break;
131 }
132 $this->cli_echo(LF);
133 }
134
135
136 }
137
138 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/lowlevel/class.tx_lowlevel_admin.php'])) {
139 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/lowlevel/class.tx_lowlevel_admin.php']);
140 }
141
142 ?>