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