8561 Checkboxes and labels are aligned badly if in one line
[Packages/TYPO3.CMS.git] / typo3 / tce_db.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2008 Kasper Skaarhoj (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 * $Id$
33 * Revised for TYPO3 3.6 July/2003 by Kasper Skaarhoj
34 *
35 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
36 */
37 /**
38 * [CLASS/FUNCTION INDEX of SCRIPT]
39 *
40 *
41 *
42 * 78: class SC_tce_db
43 * 106: function init()
44 * 162: function initClipboard()
45 * 182: function main()
46 * 218: 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 * Script Class, creating object of t3lib_TCEmain and sending the posted data to the object.
70 * Used by many smaller forms/links in TYPO3, including the QuickEdit module.
71 * 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).
72 * 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.
73 *
74 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
75 * @package TYPO3
76 * @subpackage core
77 */
78 class SC_tce_db {
79
80 // Internal, static: GPvar
81 var $flags; // Array. Accepts options to be set in TCE object. Currently it supports "reverseOrder" (boolean).
82 var $data; // Data array on the form [tablename][uid][fieldname] = value
83 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!
84 var $mirror; // Array passed to ->setMirror.
85 var $cacheCmd; // Cache command sent to ->clear_cacheCmd
86 var $redirect; // Redirect URL. Script will redirect to this location after performing operations (unless errors has occured)
87 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.
88 # var $_disableRTE;
89 var $CB; // Clipboard command array. May trigger changes in "cmd"
90 var $vC; // Verification code
91 var $uPT; // Boolean. Update Page Tree Trigger. If set and the manipulated records are pages then the update page tree signal will be set.
92 var $generalComment; // String, general comment (for raising stages of workspace versions)
93
94 // Internal, dynamic:
95 var $include_once=array(); // Files to include after init() function is called:
96
97 /**
98 * TYPO3 Core Engine
99 *
100 * @var t3lib_TCEmain
101 */
102 var $tce;
103
104
105
106
107 /**
108 * Initialization of the class
109 *
110 * @return void
111 */
112 function init() {
113 global $BE_USER;
114
115 // GPvars:
116 $this->flags = t3lib_div::_GP('flags');
117 $this->data = t3lib_div::_GP('data');
118 $this->cmd = t3lib_div::_GP('cmd');
119 $this->mirror = t3lib_div::_GP('mirror');
120 $this->cacheCmd = t3lib_div::_GP('cacheCmd');
121 $this->redirect = t3lib_div::_GP('redirect');
122 $this->prErr = t3lib_div::_GP('prErr');
123 $this->_disableRTE = t3lib_div::_GP('_disableRTE');
124 $this->CB = t3lib_div::_GP('CB');
125 $this->vC = t3lib_div::_GP('vC');
126 $this->uPT = t3lib_div::_GP('uPT');
127 $this->generalComment = t3lib_div::_GP('generalComment');
128
129 // Creating TCEmain object
130 $this->tce = t3lib_div::makeInstance('t3lib_TCEmain');
131 $this->tce->stripslashes_values=0;
132 $this->tce->generalComment = $this->generalComment;
133
134 // Configuring based on user prefs.
135 if ($BE_USER->uc['recursiveDelete']) {
136 $this->tce->deleteTree = 1; // True if the delete Recursive flag is set.
137 }
138 if ($BE_USER->uc['copyLevels']) {
139 $this->tce->copyTree = t3lib_div::intInRange($BE_USER->uc['copyLevels'],0,100); // Set to number of page-levels to copy.
140 }
141 if ($BE_USER->uc['neverHideAtCopy']) {
142 $this->tce->neverHideAtCopy = 1;
143 }
144
145 $TCAdefaultOverride = $BE_USER->getTSConfigProp('TCAdefaults');
146 if (is_array($TCAdefaultOverride)) {
147 $this->tce->setDefaultsFromUserTS($TCAdefaultOverride);
148 }
149
150 // Reverse order.
151 if ($this->flags['reverseOrder']) {
152 $this->tce->reverseOrder=1;
153 }
154
155 # $this->tce->disableRTE = $this->_disableRTE;
156
157 // Clipboard?
158 if (is_array($this->CB)) {
159 $this->include_once[]=PATH_t3lib.'class.t3lib_clipboard.php';
160 }
161 }
162
163 /**
164 * Clipboard pasting and deleting.
165 *
166 * @return void
167 */
168 function initClipboard() {
169 if (is_array($this->CB)) {
170 $clipObj = t3lib_div::makeInstance('t3lib_clipboard');
171 $clipObj->initializeClipboard();
172 if ($this->CB['paste']) {
173 $clipObj->setCurrentPad($this->CB['pad']);
174 $this->cmd = $clipObj->makePasteCmdArray($this->CB['paste'],$this->cmd);
175 }
176 if ($this->CB['delete']) {
177 $clipObj->setCurrentPad($this->CB['pad']);
178 $this->cmd = $clipObj->makeDeleteCmdArray($this->cmd);
179 }
180 }
181 }
182
183 /**
184 * Executing the posted actions ...
185 *
186 * @return void
187 */
188 function main() {
189 global $BE_USER,$TYPO3_CONF_VARS;
190
191 // LOAD TCEmain with data and cmd arrays:
192 $this->tce->start($this->data,$this->cmd);
193 if (is_array($this->mirror)) {$this->tce->setMirror($this->mirror);}
194
195 // Checking referer / executing
196 $refInfo=parse_url(t3lib_div::getIndpEnv('HTTP_REFERER'));
197 $httpHost = t3lib_div::getIndpEnv('TYPO3_HOST_ONLY');
198 if ($httpHost!=$refInfo['host'] && $this->vC!=$BE_USER->veriCode() && !$TYPO3_CONF_VARS['SYS']['doNotCheckReferer']) {
199 $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));
200 } else {
201 // Register uploaded files
202 $this->tce->process_uploads($_FILES);
203
204 // Execute actions:
205 $this->tce->process_datamap();
206 $this->tce->process_cmdmap();
207
208 // Clearing cache:
209 $this->tce->clear_cacheCmd($this->cacheCmd);
210
211 // Update page tree?
212 if ($this->uPT && (isset($this->data['pages'])||isset($this->cmd['pages']))) {
213 t3lib_BEfunc::getSetUpdateSignal('updatePageTree');
214 }
215 }
216 }
217
218 /**
219 * Redirecting the user after the processing has been done.
220 * Might also display error messages directly, if any.
221 *
222 * @return void
223 */
224 function finish() {
225 // Prints errors, if...
226 if ($this->prErr) {
227 $this->tce->printLogErrorMessages($this->redirect);
228 }
229
230 if ($this->redirect && !$this->tce->debug) {
231 Header('Location: '.t3lib_div::locationHeaderUrl($this->redirect));
232 }
233 }
234 }
235
236
237 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/tce_db.php']) {
238 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/tce_db.php']);
239 }
240
241
242
243 // Make instance:
244 $SOBE = t3lib_div::makeInstance('SC_tce_db');
245 $SOBE->init();
246
247 // Include files?
248 foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE);
249
250 $SOBE->initClipboard();
251 $SOBE->main();
252 $SOBE->finish();
253
254 ?>