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 #######################################################################
 
  45 use List::MoreUtils qw(apply);
 
  52   $::lxdebug->enter_sub;
 
  54   my $callback  = $::form->unescape($::form->{callback});
 
  55   $callback     = URI->new($callback)->rel($callback) if $callback;
 
  56   $callback     = "login.pl?action=company_logo"      if $callback =~ /^(\.\/)?$/;
 
  57   my $framesize = _calc_framesize();
 
  59   $::form->header(doctype => 'frameset');
 
  62 <frameset rows="28px,*" cols="*" framespacing="0" frameborder="0">
 
  63   <frame  src="controller.pl?action=FrameHeader/header" scrolling="NO">
 
  64   <frameset cols="$framesize,*" framespacing="0" frameborder="0" border="0" id="menuframe" name="menuframe">
 
  65     <frame src="$::form->{script}?action=acc_menu" name="acc_menu"  scrolling="auto" noresize marginwidth="0">
 
  66     <frame src="$callback" name="main_window" scrolling="auto">
 
  69   You need a browser that can read frames to see this page.
 
  75   $::lxdebug->leave_sub;
 
  79   $::lxdebug->enter_sub;
 
  81   my $framesize    = _calc_framesize() - 2;
 
  82   my $menu         = Menu->new("menu.ini");
 
  83   $::form->{title} = $::locale->text('kivitendo');
 
  86   $::lxdebug->dump(0,  "menu", $menu);
 
  88   my $sections = section_menu($menu);
 
  90   print $::form->parse_html_template('menu/menu', {
 
  91     framesize => $framesize,
 
  92     sections  => $sections,
 
  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 $spacer     = $nbsp x (($item =~ s/--/--/g) * 2);
 
 109     my $label_icon = $level . "--" . $label . ".png";
 
 111     next if $level && $item ne "$level--$label";
 
 113     $label         = $::locale->text($label);
 
 115     $menuitem->{module} ||= $::form->{script};
 
 116     $menuitem->{action} ||= "section_menu";
 
 117     $menuitem->{target} ||= "main_window";
 
 118     $menuitem->{href}   ||= "$menuitem->{module}?action=$menuitem->{action}";
 
 121     foreach my $key (keys %$menuitem) {
 
 122       next if $key =~ /target|module|action|href/;
 
 123       $menuitem->{href} .= "&" . $::form->escape($key, 1) . "=";
 
 124       my ($value, $conf) = split(/=/, $menuitem->{$key}, 2);
 
 125       $value = $::myconfig{$value} . "/$conf" if ($conf);
 
 126       $menuitem->{href} .= $::form->escape($value, 1);
 
 129     my $anchor = $menuitem->{href};
 
 131     if (!$level) { # toplevel
 
 132       push @items, make_item(
 
 134         img      =>  make_image(icon => $item . '.png', size => 24, label => $label),
 
 138         subitems => section_menu($menu, $item)
 
 140     } elsif ($menuitem->{submenu}) {
 
 141       push @items, make_item(
 
 142         target   => $menuitem->{target},
 
 144         img      => make_image(submenu => 1),
 
 147         subitems => section_menu($menu, $item),
 
 149     } elsif ($menuitem->{module}) {
 
 150       push @items, make_item(
 
 151         target => $menuitem->{target},
 
 152         img    => make_image(label => $label, icon => $label_icon),
 
 160   $::lxdebug->leave_sub;
 
 166   $params{spacer} ||= '';
 
 167   $params{height} ||= 16;
 
 171     chunks => [ multiline($params{label}) ],
 
 175 # multi line hack, sschoeling jul06
 
 176 # if a label is too long, try to split it at whitespaces, then join it to chunks of less
 
 177 # than 20 chars and store it in an array.
 
 178 # use this array later instead of the  -ed label
 
 183   for (split / /, $label) {
 
 186       $chunks[-1] .= " $_";
 
 198   my $icon   = $params{icon};
 
 199   my $size   = $params{size}   || 16;
 
 201   return unless _show_images();
 
 203   my $icon_found = $icon && -f _icon_path($icon, $size);
 
 204   my $padding    = $size == 16 && $icon_found ? $nbsp x 2
 
 205                  : $size == 24                ? $nbsp
 
 209     src     => $icon_found ? _icon_path($icon, $size) : "image/unterpunkt.png",
 
 210     alt     => $params{label},
 
 211     width   => $icon_found ? $size : 24,
 
 216 sub _calc_framesize {
 
 217   my $is_lynx_browser   = $ENV{HTTP_USER_AGENT} =~ /links/i;
 
 218   my $is_mobile_browser = $ENV{HTTP_USER_AGENT} =~ /mobile/i;
 
 219   my $is_mobile_style   = $::form->{stylesheet} =~ /mobile/i;
 
 221   return  $is_mobile_browser && $is_mobile_style ?  130
 
 222         : $is_lynx_browser                       ?  240
 
 227   # don't show images in links
 
 228   _calc_framesize() != 240;
 
 232   my ($label, $size) = @_;
 
 236   return "image/icons/${size}x${size}/$label";