aboutsummaryrefslogtreecommitdiff
path: root/lib/export/export_linking_func.inc.php
blob: 52ea828fd0540547d3cf4c85d72530fb6f767cd1 (plain)
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
<?
# Lifter002: TODO
# Lifter007: TODO
# Lifter003: TODO
# Lifter010: TODO
/**
* Export-functions to create links to the export-module.
*
* In this file there are three functions which help to include the export-module into Stud.IP-pages.
*
* @author       Arne Schroeder <schroeder@data.quest.de>
* @access       public
* @modulegroup      export_modules
* @module       export_linking_functions
* @package      Export
*/
require_once 'lib/export/export_config.inc.php';

use Studip\Button, Studip\LinkButton;

/**
* Generates a form that can be put into Stud.IP-pages to link to the export-module.
*
* This function returns a string with a HTML-form that links to the export-module.
* It passes the given parameters in order to allow to jump to a specific part of the export-module.
*
* @access   public
* @param        string  $range_id   export-range
* @param        string  $ex_type    type of data to be exported
* @param        string  $filename   filename for data-file
* @param        string  $format file-format for export
* @param        string  $filter grouping-category for export
* @return       string
*/
function export_form($range_id, $ex_type = "", $filename = "", $format = "", $filter = "")
{
    global $output_formats, $xslt_filename;
    $filename = $xslt_filename;
    require_once ("lib/export/export_xslt_vars.inc.php");
    $export_string = "<form action=\"" . "export.php\" method=\"post\">";
    $export_string .= CSRFProtection::tokenTag();
    $export_string .= "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><tr><td class=\"table_row_even\"> &nbsp; &nbsp; &nbsp; ";

    $export_string .= "<b> "._("Diese Daten exportieren: ") .  "</b>";
    $export_string .= "</td><td align=\"center\" class=\"table_row_even\">";
    $export_string .= "<select name=\"format\">";
    foreach ($output_formats as $key => $val)
    {
        $export_string .= "<option value=\"" . $key . "\"";
        if ($format==$key) {
            $export_string .= " selected";
        }
        $export_string .= ">" . $val;
    }
    $export_string .= "</select>";

    $export_string .= "</td><td align=\"right\" class=\"table_row_even\">";
    $export_string .= Button::create(_('Export'), 'export', ['title' => _('Diese Daten exportieren')]);

    $export_string .= "<input type=\"hidden\" name=\"range_id\" value=\"$range_id\">";
    $export_string .= "<input type=\"hidden\" name=\"o_mode\" value=\"choose\">";
    $export_string .= "<input type=\"hidden\" name=\"page\" value=\"1\">";
    $export_string .= "<input type=\"hidden\" name=\"ex_type\" value=\"$ex_type\">";
    $export_string .= "<input type=\"hidden\" name=\"filter\" value=\"$filter\">";
    $export_string .= "<input type=\"hidden\" name=\"xslt_filename\" value=\"$filename\">";
    $export_string .= "</td></tr></table>";
    $export_string .= "</form>";
    return $export_string;
}

/**
* Generates a form that can be put into the sidebar to link to the export-module.
*
* This function returns a string with a HTML-form that links to the export-module.
* It passes the given parameters in order to allow to jump to a specific part of the export-module.
*
* @access   public
* @param        string  $range_id   export-range
* @param        string  $ex_type    type of data to be exported
* @param        string  $filename   filename for data-file
* @param        string  $format file-format for export
* @param        string  $filter grouping-category for export
* @return       string
*/
function export_form_sidebar($range_id, $ex_type = "", $filename = "", $format = "", $filter = "")
{
    global $output_formats, $xslt_filename;
    $filename = $xslt_filename;
    require_once ("lib/export/export_xslt_vars.inc.php");
    $export_string .= "<form class=\"default\" action=\"" . URLHelper::getLink('export.php') . "\" method=\"post\">";
    $export_string .= CSRFProtection::tokenTag();
    $export_string .= "<select name=\"format\">";
    foreach ($output_formats as $key => $val)
    {
        $export_string .= "<option value=\"" . htmlReady($key) . "\"";
        if ($format==$key) {
            $export_string .= " selected";
        }
        $export_string .= ">" . htmlReady(my_substr($val, 0, 20)) . "</option>";
    }
    $export_string .= "</select>";

    $export_string .= Button::create(_('Export'), 'export', ['title' => _('Daten Exportieren')]);
    $export_string .= "<input type=\"hidden\" name=\"range_id\" value=\"" . htmlReady($range_id) . "\">";
    $export_string .= "<input type=\"hidden\" name=\"o_mode\" value=\"choose\">";
    $export_string .= "<input type=\"hidden\" name=\"page\" value=\"1\">";
    $export_string .= "<input type=\"hidden\" name=\"ex_type\" value=\"" . htmlReady($ex_type) . "\">";
    $export_string .= "<input type=\"hidden\" name=\"filter\" value=\"" . htmlReady($filter) . "\">";
    $export_string .= "<input type=\"hidden\" name=\"xslt_filename\" value=\"" . htmlReady($filename) . "\">";
    $export_string .= "</form>";
    return $export_string;
}

