Annotation of loncom/interface/lonmenu.pm, revision 1.3
1.1 www 1: # The LearningOnline Network with CAPA
2: # Routines to control the menu
3: #
4: # (TeX Conversion Module
5: #
6: # 05/29/00,05/30 Gerd Kortemeyer)
7: #
1.3 ! www 8: # 10/05,05/28,05/30,06/01 Gerd Kortemeyer
1.1 www 9:
10: package Apache::lonmenu;
11:
12: use strict;
1.2 www 13: use Apache::lonnet;
14: use Apache::File;
15: use vars qw(@desklines $readdesk);
16:
1.1 www 17: # =============================================================== Open the menu
18:
19: sub open {
20: return(<<ENDOPEN);
21: <script>
22: window.status='MenuControl:nologout';
23: menu=window.open("/res/adm/pages/menu.html","LONCAPAmenu",
24: "height=350,width=150,scrollbars=no,menubar=no");
25: </script>
26: ENDOPEN
27: }
28:
1.2 www 29: # ============================================================ Switch Menu Item
30:
31: sub switchmenu {
32: my ($row,$col,$imgsrc,$texttop,$textbot,$action)=@_;
33: return(<<ENDSMENU);
34: <script>
35: swmenu=window.open('','LONCAPAmenu');
36: swmenu.switchbutton($row,$col,"$imgsrc","$texttop","$textbot","$action");
37: </script>
38: ENDSMENU
39: }
40:
41: # ================================================================== Raw Config
42:
1.3 ! www 43: sub clear {
! 44: my ($row,$col)=@_;
! 45: return qq(swmenu.clearbut($row,$col););
! 46: }
! 47:
1.2 www 48: sub switch {
49: my ($uname,$udom,$row,$col,$img,$top,$bot,$act)=@_;
50: $act=~s/\$uname/$uname/g;
51: $act=~s/\$udom/$udom/g;
52: return "\n".
1.3 ! www 53: qq(swmenu.switchbutton($row,$col,"$img","$top","$bot","$act"););
1.2 www 54: }
55:
56: sub secondlevel {
57: my $output='';
58: my
59: ($uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act)=@_;
60: if ($prt eq 'any') {
61: $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act);
62: } elsif ($prt=~/^r(\w+)/) {
63: if ($rol eq $1) {
64: $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act);
65: }
66: }
67: return $output;
68: }
69:
70: sub rawconfig {
71: my $output="swmenu=window.open('','LONCAPAmenu');";
72: my $uname=$ENV{'user.name'};
73: my $udom=$ENV{'user.domain'};
74: my $adv=$ENV{'user.adv'};
1.3 ! www 75: my $crs='/'.$ENV{'request.course.id'};
! 76: $crs=~s/\_/\//;
1.2 www 77: my $pub=($ENV{'request.state'} eq 'published');
78: my $con=($ENV{'request.state'} eq 'construct');
79: my $rol=$ENV{'request.role'};
80: map {
81: my ($row,$col,$pro,$prt,$img,$top,$bot,$act)=split(/\:/,$_);
1.3 ! www 82: $prt=~s/\$uname/$uname/g;
! 83: $prt=~s/\$udom/$udom/g;
! 84: $prt=~s/\$crs/$crs/g;
! 85: if ($pro eq 'clear') {
! 86: &clear($row,$col);
! 87: } elsif ($pro eq 'any') {
1.2 www 88: $output.=&secondlevel(
89: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act);
90: } elsif ($pro eq 'smp') {
91: unless ($adv) {
92: $output.=&secondlevel(
93: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act);
94: }
95: } elsif ($pro eq 'adv') {
96: if ($adv) {
97: $output.=&secondlevel(
98: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act);
99: }
100: } elsif (($pro=~/p(\w+)/) && ($prt)) {
101: if (&Apache::lonnet::allowed($1,$prt)) {
102: $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act);
103: }
104: }
105: } @desklines;
106: return $output;
107: }
108:
109: # ======================================================================= Close
1.1 www 110:
111: sub close {
112: return(<<ENDCLOSE);
113: <script>
114: window.status='MenuControl:nologout';
115: menu=window.open("/adm/rat/empty.html","LONCAPAmenu",
116: "height=350,width=150,scrollbars=no,menubar=no");
117: menu.close();
118: </script>
119: ENDCLOSE
120: }
121:
122: # ====================================================================== Footer
123:
124: sub footer {
125:
126: }
127:
1.2 www 128: # ================================================================ Main Program
129:
130: sub BEGIN {
131: if ($readdesk ne 'done') {
132: {
133: my $config=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}.
134: '/mydesk.tab');
135: while (my $configline=<$config>) {
136: chomp($configline);
137: $desklines[$#desklines+1]=$configline;
138: }
139: }
140: }
141: }
1.1 www 142: 1;
143: __END__
144:
145:
146:
147:
148:
149:
150:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>