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