* Modified typo3/sysext/cms/tslib/class.tslib_content.php:
[Packages/TYPO3.CMS.git] / typo3 / tce_db.php
index 88cfdc7..696bdda 100644 (file)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *  
-*  (c) 1999-2003 Kasper Skaarhoj (kasper@typo3.com)
+*  (c) 1999-2004 Kasper Skaarhoj (kasper@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is 
  *
  *
  *
- *   77: class SC_tce_db 
- *   94:     function init()   
- *  143:     function initClipboard()  
- *  163:     function main()   
- *  198:     function finish() 
+ *   80: class SC_tce_db 
+ *  107:     function init()   
+ *  161:     function initClipboard()  
+ *  181:     function main()   
+ *  217:     function finish() 
  *
  * TOTAL FUNCTIONS: 4
  * (This index is automatically created/updated by the extension "extdeveval")
@@ -69,41 +69,60 @@ require_once (PATH_t3lib.'class.t3lib_tcemain.php');
 
 /**
  * Script Class, creating object of t3lib_TCEmain and sending the posted data to the object.
- * 
+ * Used by many smaller forms/links in TYPO3, including the QuickEdit module.
+ * 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).
+ * 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.
+ *
  * @author     Kasper Skaarhoj <kasper@typo3.com>
  * @package TYPO3
  * @subpackage core
  */
 class SC_tce_db {
-       var $include_once=array();
-       var $tce;
-       var $CB;
        
+               // Internal, static: GPvar
        var $flags;
        var $data;
        var $cmd;
        var $mirror;
        var $cacheCmd;
        var $redirect;
-       
+       var $prErr;
+       var $_disableRTE;
+       var $CB;
+       var $vC;
+       var $uPT;
+
+               // Internal, dynamic:   
+       var $include_once=array();              // Files to include after init() function is called:
+       var $tce;                                               // TCEmain object
+
+
+
+
        /**
-        * Initialization.
-        * 
-        * @return      void            
+        * Initialization of the class
+        *
+        * @return      void
         */
        function init() {
                global $BE_USER;
 
-                       // Registering Incoming data
-               $this->flags = t3lib_div::GPvar('flags');
-               $this->data = t3lib_div::GPvar('data');
-               $this->cmd = t3lib_div::GPvar('cmd');
-               $this->mirror = t3lib_div::GPvar('mirror');
-               $this->cacheCmd = t3lib_div::GPvar('cacheCmd');
-               $this->redirect = t3lib_div::GPvar('redirect');
-               
+                       // GPvars:
+               $this->flags = t3lib_div::_GP('flags');
+               $this->data = t3lib_div::_GP('data');
+               $this->cmd = t3lib_div::_GP('cmd');
+               $this->mirror = t3lib_div::_GP('mirror');
+               $this->cacheCmd = t3lib_div::_GP('cacheCmd');
+               $this->redirect = t3lib_div::_GP('redirect');
+               $this->prErr = t3lib_div::_GP('prErr');
+               $this->_disableRTE = t3lib_div::_GP('_disableRTE');
+               $this->CB = t3lib_div::_GP('CB');
+               $this->vC = t3lib_div::_GP('vC');
+               $this->uPT = t3lib_div::_GP('uPT');
+
                        // Creating TCEmain object
                $this->tce = t3lib_div::makeInstance('t3lib_TCEmain');
+               $this->tce->stripslashes_values=0;
                
                        // Configuring based on user prefs.
                if ($BE_USER->uc['recursiveDelete'])    {
@@ -126,10 +145,9 @@ class SC_tce_db {
                        $this->tce->reverseOrder=1;
                }
                
-               $this->tce->disableRTE = t3lib_div::GPvar('_disableRTE');
+               $this->tce->disableRTE = $this->_disableRTE;
 
                        // Clipboard?
-               $this->CB = t3lib_div::GPvar('CB');
                if (is_array($this->CB))        {
                        $this->include_once[]=PATH_t3lib.'class.t3lib_clipboard.php';
                }
@@ -137,8 +155,8 @@ class SC_tce_db {
 
        /**
         * Clipboard pasting and deleting.
-        * 
-        * @return      void            
+        *
+        * @return      void
         */
        function initClipboard()        {
                if (is_array($this->CB))        {
@@ -157,11 +175,11 @@ class SC_tce_db {
 
        /**
         * Executing the posted actions ...
-        * 
-        * @return      void            
+        *
+        * @return      void
         */
        function main() {
-               global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
+               global $BE_USER,$TYPO3_CONF_VARS;
 
                        // LOAD TCEmain with data and cmd arrays:
                $this->tce->start($this->data,$this->cmd);
@@ -170,7 +188,7 @@ class SC_tce_db {
                        // Checking referer / executing
                $refInfo=parse_url(t3lib_div::getIndpEnv('HTTP_REFERER'));
                $httpHost = t3lib_div::getIndpEnv('TYPO3_HOST_ONLY');
-               if ($httpHost!=$refInfo['host'] && t3lib_div::GPvar('vC')!=$BE_USER->veriCode() && !$TYPO3_CONF_VARS['SYS']['doNotCheckReferer'])       {
+               if ($httpHost!=$refInfo['host'] && $this->vC!=$BE_USER->veriCode() && !$TYPO3_CONF_VARS['SYS']['doNotCheckReferer'])    {
                        $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));
                } else {
                                // Register uploaded files
@@ -179,42 +197,31 @@ class SC_tce_db {
                                // Execute actions:
                        $this->tce->process_datamap();
                        $this->tce->process_cmdmap();
-                       
+
                                // Clearing cache:
                        $this->tce->clear_cacheCmd($this->cacheCmd);
                        
                                // Update page tree?
-                       if (t3lib_div::GPvar('uPT') && (isset($this->data['pages'])||isset($this->cmd['pages'])))       {
+                       if ($this->uPT && (isset($this->data['pages'])||isset($this->cmd['pages'])))    {
                                t3lib_BEfunc::getSetUpdateSignal('updatePageTree');
                        }
                }
        }
 
        /**
-        * Redirecting...
-        * 
-        * @return      void            
+        * Redirecting the user after the processing has been done.
+        * Might also display error messages directly, if any.
+        *
+        * @return      void
         */
        function finish()       {
                        // Prints errors, if...
-               if (t3lib_div::GPvar('prErr'))  {
+               if ($this->prErr)       {
                        $this->tce->printLogErrorMessages($this->redirect);
                }
-               
-                       // Redirecting
-               if (!$this->redirect)   {
-                       $this->redirect = 'status.php';
-               }
-               if (!$this->tce->debug) {
+
+               if ($this->redirect && !$this->tce->debug) {
                        Header('Location: '.t3lib_div::locationHeaderUrl($this->redirect));
-               
-                       echo '
-                               <script type="text/javascript">
-                                       if (confirm(\'System Error:\n\n Some error happend in tce_db.php. Continue?\')) {
-                                               document.location = \''.$this->redirect.'\';
-                                       }
-                               </script>
-                       ';
                }
        }       
 }
@@ -235,8 +242,7 @@ $SOBE = t3lib_div::makeInstance('SC_tce_db');
 $SOBE->init();
 
 // Include files?
-reset($SOBE->include_once);    
-while(list(,$INC_FILE)=each($SOBE->include_once))      {include_once($INC_FILE);}
+foreach($SOBE->include_once as $INC_FILE)      include_once($INC_FILE);
 
 $SOBE->initClipboard();
 $SOBE->main();