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