]>
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 | 34 | require "${General::swroot}/lang.pl"; |
935f311e | 35 | |
af731c7d AM |
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 | } | |
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 | |
66 | sub 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> |
74 | Out <span id='tx_kbs'>--.-- bit/s</span> | |
865c7615 MT |
75 | </div> |
76 | EOF | |
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 | |
100 | sub 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 | my @stylesheets = ("style.css"); |
118 | if ($THEME_NAME eq "ipfire-rounded") { | |
119 | push(@stylesheets, "style-rounded.css"); | |
120 | } | |
121 | ||
122 | print <<END; | |
7fbb7718 | 123 | <!DOCTYPE html> |
af731c7d AM |
124 | <html> |
125 | <head> | |
697a4d52 | 126 | <title>$headline - $title</title> |
af731c7d AM |
127 | $extrahead |
128 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> | |
129 | <link rel="shortcut icon" href="/favicon.ico" /> | |
dd2ef3b2 | 130 | <script type="text/javascript" src="/include/jquery.js"></script> |
a636a760 | 131 | |
0f431650 | 132 | <script type="text/javascript"> |
a636a760 AH |
133 | function swapVisibility(id) { |
134 | \$('#' + id).toggle(); | |
135 | } | |
136 | </script> | |
af731c7d | 137 | END |
935f311e MT |
138 | |
139 | foreach my $stylesheet (@stylesheets) { | |
140 | print "<link href=\"/themes/ipfire/include/css/$stylesheet\" rel=\"stylesheet\" type=\"text/css\" />\n"; | |
141 | } | |
142 | ||
af731c7d AM |
143 | if ($settings{'SPEED'} ne 'off') { |
144 | print <<END | |
f14e224b | 145 | <script type="text/javascript" src="/themes/ipfire/include/js/refreshInetInfo.js"></script> |
af731c7d AM |
146 | END |
147 | ; | |
148 | } | |
149 | ||
af731c7d | 150 | print <<END |
697a4d52 MT |
151 | </head> |
152 | <body> | |
153 | <div id="header" class="fixed"> | |
af731c7d | 154 | <div id="logo"> |
a2069a37 L |
155 | <a href="http://www.ipfire.org" style="text-decoration: none;"> |
156 | <img src="/themes/ipfire/images/tux2.png" style="float:left; margin-left: -3px; margin-top: -3px;"/> | |
af731c7d AM |
157 | END |
158 | ; | |
fe9f7588 | 159 | if ($settings{'WINDOWWITHHOSTNAME'} ne 'off') { |
a2069a37 | 160 | print "</a><h1>$settings{'HOSTNAME'}.$settings{'DOMAINNAME'}</h1>"; |
af731c7d | 161 | } else { |
a2069a37 | 162 | print "<h1>IPFire</h1></a>"; |
af731c7d AM |
163 | } |
164 | ||
165 | print <<END | |
af731c7d AM |
166 | </div> |
167 | </div> | |
168 | END | |
169 | ; | |
170 | ||
171 | &showmenu() if ($suppressMenu != 1); | |
172 | ||
173 | print <<END | |
697a4d52 MT |
174 | <div class="bigbox fixed"> |
175 | <div id="main_inner" class="fixed"> | |
176 | <h1>$title</h1> | |
af731c7d AM |
177 | END |
178 | ; | |
179 | } | |
180 | ||
181 | ############################################################################### | |
182 | # | |
183 | # print page opening html layout without menu | |
184 | # @param page title | |
185 | # @param boh | |
186 | # @param extra html code for html head section | |
187 | sub openpagewithoutmenu { | |
188 | openpage(shift,shift,shift,1); | |
189 | return; | |
190 | } | |
191 | ||
af731c7d AM |
192 | ############################################################################### |
193 | # | |
194 | # print page closing html layout | |
195 | ||
196 | sub closepage () { | |
c3f00878 MT |
197 | open(FILE, "</etc/system-release"); |
198 | my $system_release = <FILE>; | |
6e8089a9 | 199 | $system_release =~ s/core/Core Update /; |
c3f00878 | 200 | close(FILE); |
af731c7d | 201 | |
697a4d52 | 202 | print <<END; |
af731c7d AM |
203 | </div> |
204 | </div> | |
697a4d52 MT |
205 | |
206 | <div id="footer" class='bigbox fixed'> | |
c3f00878 MT |
207 | <span class="pull-right"> |
208 | <a href="http://www.ipfire.org/" target="_blank"><strong>IPFire.org</strong></a> • | |
209 | <a href="http://www.ipfire.org/donate" target="_blank">$Lang::tr{'support donation'}</a> | |
210 | </span> | |
211 | ||
212 | <strong>$system_release</strong> | |
697a4d52 | 213 | </div> |
af731c7d AM |
214 | </body> |
215 | </html> | |
af731c7d AM |
216 | END |
217 | ; | |
218 | } | |
219 | ||
220 | ############################################################################### | |
221 | # | |
222 | # print big box opening html layout | |
697a4d52 | 223 | sub openbigbox { |
af731c7d AM |
224 | } |
225 | ||
226 | ############################################################################### | |
227 | # | |
228 | # print big box closing html layout | |
697a4d52 | 229 | sub closebigbox { |
af731c7d AM |
230 | } |
231 | ||
232 | ############################################################################### | |
233 | # | |
234 | # print box opening html layout | |
235 | # @param page width | |
236 | # @param page align | |
237 | # @param page caption | |
697a4d52 | 238 | sub openbox { |
af731c7d AM |
239 | $width = $_[0]; |
240 | $align = $_[1]; | |
241 | $caption = $_[2]; | |
242 | ||
480f354d AH |
243 | if($align eq 'center') { |
244 | print "<div class='post' align='center'>\n" | |
245 | } | |
246 | else { | |
247 | print "<div class='post'>\n"; | |
248 | } | |
697a4d52 MT |
249 | |
250 | if ($caption) { | |
251 | print "<h2>$caption</h2>\n"; | |
252 | } | |
af731c7d AM |
253 | } |
254 | ||
255 | ############################################################################### | |
256 | # | |
257 | # print box closing html layout | |
697a4d52 MT |
258 | sub closebox { |
259 | print "</div>"; | |
af731c7d AM |
260 | } |
261 | ||
262 | 1; |