Initial revision
[Packages/TYPO3.CMS.git] / typo3 / wizard_edit.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2003 Kasper Skårhøj (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 to a table
29 *
30 * @author Kasper Skårhøj <kasper@typo3.com>
31 * @package TYPO3
32 * @subpackage core
33 *
34 */
35
36
37
38 $BACK_PATH="";
39 require ("init.php");
40 require ("template.php");
41 include ("sysext/lang/locallang_wizards.php");
42 require_once (PATH_t3lib."class.t3lib_loaddbgroup.php");
43
44
45
46
47 // ***************************
48 // Script Classes
49 // ***************************
50 class SC_wizard_edit {
51 var $P;
52
53 function init() {
54 $this->P = t3lib_div::GPvar("P",1);
55 }
56 function main() {
57 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
58
59 if (t3lib_div::GPvar("doClose")) {
60 echo '<script language="javascript" type="text/javascript">close();</script>';
61 } else {
62 $table = $this->P["table"];
63 $field = $this->P["field"];
64 t3lib_div::loadTCA($table);
65 $config = $TCA[$table]["columns"][$field]["config"];
66 $fTable = $this->P["currentValue"]<0 ? $config["neg_foreign_table"] : $config["foreign_table"];
67
68 if (is_array($config) && $config["type"]=="select" && !$config["MM"] && t3lib_div::testInt($this->P["currentValue"]) && $this->P["currentValue"] && $fTable) {
69 header("Location: ".t3lib_div::locationHeaderUrl("alt_doc.php?returnUrl=".rawurlencode("wizard_edit.php?doClose=1")."&edit[".$fTable."][".$this->P["currentValue"]."]=edit"));
70 } elseif (is_array($config) && $this->P["currentSelectedValues"] && (($config["type"]=="select" && $config["foreign_table"]) || ($config["type"]=="group" && $config["internal_type"]=="db"))) {
71 $allowedTables = $config["type"]=="group" ? $config["allowed"] : $config["foreign_table"].",".$config["neg_foreign_table"];
72 //$prependName = $config["type"]=="group" ? $config["prepend_tname"] : $config["neg_foreign_table"];
73 $prependName=1;
74 $dbAnalysis = t3lib_div::makeInstance("t3lib_loadDBGroup");
75 $dbAnalysis->start($this->P["currentSelectedValues"],$allowedTables);
76 $value = $dbAnalysis->getValueArray($prependName);
77 reset($value);
78 $params="";
79 while(list(,$rec)=each($value)) {
80 $recTableUidParts = t3lib_div::revExplode("_",$rec,2);
81 $params.="&edit[".$recTableUidParts[0]."][".$recTableUidParts[1]."]=edit";
82 }
83 header("Location: ".t3lib_div::locationHeaderUrl("alt_doc.php?returnUrl=".rawurlencode("wizard_edit.php?doClose=1").$params));
84 } else {
85 echo '<script language="javascript" type="text/javascript">close();</script>';
86 }
87 }
88 }
89 }
90
91 // Include extension?
92 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["typo3/wizard_edit.php"]) {
93 include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["typo3/wizard_edit.php"]);
94 }
95
96
97
98
99
100
101
102
103
104
105
106
107 // Make instance:
108 $SOBE = t3lib_div::makeInstance("SC_wizard_edit");
109 $SOBE->init();
110 $SOBE->main();
111 ?>