Annotation of loncom/interface/lonmenu.pm, revision 1.21
1.1 www 1: # The LearningOnline Network with CAPA
2: # Routines to control the menu
3: #
1.21 ! www 4: # $Id: lonmenu.pm,v 1.20 2002/05/06 21:57:11 matthew Exp $
1.11 albertel 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
1.1 www 28: # (TeX Conversion Module
29: #
30: # 05/29/00,05/30 Gerd Kortemeyer)
31: #
1.8 www 32: # 10/05,05/28,05/30,06/01,06/08,06/09,07/04,08/07 Gerd Kortemeyer
1.17 matthew 33: # 02/15/02 Matthew Hall
1.1 www 34:
35: package Apache::lonmenu;
36:
37: use strict;
1.2 www 38: use Apache::lonnet;
39: use Apache::File;
40: use vars qw(@desklines $readdesk);
41:
1.1 www 42: # =============================================================== Open the menu
43:
44: sub open {
1.17 matthew 45: # return(<<ENDOPEN);
46: #if (window.screen) {
47: # self.resizeTo(screen.availWidth-215,screen.availHeight-30);
48: # self.moveTo(190,15);
49: #}
1.1 www 50: return(<<ENDOPEN);
51: <script>
1.20 matthew 52: var menu=window.open("/res/adm/pages/menu.html","LONCAPAmenu",
1.14 www 53: "height=350,width=150,scrollbars=no,menubar=no,top=5,left=5,screenX=5,screenY=5");
1.1 www 54: </script>
55: ENDOPEN
56: }
57:
1.2 www 58: # ============================================================ Switch Menu Item
59:
60: sub switchmenu {
61: my ($row,$col,$imgsrc,$texttop,$textbot,$action)=@_;
1.18 www 62: my $openwin=&openmenu();
1.2 www 63: return(<<ENDSMENU);
64: <script>
1.20 matthew 65: var swmenu=$openwin
1.2 www 66: swmenu.switchbutton($row,$col,"$imgsrc","$texttop","$textbot","$action");
67: </script>
68: ENDSMENU
69: }
70:
71: # ================================================================== Raw Config
72:
1.3 www 73: sub clear {
74: my ($row,$col)=@_;
75: return qq(swmenu.clearbut($row,$col););
76: }
77:
1.2 www 78: sub switch {
79: my ($uname,$udom,$row,$col,$img,$top,$bot,$act)=@_;
80: $act=~s/\$uname/$uname/g;
81: $act=~s/\$udom/$udom/g;
82: return "\n".
1.3 www 83: qq(swmenu.switchbutton($row,$col,"$img","$top","$bot","$act"););
1.2 www 84: }
85:
86: sub secondlevel {
87: my $output='';
88: my
89: ($uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act)=@_;
90: if ($prt eq 'any') {
91: $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act);
92: } elsif ($prt=~/^r(\w+)/) {
93: if ($rol eq $1) {
94: $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act);
95: }
96: }
97: return $output;
98: }
99:
1.18 www 100: sub openmenu {
101: if ($ENV{'browser.type'} eq 'explorer') {
102: return "window.open('javascript:void(0);','LONCAPAmenu');";
103: } else {
104: return "window.open('','LONCAPAmenu');";
105: }
106: }
107:
1.2 www 108: sub rawconfig {
1.19 matthew 109: my $r = shift;
1.20 matthew 110: my $output="var swmenu=".&openmenu();
1.2 www 111: my $uname=$ENV{'user.name'};
112: my $udom=$ENV{'user.domain'};
113: my $adv=$ENV{'user.adv'};
1.4 www 114: my $author=$ENV{'user.author'};
1.5 www 115: my $crs='';
116: if ($ENV{'request.course.id'}) {
117: $crs='/'.$ENV{'request.course.id'};
1.7 www 118: if ($ENV{'request.course.sec'}) {
119: $crs.='_'.$ENV{'request.course.sec'};
120: }
1.8 www 121: $crs=~s/\_/\//g;
1.5 www 122: }
1.2 www 123: my $pub=($ENV{'request.state'} eq 'published');
124: my $con=($ENV{'request.state'} eq 'construct');
125: my $rol=$ENV{'request.role'};
1.13 harris41 126: foreach (@desklines) {
1.2 www 127: my ($row,$col,$pro,$prt,$img,$top,$bot,$act)=split(/\:/,$_);
1.3 www 128: $prt=~s/\$uname/$uname/g;
129: $prt=~s/\$udom/$udom/g;
1.5 www 130: $prt=~s/\$crs/$crs/g;
1.3 www 131: if ($pro eq 'clear') {
1.4 www 132: $output.=&clear($row,$col);
1.3 www 133: } elsif ($pro eq 'any') {
1.2 www 134: $output.=&secondlevel(
135: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act);
136: } elsif ($pro eq 'smp') {
137: unless ($adv) {
138: $output.=&secondlevel(
139: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act);
140: }
141: } elsif ($pro eq 'adv') {
142: if ($adv) {
143: $output.=&secondlevel(
144: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act);
145: }
146: } elsif (($pro=~/p(\w+)/) && ($prt)) {
147: if (&Apache::lonnet::allowed($1,$prt)) {
148: $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act);
1.4 www 149: }
150: } elsif ($pro eq 'author') {
151: if ($author) {
1.6 www 152: if (($prt eq 'rca') && ($ENV{'request.role'}=~/^ca/)) {
1.19 matthew 153: # Check that we are on the correct machine
1.6 www 154: my ($cadom,$caname)=
155: ($ENV{'request.role'}=~/(\w+)\/(\w+)$/);
1.19 matthew 156: my $home = &Apache::lonnet::homeserver($caname,$cadom);
157: if ($home eq $r->dir_config('lonHostID')) {
158: $output.=switch($caname,$cadom,
159: $row,$col,$img,$top,$bot,$act);
160: }
1.6 www 161: } elsif ($prt eq 'any') {
1.19 matthew 162: my $home = &Apache::lonnet::homeserver
163: ($ENV{'user.name'},$ENV{'user.domain'});
164: if ($home eq $r->dir_config('lonHostID')) {
165: $output.=switch
166: ($ENV{'user.name'},$ENV{'user.domain'},
167: $row,$col,$img,$top,$bot,$act);
168: }
1.6 www 169: }
1.2 www 170: }
171: }
1.13 harris41 172: }
1.21 ! www 173: $output.="swmenu.clock.setTime(1000*".time.");";
1.2 www 174: return $output;
175: }
176:
177: # ======================================================================= Close
1.1 www 178:
179: sub close {
180: return(<<ENDCLOSE);
181: <script>
182: menu=window.open("/adm/rat/empty.html","LONCAPAmenu",
183: "height=350,width=150,scrollbars=no,menubar=no");
184: menu.close();
185: </script>
186: ENDCLOSE
187: }
188:
189: # ====================================================================== Footer
190:
191: sub footer {
192:
193: }
194:
1.2 www 195: # ================================================================ Main Program
196:
1.16 harris41 197: BEGIN {
1.15 matthew 198: if (! defined($readdesk)) {
1.14 www 199: {
1.10 albertel 200: my $config=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}.
201: '/mydesk.tab');
202: while (my $configline=<$config>) {
1.14 www 203: $configline=(split(/\#/,$configline))[0];
204: $configline=~s/^\s+//;
1.10 albertel 205: chomp($configline);
1.14 www 206: if ($configline) {
207: $desklines[$#desklines+1]=$configline;
208: }
1.2 www 209: }
1.14 www 210: }
211: $readdesk='done';
1.10 albertel 212: }
1.2 www 213: }
1.1 www 214: 1;
215: __END__
216:
217:
218:
219:
220:
221:
222:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>