summaryrefslogtreecommitdiff
path: root/bin/lynx/menu.pl
blob: d087bc1f143dd6cc91db0b80c4dc0361da1567c5 (plain)
  1. ######################################################################
  2. # LedgerSMB Small Medium Business Accounting
  3. # Copyright (c) 2006
  4. #
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 2 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. #######################################################################
  19. #
  20. # menu for text based browsers (lynx)
  21. #
  22. #######################################################################
  23. $menufile = "menu.ini";
  24. use SL::Menu;
  25. 1;
  26. # end of main
  27. sub display {
  28. $menu = new Menu "$menufile";
  29. $menu->add_file("custom_$menufile") if -f "custom_$menufile";
  30. $menu->add_file("$form->{login}_$menufile") if -f "$form->{login}_$menufile";
  31. @menuorder = $menu->access_control(\%myconfig);
  32. $form->{title} = "LedgerSMB $form->{version}";
  33. $form->header(1);
  34. $offset = int (21 - $#menuorder)/2;
  35. print "<pre>";
  36. print "\n" x $offset;
  37. print "</pre>";
  38. print qq|<center><table>|;
  39. map { print "<tr><td>".$menu->menuitem(\%myconfig, \%$form, $_).$locale->text($_).qq|</a></td></tr>|; } @menuorder;
  40. print qq'
  41. </table>
  42. </body>
  43. </html>
  44. ';
  45. }
  46. sub section_menu {
  47. $menu = new Menu "$menufile", $form->{level};
  48. $menu->add_file("custom_$menufile") if -f "custom_$menufile";
  49. $menu->add_file("$form->{login}_$menufile") if -f "$form->{login}_$menufile";
  50. # build tiered menus
  51. @menuorder = $menu->access_control(\%myconfig, $form->{level});
  52. foreach $item (@menuorder) {
  53. $a = $item;
  54. $item =~ s/^$form->{level}--//;
  55. push @neworder, $a unless ($item =~ /--/);
  56. }
  57. @menuorder = @neworder;
  58. $level = $form->{level};
  59. $level =~ s/--/ /g;
  60. $form->{title} = $locale->text($level);
  61. $form->header;
  62. $offset = int (21 - $#menuorder)/2;
  63. print "<pre>";
  64. print "\n" x $offset;
  65. print "</pre>";
  66. print qq|<center><table>|;
  67. foreach $item (@menuorder) {
  68. $label = $item;
  69. $label =~ s/$form->{level}--//g;
  70. # remove target
  71. $menu->{$item}{target} = "";
  72. print "<tr><td>".$menu->menuitem(\%myconfig, \%$form, $item, $form->{level}).$locale->text($label)."</a></td></tr>";
  73. }
  74. print qq'</table>
  75. </body>
  76. </html>
  77. ';
  78. }
  79. sub acc_menu {
  80. &section_menu;
  81. }
  82. sub menubar {
  83. $menu = new Menu "$menufile", "";
  84. # build menubar
  85. @menuorder = $menu->access_control(\%myconfig, "");
  86. @neworder = ();
  87. map { push @neworder, $_ unless ($_ =~ /--/) } @menuorder;
  88. @menuorder = @neworder;
  89. print "<p>";
  90. $form->{script} = "menu.pl";
  91. print "| ";
  92. foreach $item (@menuorder) {
  93. $label = $item;
  94. # remove target
  95. $menu->{$item}{target} = "";
  96. print $menu->menuitem(\%myconfig, \%$form, $item, "").$locale->text($label)."</a> | ";
  97. }
  98. }