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