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