1 #=====================================================================
 
   4 # Based on SQL-Ledger Version 2.1.9
 
   5 # Web http://www.lx-office.org
 
   7 ######################################################################
 
   8 # SQL-Ledger Accounting
 
   9 # Copyright (c) 1998-2002
 
  11 #  Author: Dieter Simader
 
  12 #   Email: dsimader@sql-ledger.org
 
  13 #     Web: http://www.sql-ledger.org
 
  15 #  Contributors: Christopher Browne
 
  17 # This program is free software; you can redistribute it and/or modify
 
  18 # it under the terms of the GNU General Public License as published by
 
  19 # the Free Software Foundation; either version 2 of the License, or
 
  20 # (at your option) any later version.
 
  22 # This program is distributed in the hope that it will be useful,
 
  23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 
  24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
  25 # GNU General Public License for more details.
 
  26 # You should have received a copy of the GNU General Public License
 
  27 # along with this program; if not, write to the Free Software
 
  28 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
  29 #######################################################################
 
  31 # the frame layout with refractured menu
 
  34 #   DS. 2002-03-25  Created
 
  35 #  2004-12-14 - New Optik - Marco Welter <mawe@linux-studio.de>
 
  36 #  2010-08-19 - Icons for sub entries and single click behavior, unlike XUL-Menu
 
  37 #               JS switchable HTML-menu - Sven Donath <lxo@dexo.de>
 
  38 #######################################################################
 
  46 use List::MoreUtils qw(apply);
 
  48 my $menufile = "menu.ini";
 
  55   $::lxdebug->enter_sub;
 
  57   my $callback  = $::form->unescape($::form->{callback});
 
  58   $callback     = URI->new($callback)->rel($callback) if $callback;
 
  59   $callback     = "login.pl?action=company_logo"      if $callback =~ /^(\.\/)?$/;
 
  60   my $framesize = _calc_framesize();
 
  62   $::form->header(doctype => 'frameset');
 
  65 <frameset rows="28px,*" cols="*" framespacing="0" frameborder="0">
 
  66   <frame  src="controller.pl?action=FrameHeader/header" scrolling="NO">
 
  67   <frameset cols="$framesize,*" framespacing="0" frameborder="0" border="0" id="menuframe" name="menuframe">
 
  68     <frame src="$::form->{script}?action=acc_menu" name="acc_menu"  scrolling="auto" noresize marginwidth="0">
 
  69     <frame src="$callback" name="main_window" scrolling="auto">
 
  72   You need a browser that can read frames to see this page.
 
  78   $::lxdebug->leave_sub;
 
  82   $::lxdebug->enter_sub;
 
  84   my $framesize    = _calc_framesize() - 2;
 
  85   my $menu         = Menu->new("menu.ini");
 
  86   $mainlevel       = $::form->{level};
 
  87   $::form->{title} = $::locale->text('kivitendo');
 
  90   print $::form->parse_html_template('menu/menu', {
 
  91     framesize => $framesize,
 
  92     sections  => [ section_menu($menu) ],
 
  95   $::lxdebug->leave_sub;
 
  99   $::lxdebug->enter_sub;
 
 100   my ($menu, $level) = @_;
 
 101   my @menuorder = $menu->access_control(\%::myconfig, $level);
 
 104   for my $item (@menuorder) {
 
 105     my $menuitem   = $menu->{$item};
 
 106     my $label      = apply { s/.*--// } $item;
 
 107     my $ml         = apply { s/--.*// } $item;
 
 108     my $show       = $ml eq $mainlevel;
 
 109     my $spacer     = $nbsp x (($item =~ s/--/--/g) * 2);
 
 110     my $label_icon = $level . "--" . $label . ".png";
 
 112     next if $level && $item ne "$level--$label";
 
 114     $label         = $::locale->text($label);
 
 116     $menuitem->{target} ||= "main_window";
 
 118     my $anchor     = $menu->menuitem(\%::myconfig, $::form, $item, $level);
 
 120     if (!$level) { # toplevel
 
 121       my $ml_    = $::form->escape($ml);
 
 122       my $image  = make_image(icon => $item . '.png', size => 24, label => $label);
 
 123       my $anchor = "<a href='menu.pl?action=acc_menu&level=$ml_' class='nohover' title='$label'>";
 
 125       push @items, make_item(a => $anchor, img => $image, label => $label, height => 24, class => 'menu');
 
 126       push @items, section_menu($menu, $item);
 
 128     } elsif ($menuitem->{submenu}) {
 
 129       my $image = make_image(submenu => 1);
 
 130       if ($mainlevel && $item =~ /^\Q$mainlevel\E/) {
 
 131         push @items, make_item(spacer => $spacer, bold => 1, img => $image, label => $label, class => 'submenu') if $show;
 
 132         push @items, section_menu($menu, $item);
 
 134         push @items, make_item(spacer => $spacer, a => $anchor, img => $image, label => $label . ' ...', class => 'submenu') if $show;
 
 136     } elsif ($menuitem->{module}) {
 
 137       my $image = make_image(label => $label, icon => $label_icon);
 
 138       push @items, make_item(img => $image, a => $anchor, spacer => $spacer, label => $label, class => 'item') if $show;
 
 139       push @items, section_menu($menu, $item) if $show && $::form->{$item} && $::form->{level} eq $item;
 
 142   $::lxdebug->leave_sub;
 
 149   $params{spacer} ||= '';
 
 150   $params{height} ||= 16;
 
 154     chunks => [ multiline($params{label}) ],
 
 158 # multi line hack, sschoeling jul06
 
 159 # if a label is too long, try to split it at whitespaces, then join it to chunks of less
 
 160 # than 20 chars and store it in an array.
 
 161 # use this array later instead of the  -ed label
 
 166   for (split / /, $label) {
 
 169       $chunks[-1] .= " $_";
 
 181   my $label  = $params{label};
 
 182   my $icon   = $params{icon};
 
 183   my $size   = $params{size}   || 16;
 
 185   return unless _show_images();
 
 187   my $icon_found = $icon && -f _icon_path($icon, $size);
 
 189   my $image_url = $icon_found ? _icon_path($icon, $size) : "image/unterpunkt.png";
 
 190   my $width     = $icon_found ? $size : 24;
 
 192   my $padding   = $size == 16 && $icon_found ? $nbsp x 2
 
 193                 : $size == 24                ? $nbsp
 
 196   return "<img src='$image_url' title='$label' width='$width' height='$size'>$padding";
 
 199 sub _calc_framesize {
 
 200   my $is_lynx_browser   = $ENV{HTTP_USER_AGENT} =~ /links/i;
 
 201   my $is_mobile_browser = $ENV{HTTP_USER_AGENT} =~ /mobile/i;
 
 202   my $is_mobile_style   = $::form->{stylesheet} =~ /mobile/i;
 
 204   return  $is_mobile_browser && $is_mobile_style ?  130
 
 205         : $is_lynx_browser                       ?  240
 
 210   # don't show images in links
 
 211   _calc_framesize() != 240;
 
 215   my ($label, $size) = @_;
 
 219   return "image/icons/${size}x${size}/$label";