Main Page | Directories | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages | Examples

tce_db.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2004 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00054 require ('init.php');
00055 require ('template.php');
00056 require_once (PATH_t3lib.'class.t3lib_tcemain.php');
00057 
00058 
00059 
00060 
00061 
00062 
00063 
00064 
00065 
00066 
00067 
00068 
00079 class SC_tce_db {
00080 
00081       // Internal, static: GPvar
00082    var $flags;       // Array. Accepts options to be set in TCE object. Currently it supports "reverseOrder" (boolean).
00083    var $data;        // Data array on the form [tablename][uid][fieldname] = value
00084    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!
00085    var $mirror;      // Array passed to ->setMirror.
00086    var $cacheCmd;    // Cache command sent to ->clear_cacheCmd
00087    var $redirect;    // Redirect URL. Script will redirect to this location after performing operations (unless errors has occured)
00088    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.
00089 #  var $_disableRTE;
00090    var $CB;       // Clipboard command array. May trigger changes in "cmd"
00091    var $vC;       // Verification code
00092    var $uPT;         // Boolean. Update Page Tree Trigger. If set and the manipulated records are pages then the update page tree signal will be set.
00093 
00094       // Internal, dynamic:
00095    var $include_once=array();    // Files to include after init() function is called:
00096    var $tce;                  // TCEmain object
00097 
00098 
00099 
00100 
00106    function init()   {
00107       global $BE_USER;
00108 
00109          // GPvars:
00110       $this->flags = t3lib_div::_GP('flags');
00111       $this->data = t3lib_div::_GP('data');
00112       $this->cmd = t3lib_div::_GP('cmd');
00113       $this->mirror = t3lib_div::_GP('mirror');
00114       $this->cacheCmd = t3lib_div::_GP('cacheCmd');
00115       $this->redirect = t3lib_div::_GP('redirect');
00116       $this->prErr = t3lib_div::_GP('prErr');
00117       $this->_disableRTE = t3lib_div::_GP('_disableRTE');
00118       $this->CB = t3lib_div::_GP('CB');
00119       $this->vC = t3lib_div::_GP('vC');
00120       $this->uPT = t3lib_div::_GP('uPT');
00121 
00122          // Creating TCEmain object
00123       $this->tce = t3lib_div::makeInstance('t3lib_TCEmain');
00124       $this->tce->stripslashes_values=0;
00125 
00126          // Configuring based on user prefs.
00127       if ($BE_USER->uc['recursiveDelete'])   {
00128          $this->tce->deleteTree = 1;   // True if the delete Recursive flag is set.
00129       }
00130       if ($BE_USER->uc['copyLevels'])  {
00131          $this->tce->copyTree = t3lib_div::intInRange($BE_USER->uc['copyLevels'],0,100);  // Set to number of page-levels to copy.
00132       }
00133       if ($BE_USER->uc['neverHideAtCopy'])   {
00134          $this->tce->neverHideAtCopy = 1;
00135       }
00136 
00137       $TCAdefaultOverride = $BE_USER->getTSConfigProp('TCAdefaults');
00138       if (is_array($TCAdefaultOverride))  {
00139          $this->tce->setDefaultsFromUserTS($TCAdefaultOverride);
00140       }
00141 
00142          // Reverse order.
00143       if ($this->flags['reverseOrder'])   {
00144          $this->tce->reverseOrder=1;
00145       }
00146 
00147 #     $this->tce->disableRTE = $this->_disableRTE;
00148 
00149          // Clipboard?
00150       if (is_array($this->CB))   {
00151          $this->include_once[]=PATH_t3lib.'class.t3lib_clipboard.php';
00152       }
00153    }
00154 
00160    function initClipboard()   {
00161       if (is_array($this->CB))   {
00162          $clipObj = t3lib_div::makeInstance('t3lib_clipboard');
00163          $clipObj->initializeClipboard();
00164          if ($this->CB['paste']) {
00165             $clipObj->setCurrentPad($this->CB['pad']);
00166             $this->cmd = $clipObj->makePasteCmdArray($this->CB['paste'],$this->cmd);
00167          }
00168          if ($this->CB['delete'])   {
00169             $clipObj->setCurrentPad($this->CB['pad']);
00170             $this->cmd = $clipObj->makeDeleteCmdArray($this->cmd);
00171          }
00172       }
00173    }
00174 
00180    function main()   {
00181       global $BE_USER,$TYPO3_CONF_VARS;
00182 
00183          // LOAD TCEmain with data and cmd arrays:
00184       $this->tce->start($this->data,$this->cmd);
00185       if (is_array($this->mirror))  {$this->tce->setMirror($this->mirror);}
00186 
00187          // Checking referer / executing
00188       $refInfo=parse_url(t3lib_div::getIndpEnv('HTTP_REFERER'));
00189       $httpHost = t3lib_div::getIndpEnv('TYPO3_HOST_ONLY');
00190       if ($httpHost!=$refInfo['host'] && $this->vC!=$BE_USER->veriCode() && !$TYPO3_CONF_VARS['SYS']['doNotCheckReferer']) {
00191          $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));
00192       } else {
00193             // Register uploaded files
00194          $this->tce->process_uploads($_FILES);
00195 
00196             // Execute actions:
00197          $this->tce->process_datamap();
00198          $this->tce->process_cmdmap();
00199 
00200             // Clearing cache:
00201          $this->tce->clear_cacheCmd($this->cacheCmd);
00202 
00203             // Update page tree?
00204          if ($this->uPT && (isset($this->data['pages'])||isset($this->cmd['pages'])))  {
00205             t3lib_BEfunc::getSetUpdateSignal('updatePageTree');
00206          }
00207       }
00208    }
00209 
00216    function finish() {
00217          // Prints errors, if...
00218       if ($this->prErr) {
00219          $this->tce->printLogErrorMessages($this->redirect);
00220       }
00221 
00222       if ($this->redirect && !$this->tce->debug) {
00223          Header('Location: '.t3lib_div::locationHeaderUrl($this->redirect));
00224       }
00225    }
00226 }
00227 
00228 // Include extension?
00229 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/tce_db.php'])  {
00230    include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/tce_db.php']);
00231 }
00232 
00233 
00234 
00235 
00236 
00237 
00238 
00239 // Make instance:
00240 $SOBE = t3lib_div::makeInstance('SC_tce_db');
00241 $SOBE->init();
00242 
00243 // Include files?
00244 foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE);
00245 
00246 $SOBE->initClipboard();
00247 $SOBE->main();
00248 $SOBE->finish();
00249 ?>

Generated on Sun Oct 3 01:06:01 2004 for TYPO3core 3.7.0 dev by  doxygen 1.3.8-20040913