diff options
author | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-06-27 15:19:55 +0000 |
---|---|---|
committer | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-06-27 15:19:55 +0000 |
commit | 50be11c3574706cae5e219ba910e8221e50da4e8 (patch) | |
tree | a2b6f050da940fdf1650a42bd5269469e6483467 | |
parent | 80d758a1abf3d2b696fd14521726806236a2c2b6 (diff) |
Moving menu.pl to old-handler.pl and adjusting top level scripts accordingly.
Including also an unfinished and inactive version of the menu system running under the new architecture.
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1334 4979c152-3d1c-0410-bac9-87ea11338e46
-rwxr-xr-x | LedgerSMB.pm | 5 | ||||
-rw-r--r-- | LedgerSMB/Menu.pm | 21 | ||||
-rw-r--r-- | UI/menu_expand.html | 56 | ||||
-rwxr-xr-x | menu.pl | 2 | ||||
-rw-r--r-- | scripts/menu.pl | 39 |
5 files changed, 74 insertions, 49 deletions
diff --git a/LedgerSMB.pm b/LedgerSMB.pm index 022caeb3..c75482f3 100755 --- a/LedgerSMB.pm +++ b/LedgerSMB.pm @@ -214,6 +214,9 @@ sub new { exit; } } + + $self->{stylesheet} = $self->{_user}->{stylesheet}; + $self->_db_init; $self; @@ -248,7 +251,7 @@ sub debug { my $args = shift @_; my $file; if (scalar keys %$args){ - my $file = $args->{'file'}; + $file = $args->{'file'}; } my $d = Data::Dumper->new( [$self] ); $d->Sortkeys(1); diff --git a/LedgerSMB/Menu.pm b/LedgerSMB/Menu.pm index 30aa28c6..5c017a7c 100644 --- a/LedgerSMB/Menu.pm +++ b/LedgerSMB/Menu.pm @@ -48,19 +48,18 @@ sub new { 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}; + $ref->{subs} ||= {}; + $ref->{subs}->{$1} ||= {}; + $ref = $ref->{subs}->{$1}; } - for (keys %{$config->{$orig_key}}){ - $ref->{$_} = $config{$orig_key}->{$_}; + $ref->{subs} ||= {}; + $ref->{subs}->{key} ||= {}; + $ref = $ref->{subs}->{$key}; + for (keys %{$config{$orig_key}}){ + $ref->{$_} = ${$config{$orig_key}}{$_}; } - $ref->{$key}{id} = $index; - $ref->{$key}{label} = $key; + $ref->{id} = $index; + $ref->{label} = $key; ++$index; } } diff --git a/UI/menu_expand.html b/UI/menu_expand.html index 7a78e24c..82c82db3 100644 --- a/UI/menu_expand.html +++ b/UI/menu_expand.html @@ -34,38 +34,34 @@ <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 FOREACH item = subs ?> + <?lsmb old_id = id ?><?lsmb old_path = path ?> + <?lsmb id = item.id ?><?lsmb path = item.path ?> + <?lsmb IF (id != old_id) AND id ?> + <?lsmb desc_ids = [id, ''] ?> + <?lsmb asc_ids = [old_id, ''] ?> + <?lsmb IF old_id.search(desc_ids.join('--')) ?> + <div id="sub_<?lsmb old_id ?>" class="Submenu"> + <?lsmb ELSIF id.search(asc_ids.join('--')) ?> + </div> <?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) ?> + <?lsmb END ?> + <div class="Menu" id="menu_<?lsmb id ?>"> + <a href="<?lsmb IF item.module ?><?lsmb item.module + ?><?lsmb ELSE ?>menu.pl<?lsmb END + ?>?login=<?lsmb login + ?><?lsmb FOREACH key IN item.keys ?>&<?lsmb key + ?>=<?lsmb item.$key ?><?lsmb END ?>" + target = "main_window" + onclick="return <?lsmb IF item.module + ?>SwitchMenu(<?lsmb id ?>)<?lsmb END ?>" + class = "<?lsmb IF item.module ?>Menu<?lsmb + ELSE ?>Item<?lsmb END ?>" + ><?lsmb text(item.label) ?></a> </div> + <?lsmb END ?> + + </body> </html> @@ -1,3 +1,3 @@ #!/usr/bin/perl -require "lsmb-request.pl"; +require "old-handler.pl"; diff --git a/scripts/menu.pl b/scripts/menu.pl index 622c0cce..6836c1b4 100644 --- a/scripts/menu.pl +++ b/scripts/menu.pl @@ -44,15 +44,42 @@ sub expanding_menu { template => 'menu_expand', format => 'HTML', ); - $request->{menu_items} = []; - for (keys %$menu){ - push @{$request->{menu_items}}, $menu->{$_}; - } + $request->{subs} = []; + _attach_references({source => $menu, dest => $request->{subs}, path => ""}); $menu->debug({file => '/tmp/debug-menu'}); - $request->{menu_items} = {}; - $request->{menu_items}->{subs} = $menu; $request->debug({file => '/tmp/debug'}); $template->render($request); } +sub _attach_references { + no strict qw(refs); + my ($args) = @_; + my ($source, $dest, $path) + = ($args->{source}, $args->{dest}, $args->{path}); + my %hash; + if ($path and $source->{id}){ + for (sort keys %$source){ + next if $_ eq 'subs'; + $hash{$_} = $source->{$_}; + } + $hash{path} = $path; + push @{$dest}, \%hash; + foreach (sort keys %{$source->{subs}}) { + _attach_references({ + source => $source->{subs}->{$_}, + dest => $dest, + path => "$path--$_", + }); + } + } else { + foreach (sort keys %$source){ + _attach_references({ + source => $source->{$_}, + dest => $dest, + path => "$_", + }); + } + } +} + 1; |