1
|
<?php
|
2
|
require_once dirname(__FILE__)."/util.php";
|
3
|
|
4
|
# config
|
5
|
$alias = "j.mp/vegpath#";
|
6
|
|
7
|
function by_prefix($url, $main_url=null)
|
8
|
{
|
9
|
if (!isset($main_url)) $main_url = $url;
|
10
|
|
11
|
return function($path) use($url, $main_url)
|
12
|
{
|
13
|
return $path ? $url.$path : $main_url;
|
14
|
};
|
15
|
}
|
16
|
|
17
|
$h_level = 5;
|
18
|
$path = parse_mixed_path($_SERVER["QUERY_STRING"]);
|
19
|
$ref = strtolower($path->head);
|
20
|
|
21
|
function add_ref($name, $suffix, $url_func)
|
22
|
{
|
23
|
global $alias, $h_level, $path, $ref;
|
24
|
if (is_string($url_func)) $url_func = by_prefix($url_func);
|
25
|
|
26
|
print("<h".$h_level.' id="'.$name.'">'.$alias.'<big><a href="http://'.$alias
|
27
|
.$name.'">'.$name."</a></big><i>".$suffix."</i></h".$h_level.">\n");
|
28
|
if ($ref === strtolower($name)) # found match, so redirect
|
29
|
{
|
30
|
header("Location: ".strip_url($url_func($path->tail)));
|
31
|
ob_end_flush();
|
32
|
exit;
|
33
|
}
|
34
|
}
|
35
|
|
36
|
function custom_separator($url, $sep, $main_url)
|
37
|
{
|
38
|
if (!isset($main_url)) $main_url = $url;
|
39
|
|
40
|
return function($path) use($url, $sep, $main_url)
|
41
|
{
|
42
|
if ($path === "") return $main_url;
|
43
|
$path = parse_dot_path($path);
|
44
|
return $url.join_non_empty($sep, array($path->head, $path->tail));
|
45
|
};
|
46
|
}
|
47
|
|
48
|
function fragment_override($url, $fragment=null)
|
49
|
{
|
50
|
return function($path) use($url, $fragment)
|
51
|
{
|
52
|
if (!isset($fragment))
|
53
|
{
|
54
|
$path = parse_dot_path($path);
|
55
|
$fragment = $path->head;
|
56
|
$path = $path->tail;
|
57
|
}
|
58
|
if ($path !== "") $url .= "?".$path;
|
59
|
return $url."#".$fragment;
|
60
|
};
|
61
|
}
|
62
|
|
63
|
function phpPgAdmin($url)
|
64
|
{
|
65
|
return function($path) use($url)
|
66
|
{
|
67
|
$path = parse_dot_path($path);
|
68
|
$subject = "schema";
|
69
|
if ($path->head !== "")
|
70
|
{
|
71
|
$url .= "&table=".$path->head;
|
72
|
if ($path->tail !== "")
|
73
|
{
|
74
|
$url .= "&column=".$path->tail;
|
75
|
$subject = "column";
|
76
|
}
|
77
|
else $subject = "table";
|
78
|
}
|
79
|
$url .= "&subject=".$subject;
|
80
|
return $url;
|
81
|
};
|
82
|
}
|
83
|
|
84
|
function phpMyAdmin($url)
|
85
|
{
|
86
|
return function($path) use($url)
|
87
|
{
|
88
|
$path = parse_dot_path($path);
|
89
|
$target = "db_structure";
|
90
|
if ($path->head !== "")
|
91
|
{
|
92
|
$url .= "&table=".$path->head;
|
93
|
if ($path->tail !== "") $url .= "&column=".$path->tail;
|
94
|
$target = "tbl_structure";
|
95
|
}
|
96
|
$url .= "&target=".$target.".php";
|
97
|
return $url;
|
98
|
};
|
99
|
}
|
100
|
|
101
|
function VegBank($url)
|
102
|
{
|
103
|
return custom_separator($url."/vegbank/views/dba_tabledescription_detail.jsp?view=detail&entity=dba_tabledescription&where=where_tablename&wparam=",
|
104
|
"#", $url."/get/index/dba_tabledescription");
|
105
|
}
|
106
|
|
107
|
ob_start(); // delay output in case there is a redirect
|
108
|
?>
|
109
|
<html>
|
110
|
<head>
|
111
|
<title>VegPath</title>
|
112
|
<link rel="stylesheet" type="text/css" href="main.css" />
|
113
|
<style type="text/css">
|
114
|
h1 {color: green;}
|
115
|
</style>
|
116
|
<script type="text/javascript" src="util.js"></script>
|
117
|
</head>
|
118
|
<body>
|
119
|
<h1>VegPath <small>human-readable URLs for vegetation resources</small></h1>
|
120
|
<div>Supported URL patterns: <small><i>(elements can be left out successively from the end of the URL)</i></small></div>
|
121
|
<blockquote>
|
122
|
<?php
|
123
|
# add and list URLs
|
124
|
print("<h2>Terms</h2>");
|
125
|
{
|
126
|
print("<blockquote>\n");
|
127
|
print("<h3>Exchange schemas</h3>");
|
128
|
{
|
129
|
print("<blockquote>\n");
|
130
|
add_ref("VegCore", ".table.column", "https://projects.nceas.ucsb.edu/nceas/projects/bien/wiki/VegCore#");
|
131
|
add_ref("DwC", ".term", "http://rs.tdwg.org/dwc/terms/#");
|
132
|
{
|
133
|
print("<blockquote>\n"); $h_level++;
|
134
|
add_ref("DwC-history", ".term", "http://rs.tdwg.org/dwc/terms/history/#");
|
135
|
print("</blockquote>\n"); $h_level--;
|
136
|
}
|
137
|
add_ref("TCS", "/XPath", "http://www.tdwg.org/standards/117/download/#/v101.xsd#");
|
138
|
add_ref("VegX", "/XPath", "http://wiki.tdwg.org/twiki/pub/Vegetation/WebHome/VegX_Schema_1.5.3_proposed.zip#/veg.xsd#");
|
139
|
print("</blockquote>\n");
|
140
|
}
|
141
|
print("<h3>Aggregators</h3>");
|
142
|
{
|
143
|
print("<blockquote>\n");
|
144
|
add_ref("VegBank", ".table.column", VegBank("http://vegbank.org"));
|
145
|
add_ref("SALVIAS", ".table.column", "http://salvias.net/Documents/salvias_data_dictionary.html#");
|
146
|
add_ref("BIEN2", ".table.column", phpMyAdmin("http://nimoy.nceas.ucsb.edu/phpmyadmin/index.php?db=bien_web"));
|
147
|
add_ref("VegBIEN", ".table.column", phpPgAdmin("http://vegbiendev.nceas.ucsb.edu/phppgadmin/redirect.php?server=localhost%3A5432%3Aallow&database=vegbien&schema=public"));
|
148
|
print("</blockquote>\n");
|
149
|
}
|
150
|
print("<h3>Primary databases</h3>");
|
151
|
{
|
152
|
print("<blockquote>\n");
|
153
|
add_ref("TNRS", ".term", fragment_override("http://tnrs.iplantcollaborative.org/instructions.html", "download_results"));
|
154
|
print("</blockquote>\n");
|
155
|
}
|
156
|
print("</blockquote>\n");
|
157
|
}
|
158
|
print("<h2>Data</h2>");
|
159
|
{
|
160
|
print("<blockquote>\n");
|
161
|
add_ref("IH", ".herbarium_code", by_prefix("http://sweetgum.nybg.org/ih/herbarium_list.php?QueryName=DetailedQuery&Restriction=NamPartyType+%3D+%27IH+Herbarium%27&col_NamOrganisationAcronym=",
|
162
|
"http://sweetgum.nybg.org/ih/"));
|
163
|
print("</blockquote>\n");
|
164
|
}
|
165
|
?>
|
166
|
<script type="text/javascript">
|
167
|
var loc = document.location
|
168
|
if (loc.hash)
|
169
|
{
|
170
|
var fragment = rm_prefix('#', loc.hash)
|
171
|
var namespace = parse_dot_path(fragment).head
|
172
|
document.getElementById(namespace).className = 'progress'
|
173
|
document.location = fragment
|
174
|
}
|
175
|
</script>
|
176
|
</blockquote>
|
177
|
</body>
|
178
|
</html>
|
179
|
<?php
|
180
|
ob_end_flush();
|
181
|
?>
|