summaryrefslogtreecommitdiff
path: root/LedgerSMB/Menu.pm
blob: 9e29fdf29de4682c0733060b888d1823fecbc382 (plain)
  1. =head1 NAME
  2. LedgerSMB::Menu: Menu Handling Back-end Routines for LedgerSMB
  3. =head1 SYNOPSIS
  4. Provides the functions for generating the data structures for the LedgerSMB
  5. menu.
  6. =head1 COPYRIGHT
  7. Copyright (c) 2007 The LedgerSMB Core Team. Licensed under the GNU General
  8. Public License version 2 or at your option any later version. Please see the
  9. included COPYRIGHT and LICENSE files for more information.
  10. =cut
  11. package LedgerSMB::Menu;
  12. use Config::Std;
  13. use base(qw(LedgerSMB::DBObject));
  14. 1;
  15. =head1 METHODS
  16. =over
  17. =item LedgerSMB::Menu->new()
  18. Inherited from LedgerSMB::DBObject. Please see that documnetation for details.
  19. =item $menu->generate()
  20. This function returns a list of menu items. Each list item is a hashref:
  21. keys %menu_item would return the equivalent of qw(position id level label path
  22. args). Returns the complete list and sets $menu->{menu_items} to a referene to
  23. th result set, This function does not return an entry for the top-level menu.
  24. =cut
  25. sub generate {
  26. my ($self) = shift @_;
  27. my @args;
  28. @{$self->{menu_items}} = $self->exec_method(funcname => 'menu_generate');
  29. $self->debug({file => '/tmp/menu'});
  30. shift @{$self->{menu_items}};
  31. for my $attribute (@{$self->{menu_items}}){
  32. @args = $self->_parse_array($attribute->{args});
  33. delete $attribute->{args};
  34. @{$attribute->{args}} = @args;
  35. for (@{$attribute->{args}}){
  36. if ($_ =~ /(module|menu|action)=/){
  37. @elems = split(/=/, $_);
  38. print STDERR join(','. @elems) . "\n";
  39. $attribute->{$elems[0]} = $elems[1];
  40. }
  41. }
  42. }
  43. return @{$self->{menu_items}};
  44. }