Only changes to function indexes, comments and stripping of trailing whitespace in...
[Packages/TYPO3.CMS.git] / typo3 / wizard_edit.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2004 Kasper Skaarhoj (kasper@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Wizard to edit records from group/select lists in TCEforms
29 *
30 * $Id$
31 * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
32 *
33 * @author Kasper Skaarhoj <kasper@typo3.com>
34 */
35 /**
36 * [CLASS/FUNCTION INDEX of SCRIPT]
37 *
38 *
39 *
40 * 76: class SC_wizard_edit
41 * 90: function init()
42 * 101: function main()
43 * 149: function closeWindow()
44 *
45 * TOTAL FUNCTIONS: 3
46 * (This index is automatically created/updated by the extension "extdeveval")
47 *
48 */
49
50
51
52 $BACK_PATH='';
53 require ('init.php');
54 require ('template.php');
55 include ('sysext/lang/locallang_wizards.php');
56 require_once (PATH_t3lib.'class.t3lib_loaddbgroup.php');
57
58
59
60
61
62
63
64
65
66
67
68
69 /**
70 * Script Class for redirecting a backend user to the editing form when an "Edit wizard" link was clicked in TCEforms somewhere
71 *
72 * @author Kasper Skaarhoj <kasper@typo3.com>
73 * @package TYPO3
74 * @subpackage core
75 */
76 class SC_wizard_edit {
77
78 // Internal, static: GPvars
79 var $P; // Wizard parameters, coming from TCEforms linking to the wizard.
80 var $doClose; // Boolean; if set, the window will be closed by JavaScript
81
82
83
84
85 /**
86 * Initialization of the script
87 *
88 * @return void
89 */
90 function init() {
91 $this->P = t3lib_div::_GP('P');
92 $this->doClose = t3lib_div::_GP('doClose'); // Used for the return URL to alt_doc.php so that we can close the window.
93 }
94
95 /**
96 * Main function
97 * Makes a header-location redirect to an edit form IF POSSIBLE from the passed data - otherwise the window will just close.
98 *
99 * @return void
100 */
101 function main() {
102 global $TCA;
103
104 if ($this->doClose) {
105 $this->closeWindow();
106 } else {
107
108 // Initialize:
109 $table = $this->P['table'];
110 $field = $this->P['field'];
111 t3lib_div::loadTCA($table);
112 $config = $TCA[$table]['columns'][$field]['config'];
113 $fTable = $this->P['currentValue']<0 ? $config['neg_foreign_table'] : $config['foreign_table'];
114
115 // Detecting the various allowed field type setups and acting accordingly.
116 if (is_array($config) && $config['type']=='select' && !$config['MM'] && t3lib_div::testInt($this->P['currentValue']) && $this->P['currentValue'] && $fTable) { // SINGLE value:
117 header('Location: '.t3lib_div::locationHeaderUrl('alt_doc.php?returnUrl='.rawurlencode('wizard_edit.php?doClose=1').'&edit['.$fTable.']['.$this->P['currentValue'].']=edit'));
118 } elseif (is_array($config) && $this->P['currentSelectedValues'] && (($config['type']=='select' && $config['foreign_table']) || ($config['type']=='group' && $config['internal_type']=='db'))) { // MULTIPLE VALUES:
119
120 // Init settings:
121 $allowedTables = $config['type']=='group' ? $config['allowed'] : $config['foreign_table'].','.$config['neg_foreign_table'];
122 $prependName=1;
123 $params='';
124
125 // Selecting selected values into an array:
126 $dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup');
127 $dbAnalysis->start($this->P['currentSelectedValues'],$allowedTables);
128 $value = $dbAnalysis->getValueArray($prependName);
129
130 // Traverse that array and make parameters for alt_doc.php:
131 foreach($value as $rec) {
132 $recTableUidParts = t3lib_div::revExplode('_',$rec,2);
133 $params.='&edit['.$recTableUidParts[0].']['.$recTableUidParts[1].']=edit';
134 }
135
136 // Redirect to alt_doc.php:
137 header('Location: '.t3lib_div::locationHeaderUrl('alt_doc.php?returnUrl='.rawurlencode('wizard_edit.php?doClose=1').$params));
138 } else {
139 $this->closeWindow();
140 }
141 }
142 }
143
144 /**
145 * Printing a little JavaScript to close the open window.
146 *
147 * @return void
148 */
149 function closeWindow() {
150 echo '<script language="javascript" type="text/javascript">close();</script>';
151 exit;
152 }
153 }
154
155 // Include extension?
156 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/wizard_edit.php']) {
157 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/wizard_edit.php']);
158 }
159
160
161
162
163
164
165
166
167
168
169
170
171 // Make instance:
172 $SOBE = t3lib_div::makeInstance('SC_wizard_edit');
173 $SOBE->init();
174 $SOBE->main();
175 ?>