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