From 80d758a1abf3d2b696fd14521726806236a2c2b6 Mon Sep 17 00:00:00 2001 From: einhverfr Date: Wed, 27 Jun 2007 01:28:23 +0000 Subject: Committing first-run of broken infrastructure git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1333 4979c152-3d1c-0410-bac9-87ea11338e46 --- LedgerSMB/Menu.pm | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++ UI/menu_expand.html | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++ scripts/menu.pl | 58 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 200 insertions(+) create mode 100644 LedgerSMB/Menu.pm create mode 100644 UI/menu_expand.html create mode 100644 scripts/menu.pl diff --git a/LedgerSMB/Menu.pm b/LedgerSMB/Menu.pm new file mode 100644 index 00000000..30aa28c6 --- /dev/null +++ b/LedgerSMB/Menu.pm @@ -0,0 +1,71 @@ +=head1 NAME + +LedgerSMB::Menu: Menu Handling Back-end Routines for LedgerSMB + +=head1 SYNOPSIS + +Provides the functions for generating the data structures for the LedgerSMB +menu. + +=head1 COPYRIGHT + +Copyright (c) 2007 The LedgerSMB Core Team. Licensed under the GNU General +Public License version 2 or at your option any later version. Please see the +included COPYRIGHT and LICENSE files for more information. + +=cut + +package LedgerSMB::Menu; + +use Config::Std; +use base(qw(LedgerSMB)); + +1; + +=head1 METHODS + +=over + +=item new({files => ['path/to/file/glob' ... ], user = $user_ref}) + +Creates a new Menu data structure with the files listed and the files in the +paths. + +=cut + + +sub new { + my ($class, $args) = @_; + my $self = {}; + bless ($self, $class); + my $index = 1; + for $file_glob (@{$args->{files}}){ + for $file (glob($file_glob)){ + my %config; + read_config($file => %config ); + for $key (keys %config){ + next if $args->{user}->{acs} =~ /$key/; + my $orig_key = $key; + my $ref = $self; + while ($key =~ s/^([^-]*)--//){ + if (!defined $ref->{$1}){ + $ref->{$1} = {}; + } + if (!defined $ref->{$1}->{subs}){ + $ref->{$1}->{subs} = {}; + } + $ref = $ref->{$1}->{subs}; + } + for (keys %{$config->{$orig_key}}){ + $ref->{$_} = $config{$orig_key}->{$_}; + } + $ref->{$key}{id} = $index; + $ref->{$key}{label} = $key; + ++$index; + } + } + } + return $self; +} +1; +=back diff --git a/UI/menu_expand.html b/UI/menu_expand.html new file mode 100644 index 00000000..7a78e24c --- /dev/null +++ b/UI/menu_expand.html @@ -0,0 +1,71 @@ + + + + Accounting Menu - LedgerSMB Version 1.2.7 - Chris Travers - metatron_ledger + + + + + + + + + + + + + + + +
+ + + + + + +
+ + + diff --git a/scripts/menu.pl b/scripts/menu.pl new file mode 100644 index 00000000..622c0cce --- /dev/null +++ b/scripts/menu.pl @@ -0,0 +1,58 @@ +#!/usr/bin/perl + +# This file is copyright (C) 2007the LedgerSMB core team and licensed under +# the GNU General Public License. For more information please see the included +# LICENSE and COPYRIGHT files + +package LedgerSMB::Scripts::menu; +our $VERSION = '0.1'; + +$menufile = "menu.ini"; +use LedgerSMB::Menu; +use LedgerSMB::Template; +use strict; + +sub display { + my ($request) = @_; + my $template; + if (!$request->{menubar}){ + $request->{main} = "splash.html" if $request->{main} eq 'company_logo'; + $request->{main} = "am.pl?action=recurring_transactions" + if $request->{main} eq 'recurring_transactions'; + $template = LedgerSMB::Template->new( + user =>$request->{_user}, + locale => $request->{_locale}, + path => 'UI', + template => 'frameset', + format => 'HTML' + ); + } else { + # TODO: Create Lynx Initial Menu + } + $template->render($request); +} + +sub expanding_menu { + my ($request) = @_; + my $menu = new LedgerSMB::Menu( + {files => ['menu.ini'], user => $request->{_user}} + ); + my $template = LedgerSMB::Template->new( + user => $request->{_user}, + locale => $request->{_locale}, + path => 'UI', + template => 'menu_expand', + format => 'HTML', + ); + $request->{menu_items} = []; + for (keys %$menu){ + push @{$request->{menu_items}}, $menu->{$_}; + } + $menu->debug({file => '/tmp/debug-menu'}); + $request->{menu_items} = {}; + $request->{menu_items}->{subs} = $menu; + $request->debug({file => '/tmp/debug'}); + $template->render($request); +} + +1; -- cgit v1.2.3