forked from ifgi-webteam/Campusplan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uni-a-z.php
141 lines (102 loc) · 3.35 KB
/
uni-a-z.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
139
140
141
<?php
require_once("functions.php");
checkCache();
getHead("Uni A-Z");
?>
<div class="container">
<?php
if(isset($_GET['search'])){
getSearchList($_GET['search']);
}else if(isset($_GET['letter'])){
getLetterList($_GET['letter']);
}else{
getAZList();
}
?>
</div><!--/container -->
<?php
getFoot();
function searchForm($value){
echo '
<div class="row-fluid">
<div class="span12">
<h1>Uni A-Z</h1>
<p class="lead">Das Einrichtungsverzeichnis der WWU.</p>
<form action="uni-a-z.php">
<div class="input-append">
<input class="searchfield" name="search" placeholder="Suche..." id="appendedInputButton" type="text">
<button class="btn btn-large" type="submit"><i class="icon-search"></i></button>
</div>
</form>
</div>
</div>
';
// echo '<form><input type="search" name="search" id="search-basic" value="'.$value.'" /><input type="submit" value="Einrichtung suchen" /></form>';
}
function getAZList(){
searchForm('');
echo '<p class="lead">... oder nach Anfangsbuchstabe:</p>';
echo '<p class="az">';
$az = array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");
foreach ($az as $letter) {
echo '<a class="btn btn-large btn-letter internal" href="uni-a-z.php?letter='.$letter.'">'.$letter.'</a> ';
}
for($i=1; $i<=10; $i++) { echo '<a class="btn btn-large btn-letter internal invisible" href="uni-a-z.php?letter=" style="height:1px;"> </a> ';}
echo '</p>';
}
function getLetterList($letter){
$orgs = sparql_get("
prefix foaf: <http://xmlns.com/foaf/0.1/>
prefix aiiso: <http://purl.org/vocab/aiiso/schema#>
prefix lodum: <http://vocab.lodum.de/helper/>
SELECT DISTINCT ?orga ?name WHERE {
Graph <http://data.uni-muenster.de/context/uniaz/> {
?orga a ?type ;
foaf:name ?name .
BIND(lcase(?name) as ?lname) .
FILTER langMatches(lang(?name),'DE') .
FILTER (STRSTARTS(?name, '".$letter."')) .
FILTER (STRLEN(?name) > 0) .
FILTER regex(str(?orga),'uniaz') .
}
} ORDER BY ?lname
");
listOrgs($orgs, $letter);
}
function getSearchList($searchterm){
$orgs = sparql_get("
prefix foaf: <http://xmlns.com/foaf/0.1/>
prefix aiiso: <http://purl.org/vocab/aiiso/schema#>
prefix lodum: <http://vocab.lodum.de/helper/>
SELECT DISTINCT ?orga ?name WHERE {
Graph <http://data.uni-muenster.de/context/uniaz/> {
?orga a ?type ;
foaf:name ?name .
BIND(lcase(?name) as ?lname) .
FILTER langMatches(lang(?name),'DE') .
FILTER regex(?name, '".$searchterm."', 'i' ) .
FILTER (STRLEN(?name) > 0) .
FILTER regex(str(?orga),'uniaz') .
}
} ORDER BY ?lname
");
listOrgs($orgs, $searchterm);
}
function listOrgs($orgs, $template){
// only start if there are any results:
if($orgs->results->bindings){
echo '<h2>Einrichtungen mit <em>'.$template.'</em></h2>
<div class="btn-group btn-group-vertical">';
foreach ($orgs->results->bindings as $fb) {
$name = $fb->name->value;
$orga = $fb->orga->value;
echo '<a class="btn btn-large btn-stacked internal" href="orgdetails.php?org_uri='.$orga.'">'.$name.'</a>';
}
echo '</div>';
} else {
print "<h3>Keine Einrichtungen mit <em>".$template."</em> gefunden.</h3>";
getAZList();
}
}
flushCache();
?>