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 8033 aaronmk
		<link rel="stylesheet" type="text/css" href="/main.css" />
115 7876 aaronmk
		<style type="text/css">
116
h1 {color: green;}
117
		</style>
118 8033 aaronmk
		<script type="text/javascript" src="/util.js"></script>
119 7876 aaronmk
	</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 8044 aaronmk
				<td nowrap="nowrap"><h2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</h2></td>
141 7931 aaronmk
				<td nowrap="nowrap"><h2>Data</h2></td>
142
			</tr>
143
			<tr valign="top">
144
				<td nowrap="nowrap">
145
<?php
146
print("<blockquote>\n");
147
print("<h3>Exchange schemas</h3>");
148 7876 aaronmk
{
149
	print("<blockquote>\n");
150 7939 aaronmk
	add_ns("VegCore", ".term", "https://projects.nceas.ucsb.edu/nceas/projects/bien/wiki/VegCore#");
151
	add_ns("DwC", ".term", "http://rs.tdwg.org/dwc/terms/#");
152 7876 aaronmk
	{
153 7931 aaronmk
		print("<blockquote>\n"); $h_level++;
154 8050 aaronmk
		add_ns("DwC.history", ".term", "http://rs.tdwg.org/dwc/terms/history/#");
155 7931 aaronmk
		print("</blockquote>\n"); $h_level--;
156 7876 aaronmk
	}
157 7942 aaronmk
	add_ns("TCS", "#/XPath", "http://www.tdwg.org/standards/117/download/#/v101.xsd");
158
	add_ns("VegX", "#/XPath", "http://wiki.tdwg.org/twiki/pub/Vegetation/WebHome/VegX_Schema_1.5.3_proposed.zip#/veg.xsd");
159 7931 aaronmk
	print("</blockquote>\n");
160
}
161
print("<h3>Aggregators</h3>");
162
{
163
	print("<blockquote>\n");
164 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=",
165 7931 aaronmk
		"#", "http://vegbank.org/get/index/dba_tabledescription"));
166 7945 aaronmk
	add_ns("SALVIAS", ".table.column", by_prefix($SALVIAS."#Plot_", $SALVIAS));
167 7876 aaronmk
	{
168 7931 aaronmk
		print("<blockquote>\n"); $h_level++;
169 8050 aaronmk
		add_ns("SALVIAS.db", ".table.column", nimoy_db("salvias_plots"));
170
		add_ns("SALVIAS.users", ".table.column", nimoy_db("salvias_users"));
171 7931 aaronmk
		print("</blockquote>\n"); $h_level--;
172 7876 aaronmk
	}
173 7939 aaronmk
	add_ns("BIEN2", "", $nimoy."?target=server_databases.php");
174 7876 aaronmk
	{
175 7931 aaronmk
		print("<blockquote>\n"); $h_level++;
176 8050 aaronmk
		add_ns("BIEN2.web", ".table.column", nimoy_db("bien_web"));
177
		add_ns("BIEN2.core", ".table.column", nimoy_db("bien2"));
178
		add_ns("BIEN2.geoscrub", ".table.column", nimoy_db("geoscrub"));
179
		add_ns("BIEN2.staging", ".table.column", nimoy_db("bien2_staging"));
180 7931 aaronmk
		print("</blockquote>\n"); $h_level--;
181 7876 aaronmk
	}
182 7939 aaronmk
	add_ns("VegBIEN", ".table.column", phpPgAdmin("http://vegbiendev.nceas.ucsb.edu/phppgadmin/redirect.php?server=localhost%3A5432%3Aallow&database=vegbien&schema=public"));
183 7931 aaronmk
	print("</blockquote>\n");
184
}
185
print("<h3>Primary databases</h3>");
186
{
187
	print("<blockquote>\n");
188 7939 aaronmk
	add_ns("TNRS", ".term", fragment_override("http://tnrs.iplantcollaborative.org/instructions.html", "download_results"));
189 7961 aaronmk
	add_ns("CTFS", "", $Redmine."/wiki/CTFS");
190 7929 aaronmk
	{
191 7931 aaronmk
		print("<blockquote>\n"); $h_level++;
192 8050 aaronmk
		add_ns("CTFS.schema", ".table.column", $Redmine_svn."/inputs/CTFS/_archive/DBv5.txt#");
193
		add_ns("CTFS.tables", ".table", fragment_override($Redmine."/wiki/CTFS", "Tables"));
194
		add_ns("CTFS.terms", ".term", $Redmine_svn."/inputs/CTFS/_src/ctfs-comments_worksheet.xls#");
195 7931 aaronmk
		print("</blockquote>\n"); $h_level--;
196 7929 aaronmk
	}
197 8050 aaronmk
	add_ns("IH.db", ".term", $IH_db);
198 7876 aaronmk
	print("</blockquote>\n");
199
}
200 7931 aaronmk
print("<h3>People</h3>");
201 7876 aaronmk
{
202
	print("<blockquote>\n");
203 8042 aaronmk
	add_ns("Brad", "", "mailto:bboyleATemail.arizona.edu");
204 7931 aaronmk
	{
205
		print("<blockquote>\n"); $h_level++;
206
		$Brad_Boyle_VegCore = $Redmine_svn."/schemas/VegCore/Brad_Boyle";
207 8050 aaronmk
		add_ns("Brad.data-provenance", ".term", $Brad_Boyle_VegCore."/BIEN%20database%20entities%20related%20to%20data%20provenance%20and%20ownership.docx#");
208
		add_ns("Brad.DwC-IDs.2013-2-7", ".term", $Brad_Boyle_VegCore."/vegbien_identifiers.xlsx#");
209
		add_ns("Brad.DwC-IDs.2013-1-31", ".term", $Brad_Boyle_VegCore."/vegbien_identifier_examples.xlsx#");
210 7931 aaronmk
		print("</blockquote>\n"); $h_level--;
211
	}
212 7876 aaronmk
	print("</blockquote>\n");
213
}
214 7931 aaronmk
print("</blockquote>\n");
215
?>
216
				</td>
217 8044 aaronmk
				<td nowrap="nowrap"></td>
218 7931 aaronmk
				<td nowrap="nowrap">
219
<?php
220
print("<blockquote>\n");
221 7932 aaronmk
print("<h3>Institutions</h3>");
222
{
223
	print("<blockquote>\n");
224 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=",
225 7931 aaronmk
		"http://sweetgum.nybg.org/ih/"));
226 7932 aaronmk
	print("</blockquote>\n");
227
}
228 7931 aaronmk
print("</blockquote>\n");
229
?>
230
				</td>
231
			</tr>
232
		</table>
233
<?php
234 7967 aaronmk
if (ends_with($root, '#')) # URL shortener requires fragment redirect
235 7922 aaronmk
{
236 7876 aaronmk
?>
237 7931 aaronmk
		<script type="text/javascript">
238 7876 aaronmk
var loc = document.location
239 7926 aaronmk
if (loc.hash) document.location = rm_prefix('#', loc.hash)
240 7931 aaronmk
		</script>
241 7922 aaronmk
<?php
242
}
243
?>
244 7876 aaronmk
	</body>
245
</html>
246
<?php
247
ob_end_flush();
248
?>