[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb: [1333] trunk



Revision: 1333
          http://svn.sourceforge.net/ledger-smb/?rev=1333&view=rev
Author:   einhverfr
Date:     2007-06-26 18:28:23 -0700 (Tue, 26 Jun 2007)

Log Message:
-----------
Committing first-run of broken infrastructure

Added Paths:
-----------
    trunk/LedgerSMB/Menu.pm
    trunk/UI/menu_expand.html
    trunk/scripts/menu.pl

Added: trunk/LedgerSMB/Menu.pm
===================================================================
--- trunk/LedgerSMB/Menu.pm	                        (rev 0)
+++ trunk/LedgerSMB/Menu.pm	2007-06-27 01:28:23 UTC (rev 1333)
@@ -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

Added: trunk/UI/menu_expand.html
===================================================================
--- trunk/UI/menu_expand.html	                        (rev 0)
+++ trunk/UI/menu_expand.html	2007-06-27 01:28:23 UTC (rev 1333)
@@ -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>

Added: trunk/scripts/menu.pl
===================================================================
--- trunk/scripts/menu.pl	                        (rev 0)
+++ trunk/scripts/menu.pl	2007-06-27 01:28:23 UTC (rev 1333)
@@ -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;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.