Project

General

Profile

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