]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - html/html/themes/ipfire/include/functions.pl
webgui menus: Make top menu item clickable on mobile safari
[people/teissler/ipfire-2.x.git] / html / html / themes / ipfire / 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 require "${General::swroot}/lang.pl";
35
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.'">'.$submenus->{$item}->{'caption'}.'</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" class="bigbox fixed">';
68
69 if ($settings{'SPEED'} ne 'off') {
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>
76 EOF
77 }
78
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 href="#"><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>";
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];
107
108 @URI=split ('\?', $ENV{'REQUEST_URI'} );
109 &General::readhash("${swroot}/main/settings", \%settings);
110 &genmenu();
111
112 my $headline = "IPFire";
113 if ($settings{'WINDOWWITHHOSTNAME'} eq 'on') {
114 $headline = "$settings{'HOSTNAME'}.$settings{'DOMAINNAME'}";
115 }
116
117 my @stylesheets = ("style.css");
118 if ($THEME_NAME eq "ipfire-rounded") {
119 push(@stylesheets, "style-rounded.css");
120 }
121
122 print <<END;
123 <!DOCTYPE html>
124 <html>
125 <head>
126 <title>$headline - $title</title>
127 $extrahead
128 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
129 <link rel="shortcut icon" href="/favicon.ico" />
130 <script type="text/javascript" src="/include/jquery.js"></script>
131 END
132
133 foreach my $stylesheet (@stylesheets) {
134 print "<link href=\"/themes/ipfire/include/css/$stylesheet\" rel=\"stylesheet\" type=\"text/css\" />\n";
135 }
136
137 if ($settings{'SPEED'} ne 'off') {
138 print <<END
139 <script type="text/javascript" src="/themes/ipfire/include/js/refreshInetInfo.js"></script>
140 END
141 ;
142 }
143
144 print <<END
145 </head>
146 <body>
147 <div id="header" class="fixed">
148 <div id="logo">
149 END
150 ;
151 if ($settings{'WINDOWWITHHOSTNAME'} ne 'off') {
152 print "<h1>$settings{'HOSTNAME'}.$settings{'DOMAINNAME'}</h1>";
153 } else {
154 print "<h1>IPFire</h1>";
155 }
156
157 print <<END
158 </div>
159 </div>
160 END
161 ;
162
163 &showmenu() if ($suppressMenu != 1);
164
165 print <<END
166 <div class="bigbox fixed">
167 <div id="main_inner" class="fixed">
168 <h1>$title</h1>
169 END
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
179 sub openpagewithoutmenu {
180 openpage(shift,shift,shift,1);
181 return;
182 }
183
184 ###############################################################################
185 #
186 # print page closing html layout
187
188 sub closepage () {
189 open(FILE, "</etc/system-release");
190 my $system_release = <FILE>;
191 $system_release =~ s/core/Core Update/;
192 close(FILE);
193
194 print <<END;
195 </div>
196 </div>
197
198 <div id="footer" class='bigbox fixed'>
199 <span class="pull-right">
200 <a href="http://www.ipfire.org/" target="_blank"><strong>IPFire.org</strong></a> &bull;
201 <a href="http://www.ipfire.org/donate" target="_blank">$Lang::tr{'support donation'}</a>
202 </span>
203
204 <strong>$system_release</strong>
205 </div>
206 </body>
207 </html>
208 END
209 ;
210 }
211
212 ###############################################################################
213 #
214 # print big box opening html layout
215 sub openbigbox {
216 }
217
218 ###############################################################################
219 #
220 # print big box closing html layout
221 sub closebigbox {
222 }
223
224 ###############################################################################
225 #
226 # print box opening html layout
227 # @param page width
228 # @param page align
229 # @param page caption
230 sub openbox {
231 $width = $_[0];
232 $align = $_[1];
233 $caption = $_[2];
234
235 print "<div class='post' align='$align'>\n";
236
237 if ($caption) {
238 print "<h2>$caption</h2>\n";
239 }
240 }
241
242 ###############################################################################
243 #
244 # print box closing html layout
245 sub closebox {
246 print "</div>";
247 }
248
249 1;