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