[TASK] Remove old code related to the extension tstemplate_styler
[Packages/TYPO3.CMS.git] / typo3 / tce_db.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-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 * 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 * Revised for TYPO3 3.6 July/2003 by Kasper Skårhøj
33 *
34 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
35 */
36
37
38 require ('init.php');
39 require ('template.php');
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 * Used by many smaller forms/links in TYPO3, including the QuickEdit module.
54 * Is not used by alt_doc.php though (main form rendering script) - that uses the same class (TCEmain) but makes its own initialization (to save the redirect request).
55 * For all other cases than alt_doc.php it is recommended to use this script for submitting your editing forms - but the best solution in any case would probably be to link your application to alt_doc.php, that will give you easy form-rendering as well.
56 *
57 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
58 * @package TYPO3
59 * @subpackage core
60 */
61 class SC_tce_db {
62
63 // Internal, static: GPvar
64 var $flags; // Array. Accepts options to be set in TCE object. Currently it supports "reverseOrder" (boolean).
65 var $data; // Data array on the form [tablename][uid][fieldname] = value
66 var $cmd; // Command array on the form [tablename][uid][command] = value. This array may get additional data set internally based on clipboard commands send in CB var!
67 var $mirror; // Array passed to ->setMirror.
68 var $cacheCmd; // Cache command sent to ->clear_cacheCmd
69 var $redirect; // Redirect URL. Script will redirect to this location after performing operations (unless errors has occured)
70 var $prErr; // Boolean. If set, errors will be printed on screen instead of redirection. Should always be used, otherwise you will see no errors if they happen.
71 # var $_disableRTE;
72 var $CB; // Clipboard command array. May trigger changes in "cmd"
73 var $vC; // Verification code
74 var $uPT; // Boolean. Update Page Tree Trigger. If set and the manipulated records are pages then the update page tree signal will be set.
75 var $generalComment; // String, general comment (for raising stages of workspace versions)
76
77 // Internal, dynamic:
78 var $include_once=array(); // Files to include after init() function is called:
79
80 /**
81 * TYPO3 Core Engine
82 *
83 * @var t3lib_TCEmain
84 */
85 var $tce;
86
87
88
89
90 /**
91 * Initialization of the class
92 *
93 * @return void
94 */
95 function init() {
96
97 // GPvars:
98 $this->flags = t3lib_div::_GP('flags');
99 $this->data = t3lib_div::_GP('data');
100 $this->cmd = t3lib_div::_GP('cmd');
101 $this->mirror = t3lib_div::_GP('mirror');
102 $this->cacheCmd = t3lib_div::_GP('cacheCmd');
103 $this->redirect = t3lib_div::sanitizeLocalUrl(t3lib_div::_GP('redirect'));
104 $this->prErr = t3lib_div::_GP('prErr');
105 $this->_disableRTE = t3lib_div::_GP('_disableRTE');
106 $this->CB = t3lib_div::_GP('CB');
107 $this->vC = t3lib_div::_GP('vC');
108 $this->uPT = t3lib_div::_GP('uPT');
109 $this->generalComment = t3lib_div::_GP('generalComment');
110
111 // Creating TCEmain object
112 $this->tce = t3lib_div::makeInstance('t3lib_TCEmain');
113 $this->tce->stripslashes_values=0;
114 $this->tce->generalComment = $this->generalComment;
115
116 // Configuring based on user prefs.
117 if ($GLOBALS['BE_USER']->uc['recursiveDelete']) {
118 $this->tce->deleteTree = 1; // TRUE if the delete Recursive flag is set.
119 }
120 if ($GLOBALS['BE_USER']->uc['copyLevels']) {
121 // Set to number of page-levels to copy.
122 $this->tce->copyTree = t3lib_utility_Math::forceIntegerInRange($GLOBALS['BE_USER']->uc['copyLevels'], 0, 100);
123 }
124 if ($GLOBALS['BE_USER']->uc['neverHideAtCopy']) {
125 $this->tce->neverHideAtCopy = 1;
126 }
127
128 $TCAdefaultOverride = $GLOBALS['BE_USER']->getTSConfigProp('TCAdefaults');
129 if (is_array($TCAdefaultOverride)) {
130 $this->tce->setDefaultsFromUserTS($TCAdefaultOverride);
131 }
132
133 // Reverse order.
134 if ($this->flags['reverseOrder']) {
135 $this->tce->reverseOrder=1;
136 }
137
138 # $this->tce->disableRTE = $this->_disableRTE;
139
140 // Clipboard?
141 if (is_array($this->CB)) {
142 $this->include_once[]=PATH_t3lib.'class.t3lib_clipboard.php';
143 }
144 }
145
146 /**
147 * Clipboard pasting and deleting.
148 *
149 * @return void
150 */
151 function initClipboard() {
152 if (is_array($this->CB)) {
153 $clipObj = t3lib_div::makeInstance('t3lib_clipboard');
154 $clipObj->initializeClipboard();
155 if ($this->CB['paste']) {
156 $clipObj->setCurrentPad($this->CB['pad']);
157 $this->cmd = $clipObj->makePasteCmdArray($this->CB['paste'],$this->cmd);
158 }
159 if ($this->CB['delete']) {
160 $clipObj->setCurrentPad($this->CB['pad']);
161 $this->cmd = $clipObj->makeDeleteCmdArray($this->cmd);
162 }
163 }
164 }
165
166 /**
167 * Executing the posted actions ...
168 *
169 * @return void
170 */
171 function main() {
172
173 // LOAD TCEmain with data and cmd arrays:
174 $this->tce->start($this->data,$this->cmd);
175 if (is_array($this->mirror)) {$this->tce->setMirror($this->mirror);}
176
177 // Checking referer / executing
178 $refInfo=parse_url(t3lib_div::getIndpEnv('HTTP_REFERER'));
179 $httpHost = t3lib_div::getIndpEnv('TYPO3_HOST_ONLY');
180 if ($httpHost != $refInfo['host'] && $this->vC != $GLOBALS['BE_USER']->veriCode() && !$GLOBALS['TYPO3_CONF_VARS']['SYS']['doNotCheckReferer']) {
181 $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));
182 } else {
183 // Register uploaded files
184 $this->tce->process_uploads($_FILES);
185
186 // Execute actions:
187 $this->tce->process_datamap();
188 $this->tce->process_cmdmap();
189
190 // Clearing cache:
191 $this->tce->clear_cacheCmd($this->cacheCmd);
192
193 // Update page tree?
194 if ($this->uPT && (isset($this->data['pages'])||isset($this->cmd['pages']))) {
195 t3lib_BEfunc::setUpdateSignal('updatePageTree');
196 }
197 }
198 }
199
200 /**
201 * Redirecting the user after the processing has been done.
202 * Might also display error messages directly, if any.
203 *
204 * @return void
205 */
206 function finish() {
207 // Prints errors, if...
208 if ($this->prErr) {
209 $this->tce->printLogErrorMessages($this->redirect);
210 }
211
212 if ($this->redirect && !$this->tce->debug) {
213 t3lib_utility_Http::redirect($this->redirect);
214 }
215 }
216 }
217
218
219 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/tce_db.php'])) {
220 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/tce_db.php']);
221 }
222
223
224
225 // Make instance:
226 $SOBE = t3lib_div::makeInstance('SC_tce_db');
227 $SOBE->init();
228
229 // Include files?
230 foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE);
231
232 $formprotection = t3lib_formprotection_Factory::get();
233
234 if ($formprotection->validateToken(t3lib_div::_GP('formToken'), 'tceAction')) {
235 $SOBE->initClipboard();
236 $SOBE->main();
237 }
238 $SOBE->finish();
239
240 ?>