]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - html/html/themes/ipfire-new/include/functions.pl
ipfire-new: Re-indent CSS file.
[people/teissler/ipfire-2.x.git] / html / html / themes / ipfire-new / include / functions.pl
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
34 use File::Basename;
35 require "${General::swroot}/lang.pl";
36 ###############################################################################
37 #
38 # print menu html elements for submenu entries
39 # @param submenu entries
40 sub 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
66 sub 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 print "</ul>";
77
78 if ($settings{'SPEED'} ne 'off') {
79 print <<EOF;
80 <div id='traffic'>
81 <strong>Traffic:</strong>
82 In <span id='rx_kbs'>--.-- Bit/s</span> &nbsp;
83 Out <span id='tx_kbs'>--.-- Bit/s</span>
84 </div>
85 EOF
86 }
87
88 print "</div>";
89 }
90
91 ###############################################################################
92 #
93 # print page opening html layout
94 # @param page title
95 # @param boh
96 # @param extra html code for html head section
97 # @param suppress menu option, can be numeric 1 or nothing.
98 # menu will be suppressed if param is 1
99 sub openpage {
100 my $title = shift;
101 my $boh = shift;
102 my $extrahead = shift;
103 my $suppressMenu = shift;
104 my @tmp = split(/\./, basename($0));
105 my $scriptName = @tmp[0];
106 my $h2 = $title;
107
108 @URI=split ('\?', $ENV{'REQUEST_URI'} );
109 &General::readhash("${swroot}/main/settings", \%settings);
110 &genmenu();
111
112 $title = "IPFire - $title";
113 if ($settings{'WINDOWWITHHOSTNAME'} eq 'on') {
114 $title = "$settings{'HOSTNAME'}.$settings{'DOMAINNAME'} - $title";
115 }
116
117 print <<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>
121 <title>$title</title>
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>
127 END
128 ;
129 if ($settings{'SPEED'} ne 'off') {
130 print <<END
131 <script type="text/javascript" src="/themes/ipfire-new/include/js/refreshInetInfo.js"></script>
132 END
133 ;
134 }
135
136 if ($settings{'FX'} ne 'off') {
137 print <<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)" />
140 END
141 ;
142 }
143
144 print <<END
145 </head>
146 <body>
147 END
148 ;
149
150 print <<END
151 <!-- IPFIRE HEADER -->
152 <div id="header_inner" class="fixed">
153 <div id="logo">
154 END
155 ;
156 if ($settings{'WINDOWWITHHOSTNAME'} eq 'on') {
157 print "<h1><span>$settings{'HOSTNAME'}.$settings{'DOMAINNAME'}</span></h1><br />";
158 } else {
159 print "<h1><span>IPFire</span></h1><br />";
160 }
161
162 print <<END
163 </div>
164 </div>
165 END
166 ;
167
168 &showmenu() if ($suppressMenu != 1);
169
170 print <<END
171 <div id="main">
172 <div id="main_inner" class="fixed">
173 <h1>$h2</h1>
174
175 <div id="columnA_2columns">
176 END
177 ;
178 }
179
180 ###############################################################################
181 #
182 # print page opening html layout without menu
183 # @param page title
184 # @param boh
185 # @param extra html code for html head section
186 sub openpagewithoutmenu {
187 openpage(shift,shift,shift,1);
188 return;
189 }
190
191
192 ###############################################################################
193 #
194 # print page closing html layout
195
196 sub closepage () {
197 my $status = &connectionstatus();
198 my $uptime = `/usr/bin/uptime|cut -d \" \" -f 4-`;
199 $uptime =~ s/year(s|)/$Lang::tr{'year'}/;
200 $uptime =~ s/month(s|)/$Lang::tr{'month'}/;
201 $uptime =~ s/days/$Lang::tr{'days'}/;
202 $uptime =~ s/day /$Lang::tr{'day'}/;
203 $uptime =~ s/user(s|)/$Lang::tr{'user'}/;
204 $uptime =~ s/load average/$Lang::tr{'uptime load average'}/;
205 print <<END
206 <!-- closepage begin -->
207 </div>
208 </div>
209 END
210 ;
211
212 print "<div id='columnC_2columns'>";
213 print <<END
214 <table cellspacing="5" class="statusdisplay" border="0">
215 <tr><td align='center'>$status Uptime: $uptime</td></tr>
216 END
217 ;
218
219 print <<END
220 </table>
221 </div>
222 </div>
223 </body>
224 </html>
225 <!-- closepage end -->
226 END
227 ;
228 }
229
230 ###############################################################################
231 #
232 # print big box opening html layout
233 sub openbigbox
234 {
235 }
236
237 ###############################################################################
238 #
239 # print big box closing html layout
240 sub closebigbox
241 {
242 }
243
244 ###############################################################################
245 #
246 # print box opening html layout
247 # @param page width
248 # @param page align
249 # @param page caption
250 sub openbox
251 {
252 $width = $_[0];
253 $align = $_[1];
254 $caption = $_[2];
255
256 print <<END
257 <!-- openbox -->
258 <div class="post" align="$align">
259 END
260 ;
261 if ($caption) { print "<h3>$caption</h3>\n"; } else { print "&nbsp;"; }
262 }
263
264 ###############################################################################
265 #
266 # print box closing html layout
267 sub closebox
268 {
269 print <<END
270 </div>
271 <br class="clear" />
272 <!-- closebox -->
273 END
274 ;
275 }
276
277 1;