forked from teleyinex/jarifa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
html.inc
201 lines (177 loc) · 7.28 KB
/
html.inc
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<?php
/*
Copyright 2008 Daniel Lombraña González, David P. Anderson, Francisco Fernández de Vega
This file is part of Jarifa.
Jarifa is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Jarifa 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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Jarifa. If not, see <http://www.gnu.org/licenses/>.
*/
require_once("model/data.inc");
class html
{
public $logo;
public $conf;
public $volunteer_enabled = 1; // By default Volunteer Role is enabled
function __construct($language='en_US.utf8')
{
putenv("LANG=$language");
setlocale(LC_ALL, $language);
$domain = 'messages';
bindtextdomain($domain, "locale");
textdomain($domain);
}
function load_config()
{
$this->conf = simplexml_load_file("conf/jarifa.conf");
$this->logo = $this->conf->account_manager->logo;
$this->volunteer_enabled = $this->conf->account_manager->volunteer;
}
function header($msg=null,$js=null)
{
$title = gettext("Jarifa Server");
printf('
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="content-type">
<title>'.$title.'</title>
<style type="text/css">
@import url("views/style.css");
</style>
</head>');
if ($js == null)
{
print('<body onload="initialize()" onunload="GUnload()">');
}
else
{
print('<script type="text/javascript" src="'.$js.'"></script>');
}
print('<div id="container">
<div id="logo" align="center">
<a href=index.php><img src="'.$this->logo.'" alt="logo" border="0"></a>
</div>
<div id="header">
<h1>'.$msg.'</h1>
</div>
');
}
function menu($role=null,$h2=null)
{
printf('
<div id="menu">
<ul id="menu_list">
<li><a href="index.php">'.gettext("Start").'</a>
');
switch ($role)
{
case 'allocator':
{
printf('<li><a href="index.php?action=user">'.gettext("Profile").'</a>');
printf('<li><a href="index.php?action=project">'.gettext("Projects").'</a>');
printf('<li><a href="index.php?action=stat">'.gettext("Statistics").'</a>');
printf('<li><a href="index.php?action=logout">'.gettext("Log Out").'</a>');
break;
}
case 'volunteer':
{
printf('<li><a href="index.php?action=host">'.gettext("Hosts").'</a>
<li><a href="index.php?action=user">'.gettext("Profile").'</a>
<li><a href="index.php?action=logout">'.gettext("Log Out").'</a>');
//printf('<li><a href="index.php?action=stat">'.gettext("Statistics").'</a>');
break;
}
case 'supplier':
{
printf('<li><a href="index.php?action=host">'.gettext("Hosts").'</a>
<li><a href="index.php?action=user">'.gettext("Profile").'</a>
<li><a href="index.php?action=pool">'.gettext("Pools").'</a>
<li><a href="index.php?action=stat">'.gettext("Statistics").'</a>
<li><a href="index.php?action=logout">'.gettext("Log Out").'</a>');
break;
}
case 'root':
{
printf('<li><a href="index.php?action=project">'.gettext("Projects").'</a>
<li><a href="index.php?action=host">'.gettext("Hosts").'</a>
<li><a href="index.php?action=pool">'.gettext("Pools").'</a>
<li><a href="index.php?action=user">'.gettext("Users").'</a>
<li><a href="index.php?action=stat">'.gettext("Statistics").'</a>
<li><a href="index.php?action=logout">'.gettext("Log Out").'</a>');
break;
}
}
printf ('
</ul></div>
<div id="content">
<h2>'.$h2.'</h2>
');
}
function table_project($obj)
{
// acction=up -> Update Project -> up
printf('<table border=1 align=center cellpadding="4">');
printf('<tr><td align="center">Name</td><td align="center">Share</td></tr>');
$row = count($obj);
for ($i=0 ; $i<$row;$i++)
{
printf ("<tr>");
printf ('<td align=center><a href=index.php?action=ed_project&id='.$obj[$i]->id.'>'.$obj[$i]->name.'</a></td><td align=center>'.$obj[$i]->share.'');
printf ("\n</tr>");
}
printf("</table>");
printf('<div style="text-align: center;"><a href=index.php?action=vin_project>'.gettext("New Project").'</a></div>');
}
function table_project_edit($obj)
{
printf('<form method="post" action="index.php?action=up_project&id='.$obj->id.'" name="project">');
printf('<table border=1 align=center cellpading="4">');
printf('<tr><td align="center">Name</td><td align="center">Share</td><td align="center">Delete</td></tr>');
printf ('<tr>');
printf ('<td align=center><a href=index.php?action=ed_project&id='.$obj->id.'>'.$obj->name.'</a></td><td
align="center"><input name="share" size="2" value="'.$obj->share.'"><td align=center><input name="delete" type="checkbox"></td>');
printf ("\n</tr>");
printf('<tr align="center"> <td colspan="3" rowspan="1"><input name="submit" type="submit"></td> </tr>');
printf("</table>");
printf("</form>");
}
function empty_table()
{
printf('
<table style="text-align: left; width: 100px; height: 391px;"
border="0" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
');
}
function footer($container=false)
{
printf('
</div>
<div id="credits" align="center">
<a href="http://validator.w3.org/check?uri=referer"><img style="border:0;"
src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31px" width="88px"></a>
<a href="http://jigsaw.w3.org/css-validator/"><img style="border:0;width:88px;height:31px" src="img/vcss.png" alt="vcss"></a>
<a href="http://www.fsf.org/licensing/licenses/agpl-3.0.html"><img style="border:0;" src="img/agplv3.png" alt="agplv3"></a>
<a href="http://github.com/teleyinex/jarifa"><img style="border:0;" src="img/download.png" alt="download"></a>
</div>
');
if ($container) print("</div>");
printf('
</body>
</html>
');
}
}
?>