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