Project

General

Profile

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

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

    
6
function by_prefix($url, $main_url=null)
7
{
8
	if (!isset($main_url)) $main_url = $url;
9
	
10
	return function($path) use($url, $main_url)
11
	{
12
		return $path ? $url.$path : $main_url;
13
	};
14
}
15

    
16
$h_level = 5;
17
$root = $_SERVER["SERVER_NAME"].rm_suffix("/", $self_dir)."?";
18
# instead of PATH_INFO, to support the Apache ErrorDocument directive
19
$rel_fs_path = rm_prefix($self_dir, $_SERVER["REQUEST_URI"]);
20
$path = parse_dot_path($rel_fs_path);
21
$ns = strtolower($path->head);
22

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

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

    
50
function fragment_override($url, $fragment=null)
51
{
52
	return function($path) use($url, $fragment)
53
	{
54
		if (!isset($fragment))
55
		{
56
			$path = parse_dot_path($path);
57
			$fragment = $path->head;
58
			$path = $path->tail;
59
		}
60
		if ($path !== "") $url .= "?".$path;
61
		return $url."#".$fragment;
62
	};
63
}
64

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

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

    
105
ob_start(); // delay output in case there is a redirect
106
?>
107
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
108
<html xmlns="http://www.w3.org/1999/xhtml">
109
	<head>
110
		<title>VegPath</title>
111
		<link rel="stylesheet" type="text/css" href="/main.css" />
112
		<style type="text/css">
113
h1 {color: green;}
114
		</style>
115
		<script type="text/javascript" src="/util.js"></script>
116
	</head>
117
	<body>
118
		<h1>VegPath&nbsp;&nbsp; <small><a href="http://en.wikipedia.org/wiki/PURL">persistent URLs</a> for vegetation resources</small></h1>
119
		<div>Supported URL patterns:&nbsp;&nbsp; <small>(elements in <i>italics</i> are optional)</small></div>
120
<?php
121
# add and list URLs
122

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

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

    
129
$IH_db = phpMyAdmin($nimoy."?db=bien3_adb", "ih");
130

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

    
244
# full directory index
245
fpassthru(fopen($_SERVER["SCRIPT_URI"]."all?".$_SERVER["QUERY_STRING"], "r"));
246
?>
247
	</body>
248
</html>
(28-28/34)