-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditimport.php
More file actions
210 lines (196 loc) · 6.9 KB
/
Copy patheditimport.php
File metadata and controls
210 lines (196 loc) · 6.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<?php
/************************************************************************/
/* Oscailt */
/* Indepenent Media Centre Content Management System */
/* ==================================================================== */
/* Copyright (c)2003-2005 by Independent Media Centre Ireland */
/* http://www.indymedia.ie */
/* Development List: oscailt@lists.indymedia.org */
/* See contributions.txt for the list of contributors */
/* */
/* This program 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. http://www.gnu.org/copyleft/gpl.html */
/* */
/* This program 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 */
/* GNU General Public License for more details. */
/************************************************************************/
require_once("oscailt_init.inc");
addToPageTitle("Oscailt Import / Export Page");
$OSCAILT_SCRIPT = "editimport.php";
require_once("objects/indyobjects/indydataobjects.inc");
require_once("objects/indyobjects/indysiteimporter.inc");
require_once("objects/indyobjects/indysiteexporter.inc");
require_once("objects/adminutilities.inc");
function writeImportIntroPage()
{
global $system_config, $editor_session, $txt_strs, $obj_set, $importer;
$cols = 4;
$new_txt = $txt_strs->getString("create_export_text");
if($editor_session->editor->allowedWriteAccessTo("importdataobjects"))
{
$title = $txt_strs->getString("import_title");
$intro = $txt_strs->getString("import_intro");
echo "<h3>$title</h3><P>$intro</P>";
$importer->writeChooseCollectionSection($cols, $txt_strs, "import");
}
elseif($editor_session->editor->allowedReadAccessTo("importdataobjects"))
{
$title = $txt_strs->getString("view_imports_title");
$intro = $txt_strs->getString("view_imports_intro");
echo "<h3>$title</h3><P>$intro</P>";
$importer->writeChooseCollectionSection($cols-1, $txt_strs, "import");
}
}
function writeChooseImportPage()
{
if(!isset($_REQUEST['target_collection']))
{
writeError("No target collection specified");
}
else
{
global $importer, $txt_strs;
$cols = 2;
writeMenuSpacer();
writeMenuHeader();
echo "<form name='importform' action='?' method='POST'>\n";
$importer->writeChoiceForm($cols, $txt_strs, $_REQUEST['target_collection'], true);
echo "</form>";
}
}
function writeImportPage()
{
if(!isset($_REQUEST['target_collection']))
{
writeError("No target collection specified");
}
else
{
global $importer, $txt_strs;
$cols = 3;
echo "<form name='importform' action='?' method='GET'>\n";
$importer->writeChoiceForm($cols, $txt_strs, $_REQUEST['target_collection']);
echo "</form>";
}
}
function writeConfirmImportPage()
{
global $importer;
echo "<form name='exportform' action='' method=post>\n";
echo "<input type='hidden' name='action' value='".htmlspecialchars($_REQUEST['action'], ENT_QUOTES)."'>";
echo "<input type='hidden' name='save' value='true'>";
$importer->writeHiddenChoices();
$warning = "Check to make sure you want to import the data below";
$buttons = "<p>".$importer->getChoicesInfo();
$act = "Import Data";
$title = "Confirm $act";
$buttons .= "<input type='submit' name='confirm' value='Confirm Import >>'>";
$id = "";
$reqd = true;
echo $importer->getNotifyForm($title, $warning, $act, "", $id, $reqd, $buttons);
echo "</form>";
}
ob_start();
$e = false;
$txt_strs = new indyItemSet();
if($txt_strs->load($system_config->xml_store, "universal_config_options") === false)
{
writeError("Failed to load the list of XML Options from $system_config->xml_store");
$e = true;
}
$obj_set = new indyObjectSet($system_config->xmltypedef_dir, $system_config->object_index_storage);
$dummy = new indyObjectActionRequest();
if(!$obj_set->load(array("*"), array("*"), $dummy))
{
writeError("Failed to load the object set with data types from $system_config->xmltypedef_dir");
$e = true;
}
$importer = new indySiteImporter($obj_set, $dummy);
if(!$e && $editor_session->isSessionOpen())
{
writeAdminHeader();
if($editor_session->editor->allowedReadAccessTo("importdataobjects"))
{
if(isset($_REQUEST['action']))
{
$action = $_REQUEST['action'];
}
else
{
$action = '';
}
if($action != 'import' && $action != 'import-choose')
{
writeImportIntroPage();
}
elseif(!isset($_REQUEST['save']))
{
if($action == 'import-choose')
{
writeChooseImportPage();
}
else
{
writeImportPage();
}
}
elseif($editor_session->editor->allowedWriteAccessTo("importdataobjects"))
{
if($action == 'import')
{
$importer->readBasicChoices();
}
else
{
$importer->readFullChoices();
}
if($importer->checkUserInput())
{
if(isset($_REQUEST['confirm']))
{
if($importer->import($action, true))
{
echo "<div class='user-message'>";
echo "<ul>";
echo "<li>";
echo implode("</li><li>", $importer->import_record);
echo "</ul></div>";
if(isset($_REQUEST['target_collection']))
logAction("", $_REQUEST['target_collection'], "objects", "import ok");
}
else
{
writeError("Errors occurred during import: ".$importer->getUserMessage());
if(isset($_REQUEST['target_collection']))
logAction("", $_REQUEST['target_collection'], "objects", "import failure");
}
writeImportIntroPage();
}
else
{
writeConfirmImportPage();
}
}
else
{
writeError($importer->getUserMessage());
if($action == 'import')
{
writeImportPage();
}
else
{
writeChooseImportPage();
}
}
}
else $editor_session->writeNoWritePermissionError();
}
else $editor_session->writeNoReadPermissionError();
}
else $editor_session->writeNoSessionError();
include_once("adminfooter.inc");
?>