Project

General

Profile

1
<?php
2
require_once dirname(__FILE__)."/util.php";
3

    
4
$self_dir = ensure_suffix("/", dirname($_SERVER["SCRIPT_NAME"]));
5

    
6
# config
7
$alias = "j.mp/vegpath#";
8

    
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
$h_level = 5;
20
$root = $_SERVER["HTTP_HOST"] === $_SERVER["SERVER_NAME"]
21
	? $alias : $_SERVER["HTTP_HOST"].$self_dir;
22
# 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
$ns = strtolower($path->head);
26

    
27
function add_ns($name, $path_pat, $url_func)
28
{
29
	global $root, $h_level, $path, $ns;
30
	if (is_string($url_func)) $url_func = by_prefix($url_func);
31
	
32
	print("<h".$h_level.' id="'.$name.'">'.$root.'<big><a href="http://'.$root
33
		.$name.'">'.$name."</a></big><i>".$path_pat."</i></h".$h_level.">\n");
34
	if ($ns === strtolower($name)) # found match, so redirect
35
	{
36
		header("Location: ".strip_url($url_func($path->tail)));
37
		ob_end_flush();
38
		exit;
39
	}
40
}
41

    
42
function custom_separator($url, $sep, $main_url=null)
43
{
44
	if (!isset($main_url)) $main_url = $url;
45
	
46
	return function($path) use($url, $sep, $main_url)
47
	{
48
		if ($path === "") return $main_url;
49
		$path = parse_dot_path($path);
50
		return $url.join_non_empty($sep, array($path->head, $path->tail));
51
	};
52
}
53

    
54
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
		if ($path !== "") $url .= "?".$path;
65
		return $url."#".$fragment;
66
	};
67
}
68

    
69
function phpPgAdmin($url, $table=null)
70
{
71
	return function($path) use($url, $table)
72
	{
73
		$path = join_non_empty(".", array($table, $path));
74
		$path = parse_dot_path($path);
75
		$subject = "schema";
76
		if ($path->head !== "")
77
		{
78
			$url .= "&table=".$path->head;
79
			if ($path->tail !== "")
80
			{
81
				$url .= "&column=".$path->tail;
82
				$subject = "column";
83
			}
84
			else $subject = "table";
85
		}
86
		$url .= "&subject=".$subject;
87
		return $url;
88
	};
89
}
90

    
91
function phpMyAdmin($url, $table=null)
92
{
93
	return function($path) use($url, $table)
94
	{
95
		$path = join_non_empty(".", array($table, $path));
96
		$path = parse_dot_path($path);
97
		$target = "db_structure";
98
		if ($path->head !== "")
99
		{
100
			$url .= "&table=".$path->head;
101
			if ($path->tail !== "") $url .= "&column=".$path->tail;
102
			$target = "tbl_structure";
103
		}
104
		$url .= "&target=".$target.".php";
105
		return $url;
106
	};
107
}
108

    
109
ob_start(); // delay output in case there is a redirect
110
?>
111
<html>
112
	<head>
113
		<title>VegPath</title>
114
		<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
		<h1>VegPath&nbsp;&nbsp; <small><a href="http://en.wikipedia.org/wiki/PURL">persistent URLs</a> for vegetation resources</small></h1>
122
		<div>Supported URL patterns:&nbsp;&nbsp; <small>(elements in <i>italics</i> are optional)</small></div>
123
		<p></p>
124
<?php
125
# add and list URLs
126

    
127
$Redmine = "https://projects.nceas.ucsb.edu/nceas/projects/bien";
128
$Redmine_svn = $Redmine."/repository/raw";
129

    
130
$nimoy = "http://nimoy.nceas.ucsb.edu/phpmyadmin/index.php";
131
function nimoy_db($db) { global $nimoy; return phpMyAdmin($nimoy."?db=".$db); }
132

    
133
$IH_db = phpMyAdmin($nimoy."?db=bien3_adb", "ih");
134

    
135
$SALVIAS = "http://salvias.net/Documents/salvias_data_dictionary.html";
136
?>
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
{
148
	print("<blockquote>\n");
149
	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
	{
152
		print("<blockquote>\n"); $h_level++;
153
		add_ns("DwC-history", ".term", "http://rs.tdwg.org/dwc/terms/history/#");
154
		print("</blockquote>\n"); $h_level--;
155
	}
156
	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
	print("</blockquote>\n");
159
}
160
print("<h3>Aggregators</h3>");
161
{
162
	print("<blockquote>\n");
163
	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
		"#", "http://vegbank.org/get/index/dba_tabledescription"));
165
	add_ns("SALVIAS", ".table.column", by_prefix($SALVIAS."#Plot_", $SALVIAS));
166
	{
167
		print("<blockquote>\n"); $h_level++;
168
		add_ns("SALVIAS-db", ".table.column", nimoy_db("salvias_plots"));
169
		add_ns("SALVIAS-users", ".table.column", nimoy_db("salvias_users"));
170
		print("</blockquote>\n"); $h_level--;
171
	}
172
	add_ns("BIEN2", "", $nimoy."?target=server_databases.php");
173
	{
174
		print("<blockquote>\n"); $h_level++;
175
		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
		print("</blockquote>\n"); $h_level--;
180
	}
181
	add_ns("VegBIEN", ".table.column", phpPgAdmin("http://vegbiendev.nceas.ucsb.edu/phppgadmin/redirect.php?server=localhost%3A5432%3Aallow&database=vegbien&schema=public"));
182
	print("</blockquote>\n");
183
}
184
print("<h3>Primary databases</h3>");
185
{
186
	print("<blockquote>\n");
187
	add_ns("TNRS", ".term", fragment_override("http://tnrs.iplantcollaborative.org/instructions.html", "download_results"));
188
	add_ns("CTFS", "", $Redmine."/wiki/CTFS");
189
	{
190
		print("<blockquote>\n"); $h_level++;
191
		add_ns("CTFS-schema", ".table.column", $Redmine_svn."/inputs/CTFS/_archive/DBv5.txt#");
192
		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
		print("</blockquote>\n"); $h_level--;
195
	}
196
	add_ns("IH-db", ".term", $IH_db);
197
	print("</blockquote>\n");
198
}
199
print("<h3>People</h3>");
200
{
201
	print("<blockquote>\n");
202
	add_ns("Brad-Boyle", "", "mailto:bboyleATemail.arizona.edu");
203
	{
204
		print("<blockquote>\n"); $h_level++;
205
		$Brad_Boyle_VegCore = $Redmine_svn."/schemas/VegCore/Brad_Boyle";
206
		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
		print("</blockquote>\n"); $h_level--;
210
	}
211
	print("</blockquote>\n");
212
}
213
print("</blockquote>\n");
214
?>
215
				</td>
216
				<td nowrap="nowrap">
217
<?php
218
print("<blockquote>\n");
219
print("<h3>Institutions</h3>");
220
{
221
	print("<blockquote>\n");
222
	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
		"http://sweetgum.nybg.org/ih/"));
224
	print("</blockquote>\n");
225
}
226
print("</blockquote>\n");
227
?>
228
				</td>
229
			</tr>
230
		</table>
231
<?php
232
if (ends_with($root, '#')) # URL shortener requires fragment redirect
233
{
234
?>
235
		<script type="text/javascript">
236
var loc = document.location
237
if (loc.hash) document.location = rm_prefix('#', loc.hash)
238
		</script>
239
<?php
240
}
241
?>
242
	</body>
243
</html>
244
<?php
245
ob_end_flush();
246
?>
(2-2/5)