TYPO3 API  SVNRelease
wizard_edit.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2011 Kasper Skårhøj (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 ***************************************************************/
00027 /**
00028  * Wizard to edit records from group/select lists in TCEforms
00029  *
00030  * $Id: wizard_edit.php 10121 2011-01-18 20:15:30Z ohader $
00031  * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj
00032  *
00033  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00034  */
00035 /**
00036  * [CLASS/FUNCTION INDEX of SCRIPT]
00037  *
00038  *
00039  *
00040  *   76: class SC_wizard_edit
00041  *   90:     function init()
00042  *  101:     function main()
00043  *  149:     function closeWindow()
00044  *
00045  * TOTAL FUNCTIONS: 3
00046  * (This index is automatically created/updated by the extension "extdeveval")
00047  *
00048  */
00049 
00050 
00051 
00052 $BACK_PATH='';
00053 require ('init.php');
00054 require ('template.php');
00055 $LANG->includeLLFile('EXT:lang/locallang_wizards.xml');
00056 
00057 
00058 /**
00059  * Script Class for redirecting a backend user to the editing form when an "Edit wizard" link was clicked in TCEforms somewhere
00060  *
00061  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00062  * @package TYPO3
00063  * @subpackage core
00064  */
00065 class SC_wizard_edit {
00066 
00067         // Internal, static: GPvars
00068     var $P;                     // Wizard parameters, coming from TCEforms linking to the wizard.
00069     var $doClose;               // Boolean; if set, the window will be closed by JavaScript
00070 
00071 
00072 
00073 
00074     /**
00075      * Initialization of the script
00076      *
00077      * @return  void
00078      */
00079     function init() {
00080         $this->P = t3lib_div::_GP('P');
00081         $this->doClose = t3lib_div::_GP('doClose');     // Used for the return URL to alt_doc.php so that we can close the window.
00082     }
00083 
00084     /**
00085      * Main function
00086      * Makes a header-location redirect to an edit form IF POSSIBLE from the passed data - otherwise the window will just close.
00087      *
00088      * @return  void
00089      */
00090     function main() {
00091         global $TCA;
00092 
00093         if ($this->doClose) {
00094             $this->closeWindow();
00095         } else {
00096 
00097                 // Initialize:
00098             $table = $this->P['table'];
00099             $field = $this->P['field'];
00100             t3lib_div::loadTCA($table);
00101             $config = $TCA[$table]['columns'][$field]['config'];
00102             $fTable = $this->P['currentValue']<0 ? $config['neg_foreign_table'] : $config['foreign_table'];
00103 
00104                 // Detecting the various allowed field type setups and acting accordingly.
00105             if (is_array($config) && $config['type']=='select' && !$config['MM'] && $config['maxitems']<=1 && t3lib_div::testInt($this->P['currentValue']) && $this->P['currentValue'] && $fTable)  {   // SINGLE value:
00106                 $redirectUrl = 'alt_doc.php?returnUrl=' . rawurlencode('wizard_edit.php?doClose=1') . '&edit[' . $fTable . '][' . $this->P['currentValue'] . ']=edit';
00107                 t3lib_utility_Http::redirect($redirectUrl);
00108             } elseif (is_array($config) && $this->P['currentSelectedValues'] && (($config['type']=='select' && $config['foreign_table']) || ($config['type']=='group' && $config['internal_type']=='db')))  {   // MULTIPLE VALUES:
00109 
00110                     // Init settings:
00111                 $allowedTables = $config['type']=='group' ? $config['allowed'] : $config['foreign_table'].','.$config['neg_foreign_table'];
00112                 $prependName=1;
00113                 $params='';
00114 
00115                     // Selecting selected values into an array:
00116                 $dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup');
00117                 $dbAnalysis->start($this->P['currentSelectedValues'],$allowedTables);
00118                 $value = $dbAnalysis->getValueArray($prependName);
00119 
00120                     // Traverse that array and make parameters for alt_doc.php:
00121                 foreach($value as $rec) {
00122                     $recTableUidParts = t3lib_div::revExplode('_',$rec,2);
00123                     $params.='&edit['.$recTableUidParts[0].']['.$recTableUidParts[1].']=edit';
00124                 }
00125 
00126                     // Redirect to alt_doc.php:
00127                 t3lib_utility_Http::redirect('alt_doc.php?returnUrl=' . rawurlencode('wizard_edit.php?doClose=1') . $params);
00128             } else {
00129                 $this->closeWindow();
00130             }
00131         }
00132     }
00133 
00134     /**
00135      * Printing a little JavaScript to close the open window.
00136      *
00137      * @return  void
00138      */
00139     function closeWindow()  {
00140         echo '<script language="javascript" type="text/javascript">close();</script>';
00141         exit;
00142     }
00143 }
00144 
00145 
00146 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/wizard_edit.php'])) {
00147     include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/wizard_edit.php']);
00148 }
00149 
00150 
00151 
00152 // Make instance:
00153 $SOBE = t3lib_div::makeInstance('SC_wizard_edit');
00154 $SOBE->init();
00155 $SOBE->main();
00156 
00157 ?>