TYPO3 CMS  TYPO3_6-2
SimpleDataHandlerController.php
Go to the documentation of this file.
1 <?php
3 
18 
30 
31  // Internal, static: GPvar
32  // Array. Accepts options to be set in TCE object. Currently it supports "reverseOrder" (boolean).
36  public $flags;
37 
38  // Data array on the form [tablename][uid][fieldname] = value
42  public $data;
43 
44  // 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!
48  public $cmd;
49 
50  // Array passed to ->setMirror.
54  public $mirror;
55 
56  // Cache command sent to ->clear_cacheCmd
60  public $cacheCmd;
61 
62  // Redirect URL. Script will redirect to this location after performing operations (unless errors has occurred)
66  public $redirect;
67 
68  // 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.
72  public $prErr;
73 
74  // Clipboard command array. May trigger changes in "cmd"
78  public $CB;
79 
80  // Verification code
84  public $vC;
85 
86  // Boolean. Update Page Tree Trigger. If set and the manipulated records are pages then the update page tree signal will be set.
90  public $uPT;
91 
92  // String, general comment (for raising stages of workspace versions)
97 
98  // Internal, dynamic:
99  // Files to include after init() function is called:
103  public $include_once = array();
104 
111  public $tce;
112 
116  public function __construct() {
117  $GLOBALS['SOBE'] = $this;
118  $this->init();
119  }
120 
127  public function init() {
128  // GPvars:
129  $this->flags = GeneralUtility::_GP('flags');
130  $this->data = GeneralUtility::_GP('data');
131  $this->cmd = GeneralUtility::_GP('cmd');
132  $this->mirror = GeneralUtility::_GP('mirror');
133  $this->cacheCmd = GeneralUtility::_GP('cacheCmd');
134  $this->redirect = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('redirect'));
135  $this->prErr = GeneralUtility::_GP('prErr');
136  $this->_disableRTE = GeneralUtility::_GP('_disableRTE');
137  $this->CB = GeneralUtility::_GP('CB');
138  $this->vC = GeneralUtility::_GP('vC');
139  $this->uPT = GeneralUtility::_GP('uPT');
140  $this->generalComment = GeneralUtility::_GP('generalComment');
141  // Creating TCEmain object
142  $this->tce = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
143  $this->tce->stripslashes_values = 0;
144  $this->tce->generalComment = $this->generalComment;
145  // Configuring based on user prefs.
146  if ($GLOBALS['BE_USER']->uc['recursiveDelete']) {
147  // TRUE if the delete Recursive flag is set.
148  $this->tce->deleteTree = 1;
149  }
150  if ($GLOBALS['BE_USER']->uc['copyLevels']) {
151  // Set to number of page-levels to copy.
152  $this->tce->copyTree = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($GLOBALS['BE_USER']->uc['copyLevels'], 0, 100);
153  }
154  if ($GLOBALS['BE_USER']->uc['neverHideAtCopy']) {
155  $this->tce->neverHideAtCopy = 1;
156  }
157  $TCAdefaultOverride = $GLOBALS['BE_USER']->getTSConfigProp('TCAdefaults');
158  if (is_array($TCAdefaultOverride)) {
159  $this->tce->setDefaultsFromUserTS($TCAdefaultOverride);
160  }
161  // Reverse order.
162  if ($this->flags['reverseOrder']) {
163  $this->tce->reverseOrder = 1;
164  }
165  }
166 
173  public function initClipboard() {
174  if (is_array($this->CB)) {
175  $clipObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Clipboard\\Clipboard');
176  $clipObj->initializeClipboard();
177  if ($this->CB['paste']) {
178  $clipObj->setCurrentPad($this->CB['pad']);
179  $this->cmd = $clipObj->makePasteCmdArray(
180  $this->CB['paste'],
181  $this->cmd,
182  isset($this->CB['update']) ? $this->CB['update'] : NULL
183  );
184  }
185  if ($this->CB['delete']) {
186  $clipObj->setCurrentPad($this->CB['pad']);
187  $this->cmd = $clipObj->makeDeleteCmdArray($this->cmd);
188  }
189  }
190  }
191 
198  public function main() {
199  // LOAD TCEmain with data and cmd arrays:
200  $this->tce->start($this->data, $this->cmd);
201  if (is_array($this->mirror)) {
202  $this->tce->setMirror($this->mirror);
203  }
204  // Checking referer / executing
205  $refInfo = parse_url(GeneralUtility::getIndpEnv('HTTP_REFERER'));
206  $httpHost = GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY');
207  if ($httpHost != $refInfo['host'] && $this->vC != $GLOBALS['BE_USER']->veriCode() && !$GLOBALS['TYPO3_CONF_VARS']['SYS']['doNotCheckReferer']) {
208  $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));
209  } else {
210  // Register uploaded files
211  $this->tce->process_uploads($_FILES);
212  // Execute actions:
213  $this->tce->process_datamap();
214  $this->tce->process_cmdmap();
215  // Clearing cache:
216  if (!empty($this->cacheCmd)) {
217  $this->tce->clear_cacheCmd($this->cacheCmd);
218  }
219  // Update page tree?
220  if ($this->uPT && (isset($this->data['pages']) || isset($this->cmd['pages']))) {
222  }
223  }
224  }
225 
233  public function finish() {
234  // Prints errors, if...
235  if ($this->prErr) {
236  $this->tce->printLogErrorMessages($this->redirect);
237  }
238  if ($this->redirect && !$this->tce->debug) {
240  }
241  }
242 
243 }
static forceIntegerInRange($theInt, $min, $max=2000000000, $defaultValue=0)
Definition: MathUtility.php:32
static setUpdateSignal($set='', $params='')
static redirect($url, $httpStatus=self::HTTP_STATUS_303)
Definition: HttpUtility.php:76
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]