ipfire-new: Cleanup CSS code.
[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 }
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>
73 In <span id='rx_kbs'>--.-- Bit/s</span> &nbsp;
74 Out <span id='tx_kbs'>--.-- Bit/s</span>
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 '');
83 print '<li class="has-sub "><a><span>'.$menu->{$k1}->{'caption'}.'</span></a>';
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";
af731c7d 113 if ($settings{'WINDOWWITHHOSTNAME'} eq 'on') {
697a4d52 114 $headline = "$settings{'HOSTNAME'}.$settings{'DOMAINNAME'}";
af731c7d
AM
115 }
116
117print <<END
118<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
119<html>
120 <head>
697a4d52 121 <title>$headline - $title</title>
af731c7d
AM
122 $extrahead
123 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
124 <link rel="shortcut icon" href="/favicon.ico" />
125 <link href="/themes/ipfire-new/include/css/style.css" rel="stylesheet" type="text/css" />
126 <script type="text/javascript" src="/include/jquery-1.9.1.min.js"></script>
127END
128;
129if ($settings{'SPEED'} ne 'off') {
130print <<END
131 <script type="text/javascript" src="/themes/ipfire-new/include/js/refreshInetInfo.js"></script>
132END
133;
134}
135
136if ($settings{'FX'} ne 'off') {
137print <<END
138 <meta http-equiv="Page-Enter" content="blendTrans(Duration=0.5,Transition=12)" />
139 <meta http-equiv="Page-Exit" content="blendTrans(Duration=0.5,Transition=12)" />
140END
141;
142}
143
144print <<END
697a4d52
MT
145 </head>
146 <body>
147 <div id="header" class="fixed">
af731c7d
AM
148 <div id="logo">
149END
150;
151 if ($settings{'WINDOWWITHHOSTNAME'} eq 'on') {
697a4d52 152 print "<h1>$settings{'HOSTNAME'}.$settings{'DOMAINNAME'}</h1>";
af731c7d 153 } else {
697a4d52 154 print "<h1>IPFire</h1>";
af731c7d
AM
155 }
156
157print <<END
af731c7d
AM
158 </div>
159 </div>
160END
161;
162
163&showmenu() if ($suppressMenu != 1);
164
165print <<END
697a4d52
MT
166 <div class="bigbox fixed">
167 <div id="main_inner" class="fixed">
168 <h1>$title</h1>
af731c7d
AM
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
af731c7d
AM
184###############################################################################
185#
186# print page closing html layout
187
188sub closepage () {
189 my $status = &connectionstatus();
190 my $uptime = `/usr/bin/uptime|cut -d \" \" -f 4-`;
191 $uptime =~ s/year(s|)/$Lang::tr{'year'}/;
192 $uptime =~ s/month(s|)/$Lang::tr{'month'}/;
193 $uptime =~ s/days/$Lang::tr{'days'}/;
194 $uptime =~ s/day /$Lang::tr{'day'}/;
195 $uptime =~ s/user(s|)/$Lang::tr{'user'}/;
196 $uptime =~ s/load average/$Lang::tr{'uptime load average'}/;
af731c7d 197
697a4d52 198print <<END;
af731c7d
AM
199 </div>
200 </div>
697a4d52
MT
201
202 <div id="footer" class='bigbox fixed'>
203 $status Uptime: $uptime
204 </div>
af731c7d
AM
205</body>
206</html>
af731c7d
AM
207END
208;
209}
210
211###############################################################################
212#
213# print big box opening html layout
697a4d52 214sub openbigbox {
af731c7d
AM
215}
216
217###############################################################################
218#
219# print big box closing html layout
697a4d52 220sub closebigbox {
af731c7d
AM
221}
222
223###############################################################################
224#
225# print box opening html layout
226# @param page width
227# @param page align
228# @param page caption
697a4d52 229sub openbox {
af731c7d
AM
230 $width = $_[0];
231 $align = $_[1];
232 $caption = $_[2];
233
697a4d52
MT
234 print "<div class='post' align='$align'>\n";
235
236 if ($caption) {
237 print "<h2>$caption</h2>\n";
238 }
af731c7d
AM
239}
240
241###############################################################################
242#
243# print box closing html layout
697a4d52
MT
244sub closebox {
245 print "</div>";
af731c7d
AM
246}
247
2481;