/**
* Generates a link to the export-module that can be put into Stud.IP-pages.
*
* This function returns a string with a  link to the export-module.
* It passes the given parameters in order to allow to jump to a specific part of the export-module.
*
* @access   public
* @param        string  $range_id   export-range
* @param        string  $ex_type    type of data to be exported
* @param        string  $filename   filename for data-file
* @param        string  $format file-format for export
* @param        string  $choose xslt-Script for transformation
* @param        string  $filter grouping-category for export
* @return       string
*/
function export_link($range_id, $ex_type = "", $filename = "", $format = "", $choose = "", $filter = "", $content = "", $o_mode = 'processor')
{
    global $i_page;

    $export_string = '<a href="';
    if ($choose != "") {
        $export_string .= URLHelper::getLink(
            'export.php',
            [
                'range_id' => $range_id,
                'ex_type' => $ex_type,
                'xslt_filename' => $filename,
                'format' => $format,
                'choose' => $choose,
                'o_mode' => $o_mode,
                'filter' => $filter,
                'jump' => $i_page
            ]
        );
    }
    elseif ($ex_type != "") {
        $export_string .= URLHelper::getLink(
            'export.php',
            [
                'range_id' => $range_id,
                'ex_type' => $ex_type,
                'xslt_filename' =>  $filename,
                'o_mode' => 'choose',
                'filter' => $filter
            ]
        );
    }
    else {
        $export_string .= URLHelper::getLink(
            'export.php',
            [
                'range_id' => $range_id,
                'o_mode' => 'start'
            ]
        );
    }

    $export_string .= '">' . ($content ? $content : _("Diese Daten exportieren"));
    $export_string .= '</a>';
    return $export_string;
}

/**
* Generates a Button with a link to the export-module that can be put into Stud.IP-pages.
*
* This function returns a string containing an export-button with a link to the export-module.
* It passes the given parameters in order to allow to jump to a specific part of the export-module.
*
* @access   public
* @param        string  $range_id   export-range
* @param        string  $ex_type    type of data to be exported
* @param        string  $filename   filename for data-file
* @param        string  $format file-format for export
* @param        string  $choose xslt-Script for transformation
* @param        string  $filter grouping-category for export
* @return       string
*/
function export_button($range_id, $ex_type = "", $filename = "", $format = "", $choose = "", $filter = "")
{
    global $i_page;
    if ($choose != "") {
        $parameters = [
            'range_id' => $range_id,
            'ex_type' => $ex_type,
            'xslt_filename' => $filename,
            'format' => $format,
            'choose' => $choose,
            'o_mode' => 'processor',
            'filter' => $filter,
            'jump' => $i_page
        ];
    }
    elseif ($ex_type != "") {
        $parameters = [
            'range_id' => $range_id,
            'ex_type' => $ex_type,
            'xslt_filename' => $filename,
            'o_mode' => 'choose',
            'filter' => $filter,
        ];
    }
    else {
        $parameters = [
            'range_id' => $range_id,
            'o_mode' => 'start',
        ];
    }
    return Studip\LinkButton::create(_('Export'), URLHelper::getURL('export.php', $parameters));
}