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