1
|
<?php
|
2
|
require_once dirname(__FILE__)."/util.php";
|
3
|
|
4
|
# config
|
5
|
#$alias = "path.vg/";
|
6
|
$alias = "j.mp/vegpath#";
|
7
|
|
8
|
function by_prefix($url, $main_url=null)
|
9
|
{
|
10
|
if (!isset($main_url)) $main_url = $url;
|
11
|
|
12
|
return function($path) use($url, $main_url)
|
13
|
{
|
14
|
return $path ? $url.$path : $main_url;
|
15
|
};
|
16
|
}
|
17
|
|
18
|
$h_level = 5;
|
19
|
$path = parse_dot_path(rm_prefix("/", $_SERVER["PATH_INFO"]));
|
20
|
$ns = strtolower($path->head);
|
21
|
|
22
|
function add_ns($name, $path_pat, $url_func)
|
23
|
{
|
24
|
global $alias, $h_level, $path, $ns;
|
25
|
if (is_string($url_func)) $url_func = by_prefix($url_func);
|
26
|
|
27
|
print("<h".$h_level.' id="'.$name.'">'.$alias.'<big><a href="http://'.$alias
|
28
|
.$name.'">'.$name."</a></big><i>".$path_pat."</i></h".$h_level.">\n");
|
29
|
if ($ns === strtolower($name)) # found match, so redirect
|
30
|
{
|
31
|
header("Location: ".strip_url($url_func($path->tail)));
|
32
|
ob_end_flush();
|
33
|
exit;
|
34
|
}
|
35
|
}
|
36
|
|
37
|
function custom_separator($url, $sep, $main_url=null)
|
38
|
{
|
39
|
if (!isset($main_url)) $main_url = $url;
|
40
|
|
41
|
return function($path) use($url, $sep, $main_url)
|
42
|
{
|
43
|
if ($path === "") return $main_url;
|
44
|
$path = parse_dot_path($path);
|
45
|
return $url.join_non_empty($sep, array($path->head, $path->tail));
|
46
|
};
|
47
|
}
|
48
|
|
49
|
function fragment_override($url, $fragment=null)
|
50
|
{
|
51
|
return function($path) use($url, $fragment)
|
52
|
{
|
53
|
if (!isset($fragment))
|
54
|
{
|
55
|
$path = parse_dot_path($path);
|
56
|
$fragment = $path->head;
|
57
|
$path = $path->tail;
|
58
|
}
|
59
|
if ($path !== "") $url .= "?".$path;
|
60
|
return $url."#".$fragment;
|
61
|
};
|
62
|
}
|
63
|
|
64
|
function phpPgAdmin($url, $table=null)
|
65
|
{
|
66
|
return function($path) use($url, $table)
|
67
|
{
|
68
|
$path = join_non_empty(".", array($table, $path));
|
69
|
$path = parse_dot_path($path);
|
70
|
$subject = "schema";
|
71
|
if ($path->head !== "")
|
72
|
{
|
73
|
$url .= "&table=".$path->head;
|
74
|
if ($path->tail !== "")
|
75
|
{
|
76
|
$url .= "&column=".$path->tail;
|
77
|
$subject = "column";
|
78
|
}
|
79
|
else $subject = "table";
|
80
|
}
|
81
|
$url .= "&subject=".$subject;
|
82
|
return $url;
|
83
|
};
|
84
|
}
|
85
|
|
86
|
function phpMyAdmin($url, $table=null)
|
87
|
{
|
88
|
return function($path) use($url, $table)
|
89
|
{
|
90
|
$path = join_non_empty(".", array($table, $path));
|
91
|
$path = parse_dot_path($path);
|
92
|
$target = "db_structure";
|
93
|
if ($path->head !== "")
|
94
|
{
|
95
|
$url .= "&table=".$path->head;
|
96
|
if ($path->tail !== "") $url .= "&column=".$path->tail;
|
97
|
$target = "tbl_structure";
|
98
|
}
|
99
|
$url .= "&target=".$target.".php";
|
100
|
return $url;
|
101
|
};
|
102
|
}
|
103
|
|
104
|
ob_start(); // delay output in case there is a redirect
|
105
|
?>
|
106
|
<html>
|
107
|
<head>
|
108
|
<title>VegPath</title>
|
109
|
<link rel="stylesheet" type="text/css" href="main.css" />
|
110
|
<style type="text/css">
|
111
|
h1 {color: green;}
|
112
|
</style>
|
113
|
<script type="text/javascript" src="util.js"></script>
|
114
|
</head>
|
115
|
<body>
|
116
|
<h1>VegPath <small>human-readable URLs for vegetation resources</small></h1>
|
117
|
<div>Supported URL patterns: <small>(elements in <i>italics</i> are optional)</small></div>
|
118
|
<p></p>
|
119
|
<?php
|
120
|
# add and list URLs
|
121
|
|
122
|
$Redmine = "https://projects.nceas.ucsb.edu/nceas/projects/bien";
|
123
|
$Redmine_svn = $Redmine."/repository/raw";
|
124
|
|
125
|
$nimoy = "http://nimoy.nceas.ucsb.edu/phpmyadmin/index.php";
|
126
|
function nimoy_db($db) { global $nimoy; return phpMyAdmin($nimoy."?db=".$db); }
|
127
|
|
128
|
$IH_db = phpMyAdmin($nimoy."?db=bien3_adb", "ih");
|
129
|
|
130
|
$SALVIAS = "http://salvias.net/Documents/salvias_data_dictionary.html";
|
131
|
?>
|
132
|
<table border="0" cellspacing="0" cellpadding="0">
|
133
|
<tr valign="top">
|
134
|
<td nowrap="nowrap"><h2>Terms</h2></td>
|
135
|
<td nowrap="nowrap"><h2>Data</h2></td>
|
136
|
</tr>
|
137
|
<tr valign="top">
|
138
|
<td nowrap="nowrap">
|
139
|
<?php
|
140
|
print("<blockquote>\n");
|
141
|
print("<h3>Exchange schemas</h3>");
|
142
|
{
|
143
|
print("<blockquote>\n");
|
144
|
add_ns("VegCore", ".term", "https://projects.nceas.ucsb.edu/nceas/projects/bien/wiki/VegCore#");
|
145
|
add_ns("DwC", ".term", "http://rs.tdwg.org/dwc/terms/#");
|
146
|
{
|
147
|
print("<blockquote>\n"); $h_level++;
|
148
|
add_ns("DwC-history", ".term", "http://rs.tdwg.org/dwc/terms/history/#");
|
149
|
print("</blockquote>\n"); $h_level--;
|
150
|
}
|
151
|
add_ns("TCS", "#/XPath", "http://www.tdwg.org/standards/117/download/#/v101.xsd");
|
152
|
add_ns("VegX", "#/XPath", "http://wiki.tdwg.org/twiki/pub/Vegetation/WebHome/VegX_Schema_1.5.3_proposed.zip#/veg.xsd");
|
153
|
print("</blockquote>\n");
|
154
|
}
|
155
|
print("<h3>Aggregators</h3>");
|
156
|
{
|
157
|
print("<blockquote>\n");
|
158
|
add_ns("VegBank", ".table.column", custom_separator("http://vegbank.org/vegbank/views/dba_tabledescription_detail.jsp?view=detail&entity=dba_tabledescription&where=where_tablename&wparam=",
|
159
|
"#", "http://vegbank.org/get/index/dba_tabledescription"));
|
160
|
add_ns("SALVIAS", ".table.column", by_prefix($SALVIAS."#Plot_", $SALVIAS));
|
161
|
{
|
162
|
print("<blockquote>\n"); $h_level++;
|
163
|
add_ns("SALVIAS-db", ".table.column", nimoy_db("salvias_plots"));
|
164
|
add_ns("SALVIAS-users", ".table.column", nimoy_db("salvias_users"));
|
165
|
print("</blockquote>\n"); $h_level--;
|
166
|
}
|
167
|
add_ns("BIEN2", "", $nimoy."?target=server_databases.php");
|
168
|
{
|
169
|
print("<blockquote>\n"); $h_level++;
|
170
|
add_ns("BIEN2-web", ".table.column", nimoy_db("bien_web"));
|
171
|
add_ns("BIEN2-core", ".table.column", nimoy_db("bien2"));
|
172
|
add_ns("BIEN2-geoscrub", ".table.column", nimoy_db("geoscrub"));
|
173
|
add_ns("BIEN2-staging", ".table.column", nimoy_db("bien2_staging"));
|
174
|
print("</blockquote>\n"); $h_level--;
|
175
|
}
|
176
|
add_ns("VegBIEN", ".table.column", phpPgAdmin("http://vegbiendev.nceas.ucsb.edu/phppgadmin/redirect.php?server=localhost%3A5432%3Aallow&database=vegbien&schema=public"));
|
177
|
print("</blockquote>\n");
|
178
|
}
|
179
|
print("<h3>Primary databases</h3>");
|
180
|
{
|
181
|
print("<blockquote>\n");
|
182
|
add_ns("TNRS", ".term", fragment_override("http://tnrs.iplantcollaborative.org/instructions.html", "download_results"));
|
183
|
add_ns("CTFS", "", $CTFS);
|
184
|
{
|
185
|
print("<blockquote>\n"); $h_level++;
|
186
|
add_ns("CTFS-schema", ".table.column", "https://projects.nceas.ucsb.edu/nceas/projects/bien/repository/raw/inputs/CTFS/_archive/DBv5.txt#");
|
187
|
add_ns("CTFS-tables", ".table", fragment_override($Redmine."/wiki/CTFS", "Tables"));
|
188
|
add_ns("CTFS-terms", ".term", $Redmine_svn."/inputs/CTFS/_src/ctfs-comments_worksheet.xls#");
|
189
|
print("</blockquote>\n"); $h_level--;
|
190
|
}
|
191
|
add_ns("IH-db", ".term", $IH_db);
|
192
|
print("</blockquote>\n");
|
193
|
}
|
194
|
print("<h3>People</h3>");
|
195
|
{
|
196
|
print("<blockquote>\n");
|
197
|
add_ns("Brad-Boyle", "", $CTFS);
|
198
|
{
|
199
|
print("<blockquote>\n"); $h_level++;
|
200
|
$Brad_Boyle_VegCore = $Redmine_svn."/schemas/VegCore/Brad_Boyle";
|
201
|
add_ns("Brad-Boyle-data-provenance", ".term", $Brad_Boyle_VegCore."/BIEN%20database%20entities%20related%20to%20data%20provenance%20and%20ownership.docx#");
|
202
|
add_ns("Brad-Boyle-DwC-IDs-2013-2-7", ".term", $Brad_Boyle_VegCore."/vegbien_identifiers.xlsx#");
|
203
|
add_ns("Brad-Boyle-DwC-IDs-2013-1-31", ".term", $Brad_Boyle_VegCore."/vegbien_identifier_examples.xlsx#");
|
204
|
print("</blockquote>\n"); $h_level--;
|
205
|
}
|
206
|
print("</blockquote>\n");
|
207
|
}
|
208
|
print("</blockquote>\n");
|
209
|
?>
|
210
|
</td>
|
211
|
<td nowrap="nowrap">
|
212
|
<?php
|
213
|
print("<blockquote>\n");
|
214
|
print("<h3>Institutions</h3>");
|
215
|
{
|
216
|
print("<blockquote>\n");
|
217
|
add_ns("IH", ".herbarium_code", by_prefix("http://sweetgum.nybg.org/ih/herbarium_list.php?QueryName=DetailedQuery&Restriction=NamPartyType+%3D+%27IH+Herbarium%27&col_NamOrganisationAcronym=",
|
218
|
"http://sweetgum.nybg.org/ih/"));
|
219
|
print("</blockquote>\n");
|
220
|
}
|
221
|
print("</blockquote>\n");
|
222
|
?>
|
223
|
</td>
|
224
|
</tr>
|
225
|
</table>
|
226
|
<?php
|
227
|
if (ends_with($alias, '#')) # URL shortener requires fragment redirect
|
228
|
{
|
229
|
?>
|
230
|
<script type="text/javascript">
|
231
|
var loc = document.location
|
232
|
if (loc.hash) document.location = rm_prefix('#', loc.hash)
|
233
|
</script>
|
234
|
<?php
|
235
|
}
|
236
|
?>
|
237
|
</body>
|
238
|
</html>
|
239
|
<?php
|
240
|
ob_end_flush();
|
241
|
?>
|