forked from BOINC/boinc-site
-
Notifications
You must be signed in to change notification settings - Fork 0
/
keywords.php
133 lines (119 loc) · 3.3 KB
/
keywords.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2017 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// BOINC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
// show keywords as XML or as C or Python defines
require_once("../inc/xml.inc");
require_once("../inc/util.inc");
require_once("../inc/keywords.inc");
function kw_xml($id, $kw) {
echo "<keyword>
<id>$id</id>
<category>$kw->category</category>
<level>$kw->level</level>
<name>$kw->name</name>
<symbol>$kw->symbol</symbol>
";
if ($kw->level > 0) {
echo " <parent>$kw->parent</parent>\n";
}
echo "</keyword>\n";
}
function show_xml() {
global $job_keywords;
xml_header();
echo "<keywords>\n";
foreach ($job_keywords as $id=>$kw) {
kw_xml($id, $kw);
}
echo "</keywords>\n";
}
function show_c() {
global $job_keywords;
header('Content-type:text/plain');
foreach ($job_keywords as $id=>$kw) {
echo "#define $kw->symbol $id\n";
}
}
function show_python() {
global $job_keywords;
header('Content-type:text/plain');
foreach ($job_keywords as $id=>$kw) {
echo "$kw->symbol = $id\n";
}
}
function show_bash() {
global $job_keywords;
header('Content-type:text/plain');
foreach ($job_keywords as $id=>$kw) {
echo "$kw->symbol='$id'\n";
}
}
function show_php() {
global $job_keywords;
header('Content-type:text/plain');
foreach ($job_keywords as $id=>$kw) {
echo "define('$kw->symbol', $id);\n";
}
}
function show_kw_html($id, $kw) {
global $job_keywords;
$x = "";
for ($i=0; $i<$kw->level; $i++) {
$x .= " ";
}
row_array(array($x.$kw->name, $kw->symbol, $id));
foreach ($job_keywords as $id2=>$kw2) {
if ($kw2->parent == $id) {
show_kw_html($id2, $kw2);
}
}
}
function show_category_html($category) {
global $job_keywords;
foreach ($job_keywords as $id=>$kw) {
if ($kw->level) continue;
if ($kw->category != $category) continue;
show_kw_html($id, $kw);
}
}
function show_html() {
page_head("Keywords");
start_table('table-striped');
row_heading("Science Area");
row_array(array("name", "symbol", "ID"));
show_category_html(KW_CATEGORY_SCIENCE);
row_heading("Location");
row_array(array("name", "symbol", "ID"));
show_category_html(KW_CATEGORY_LOC);
end_table();
page_tail();
}
$header = get_str('header', true);
if ($header == 'c') {
show_c();
} else if ($header == 'python') {
show_python();
} else if ($header == 'bash') {
show_bash();
} else if ($header == 'php') {
show_php();
} else if ($header == 'html') {
show_html();
} else {
show_xml();
}
?>