forked from ifgi-webteam/Campusplan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mensen.php
120 lines (96 loc) · 3.07 KB
/
mensen.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
<?php
require_once("functions.php");
getHead();
?>
<?php
if(isset($_GET['lang'])){
getFood($_GET['lang']);
} else {
getFood();
}
?>
<?php
getFoot();
function getFood(){
$l = setlocale(LC_TIME, 'deu', 'de_DE.UTF-8');
$time = strtotime('monday this week');
$date = date('Y-m-d', $time);
$datetime = $date.'T00:00:00Z';
$food = sparql_get('
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix gr: <http://purl.org/goodrelations/v1#>
prefix foaf: <http://xmlns.com/foaf/0.1/>
SELECT DISTINCT ?name ?start ?minPrice ?maxPrice ?mensa ?mensaname WHERE {
?menu a gr:Offering ;
gr:availabilityStarts ?start ;
gr:name ?name ;
gr:hasPriceSpecification ?priceSpec .
?priceSpec gr:hasMinCurrencyValue ?minPrice ;
gr:hasMaxCurrencyValue ?maxPrice .
?mensa gr:offers ?menu ;
foaf:name ?mensaname .
FILTER (xsd:dateTime(?start) > "'.$datetime.'"^^xsd:dateTime) .
} ORDER BY MONTH(?start) DAY(?start) LCASE(?mensaname)
');
if( !isset($food) ) {
echo '<div class="alert alert-error">Fehler beim Abruf der Mensadaten.</div>';
}else{
// only start if there are any results:
if($food->results->bindings){
$header = false;
$mns = 'none';
$tag = 'none';
$weekdays = array("Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag");
$weekday = 0;
foreach ($food->results->bindings as $menu) {
$other = false;
// create a new list for each day of the week:
$day = substr($menu->start->value, 0, 10);
if(!$header){
echo '<div class="container"><div class="row-fluid">
<div class="span12">
<h1>Mensaplan für die Woche vom '.strftime('%e. %B %Y', strtotime($menu->start->value)).'</h1>
<hr />
</div>
</div>
';
$header = true;
}
if($day !== $tag){
if($weekday < count($weekdays)){
echo '</tbody></table>';
// close the span6 div - but only if we have opened it before!
if ($tag !== 'none'){
echo '</div>';
}
// close the row-fluid div after every other span6 div
if($other){
echo '</div>';
}
echo '<div class="row-fluid"><div class="span6"';
if(!$other){ // move the right column a bit
echo ' style="padding-right: 20px"';
}
echo '><h2 id="'.$day.'">'.$weekdays[$weekday++].'</h2>
<table class="table table-bordered table-striped">';
$tag = $day;
$other = !$other;
}else{
$weekday++;
}
}
if($weekday <= count($weekdays)){
// break the list down by mensa:
if($menu->mensa->value !== $mns){
echo '<thead><tr><td><a class="internal" href="orgdetails.php?org_uri='.$menu->mensa->value.'">'.$menu->mensaname->value.'</a></td></tr></thead><tbody>';
$mns = $menu->mensa->value;
}
echo '<tr><td>'.$menu->name->value.' <span class="pull-right">'.$menu->minPrice->value.'€ | '.$menu->maxPrice->value.'€</span></td></tr>';
}
}
echo '</tbody></table></div></div></div>';
}
echo '</div></div></div></div>';
}
}
?>