-
Notifications
You must be signed in to change notification settings - Fork 29
/
collab.php
81 lines (68 loc) · 2.02 KB
/
collab.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
<html>
<body>
<h2>NRNB Collaborations</h2>
<table >
<tr><td><td><b>Project Title<td><b>Investigator<td><b>NRNB Contact</b></tr>
<?php
$url = "https://spreadsheets.google.com/feeds/list/t4GxaAbYL-dqlxi3iTy-b7w/od6/public/values/";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$xml = curl_exec($ch);
curl_close($ch);
//$doc = new DOMDocument();
//$doc->loadXML($xml);
//$entries = $doc->getElementsByTagName("gsx:projecttitle");
//if ($entries->length > 0) {
// foreach($entries as $e) {
// echo $e;
// }
//}
$items = element_set('entry', $xml);
$c = 1;
foreach($items as $i){
$content = value_in('gsx:projecttitle', $i);
$name = value_in('gsx:fullnamesanddegreese.g.johne.smithmdphd', $i);
$contact = value_in('gsx:nrnbcontact', $i);
echo "<tr><td>".$c++."<td>$content<td>$name<td>$contact</tr>";
}
$title = value_in('title', $xml);
$link = value_in('link', $xml);
function value_in($element_name, $xml, $content_only = true) {
if ($xml == false) {
return false;
}
$found = preg_match('#<'.$element_name.'(?:\s+[^>]+)?>(.*?)'.
'</'.$element_name.'>#s', $xml, $matches);
if ($found != false) {
if ($content_only) {
return $matches[1]; //ignore the enclosing tags
} else {
return $matches[0]; //return the full pattern match
}
}
// No match found: return false.
return false;
}
function element_set($element_name, $xml, $content_only = false) {
if ($xml == false) {
return false;
}
$found = preg_match_all('#<'.$element_name.'(?:\s+[^>]+)?>' .
'(.*?)</'.$element_name.'>#s',
$xml, $matches, PREG_PATTERN_ORDER);
if ($found != false) {
if ($content_only) {
return $matches[1]; //ignore the enlosing tags
} else {
return $matches[0]; //return the full pattern match
}
}
// No match found: return false.
return false;
}
?>
</table>
</body>
</html>