]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - html/html/themes/ipfire/include/functions.pl
webinterface: Add links to the configuration wiki
[people/pmueller/ipfire-2.x.git] / html / html / themes / ipfire / 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
af731c7d 34require "${General::swroot}/lang.pl";
935f311e 35
af731c7d
AM
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 }
697a4d52 55 print '<a href="'.$link.'">'.$submenus->{$item}->{'caption'}.'</a>';
af731c7d
AM
56
57 &showsubmenu($subsubmenus) if ($subsubmenus);
58 print '</li>';
59 }
60 print "</ul>"
61}
62
63###############################################################################
64#
65# print menu html elements
66sub showmenu() {
697a4d52 67 print '<div id="cssmenu" class="bigbox fixed">';
865c7615 68
af731c7d 69 if ($settings{'SPEED'} ne 'off') {
865c7615
MT
70 print <<EOF;
71 <div id='traffic'>
72 <strong>Traffic:</strong>
f00699e8
AH
73 In <span id='rx_kbs'>--.-- bit/s</span> &nbsp;
74 Out <span id='tx_kbs'>--.-- bit/s</span>
865c7615
MT
75 </div>
76EOF
af731c7d 77 }
865c7615 78
697a4d52
MT
79 print "<ul>";
80 foreach my $k1 ( sort keys %$menu ) {
81 $link = getlink($menu->{$k1});
82 next if (!is_menu_visible($link) or $link eq '');
db309617 83 print '<li class="has-sub "><a href="#"><span>'.$menu->{$k1}->{'caption'}.'</span></a>';
697a4d52
MT
84 my $submenus = $menu->{$k1}->{'subMenu'};
85 &showsubmenu($submenus) if ($submenus);
86 print "</li>";
87 }
88
89 print "</ul></div>";
af731c7d
AM
90}
91
92###############################################################################
93#
94# print page opening html layout
95# @param page title
96# @param boh
97# @param extra html code for html head section
98# @param suppress menu option, can be numeric 1 or nothing.
99# menu will be suppressed if param is 1
100sub openpage {
101 my $title = shift;
102 my $boh = shift;
103 my $extrahead = shift;
104 my $suppressMenu = shift;
105 my @tmp = split(/\./, basename($0));
106 my $scriptName = @tmp[0];
af731c7d
AM
107
108 @URI=split ('\?', $ENV{'REQUEST_URI'} );
109 &General::readhash("${swroot}/main/settings", \%settings);
110 &genmenu();
111
697a4d52 112 my $headline = "IPFire";
2b6c5f25 113 if (($settings{'WINDOWWITHHOSTNAME'} eq 'on') || ($settings{'WINDOWWITHHOSTNAME'} eq '')) {
697a4d52 114 $headline = "$settings{'HOSTNAME'}.$settings{'DOMAINNAME'}";
af731c7d
AM
115 }
116
935f311e
MT
117
118print <<END;
7fbb7718 119<!DOCTYPE html>
af731c7d
AM
120<html>
121 <head>
697a4d52 122 <title>$headline - $title</title>
af731c7d
AM
123 $extrahead
124 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
125 <link rel="shortcut icon" href="/favicon.ico" />
dd2ef3b2 126 <script type="text/javascript" src="/include/jquery.js"></script>
9064bc72 127 <script src="/include/rrdimage.js"></script>
a636a760 128
0f431650 129 <script type="text/javascript">
a636a760
AH
130 function swapVisibility(id) {
131 \$('#' + id).toggle();
132 }
133 </script>
af731c7d 134END
935f311e 135
8186b372
JS
136
137print "<link href=\"/themes/ipfire/include/css/style.css\" rel=\"stylesheet\" type=\"text/css\" />\n";
138
935f311e 139
af731c7d
AM
140if ($settings{'SPEED'} ne 'off') {
141print <<END
f14e224b 142 <script type="text/javascript" src="/themes/ipfire/include/js/refreshInetInfo.js"></script>
af731c7d
AM
143END
144;
145}
146
af731c7d 147print <<END
697a4d52
MT
148 </head>
149 <body>
150 <div id="header" class="fixed">
af731c7d 151 <div id="logo">
725396af 152 <a href="https://www.ipfire.org" style="text-decoration: none;">
a2069a37 153 <img src="/themes/ipfire/images/tux2.png" style="float:left; margin-left: -3px; margin-top: -3px;"/>
af731c7d
AM
154END
155;
fe9f7588 156 if ($settings{'WINDOWWITHHOSTNAME'} ne 'off') {
a2069a37 157 print "</a><h1>$settings{'HOSTNAME'}.$settings{'DOMAINNAME'}</h1>";
af731c7d 158 } else {
a2069a37 159 print "<h1>IPFire</h1></a>";
af731c7d
AM
160 }
161
162print <<END
af731c7d
AM
163 </div>
164 </div>
165END
166;
167
168&showmenu() if ($suppressMenu != 1);
169
170print <<END
697a4d52
MT
171 <div class="bigbox fixed">
172 <div id="main_inner" class="fixed">
b0323d19
LAH
173 <div id="main_header">
174 <h1>$title</h1>
175END
176;
177
178# Print user manual link
179my $manual_url = &Header::get_manualpage_url($scriptName);
180if($manual_url) {
181 print <<END
182 <span><a href="$manual_url" title="$Lang::tr{'online help en'}" target="_blank"><img src="/images/help-browser.png" alt="$Lang::tr{'online help en'}"></a></span>
183END
184;
185}
186
187print <<END
188 </div>
af731c7d
AM
189END
190;
191}
192
193###############################################################################
194#
195# print page opening html layout without menu
196# @param page title
197# @param boh
198# @param extra html code for html head section
199sub openpagewithoutmenu {
200 openpage(shift,shift,shift,1);
201 return;
202}
203
af731c7d
AM
204###############################################################################
205#
206# print page closing html layout
207
208sub closepage () {
c3f00878
MT
209 open(FILE, "</etc/system-release");
210 my $system_release = <FILE>;
6e8089a9 211 $system_release =~ s/core/Core Update /;
c3f00878 212 close(FILE);
af731c7d 213
697a4d52 214print <<END;
af731c7d
AM
215 </div>
216 </div>
697a4d52
MT
217
218 <div id="footer" class='bigbox fixed'>
c3f00878 219 <span class="pull-right">
725396af
PM
220 <a href="https://www.ipfire.org/" target="_blank"><strong>IPFire.org</strong></a> &bull;
221 <a href="https://www.ipfire.org/donate" target="_blank">$Lang::tr{'support donation'}</a>
c3f00878
MT
222 </span>
223
224 <strong>$system_release</strong>
697a4d52 225 </div>
af731c7d
AM
226</body>
227</html>
af731c7d
AM
228END
229;
230}
231
232###############################################################################
233#
234# print big box opening html layout
697a4d52 235sub openbigbox {
af731c7d
AM
236}
237
238###############################################################################
239#
240# print big box closing html layout
697a4d52 241sub closebigbox {
af731c7d
AM
242}
243
244###############################################################################
245#
246# print box opening html layout
247# @param page width
248# @param page align
249# @param page caption
697a4d52 250sub openbox {
af731c7d
AM
251 $width = $_[0];
252 $align = $_[1];
253 $caption = $_[2];
254
480f354d
AH
255 if($align eq 'center') {
256 print "<div class='post' align='center'>\n"
257 }
258 else {
259 print "<div class='post'>\n";
260 }
697a4d52
MT
261
262 if ($caption) {
263 print "<h2>$caption</h2>\n";
264 }
af731c7d
AM
265}
266
267###############################################################################
268#
269# print box closing html layout
697a4d52
MT
270sub closebox {
271 print "</div>";
af731c7d
AM
272}
273
2741;