Added $Id$ keywords, cleaned up comment tags
[Packages/TYPO3.CMS.git] / typo3 / tce_db.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2003 Kasper Skaarhoj (kasper@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 * TCE gateway (TYPO3 Core Engine) for database handling
29 *
30 * This script is a gateway for POST forms to class.t3lib_TCEmain that manipulates all information in the database!!
31 * For syntax and API information, see the document 'TYPO3 Core APIs'
32 *
33 * Revised for TYPO3 3.6 July/2003 by Kasper Skaarhoj
34 */
35 require ('init.php');
36 require ('template.php');
37 require_once (PATH_t3lib.'class.t3lib_tcemain.php');
38
39
40
41
42
43
44
45
46
47
48
49
50
51 /**
52 * Script Class, creating object of t3lib_TCEmain and sending the posted data to the object.
53 *
54 * @author Kasper Skaarhoj <kasper@typo3.com>
55 * @package TYPO3
56 * @subpackage core
57 */
58 class SC_tce_db {
59 var $include_once=array();
60 var $tce;
61 var $CB;
62
63 var $flags;
64 var $data;
65 var $cmd;
66 var $mirror;
67 var $cacheCmd;
68 var $redirect;
69
70 /**
71 * Initialization.
72 *
73 * @return void
74 */
75 function init() {
76 global $BE_USER;
77
78 // Registering Incoming data
79 $this->flags = t3lib_div::GPvar('flags');
80 $this->data = t3lib_div::GPvar('data');
81 $this->cmd = t3lib_div::GPvar('cmd');
82 $this->mirror = t3lib_div::GPvar('mirror');
83 $this->cacheCmd = t3lib_div::GPvar('cacheCmd');
84 $this->redirect = t3lib_div::GPvar('redirect');
85
86 // Creating TCEmain object
87 $this->tce = t3lib_div::makeInstance('t3lib_TCEmain');
88
89 // Configuring based on user prefs.
90 if ($BE_USER->uc['recursiveDelete']) {
91 $this->tce->deleteTree = 1; // True if the delete Recursive flag is set.
92 }
93 if ($BE_USER->uc['copyLevels']) {
94 $this->tce->copyTree = t3lib_div::intInRange($BE_USER->uc['copyLevels'],0,100); // Set to number of page-levels to copy.
95 }
96 if ($BE_USER->uc['neverHideAtCopy']) {
97 $this->tce->neverHideAtCopy = 1;
98 }
99
100 $TCAdefaultOverride = $BE_USER->getTSConfigProp('TCAdefaults');
101 if (is_array($TCAdefaultOverride)) {
102 $this->tce->setDefaultsFromUserTS($TCAdefaultOverride);
103 }
104
105 // Reverse order.
106 if ($this->flags['reverseOrder']) {
107 $this->tce->reverseOrder=1;
108 }
109
110 $this->tce->disableRTE = t3lib_div::GPvar('_disableRTE');
111
112 // Clipboard?
113 $this->CB = t3lib_div::GPvar('CB');
114 if (is_array($this->CB)) {
115 $this->include_once[]=PATH_t3lib.'class.t3lib_clipboard.php';
116 }
117 }
118
119 /**
120 * Clipboard pasting and deleting.
121 *
122 * @return void
123 */
124 function initClipboard() {
125 if (is_array($this->CB)) {
126 $clipObj = t3lib_div::makeInstance('t3lib_clipboard');
127 $clipObj->initializeClipboard();
128 if ($this->CB['paste']) {
129 $clipObj->setCurrentPad($this->CB['pad']);
130 $this->cmd = $clipObj->makePasteCmdArray($this->CB['paste'],$this->cmd);
131 }
132 if ($this->CB['delete']) {
133 $clipObj->setCurrentPad($this->CB['pad']);
134 $this->cmd = $clipObj->makeDeleteCmdArray($this->cmd);
135 }
136 }
137 }
138
139 /**
140 * Executing the posted actions ...
141 *
142 * @return void
143 */
144 function main() {
145 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
146
147 // LOAD TCEmain with data and cmd arrays:
148 $this->tce->start($this->data,$this->cmd);
149 if (is_array($this->mirror)) {$this->tce->setMirror($this->mirror);}
150
151 // Checking referer / executing
152 $refInfo=parse_url(t3lib_div::getIndpEnv('HTTP_REFERER'));
153 $httpHost = t3lib_div::getIndpEnv('TYPO3_HOST_ONLY');
154 if ($httpHost!=$refInfo['host'] && t3lib_div::GPvar('vC')!=$BE_USER->veriCode() && !$TYPO3_CONF_VARS['SYS']['doNotCheckReferer']) {
155 $this->tce->log('',0,0,0,1,'Referer host "%s" and server host "%s" did not match and veriCode was not valid either!',1,array($refInfo['host'],$httpHost));
156 } else {
157 // Register uploaded files
158 $this->tce->process_uploads($GLOBALS['HTTP_POST_FILES']);
159
160 // Execute actions:
161 $this->tce->process_datamap();
162 $this->tce->process_cmdmap();
163
164 // Clearing cache:
165 $this->tce->clear_cacheCmd($this->cacheCmd);
166
167 // Update page tree?
168 if (t3lib_div::GPvar('uPT') && (isset($this->data['pages'])||isset($this->cmd['pages']))) {
169 t3lib_BEfunc::getSetUpdateSignal('updatePageTree');
170 }
171 }
172 }
173
174 /**
175 * Redirecting...
176 *
177 * @return void
178 */
179 function finish() {
180 // Prints errors, if...
181 if (t3lib_div::GPvar('prErr')) {
182 $this->tce->printLogErrorMessages($this->redirect);
183 }
184
185 // Redirecting
186 if (!$this->redirect) {
187 $this->redirect = 'status.php';
188 }
189 if (!$this->tce->debug) {
190 Header('Location: '.t3lib_div::locationHeaderUrl($this->redirect));
191
192 echo '
193 <script type="text/javascript">
194 if (confirm(\'System Error:\n\n Some error happend in tce_db.php. Continue?\')) {
195 document.location = \''.$this->redirect.'\';
196 }
197 </script>
198 ';
199 }
200 }
201 }
202
203 // Include extension?
204 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/tce_db.php']) {
205 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/tce_db.php']);
206 }
207
208
209
210
211
212
213
214 // Make instance:
215 $SOBE = t3lib_div::makeInstance('SC_tce_db');
216 $SOBE->init();
217
218 // Include files?
219 reset($SOBE->include_once);
220 while(list(,$INC_FILE)=each($SOBE->include_once)) {include_once($INC_FILE);}
221
222 $SOBE->initClipboard();
223 $SOBE->main();
224 $SOBE->finish();
225 ?>