forked from craigk5n/webcalendar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
export.php
138 lines (129 loc) · 3.85 KB
/
export.php
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
<?php
/**
* Page Description:
* This page will present the user with forms for exporting calendar events.
*
* Input Parameters:
* None
*/
require_once 'includes/init.php';
require_once 'includes/xcal.php';
if ( empty ( $login ) || $login == '__public__' ) {
// do not allow public access
do_redirect ( empty ( $STARTVIEW ) ? 'month.php' : "$STARTVIEW" );
exit;
}
load_user_categories();
$datem = date ( 'm' );
$dateY = date ( 'Y' );
$yearAgo = time () - 31536000; // 365 * 24 * 3600;
$dateYearAgo = date('Ymd', $yearAgo);
$selected = ' selected ';
print_header ( [], '', 'onload="updateDateFields();"' );
echo '<h2>' . translate ( 'Export' ) . '</h2>
<form action="export_handler.php" method="post" name="exportform" id="exportform">';
echo csrf_form_key();
echo '<table class="table">
<tr>
<td><label for="exformat">' . translate ( 'Export format' )
. ':</label></td>
<td>' . generate_export_select ( 'toggel_catfilter' ) . '
</td>
</tr>';
if ( is_array ( $categories ) ) {
echo '
<tr id="catfilter">
<td><label for="cat_filter">' . translate ( 'Categories' )
. ':</label></td>
<td>
<select name="cat_filter" id="cat_filter">
<option value=""' . $selected . '>' . translate ( 'All' )
. '</option>';
foreach ( $categories as $K => $V ) {
if ( $K > 0 )
echo '
<option value="' . $K . '">' . htmlentities ( $V['cat_name'] ) . '</option>';
}
echo '
</select>
</td>
</tr>';
}
// Only include layers if they are enabled.
$dateYmd = date ( 'Ymd' );
echo ( ! empty ( $LAYERS_STATUS ) && $LAYERS_STATUS == 'Y' ? '
<tr>
<td> </td>
<td>
<input type="checkbox" name="include_layers" id="include_layers" '
. 'value="y">
<label for="include_layers">' . translate ( 'Include all layers' )
. '</label>
</td>
</tr>'
: '' ) . '
<tr>
<td> </td>
<td>
<input type="checkbox" name="include_deleted" id="include_deleted" '
. 'value="y">
<label for="include_deleted">'
. translate ( 'Include deleted entries' ) . '</label>
</td>
</tr>
<tr>
<td> </td>
<td>
<input type="checkbox" name="use_all_dates" id="exportall" '
. 'value="y" checked onclick="toggle_datefields( \'dateArea\', this );">
<label for="exportall">' . translate ( 'Export all dates' )
. '</label>
</td>
</tr>
<tr>
<td colspan="2">
<table id="dateArea">
<tr>
<td><label>' . translate ( 'Start date' ) . ':</label></td>
<td>' . date_selection ( 'from', $dateYmd ) . '</td>
</tr>
<tr>
<td><label>' . translate ( 'End date' ) . ':</label></td>
<td>' . date_selection ( 'end', $dateYmd ) . '</td>
</tr>
<tr>
<td><label>' . translate ( 'Modified since' ) . ':</label></td>
<td>' . date_selection ( 'mod', $dateYearAgo ) . '</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2"><button class="btn btn-primary" type="submit">'
. translate ( 'Export' ) . '</button></td>
</tr>
</table>
</form>';
?>
<script>
function updateDateFields () {
var displayAll = $('#exportall')[0].checked;
if (displayAll) {
$('#dateArea').hide();
} else {
$('#dateArea').show();
}
}
function toggle_datefields( name, ele ) {
updateDateFields();
}
function toggel_catfilter() {
if ( $('#exformat option:selected').index() == 0 ) {
// ICalendar
$('#catfilter').show();
} else {
$('#catfilter').hide();
}
}
</script>
<?php echo print_trailer (); ?>