]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blame - html/html/themes/ipfire-new/include/functions.pl
ipfire-new: Fix encoding of refreshInetInfo.js.
[people/teissler/ipfire-2.x.git] / html / html / themes / ipfire-new / include / functions.pl
CommitLineData
af731c7d
AM
1#!/usr/bin/perl
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
5# Copyright (C) 2007 Michael Tremer & Christian Schmidt #
6# #
7# This program is free software: you can redistribute it and/or modify #
8# it under the terms of the GNU General Public License as published by #
9# the Free Software Foundation, either version 3 of the License, or #
10# (at your option) any later version. #
11# #
12# This program is distributed in the hope that it will be useful, #
13# but WITHOUT ANY WARRANTY; without even the implied warranty of #
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15# GNU General Public License for more details. #
16# #
17# You should have received a copy of the GNU General Public License #
18# along with this program. If not, see <http://www.gnu.org/licenses/>. #
19# #
20###############################################################################
21# #
22# Theme file for IPfire (based on ipfire theme) #
23# Author kay-michael köhler kmk <michael@koehler.tk> #
24# #
25# Version 1.0 March, 6th 2013 #
26###############################################################################
27# #
28# Modyfied theme by a.marx@ipfire.org January 2014 #
29# #
30# Cleanup code, deleted unused code and rewrote the rest to get a new working #
31# IPFire default theme. #
32###############################################################################
33
34use File::Basename;
35require "${General::swroot}/lang.pl";
36###############################################################################
37#
38# print menu html elements for submenu entries
39# @param submenu entries
40sub showsubmenu() {
41 my $submenus = shift;
42
43 print "<ul>";
44 foreach my $item (sort keys %$submenus) {
45 $link = getlink($submenus->{$item});
46 next if (!is_menu_visible($link) or $link eq '');
47
48 my $subsubmenus = $submenus->{$item}->{'subMenu'};
49
50 if ($subsubmenus) {
51 print '<li class="has-sub ">';
52 } else {
53 print '<li>';
54 }
55 print '<a href="'.$link.'"><span>'.$submenus->{$item}->{'caption'}.'</span></a>';
56
57 &showsubmenu($subsubmenus) if ($subsubmenus);
58 print '</li>';
59 }
60 print "</ul>"
61}
62
63###############################################################################
64#
65# print menu html elements
66sub showmenu() {
67 print '<div id="cssmenu"><ul>';
68 foreach my $k1 ( sort keys %$menu ) {
69 $link = getlink($menu->{$k1});
70 next if (!is_menu_visible($link) or $link eq '');
71 print '<li class="has-sub "><a><span>'.$menu->{$k1}->{'caption'}.'</span></a>';
72 my $submenus = $menu->{$k1}->{'subMenu'};
73 &showsubmenu($submenus) if ($submenus);
74 print "</li>";
75 }
76 if ($settings{'SPEED'} ne 'off') {
77 print"<div id='traffic'>";
78 print"<table><tr><td style='font-weight: bold;'>Traffic: &nbsp;</td>";
79 print"<td id='bandwidthCalculationContainer'>In <span id='rx_kbs'></span> &nbsp; Out <span id='tx_kbs'></span></td>";
80 print"</tr></table>";
81 print '</ul></div></div>';
82 }
83}
84
85###############################################################################
86#
87# print page opening html layout
88# @param page title
89# @param boh
90# @param extra html code for html head section
91# @param suppress menu option, can be numeric 1 or nothing.
92# menu will be suppressed if param is 1
93sub openpage {
94 my $title = shift;
95 my $boh = shift;
96 my $extrahead = shift;
97 my $suppressMenu = shift;
98 my @tmp = split(/\./, basename($0));
99 my $scriptName = @tmp[0];
100 my $h2 = $title;
101
102 @URI=split ('\?', $ENV{'REQUEST_URI'} );
103 &General::readhash("${swroot}/main/settings", \%settings);
104 &genmenu();
105
106 $title = "IPFire - $title";
107 if ($settings{'WINDOWWITHHOSTNAME'} eq 'on') {
108 $title = "$settings{'HOSTNAME'}.$settings{'DOMAINNAME'} - $title";
109 }
110
111print <<END
112<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
113<html>
114 <head>
115 <title>$title</title>
116 $extrahead
117 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
118 <link rel="shortcut icon" href="/favicon.ico" />
119 <link href="/themes/ipfire-new/include/css/style.css" rel="stylesheet" type="text/css" />
120 <script type="text/javascript" src="/include/jquery-1.9.1.min.js"></script>
121END
122;
123if ($settings{'SPEED'} ne 'off') {
124print <<END
125 <script type="text/javascript" src="/themes/ipfire-new/include/js/refreshInetInfo.js"></script>
126END
127;
128}
129
130if ($settings{'FX'} ne 'off') {
131print <<END
132 <meta http-equiv="Page-Enter" content="blendTrans(Duration=0.5,Transition=12)" />
133 <meta http-equiv="Page-Exit" content="blendTrans(Duration=0.5,Transition=12)" />
134END
135;
136}
137
138print <<END
139 </head>
140 <body>
141END
142;
143
144print <<END
145<!-- IPFIRE HEADER -->
146 <div id="header_inner" class="fixed">
147 <div id="logo">
148END
149;
150 if ($settings{'WINDOWWITHHOSTNAME'} eq 'on') {
151 print "<h1><span>$settings{'HOSTNAME'}.$settings{'DOMAINNAME'}</span></h1><br />";
152 } else {
153 print "<h1><span>IPFire</span></h1><br />";
154 }
155
156print <<END
157 <h2>$h2</h2>
158 </div>
159 </div>
160END
161;
162
163&showmenu() if ($suppressMenu != 1);
164
165print <<END
166<div id="main">
167 <div id="main_inner" class="fixed">
168 <div id="columnA_2columns">
169END
170;
171}
172
173###############################################################################
174#
175# print page opening html layout without menu
176# @param page title
177# @param boh
178# @param extra html code for html head section
179sub openpagewithoutmenu {
180 openpage(shift,shift,shift,1);
181 return;
182}
183
184
185###############################################################################
186#
187# print page closing html layout
188
189sub closepage () {
190 my $status = &connectionstatus();
191 my $uptime = `/usr/bin/uptime|cut -d \" \" -f 4-`;
192 $uptime =~ s/year(s|)/$Lang::tr{'year'}/;
193 $uptime =~ s/month(s|)/$Lang::tr{'month'}/;
194 $uptime =~ s/days/$Lang::tr{'days'}/;
195 $uptime =~ s/day /$Lang::tr{'day'}/;
196 $uptime =~ s/user(s|)/$Lang::tr{'user'}/;
197 $uptime =~ s/load average/$Lang::tr{'uptime load average'}/;
198print <<END
199 <!-- closepage begin -->
200 </div>
201 </div>
202END
203;
204
205print "<div id='columnC_2columns'>";
206print <<END
207 <table cellspacing="5" class="statusdisplay" border="0">
208 <tr><td align='center'>$status Uptime: $uptime</td></tr>
209END
210;
211
212print <<END
213 </table>
214 </div>
215 </div>
216</body>
217</html>
218<!-- closepage end -->
219END
220;
221}
222
223###############################################################################
224#
225# print big box opening html layout
226sub openbigbox
227{
228}
229
230###############################################################################
231#
232# print big box closing html layout
233sub closebigbox
234{
235}
236
237###############################################################################
238#
239# print box opening html layout
240# @param page width
241# @param page align
242# @param page caption
243sub openbox
244{
245 $width = $_[0];
246 $align = $_[1];
247 $caption = $_[2];
248
249print <<END
250<!-- openbox -->
251 <div class="post" align="$align">
252END
253;
254if ($caption) { print "<h3>$caption</h3>\n"; } else { print "&nbsp;"; }
255}
256
257###############################################################################
258#
259# print box closing html layout
260sub closebox
261{
262 print <<END
263 </div>
264 <br class="clear" />
265 <!-- closebox -->
266END
267;
268}
269
2701;