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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
|
<?
# Lifter002: TODO
# Lifter007: TODO
# Lifter003: TODO
# Lifter010: TODO
/**
* Export-subfile. Choses which XSL-Script to use.
*
* In this file there are several forms which help choosing the proper XSL-Script
* to transform the export-data into a specific file-format.
*
* @author Arne Schroeder <schroeder@data.quest.de>
* @access public
* @modulegroup export_modules
* @module export_choose_xslt
* @package Export
*/
// +---------------------------------------------------------------------------+
// This file is part of Stud.IP
// export_choose_xslt.inc.php
// pages for choosing an xslt-script
//
// Copyright (c) 2002 Arne Schroeder <schroeder@data-quest.de>
// Suchi & Berg GmbH <info@data-quest.de>
// +---------------------------------------------------------------------------+
// 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; either version 2
// of the License, or any later version.
// +---------------------------------------------------------------------------+
// 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.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// +---------------------------------------------------------------------------+
use Studip\Button, Studip\LinkButton;
$perm->check('tutor');
require_once 'lib/export/export_xslt_vars.inc.php'; // Liste der XSLT-Skripts
require_once 'lib/dates.inc.php'; // Datumsfunktionen
/**
* Checks given parameters
*
* This function checks the given parameters. If some are missing or refer to a XSL-file that
* doesn't exist it returns false and adds a warning to export_error.
*
* @access public
* @return boolean
*/
function CheckParamXSLT()
{
global $ex_type, $xml_file_id, $page, $o_mode, $format, $choose, $xslt_files, $export_o_modes, $export_ex_types, $export_error, $export_error_num;
$mod_counter = 0;
$page = (int)$page;
if ($page === 1) {
reset($xslt_files);
foreach ($xslt_files as $val) {
if (!empty($val[$ex_type]) && !empty($val[$format])) {
$mod_counter++;
}
}
if ($mod_counter === 0 && $format !== "xml") {
$export_error .= _("Für dieses Format sind keine Ausgabemodule installiert.<br>Bitte wählen Sie ein anderes Ausgabeformat.") . "<br>";
$page = 0;
}
if (!$format) {
$page = 0;
}
reset($xslt_files);
}
if ($page === 2 && !$choose) {
$page = 1;
}
if ( /*($xml_file_id != "") AND */ (in_array($ex_type, $export_ex_types)) && (in_array($o_mode, $export_o_modes))) {
return true;
}
$export_error .= "<b>" . _("Unzulässiger Seitenaufruf!") . "</b><br>";
$export_error_num++;
return false;
}
$export_pagename = _("Konvertierung der Daten: ");
$export_pagecontent = '';
$xslt_filename = mb_strlen(Request::get('xslt_filename')) ? basename(stripslashes(Request::get('xslt_filename'))) : $xslt_filename_default;
if (!CheckParamXSLT()) {
$export_pagename .= _('Es ist ein Fehler aufgetreten.');
$export_pagecontent .= MessageBox::error(
_('Die Parameter, mit denen diese Seite aufgerufen wurde, sind fehlerhaft oder unvollständig.')
);
}
// Die Seiten 2 und 3 ueberspringen, wenn als Dateiformat XML gewaehlt wurde
if ($format === "xml" && $page === 1) {
$xml_file_id = "";
$o_mode = "file";
$page = 3;
// Seite 1 : Auswahl des Dateiformats
} elseif (!isset($page) || $page === 0) {
$export_pagename .= _("Auswahl des Dateiformats");
unset($export_msg);
unset($xml_printimage);
unset($xml_printlink);
unset($xml_printdesc);
unset($xml_printcontent);
$export_info = null;
$export_pagecontent .= "<form class=\"default\" method=\"POST\" action=\"" . URLHelper::getLink() . "\">";
$export_pagecontent .= "<fieldset><legend>" . _("Bitte wählen Sie, in welchem Format die Daten ausgegeben werden sollen!") . "</legend>";
$export_pagecontent .= CSRFProtection::tokenTag();
$export_pagecontent .= "<label>" . _("Ausgabeformat:") . "<select name=\"format\">";
foreach ($output_formats as $key => $val) {
$export_pagecontent .= "<option value=\"" . $key . "\"";
if ($format == $key) {
$export_pagecontent .= " selected";
}
$export_pagecontent .= ">" . $val;
}
$export_pagecontent .= "</select></label>";
$export_pagecontent .= "<label>" . _("Name der Datei (z.B. »Test«):");
$export_pagecontent .= "<input type=\"text\" name=\"xslt_filename\" value=\"" . htmlReady($xslt_filename) . "\">";
$export_pagecontent .= "</label>";
$export_pagecontent .= "<input type=\"hidden\" name=\"page\" value=\"1\">";
$export_pagecontent .= "<input type=\"hidden\" name=\"o_mode\" value=\"" . htmlReady($o_mode) . "\">";
$export_pagecontent .= "<input type=\"hidden\" name=\"range_id\" value=\"" . htmlReady($range_id) . "\">";
$export_pagecontent .= "<input type=\"hidden\" name=\"ex_sem\" value=\"" . htmlReady($ex_sem) . "\">";
foreach (array_keys($ex_sem_class) as $semclassid) {
$export_pagecontent .= "<input type=\"hidden\" name=\"ex_sem_class[" . htmlReady($semclassid) . "]\" value=\"1\">";
}
$export_pagecontent .= "<input type=\"hidden\" name=\"ex_type\" value=\"" . htmlReady($ex_type) . "\">";
$export_pagecontent .= "<input type=\"hidden\" name=\"choose\" value=\"" . htmlReady($choose) . "\">";
$export_pagecontent .= "<input type=\"hidden\" name=\"xml_file_id\" value=\"" . htmlReady($xml_file_id) . "\">";
$export_pagecontent .= "</fieldset>";
$export_weiter_button = '<footer>' . Button::create('<< ' . _('Zurück'), 'back');
$export_weiter_button .= Button::create(_('Weiter') . ' >>', 'next') . "</div>";
$export_weiter_button .= "</footer></form>";
// Seite 2 : Auswahl des XSLT-Scripts
} elseif ($page === 1) {
if (mb_strpos($choose, $format) === false) {
unset($choose);
}
$export_pagename .= _("Auswahl des Ausgabemoduls");
$export_info = null;
$export_pagecontent .= '<form class="default" method="POST" action="' . URLHelper::getLink() . '">';
$export_pagecontent .= '<fieldset><legend>' . _('Ausgabemodul') . '</legend>';
$export_pagecontent .= CSRFProtection::tokenTag();
$export_pagecontent .= "";
$opt_num = 0;
foreach ($xslt_files as $key => $val) {
if (!empty($val[$ex_type]) && !empty($val[$format])) {
$export_pagecontent .= "<label><input type=\"radio\" name=\"choose\" value=\"" . $key . "\"";
if (empty($choose) && $opt_num == 0 || (!empty($choose) && $key == $choose)) {
$export_pagecontent .= " checked";
}
$export_pagecontent .= ">" . $val["name"];
$export_pagecontent .= tooltipIcon($val["desc"]);
$export_pagecontent .= "</label>";
$opt_num++;
}
}
$export_pagecontent .= '</fieldset>';
$export_pagecontent .= '<input type="hidden" name="page" value="2">';
$export_pagecontent .= '<input type="hidden" name="format" value="' . htmlReady($format) . '">';
$export_pagecontent .= '<input type="hidden" name="o_mode" value="' . htmlReady($o_mode) . '">';
$export_pagecontent .= '<input type="hidden" name="ex_type" value="' . htmlReady($ex_type) . '">';
$export_pagecontent .= '<input type="hidden" name="ex_sem" value="' . htmlReady($ex_sem) . '">';
foreach (array_keys($ex_sem_class) as $semclassid) {
$export_pagecontent .= '<input type="hidden" name="ex_sem_class[' . htmlReady($semclassid) . ']" value="1">';
}
$export_pagecontent .= '<input type="hidden" name="range_id" value="' . htmlReady($range_id) . '">';
$export_pagecontent .= '<input type="hidden" name="xml_file_id" value="' . htmlReady($xml_file_id) . '">';
$export_pagecontent .= '<input type="hidden" name="xslt_filename" value="' . htmlReady($xslt_filename) . '">';
$export_weiter_button = '<footer>' . Button::create('<< ' . _('Zurück'), 'back');
$export_weiter_button .= Button::create(_('Weiter') . ' >>', 'next');
$export_weiter_button .= '</footer></form>';
// Seite 3 : Download der Dateien
} elseif ($page === 2) {
$export_pagename .= _("Download der Dateien");
$export_info = _("Die benötigten Dateien liegen nun zum Download bereit.");
$export_pagecontent .= "<form class=\"default\" method=\"post\" action=\"" . URLHelper::getLink() . "\">";
$export_pagecontent .= CSRFProtection::tokenTag();
$xml_printimage = '<a href="' . FileManager::getDownloadLinkForTemporaryFile($xml_file_id, $xml_filename) . '">';
$xml_printimage .= Icon::create($export_icon['xml'])->asImg(['class' => 'text-top']);
$xml_printimage .= '</a>';
$xml_printlink = '<a href="' . FileManager::getDownloadLinkForTemporaryFile($xml_file_id, $xml_filename) . '">' . htmlReady($xml_filename) . '</a>';
$xml_printdesc = _("XML-Daten");
$xml_printcontent = _("In dieser Datei sind die Daten als XML-Tags gespeichert. Diese Tags können mit einem XSLT-Script verarbeitet werden.") . "<br>";
$xslt_printimage = '<a href="' . FileManager::getDownloadLinkForTemporaryFile($xslt_files[$choose]['file'], $xslt_files[$choose]['name'] . '.xsl') . '">';
$xslt_printimage .= Icon::create($export_icon['xslt'])->asImg(['class' => 'text-top']);
$xslt_printimage .= '</a>';
$xslt_printlink = '<a href="' . FileManager::getDownloadLinkForTemporaryFile($xslt_files[$choose]['file'], $xslt_files[$choose]['name'] . '.xsl') . '">' . $xslt_files[$choose]['name'] . '.xsl</a>';
$xslt_printdesc = _("XSLT-Datei");
$xslt_printcontent = _("Dies ist das XSLT-Script zur Konvertierung der Daten. Klicken Sie auf den Dateinamen, um die Datei zu öffnen.") . "<br>";
$export_pagecontent .= "";
$export_pagecontent .= "<input type=\"hidden\" name=\"page\" value=\"3\">";
$export_pagecontent .= "<input type=\"hidden\" name=\"choose\" value=\"" . htmlReady($choose) . "\">";
$export_pagecontent .= "<input type=\"hidden\" name=\"format\" value=\"" . htmlReady($format) . "\">";
$export_pagecontent .= "<input type=\"hidden\" name=\"o_mode\" value=\"" . htmlReady($o_mode) . "\">";
$export_pagecontent .= "<input type=\"hidden\" name=\"ex_type\" value=\"" . htmlReady($ex_type) . "\">";
$export_pagecontent .= "<input type=\"hidden\" name=\"ex_sem\" value=\"" . htmlReady($ex_sem) . "\">";
foreach (array_keys($ex_sem_class) as $semclassid) {
$export_pagecontent .= "<input type=\"hidden\" name=\"ex_sem_class[" . htmlReady($semclassid) . "]\" value=\"1\">";
}
$export_pagecontent .= "<input type=\"hidden\" name=\"range_id\" value=\"" . htmlReady($range_id) . "\">";
$export_pagecontent .= "<input type=\"hidden\" name=\"xml_file_id\" value=\"" . htmlReady($xml_file_id) . "\">";
$export_pagecontent .= "<input type=\"hidden\" name=\"xslt_filename\" value=\"" . htmlReady($xslt_filename) . "\">";
$export_weiter_button = "<footer>" . Button::create('<< ' . _('Zurück'), 'back');
if (Config::get()->XSLT_ENABLE) {
$export_pagecontent .= _("Um die Daten mit dem installierten XSLT-Prozessor in das gewünschte Format zu bringen, klicken Sie bitte auf 'weiter'") . "<br><br>";
$export_weiter_button .= LinkButton::create(_('Weiter') . ' >>', '#', ['name' => 'next']);
} else {
$export_pagecontent .= "<br><br><br>";
}
$export_weiter_button .= "</footer></form>";
$export_pagecontent .= MessageBox::info(sprintf(
_('Diese Seite bereitet die Datenausgabe vor. %s Schritt 3/3 %s'),
'<br><i>', '</i>'
));
}
|