-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathabout.rdf
173 lines (165 loc) · 7.58 KB
/
about.rdf
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
//declare content type before any text is sent to browser
header('Content-type: application/rdf+xml');
//make XML declaration
echo ("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
//get and set url protocol
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? 'https://' : 'http://';
//set and sanitize global variables for URL construction
$server = isset($_SERVER['SERVER_NAME']) ? htmlentities(strip_tags($_SERVER['SERVER_NAME'])) : null;
$path = isset($_SERVER['PHP_SELF']) ? htmlentities(strip_tags(dirname($_SERVER['PHP_SELF']))) : null;
$fileName = isset($_SERVER['SCRIPT_NAME']) ? htmlentities(strip_tags(basename($_SERVER['SCRIPT_NAME']))) : null;
$fileNameURI = isset($_SERVER['REQUEST_URI']) ? htmlentities(strip_tags($_SERVER['REQUEST_URI'])) : null;
$fileExtension = isset($_SERVER['PATH_INFO']) ? pathinfo($fileName, PATHINFO_EXTENSION) : null;
//pass database parameters and connect to database
include_once './meta/assets/database-params.inc';
//check if the $id variable was passed in url, escape the string for mysql, and validate that it is a numeric value - pass id value to select record
if (isset($_GET['id']) and is_numeric($_GET['id'])) {
$id = strip_tags($connectLibstaff->real_escape_string((int)$_GET['id']));
} else {
echo 'Query type not supported.';
exit;
}
?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:schema="http://schema.org/"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:dbo="http://dbpedia.org/ontology/"
>
<?php
//request selected person data fields
$query = "SELECT * FROM linked_people.person WHERE person_status = 'a' AND person_id='$id'";
$getPerson = $connectLibstaff->query($query);
if ($getPerson->num_rows == 0) {
header("HTTP/1.0 404 Not Found", true, 404);
readfile("https://lib.montana.edu/error.php");
exit();
}
//list person data fields, print out as RDF
while ($row = $getPerson->fetch_object()) {
$person_id = stripslashes($row->person_id);
$person_fname = stripslashes($row->givenName);
$person_lname = stripslashes($row->familyName);
$person_name = stripslashes($row->givenName . ' ' . $row->familyName);
$person_title = stripslashes($row->jobTitle);
$person_dept = stripslashes($row->memberOf);
$person_affiliation = stripslashes($row->affiliation);
$person_room = stripslashes($row->workLocation);
$person_phone = stripslashes($row->telephone);
$person_email = stripslashes($row->email);
$person_vita = stripslashes($row->person_vita);
$person_web = stripslashes($row->url);
$person_image = $protocol.$server.$path.'/meta/img/photos/'.stripslashes($row->image);
$person_identifier = htmlentities(stripslashes($row->identifier));
$person_same_as = htmlentities(stripslashes($row->sameAs));
$person_privacy = $row->person_privacy;
$person_libcal_id = $row->person_libcal_id;
// output to client
?>
<rdf:Description rdf:about="<?php echo $protocol.$server.$path.'/'.$id; ?>">
<rdf:type rdf:resource="http://schema.org/WebPage"/>
<schema:mainContentOfPage rdf:resource="<?php echo $protocol.$server.$path.'/'.$id.'#person'; ?>"/>
</rdf:Description>
<rdf:Description rdf:about="<?php echo $protocol.$server.$path.'/'.$id.'#person'; ?>">
<rdf:type rdf:resource="https://schema.org/Person"/>
<schema:address rdf:resource="<?php echo $protocol.$server.$path.'/'.$id.'#address'; ?>"/>
<schema:organization rdf:resource="<?php echo $protocol.$server.$path.'/'.$id.'#organization'; ?>"/>
<schema:name><?php echo $person_name; ?></schema:name>
<schema:jobTitle><?php echo $person_title; ?></schema:jobTitle>
<schema:telephone><?php echo $person_phone; ?></schema:telephone>
<schema:email><?php echo $person_email; ?></schema:email>
<schema:image rdf:resource="<?php echo $person_image; ?>"/>
<?php
if (strlen($person_web) > 3) {
?>
<schema:url rdf:resource="<?php echo $person_web; ?>"/>
<?php
}
?>
<schema:primaryImageOfPage rdf:resource="<?php echo $person_image; ?>"/>
<?php
//request selected person data fields
$query = "SELECT person_id FROM linked_people.person WHERE person_status = 'a' AND memberOf='$person_dept'";
$getColleagues = $connectLibstaff->query($query);
if ($getColleagues->num_rows == 0) {
die('<p>Error retrieving colleagues data from database!<br />'.
'Error: ' . mysql_error() . '</p>');
}
while ($row = $getColleagues->fetch_object()) {
$colleague_id = stripslashes($row->person_id);
?>
<schema:colleague rdf:resource="<?php echo $protocol.$server.$path; ?>/<?php echo $colleague_id; ?>"/>
<?php
}
?>
<?php
//get person's expertise topics
$query = "SELECT *
FROM linked_people.person, linked_people.create_action, linked_people.create_action_match
WHERE person.person_id = '$id'
AND create_action_match.create_id = create_action.create_id
AND create_action_match.person_id = '$id'
AND person.person_status = 'a'";
$getPersonExpertise = $connectLibstaff->query($query);
if ($getPersonExpertise->num_rows == 0) {
?>
<schema:makesOffer>No expertise or skill(s) assigned to this person.</schema:makesOffer>
<?php
}
while ($row = $getPersonExpertise->fetch_object()) {
$object_id = $row->create_id;
$object = $row->object;
$object_url = $row->object_uri;
?>
<schema:makesOffer><?php echo $object_url; ?></schema:makesOffer>
<?php
}
?>
<schema:affiliation xml:lang="en"><?php echo $person_affiliation; ?></schema:affiliation>
<schema:worksFor xml:lang="en"><?php echo $person_affiliation; ?></schema:worksFor>
<schema:memberOf xml:lang="en"><?php echo $person_dept; ?></schema:memberOf>
<?php
if (strlen($person_identifier) > 3 && strlen($person_same_as) > 3) {
?>
<owl:sameAs><?php echo $person_identifier; ?></owl:sameAs>
<schema:sameAs rdf:resource="<?php echo $person_identifier; ?>"/>
<owl:sameAs><?php echo $person_same_as; ?></owl:sameAs>
<schema:sameAs rdf:resource="<?php echo $person_same_as; ?>"/>
<?php
}
if (strlen($person_identifier) > 3 && strlen($person_same_as) < 3) {
?>
<owl:sameAs><?php echo $person_identifier; ?></owl:sameAs>
<schema:sameAs rdf:resource="<?php echo $person_identifier; ?>"/>
<?php
}
if (strlen($person_same_as) > 3 && strlen($person_identifier) < 3) {
?>
<owl:sameAs><?php echo $person_same_as; ?></owl:sameAs>
<schema:sameAs rdf:resource="<?php echo $person_same_as; ?>"/>
<?php
}
?>
</rdf:Description>
<rdf:Description rdf:about="<?php echo $protocol.$server.$path.'/'.$id.'#address'; ?>">
<rdf:type rdf:resource="https://schema.org/PostalAddress"/>
<schema:streetAddress>P.O. Box 173320, Room # <?php echo $person_room; ?></schema:streetAddress>
<schema:addressLocality>Bozeman</schema:addressLocality>
<schema:addressRegion>MT</schema:addressRegion>
<schema:postalCode>59717-3320</schema:postalCode>
</rdf:Description>
<rdf:Description rdf:about="<?php echo $protocol.$server.$path.'/'.$id.'#organization'; ?>">
<schema:member rdf:resource="<?php echo $protocol.$server.$path.'/'.$id.'#member'; ?>"/>
<schema:name>Montana State University (MSU) Library</schema:name>
<schema:sameAs rdf:resource="http://www.freebase.com/m/0j3y9r1"/>
<rdf:type rdf:resource="https://schema.org/EducationalOrganization"/>
</rdf:Description>
<rdf:Description rdf:about="<?php echo $protocol.$server.$path.'/'.$id.'#member'; ?>">
<rdf:type rdf:resource="http://schema.org/OrganizationRole"/>
<schema:member rdf:resource="<?php echo $protocol.$server.$path.'/'.$id.'#person'; ?>"/>
</rdf:Description>
<?php
}
?>
</rdf:RDF>