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