-
Notifications
You must be signed in to change notification settings - Fork 0
/
names_info.php
119 lines (103 loc) · 2.99 KB
/
names_info.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
session_start();
include "./lib/config.php";
include "./lib/html_utils.php";
include "./lib/php_utils.php";
$eb_path = "http://" . $config['ebhost'] . "/" . $config['eb_path'] . '/';
$html_path = "http://" . $config['ebhost'] . "/" . $config['html_path'] . '/';
$share_path = "http://" . $config['ebhost'] . "/" . $config['share_path'] . '/';
$names = $_SESSION['names'];
if (!$names) {
$db_handle = eb_connect_pg($config);
$names = array();
$sources = $_SESSION['sources'];
$str = "SELECT DISTINCT(name) FROM (";
$i = 0;
foreach ($sources as $source) {
if ($i > 0) $str = $str . " UNION ALL";
switch ($source['term']) {
case 'biotable':
case 'biogeographic':
$str = $str . " SELECT " . $source['namefield'] . " AS name FROM " . $source['dbloc'];
break;
case 'biotree':
$str = $str . " SELECT label AS name FROM biosql.node WHERE tree_id=" . $source['tree_id'];
break;
case 'biorelational':
$str = $str . " SELECT t.binomial AS name FROM gpdd.taxon t, gpdd.main m WHERE m.\"TaxonID\"=t.\"TaxonID\"";
break;
}
$i++;
}
$str = $str . ") AS name";
//echo "$str<br>";
$res = pg_query($db_handle, $str);
$names = pg_fetch_all_columns($res);
}
sort($names);
$c = count($names);
#HTML
echo '<html>';
#HEAD
echo '<head>';
echo "<title>Names Info</title>";
echo '<link type="text/css" rel="stylesheet" href="' . $share_path . 'entangled_bank.css">';
echo '</head>';
echo '<script src="./scripts/utils.js" type="text/javascript"></script>';
#BODY
echo "<body>";
echo "<div id='page'>";
html_entangled_bank_header($stage, $eb_path, $html_path, $share_path);
# HEADER
echo "<div id='info_header_div' class='header_div'>";
echo "<table border='0'>";
echo "<tr>";
echo "<td class='query_title'>", html_query_image('bionames', 'non-active', null, 'source', false), "</td>";
echo "<td id='query_header_title'>Names</td>";
echo "</tr>";
echo "</table>";
echo "</div>";
# INFO
echo "<table>";
echo "<tr>";
$t = "Names list format";
echo "<td class='query_title' title='$t'>Names</td>";
echo "<td>$c</td>";
echo "</tr>";
$i = 0;
$str = "";
//sort($names);
foreach($names as $name) {
if ($i == 0) {
$str = $name;
} else {
$str = $str . "\n$name";
}
$i++;
}
echo "<tr>";
echo "<td class='query_title' title='$t'>Names</td>";
echo "<td>";
echo "<textarea id='names_list' class='names_list'>$str</textarea>";
echo "</td>";
echo "</tr>";
echo "<tr>";
$t = "Names list format";
echo "<td class='query_title' title='$t'>Names Format</td>";
echo "<td>";
echo "<SELECT id='names_format' class='eb_info' onChange='textareaFormat(\"names_list\")'>";
echo "<OPTION value='0'>Not Delineated with New Line Separator</OPTION>";
echo "<OPTION value='1'>Delineated with New Line Separator</OPTION>";
echo "<OPTION value='2'>Not Delineated with Comma Separator</OPTION>";
echo "<OPTION value='3'>Delineated with Comma Separator</OPTION>";
echo "</SELECT>";
echo "<td>";
echo "</tr>";
html_queries_sql();
echo "</table>";
echo "<br>";
html_entangled_bank_footer();
echo "</div>";
echo "</body>";
echo '</html>';
?>