summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LedgerSMB/Menu.pm71
-rw-r--r--UI/menu_expand.html71
-rw-r--r--scripts/menu.pl58
3 files changed, 200 insertions, 0 deletions
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 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title>Accounting Menu - LedgerSMB Version 1.2.7 - Chris Travers - metatron_ledger</title>
+ <meta http-equiv="Pragma" content="no-cache" />
+ <meta http-equiv="Expires" content="-1" />
+ <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
+ <link rel="stylesheet" href="css/<?lsmb stylesheet ?>" type="text/css" title="LedgerSMB stylesheet" />
+
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
+
+ <meta name="robots" content="noindex,nofollow" />
+
+ <script type="text/javascript">
+
+ function SwitchMenu(obj) {
+ if (document.getElementById) {
+ var el = document.getElementById(obj);
+
+ if (el.style.display == "none") {
+ el.style.display = "block"; //display the block of info
+ } else {
+ el.style.display = "none";
+ }
+ }
+ }
+
+
+ document.onselectstart = new Function("return false");
+ </script>
+</head>
+
+
+ <body class="menu">
+ <img class="cornderlogo" src="images/ledgersmb_small.png" width="100" height="50" border="1" alt="ledger-smb" />
+ <div id="div_0" class="container">
+ <?lsmb MACRO menu(section) BLOCK ?>
+ <?lsmb IF item.id ?>
+ <div id="menu<?lsmb section.id ?>" class="menuOut"
+ onclick="SwitchMenu('sub_<?lsmb section.id ?>')">
+ <?lsmb text(section.label) ?></div>
+ <div class="submenu" id="sub<?lsmb item.id ?>">
+ <div id="div_<?lsmb item.id ?>">
+ <?lsmb END ?>
+ <?lsmb IF section.subs.size > 0 ?>
+ <?lsmb FOREACH key = section.subs.keys.sort ?>
+ <?lsmb item = section.subs.$key ?>
+ <?lsmb IF item.subs ?>
+ <?lsmb subs = items.subs ?>
+ <?lsmb FOREACH subkey = subs.keys.sort ?>
+ <?lsmb sub = item.sub.$key ?>
+ <?lsmb menu(item) ?>
+ <?lsmb END ?>
+ <?lsmb ELSE ?>
+ <div class="submenu">
+ <a class="submenu"
+ href="<?lsmb item.module ?>?login=<?lsmb login ?><?lsmb FOREACH key = item.keys ?>&<?lsmb key ?>=<?lsmb item.$key ?><?lsmb END ?>"
+ target="main_window"><?lsmb text(item.label)?></a>
+ </div>
+ <?lsmb END ?>
+ <?lsmb END ?>
+ <?lsmb END ?>
+ </div>
+ </div>
+ <?lsmb END ?>
+ <?lsmb menu(menu_items) ?>
+ </div>
+</body>
+
+</html>
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;