Fixed bug #7896: Hide the page browser if not enough entries are available (Thanks...
[Packages/TYPO3.CMS.git] / typo3 / wizard_edit.php
old mode 100755 (executable)
new mode 100644 (file)
index 94bb2fe..5c6618e
@@ -1,22 +1,22 @@
 <?php
 /***************************************************************
 *  Copyright notice
-*  
-*  (c) 1999-2004 Kasper Skaarhoj (kasper@typo3.com)
+*
+*  (c) 1999-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
-*  This script is part of the TYPO3 project. The TYPO3 project is 
+*  This script is part of the TYPO3 project. The TYPO3 project is
 *  free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
-* 
+*
 *  The GNU General Public License can be found at
 *  http://www.gnu.org/copyleft/gpl.html.
-*  A copy is found in the textfile GPL.txt and important notices to the license 
+*  A copy is found in the textfile GPL.txt and important notices to the license
 *  from the author is found in LICENSE.txt distributed with these scripts.
 *
-* 
+*
 *  This script is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *
 *  This copyright notice MUST APPEAR in all copies of the script!
 ***************************************************************/
-/** 
+/**
  * Wizard to edit records from group/select lists in TCEforms
  *
  * $Id$
  * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
- * 
- * @author     Kasper Skaarhoj <kasper@typo3.com>
+ *
+ * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
  */
 /**
  * [CLASS/FUNCTION INDEX of SCRIPT]
  *
  *
  *
- *   76: class SC_wizard_edit 
- *   90:     function init()   
- *  101:     function main()   
- *  149:     function closeWindow()    
+ *   76: class SC_wizard_edit
+ *   90:     function init()
+ *  101:     function main()
+ *  149:     function closeWindow()
  *
  * TOTAL FUNCTIONS: 3
  * (This index is automatically created/updated by the extension "extdeveval")
  *
  */
 
+
 
 $BACK_PATH='';
 require ('init.php');
 require ('template.php');
-include ('sysext/lang/locallang_wizards.php');
-require_once (PATH_t3lib.'class.t3lib_loaddbgroup.php');
-
-
-
-
-
-
-
-
-
-
+$LANG->includeLLFile('EXT:lang/locallang_wizards.xml');
 
 
 /**
  * Script Class for redirecting a backend user to the editing form when an "Edit wizard" link was clicked in TCEforms somewhere
- * 
- * @author     Kasper Skaarhoj <kasper@typo3.com>
+ *
+ * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
  * @package TYPO3
  * @subpackage core
  */
@@ -84,19 +73,19 @@ class SC_wizard_edit {
 
        /**
         * Initialization of the script
-        * 
-        * @return      void            
+        *
+        * @return      void
         */
        function init() {
-               $this->P = t3lib_div::GPvar('P',1);
-               $this->doClose = t3lib_div::GPvar('doClose');           // Used for the return URL to alt_doc.php so that we can close the window.
+               $this->P = t3lib_div::_GP('P');
+               $this->doClose = t3lib_div::_GP('doClose');             // Used for the return URL to alt_doc.php so that we can close the window.
        }
 
        /**
         * Main function
         * Makes a header-location redirect to an edit form IF POSSIBLE from the passed data - otherwise the window will just close.
-        * 
-        * @return      void            
+        *
+        * @return      void
         */
        function main() {
                global $TCA;
@@ -111,10 +100,11 @@ class SC_wizard_edit {
                        t3lib_div::loadTCA($table);
                        $config = $TCA[$table]['columns'][$field]['config'];
                        $fTable = $this->P['currentValue']<0 ? $config['neg_foreign_table'] : $config['foreign_table'];
-       
+
                                // Detecting the various allowed field type setups and acting accordingly.
-                       if (is_array($config) && $config['type']=='select' && !$config['MM'] && t3lib_div::testInt($this->P['currentValue']) && $this->P['currentValue'] && $fTable)    {       // SINGLE value:
-                               header('Location: '.t3lib_div::locationHeaderUrl('alt_doc.php?returnUrl='.rawurlencode('wizard_edit.php?doClose=1').'&edit['.$fTable.']['.$this->P['currentValue'].']=edit'));
+                       if (is_array($config) && $config['type']=='select' && !$config['MM'] && $config['maxitems']<=1 && t3lib_div::testInt($this->P['currentValue']) && $this->P['currentValue'] && $fTable)  {       // SINGLE value:
+                               $redirectUrl = 'alt_doc.php?returnUrl=' . rawurlencode('wizard_edit.php?doClose=1') . '&edit[' . $fTable . '][' . $this->P['currentValue'] . ']=edit';
+                               t3lib_utility_Http::redirect($redirectUrl);
                        } elseif (is_array($config) && $this->P['currentSelectedValues'] && (($config['type']=='select' && $config['foreign_table']) || ($config['type']=='group' && $config['internal_type']=='db')))  {       // MULTIPLE VALUES:
 
                                        // Init settings:
@@ -126,15 +116,15 @@ class SC_wizard_edit {
                                $dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup');
                                $dbAnalysis->start($this->P['currentSelectedValues'],$allowedTables);
                                $value = $dbAnalysis->getValueArray($prependName);
-                               
+
                                        // Traverse that array and make parameters for alt_doc.php:
                                foreach($value as $rec) {
                                        $recTableUidParts = t3lib_div::revExplode('_',$rec,2);
                                        $params.='&edit['.$recTableUidParts[0].']['.$recTableUidParts[1].']=edit';
                                }
-                                       
+
                                        // Redirect to alt_doc.php:
-                               header('Location: '.t3lib_div::locationHeaderUrl('alt_doc.php?returnUrl='.rawurlencode('wizard_edit.php?doClose=1').$params));
+                               t3lib_utility_Http::redirect('alt_doc.php?returnUrl=' . rawurlencode('wizard_edit.php?doClose=1') . $params);
                        } else {
                                $this->closeWindow();
                        }
@@ -143,8 +133,8 @@ class SC_wizard_edit {
 
        /**
         * Printing a little JavaScript to close the open window.
-        * 
-        * @return      void            
+        *
+        * @return      void
         */
        function closeWindow()  {
                echo '<script language="javascript" type="text/javascript">close();</script>';
@@ -152,24 +142,16 @@ class SC_wizard_edit {
        }
 }
 
-// Include extension?
+
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/wizard_edit.php'])  {
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/wizard_edit.php']);
 }
 
 
 
-
-
-
-
-
-
-
-
-
 // Make instance:
 $SOBE = t3lib_div::makeInstance('SC_wizard_edit');
 $SOBE->init();
 $SOBE->main();
+
 ?>
\ No newline at end of file