2 /***************************************************************
5 * (c) 1999-2010 Kasper Skaarhoj (kasperYYYY@typo3.com)
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.
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.
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.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
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'
33 * Revised for TYPO3 3.6 July/2003 by Kasper Skaarhoj
35 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
38 * [CLASS/FUNCTION INDEX of SCRIPT]
43 * 106: function init()
44 * 162: function initClipboard()
45 * 182: function main()
46 * 218: function finish()
49 * (This index is automatically created/updated by the extension "extdeveval")
55 require ('template.php');
68 * Script Class, creating object of t3lib_TCEmain and sending the posted data to the object.
69 * Used by many smaller forms/links in TYPO3, including the QuickEdit module.
70 * 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).
71 * 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 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
79 // Internal, static: GPvar
80 var $flags; // Array. Accepts options to be set in TCE object. Currently it supports "reverseOrder" (boolean).
81 var $data; // Data array on the form [tablename][uid][fieldname] = value
82 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!
83 var $mirror; // Array passed to ->setMirror.
84 var $cacheCmd; // Cache command sent to ->clear_cacheCmd
85 var $redirect; // Redirect URL. Script will redirect to this location after performing operations (unless errors has occured)
86 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 $CB; // Clipboard command array. May trigger changes in "cmd"
89 var $vC; // Verification code
90 var $uPT; // Boolean. Update Page Tree Trigger. If set and the manipulated records are pages then the update page tree signal will be set.
91 var $generalComment; // String, general comment (for raising stages of workspace versions)
94 var $include_once=array(); // Files to include after init() function is called:
107 * Initialization of the class
115 $this->flags
= t3lib_div
::_GP('flags');
116 $this->data
= t3lib_div
::_GP('data');
117 $this->cmd
= t3lib_div
::_GP('cmd');
118 $this->mirror
= t3lib_div
::_GP('mirror');
119 $this->cacheCmd
= t3lib_div
::_GP('cacheCmd');
120 $this->redirect
= t3lib_div
::_GP('redirect');
121 $this->prErr
= t3lib_div
::_GP('prErr');
122 $this->_disableRTE
= t3lib_div
::_GP('_disableRTE');
123 $this->CB
= t3lib_div
::_GP('CB');
124 $this->vC
= t3lib_div
::_GP('vC');
125 $this->uPT
= t3lib_div
::_GP('uPT');
126 $this->generalComment
= t3lib_div
::_GP('generalComment');
128 // Creating TCEmain object
129 $this->tce
= t3lib_div
::makeInstance('t3lib_TCEmain');
130 $this->tce
->stripslashes_values
=0;
131 $this->tce
->generalComment
= $this->generalComment
;
133 // Configuring based on user prefs.
134 if ($BE_USER->uc
['recursiveDelete']) {
135 $this->tce
->deleteTree
= 1; // True if the delete Recursive flag is set.
137 if ($BE_USER->uc
['copyLevels']) {
138 $this->tce
->copyTree
= t3lib_div
::intInRange($BE_USER->uc
['copyLevels'],0,100); // Set to number of page-levels to copy.
140 if ($BE_USER->uc
['neverHideAtCopy']) {
141 $this->tce
->neverHideAtCopy
= 1;
144 $TCAdefaultOverride = $BE_USER->getTSConfigProp('TCAdefaults');
145 if (is_array($TCAdefaultOverride)) {
146 $this->tce
->setDefaultsFromUserTS($TCAdefaultOverride);
150 if ($this->flags
['reverseOrder']) {
151 $this->tce
->reverseOrder
=1;
154 # $this->tce->disableRTE = $this->_disableRTE;
157 if (is_array($this->CB
)) {
158 $this->include_once[]=PATH_t3lib
.'class.t3lib_clipboard.php';
163 * Clipboard pasting and deleting.
167 function initClipboard() {
168 if (is_array($this->CB
)) {
169 $clipObj = t3lib_div
::makeInstance('t3lib_clipboard');
170 $clipObj->initializeClipboard();
171 if ($this->CB
['paste']) {
172 $clipObj->setCurrentPad($this->CB
['pad']);
173 $this->cmd
= $clipObj->makePasteCmdArray($this->CB
['paste'],$this->cmd
);
175 if ($this->CB
['delete']) {
176 $clipObj->setCurrentPad($this->CB
['pad']);
177 $this->cmd
= $clipObj->makeDeleteCmdArray($this->cmd
);
183 * Executing the posted actions ...
188 global $BE_USER,$TYPO3_CONF_VARS;
190 // LOAD TCEmain with data and cmd arrays:
191 $this->tce
->start($this->data
,$this->cmd
);
192 if (is_array($this->mirror
)) {$this->tce
->setMirror($this->mirror
);}
194 // Checking referer / executing
195 $refInfo=parse_url(t3lib_div
::getIndpEnv('HTTP_REFERER'));
196 $httpHost = t3lib_div
::getIndpEnv('TYPO3_HOST_ONLY');
197 if ($httpHost!=$refInfo['host'] && $this->vC
!=$BE_USER->veriCode() && !$TYPO3_CONF_VARS['SYS']['doNotCheckReferer']) {
198 $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 // Register uploaded files
201 $this->tce
->process_uploads($_FILES);
204 $this->tce
->process_datamap();
205 $this->tce
->process_cmdmap();
208 $this->tce
->clear_cacheCmd($this->cacheCmd
);
211 if ($this->uPT
&& (isset($this->data
['pages'])||
isset($this->cmd
['pages']))) {
212 t3lib_BEfunc
::setUpdateSignal('updatePageTree');
218 * Redirecting the user after the processing has been done.
219 * Might also display error messages directly, if any.
224 // Prints errors, if...
226 $this->tce
->printLogErrorMessages($this->redirect
);
229 if ($this->redirect
&& !$this->tce
->debug
) {
230 t3lib_utility_Http
::redirect($this->redirect
);
236 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/tce_db.php']) {
237 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/tce_db.php']);
243 $SOBE = t3lib_div
::makeInstance('SC_tce_db');
247 foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE);
249 $SOBE->initClipboard();