]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blobdiff - html/html/themes/ipfire/include/functions.pl
theme: Fix spacing of version string in footer.
[people/teissler/ipfire-2.x.git] / html / html / themes / ipfire / include / functions.pl
index 8956b8297d6d5e45c90d90fa2cf30013073c4386..63740d42d8385cf008b86d30d6fd2d376bca5329 100644 (file)
 #!/usr/bin/perl
-
-sub showmenu() {
-    print <<EOF
-               <div id="menu">
-                       <ul>
-EOF
-;
-    foreach my $k1 ( sort keys %$menu ) {
-       if (! $menu->{$k1}{'enabled'}) {
-           next;
-       }
-       my $link = getlink($menu->{$k1});
-       if ($link eq '') {
-           next;
-       }
-       if (! is_menu_visible($link)) {
-           next;
-       }
-       if ($menu->{$k1}->{'selected'}) {
-           print "<li><a href=\"$link\" class=\"active\">$menu->{$k1}{'caption'}</a></li>";
-       } else {
-           print "<li><a href=\"$link\">$menu->{$k1}{'caption'}</a></li>";
-       }
-    }
-    print <<EOF
-                       </ul>
-               </div>
-EOF
-;    
-}
-
-sub getselected($) {
-    my $root = shift;
-    if (!$root) {
-       return 0;
-    }
-
-    foreach my $item (%$root) {
-       if ($root->{$item}{'selected'}) {
-           return $root->{$item};
+###############################################################################
+#                                                                             #
+# IPFire.org - A linux based firewall                                         #
+# Copyright (C) 2007  Michael Tremer & Christian Schmidt                      #
+#                                                                             #
+# This program is free software: you can redistribute it and/or modify        #
+# it under the terms of the GNU General Public License as published by        #
+# the Free Software Foundation, either version 3 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+###############################################################################
+#                                                                             #
+# Theme file for IPfire (based on ipfire theme)                               #
+# Author kay-michael köhler kmk <michael@koehler.tk>                          #
+#                                                                             #
+# Version 1.0  March, 6th 2013                                               #
+###############################################################################
+#                                                                             #
+# Modyfied theme by a.marx@ipfire.org January 2014                            #
+#                                                                             #
+# Cleanup code, deleted unused code and rewrote the rest to get a new working #
+# IPFire default theme.                                                       #
+###############################################################################
+
+require "${General::swroot}/lang.pl";
+
+###############################################################################
+#
+# print menu html elements for submenu entries
+# @param submenu entries
+sub showsubmenu() {
+       my $submenus = shift;
+       
+       print "<ul>";
+       foreach my $item (sort keys %$submenus) {
+               $link = getlink($submenus->{$item});
+               next if (!is_menu_visible($link) or $link eq '');
+
+               my $subsubmenus = $submenus->{$item}->{'subMenu'};
+
+               if ($subsubmenus) {
+                       print '<li class="has-sub ">';
+               } else {
+                       print '<li>';
+               }
+               print '<a href="'.$link.'">'.$submenus->{$item}->{'caption'}.'</a>';
+
+               &showsubmenu($subsubmenus) if ($subsubmenus);
+               print '</li>';
        }
-    }
+       print "</ul>"
 }
 
-sub showsubsection($$) {
-    my $root = shift;
-
-    if (! $root) {
-       return;
-    }
-    my $selected = getselected($root);
-    if (! $selected) {
-       return;
-    }
-    my $submenus = $selected->{'subMenu'};
-    if (! $submenus) {
-       return;
-    }
-
-    print <<EOF
-       <h4><span>Side</span>menu</h4>
-       <ul class="links">
+###############################################################################
+#
+# print menu html elements
+sub showmenu() {
+       print '<div id="cssmenu" class="bigbox fixed">';
+
+       if ($settings{'SPEED'} ne 'off') {
+               print <<EOF;
+                       <div id='traffic'>
+                               <strong>Traffic:</strong>
+                               In  <span id='rx_kbs'>--.-- Bit/s</span> &nbsp;
+                               Out <span id='tx_kbs'>--.-- Bit/s</span>
+                       </div>
 EOF
-;
-    foreach my $item (sort keys %$submenus) {
-       my $hash = $submenus->{$item};
-       if (! $hash->{'enabled'}) {
-           next;
-       }
-       my $link = getlink($hash);
-       if ($link eq '') {
-           next;
-       }
-       if (! is_menu_visible($link)) {
-           next;
-       }
-       if ($hash->{'selected'}) {
-           print '<li class="selected">';
-       } else {
-           print '<li>';
        }
 
-       print "<a href=\"$link\">$hash->{'caption'}</a></li>";
-    }
+       print "<ul>";
+       foreach my $k1 ( sort keys %$menu ) {
+               $link = getlink($menu->{$k1});
+               next if (!is_menu_visible($link) or $link eq '');
+               print '<li class="has-sub "><a href="#"><span>'.$menu->{$k1}->{'caption'}.'</span></a>';
+               my $submenus = $menu->{$k1}->{'subMenu'};
+               &showsubmenu($submenus) if ($submenus);
+               print "</li>";
+       }
 
-    print <<EOF
-       </ul>
-EOF
-;
-}
-
-
-sub showsubsubsection($) {
-    my $root = shift;
-    if (!$root) {
-       return;
-    }
-    my $selected = getselected($root);
-    if (! $selected) {
-       return
-    }
-    if (! $selected->{'subMenu'}) {
-       return
-    }
-
-    showsubsection($selected->{'subMenu'}, 'menu-subtop');
+       print "</ul></div>";
 }
 
+###############################################################################
+#
+# print page opening html layout
+# @param page title
+# @param boh
+# @param extra html code for html head section
+# @param suppress menu option, can be numeric 1 or nothing.
+#               menu will be suppressed if param is 1
 sub openpage {
-    my $title = shift;
-    my $boh = shift;
-    my $extrahead = shift;
-
-    @URI=split ('\?',  $ENV{'REQUEST_URI'} );
-    &readhash("${swroot}/main/settings", \%settings);
-    &genmenu();
-
-    my $h2 = gettitle($menu);
-
-    $title = "IPFire - $title";
-    if ($settings{'WINDOWWITHHOSTNAME'} eq 'on') {
-        $title =  "$settings{'HOSTNAME'}.$settings{'DOMAINNAME'} - $title"; 
-    }
+       my $title = shift;
+       my $boh = shift;
+       my $extrahead = shift;
+       my $suppressMenu = shift;
+       my @tmp = split(/\./, basename($0));
+       my $scriptName = @tmp[0];
+
+       @URI=split ('\?',  $ENV{'REQUEST_URI'} );
+       &General::readhash("${swroot}/main/settings", \%settings);
+       &genmenu();
+
+       my $headline = "IPFire";
+       if (($settings{'WINDOWWITHHOSTNAME'} eq 'on') || ($settings{'WINDOWWITHHOSTNAME'} eq '')) {
+               $headline =  "$settings{'HOSTNAME'}.$settings{'DOMAINNAME'}";
+       }
 
-    print <<END
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+       my @stylesheets = ("style.css");
+       if ($THEME_NAME eq "ipfire-rounded") {
+               push(@stylesheets, "style-rounded.css");
+       }
 
+print <<END;
+<!DOCTYPE html>
 <html>
-  <head>
-  <title>$title</title>
+       <head>
+       <title>$headline - $title</title>
+       $extrahead
+       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+       <link rel="shortcut icon" href="/favicon.ico" />
+       <script type="text/javascript" src="/include/jquery.js"></script>
+
+       <script type="text/javascript">
+               function swapVisibility(id) {
+                       \$('#' + id).toggle();
+               }
+       </script>
+END
 
-    $extrahead
-    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+       foreach my $stylesheet (@stylesheets) {
+               print "<link href=\"/themes/ipfire/include/css/$stylesheet\" rel=\"stylesheet\" type=\"text/css\" />\n";
+       }
+
+if ($settings{'SPEED'} ne 'off') {
+print <<END
+       <script type="text/javascript" src="/themes/ipfire/include/js/refreshInetInfo.js"></script>
 END
 ;
-    if ($settings{'FX'} ne 'off') {
-    print <<END
-    <meta http-equiv="Page-Enter" content="blendTrans(Duration=0.5,Transition=12)" />
-    <meta http-equiv="Page-Exit" content="blendTrans(Duration=0.5,Transition=12)" />
+}
+
+print <<END
+       </head>
+       <body>
+               <div id="header" class="fixed">
+                       <div id="logo">
 END
 ;
-    }
-    print <<END
-    <link rel="shortcut icon" href="/favicon.ico" />
-    <link rel="stylesheet" type="text/css" href="/themes/ipfire/include/style.css" />
-    <script language="javascript" type="text/javascript">
-      
-        function swapVisibility(id) {
-            el = document.getElementById(id);
-           if(el.style.display != 'block') {
-               el.style.display = 'block'
-           }
-           else {
-               el.style.display = 'none'
-           }
-        }
-    </script>
-
-  </head>
-  <body>
-<!-- IPFIRE HEADER -->
-
-<div id="header">
-
-       <div id="header_inner" class="fixed">
-
-               <div id="logo">
-                       <h1><span>IPFire</span></h1><br />
-                       <h2>$h2</h2>
-               </div>
+       if ($settings{'WINDOWWITHHOSTNAME'} ne 'off') {
+               print "<h1>$settings{'HOSTNAME'}.$settings{'DOMAINNAME'}</h1>";
+       } else {
+               print "<h1>IPFire</h1>";
+       }
 
+print <<END
+                       </div>
+               </div>
 END
 ;
-       &showmenu();
 
-print <<END    
-       </div>
-</div>
+&showmenu() if ($suppressMenu != 1);
 
-<div id="main">
-       <div id="main_inner" class="fixed">
-               <div id="primaryContent_2columns">
-                       <div id="columnA_2columns">
+print <<END
+       <div class="bigbox fixed">
+               <div id="main_inner" class="fixed">
+                       <h1>$title</h1>
 END
 ;
 }
 
+###############################################################################
+#
+# print page opening html layout without menu
+# @param page title
+# @param boh
+# @param extra html code for html head section
 sub openpagewithoutmenu {
-    my $title = shift;
-    my $boh = shift;
-    my $extrahead = shift;
-
-    @URI=split ('\?',  $ENV{'REQUEST_URI'} );
-    &readhash("${swroot}/main/settings", \%settings);
-    &genmenu();
-
-    my $h2 = gettitle($menu);
-
-    $title = "IPFire - $title";
-    if ($settings{'WINDOWWITHHOSTNAME'} eq 'on') {
-        $title =  "$settings{'HOSTNAME'}.$settings{'DOMAINNAME'} - $title"; 
-    }
-
-    print <<END
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-
-<html>
-  <head>
-  <title>$title</title>
-
-    $extrahead
-    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
-END
-;
-    if ($settings{'FX'} ne 'off') {
-    print <<END
-    <meta http-equiv="Page-Enter" content="blendTrans(Duration=0.5,Transition=12)" />
-    <meta http-equiv="Page-Exit" content="blendTrans(Duration=0.5,Transition=12)" />
-END
-;
-    }
-    print <<END
-    <link rel="shortcut icon" href="/favicon.ico" />
-    <link rel="stylesheet" type="text/css" href="/include/style.css" />
-    <script language="javascript" type="text/javascript">
-      
-        function swapVisibility(id) {
-            el = document.getElementById(id);
-           if(el.style.display != 'block') {
-               el.style.display = 'block'
-           }
-           else {
-               el.style.display = 'none'
-           }
-        }
-    </script>
-
-  </head>
-  <body>
-<!-- IPFIRE HEADER -->
-
-<div id="header">
-
-       <div id="header_inner" class="fixed">
-
-               <div id="logo">
-                       <h1><span>IPFire</span></h1>
-                       <h2>$h2</h2>
-               </div>  
-       </div>
-</div>
-
-<div id="main">
-       <div id="main_inner" class="fixed">
-               <div id="primaryContent_2columns">
-                       <div id="columnA_2columns">
-END
-;
+       openpage(shift,shift,shift,1);
+       return;
 }
 
-sub closepage () {
-    my $status = &connectionstatus();
-    $uptime = `/usr/bin/uptime`;
-       
-    print <<END
-                       </div>
-               </div>
+###############################################################################
+#
+# print page closing html layout
 
-               <div id="secondaryContent_2columns">
-               
-                       <div id="columnC_2columns">
-END
-;
-    &showsubsection($menu);
-    &showsubsubsection($menu);
+sub closepage () {
+       open(FILE, "</etc/system-release");
+       my $system_release = <FILE>;
+       $system_release =~ s/core/Core Update /;
+       close(FILE);
 
-       print <<END                     
-                       </div>
+print <<END;
                </div>
+       </div>
 
-               <br class="clear" />    
-               <div id="footer" class="fixed">
-                       <b>Status:</b> $status <b>Uptime:</b>$uptime <b>Version:</b> $FIREBUILD
-               </div>
+       <div id="footer" class='bigbox fixed'>
+               <span class="pull-right">
+                       <a href="http://www.ipfire.org/" target="_blank"><strong>IPFire.org</strong></a> &bull;
+                       <a href="http://www.ipfire.org/donate" target="_blank">$Lang::tr{'support donation'}</a>
+               </span>
+
+               <strong>$system_release</strong>
        </div>
-</div>
 </body>
 </html>
 END
 ;
 }
 
-sub openbigbox
-{
+###############################################################################
+#
+# print big box opening html layout
+sub openbigbox {
 }
 
-sub closebigbox
-{
+###############################################################################
+#
+# print big box closing html layout
+sub closebigbox {
 }
 
-sub openbox
-{
+###############################################################################
+#
+# print box opening html layout
+# @param page width
+# @param page align
+# @param page caption
+sub openbox {
        $width = $_[0];
        $align = $_[1];
        $caption = $_[2];
 
-       print <<END
-<!-- openbox -->
-       <div class="post" align="$align">
-END
-;
+       if($align eq 'center') {
+               print "<div class='post' align='center'>\n"
+       }
+       else {
+               print "<div class='post'>\n";
+       }
 
-       if ($caption) { print "<h3>$caption</h3>\n"; } else { print "&nbsp;"; }
+       if ($caption) {
+               print "<h2>$caption</h2>\n";
+       }
 }
 
-sub closebox
-{
-       print <<END
-       </div>
-       <br class="clear" />
-       <!-- closebox -->
-END
-;
+###############################################################################
+#
+# print box closing html layout
+sub closebox {
+       print "</div>";
 }
 
 1;