-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtools.php
More file actions
173 lines (139 loc) · 6.94 KB
/
tools.php
File metadata and controls
173 lines (139 loc) · 6.94 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
<?php
function formatDate($date) {
return date('d.m.Y', strtotime($date));
}
function showTable($group1,$nameCell1,$group2,$nameCell2,$group3,$nameCell3,$group4,$nameCell4,$information,$nameCellInformation)
{
// Eingabe Arrays Sortieren:
//information Array
usort($information, function($a, $b) {
return strcmp($a['start'], $b['start']);
});
//group 1
usort($group1, function($a, $b) {
return strcmp($a['start'], $b['start']);
});
//group 2
usort($group2, function($a, $b) {
return strcmp($a['start'], $b['start']);
});
//group 3
usort($group3, function($a, $b) {
return strcmp($a['start'], $b['start']);
});
//group 4
usort($group4, function($a, $b) {
return strcmp($a['start'], $b['start']);
});
$maxCount = max(count($group1), count($group2), count($group3), count($information));
echo "<table id='ffw'>";
echo "<tr>";
if (($nameCell1 != "0") and ($nameCell1 != null)) echo "<th colspan='2'>".$nameCell1."</th>";
if (($nameCell2 != "0") and ($nameCell2 != null)) echo "<th colspan='2'>".$nameCell2."</th>";
if (($nameCell3 != "0") and ($nameCell3 != null)) echo "<th colspan='2'>".$nameCell3."</th>";
if (($nameCell4 != "0") and ($nameCell4 != null)) echo "<th colspan='2'>".$nameCell4."</th>";
if (($nameCellInformation != "0") and ($nameCellInformation != null)) echo "<th colspan='2'>".$nameCellInformation."</th>";
echo "</tr>";
for ($i = 0; $i < $maxCount; $i++) {
echo "<tr>";
// outout group 1
if (($nameCell1 != "0") and ($nameCell1 != null)){
if (isset($group1[$i])) {
echo "<td><strong>" . formatDate($group1[$i]['start']) . "</strong></td>";
echo "<td style=' border-right: 1px solid black;'>{$group1[$i]['summary']}</td>";
} else {
echo "<td></td><td style=' border-right: 1px solid black;'></td>"; // Leere Zellen, falls kein Element vorhanden
}
}// End Output group 1
// output für group 2
if (($nameCell2 != "0") and ($nameCell2 != null)){
if (isset($group2[$i])) {
echo "<td><strong>" . formatDate($group2[$i]['start']) . "</strong></td>";
echo "<td style=' border-right: 1px solid black;'>{$group2[$i]['summary']}</td>";
} else {
echo "<td></td><td style=' border-right: 1px solid black;'></td>"; // Leere Zellen, falls kein Element vorhanden
}
}// End output Group 2
// output für group 3
if (($nameCell3 != "0") and ($nameCell3 != null)){
if (isset($group3[$i])) {
echo "<td><strong>" . formatDate($group3[$i]['start']) . "</strong></td>";
echo "<td style=' border-right: 1px solid black;'>{$group3[$i]['summary']}</td>";
} else {
echo "<td></td><td style=' border-right: 1px solid black;'></td>"; // Leere Zellen, falls kein Element vorhanden
}
}//End output Group 3
if (($nameCell4 != "0") and ($nameCell4 != null)){
if (isset($group3[$i])) {
echo "<td><strong>" . formatDate($group4[$i]['start']) . "</strong></td>";
echo "<td style=' border-right: 1px solid black;'>{$group4[$i]['summary']}</td>";
} else {
echo "<td></td><td style=' border-right: 1px solid black;'></td>"; // Leere Zellen, falls kein Element vorhanden
}
}//End output Group 3
// Ausgabe für information
if (($nameCellInformation != "0") and ($nameCellInformation != null)) {
if (isset($information[$i])) {
echo "<td><strong>" . formatDate($information[$i]['start']) . "</strong></td>";
echo "<td style=' border-right: 1px solid black;'>{$information[$i]['summary']}</td>";
} else {
echo "<td></td><td style=' border-right: 1px solid black;'></td>"; // Leere Zellen, falls kein Element vorhanden
}
}// End output Group Information
echo "</tr>";
}
echo "</table>";
}
function getArrays($data, &$gruppe1,$searchstring1, &$gruppe2,$searchstring2, &$gruppe3,$searchstring3,&$gruppe4,$searchstring4, &$gesamt)
{
$now = time();
$showPast = isset($_GET['history']);
foreach ($data as $key => $value) {
if (isset($value['type']) && $value['type'] === 'VEVENT') {
// Filter out past events unless history is requested
$end = isset($value['end']) ? strtotime($value['end']) : (isset($value['start']) ? strtotime($value['start']) : 0);
$isPast = $end > 0 && $end < $now;
if (!$showPast && $isPast) continue;
// Überprüfen, ob summary vorhanden ist
if (isset($value['summary'])) {
$summaryText = explode("-", $value['summary'], 2); // Teilt die summary am "-" Zeichen
$trimmedSummaryText = isset($summaryText[1]) ? trim($summaryText[1]) : '';
// Überprüfen der Gruppenzugehörigkeit und Einfügen in das entsprechende Array
if (strpos($value['summary'], $searchstring1) === 0) {
$gruppe1[] = ['summary' => $trimmedSummaryText, 'start' => $value['start']];
} elseif (strpos($value['summary'], $searchstring2) === 0) {
$gruppe2[] = ['summary' => $trimmedSummaryText, 'start' => $value['start']];
} elseif (strpos($value['summary'], $searchstring3) === 0) {
$gruppe3[] = ['summary' => $trimmedSummaryText, 'start' => $value['start']];
} elseif (strpos($value['summary'], $searchstring4) === 0) {
$gruppe4[] = ['summary' => $trimmedSummaryText, 'start' => $value['start']];
} else {
$gesamt[] = ['summary' => $value['summary'], 'start' => $value['start']];
}
}
}
}
}
function getDataFromJson($filename,$calurl)
{
$ret = exec("node ./reload.js ".$filename.' '.$calurl.' 2>&1', $out, $err);
return json_decode( file_get_contents($filename), true );
}
function addCalender($filename,$calurl,&$array)
{
$tmpData = getDataFromJson($filename,$calurl);
$now = time();
$showPast = isset($_GET['history']);
foreach ($tmpData as $key => $value) {
if (isset($value['type']) && $value['type'] === 'VEVENT') {
// Filter out past events unless history is requested
$end = isset($value['end']) ? strtotime($value['end']) : (isset($value['start']) ? strtotime($value['start']) : 0);
$isPast = $end > 0 && $end < $now;
if (!$showPast && $isPast) continue;
// Überprüfen, ob summary vorhanden ist
if (isset($value['summary'])) {
$array[] = ['summary' => $value['summary'], 'start' => $value['start']];
}
}
}
}