Project

General

Profile

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

    
4
# config
5
$alias = "path.vg/";
6
#$alias = "j.mp/vegpath#";
7

    
8
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
$h_level = 5;
19
$self_dir = dirname($_SERVER["SCRIPT_NAME"]);
20
# 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
$ns = strtolower($path->head);
24

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

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

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

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

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

    
107
ob_start(); // delay output in case there is a redirect
108
?>
109
<html>
110
	<head>
111
		<title>VegPath</title>
112
		<link rel="stylesheet" type="text/css" href="main.css" />
113
		<style type="text/css">
114
h1 {color: green;}
115
		</style>
116
		<script type="text/javascript" src="util.js"></script>
117
	</head>
118
	<body>
119
		<h1>VegPath&nbsp;&nbsp; <small><a href="http://en.wikipedia.org/wiki/PURL">persistent URLs</a> for vegetation resources</small></h1>
120
		<div>Supported URL patterns:&nbsp;&nbsp; <small>(elements in <i>italics</i> are optional)</small></div>
121
		<p></p>
122
<?php
123
# add and list URLs
124

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

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

    
131
$IH_db = phpMyAdmin($nimoy."?db=bien3_adb", "ih");
132

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