Annotation of loncom/interface/lonmenu.pm, revision 1.43
1.1 www 1: # The LearningOnline Network with CAPA
2: # Routines to control the menu
3: #
1.43 ! www 4: # $Id: lonmenu.pm,v 1.42 2003/02/17 22:59:37 www 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;
1.33 www 39: use Apache::Constants qw(:common);
40: use Apache::loncommon;
1.2 www 41: use Apache::File;
42: use vars qw(@desklines $readdesk);
1.38 www 43:
1.40 www 44: # ============================= This gets called at the top of the body section
1.38 www 45:
46: sub menubuttons {
47: my $forcereg=shift;
48: my $target =shift;
1.40 www 49: my $registration=shift;
1.38 www 50: unless ($ENV{'browser.interface'} eq 'textual') { return ''; }
1.41 www 51: # Textual display only
1.43 ! www 52: my $output='<a href="/adm/menu" target="_top">Main Menu</a><br />';
1.40 www 53: if ($registration) { $output.=&innerregister($forcereg,$target); }
1.39 www 54: return $output."<hr />";
1.38 www 55: }
56:
1.40 www 57: # ====================================== This gets called in the header section
1.38 www 58:
59: sub registerurl {
60: my $forcereg=shift;
61: my $target = shift;
62: my $result = '';
63:
64: if ($target eq 'edit') {
65: $result .="<script type=\"text/javascrtipt\">\n".
66: "if (typeof swmenu != 'undefined') {swmenu.currentURL=null;}\n".
67: &Apache::loncommon::browser_and_searcher_javascript().
68: "\n</script>\n";
69: }
70: if (($ENV{'browser.interface'} eq 'textual') ||
71: ((($ENV{'request.publicaccess'}) ||
72: (!&Apache::lonnet::is_on_map($ENV{'REQUEST_URI'}))) &&
73: (!$forcereg))) {
74: return $result.
75: '<script type="text/javascript">function LONCAPAreg(){;} function LONCAPAstale(){}</script>';
76: }
1.41 www 77: # Graphical display after login only
1.38 www 78: if ($Apache::lonxml::registered && !$forcereg) { return ''; }
1.40 www 79: $result.=&innerregister($forcereg,$target);
80: return $result;
81: }
82:
83: # =========== This gets called in order to register a URL, both with the Remote
84: # =========== and in the body of the document
85:
86: sub innerregister {
87: my $forcereg=shift;
88: my $target = shift;
89: my $result = '';
90:
1.38 www 91: $Apache::lonxml::registered=1;
1.40 www 92:
93: my $textual=($ENV{'browser.interface'} eq 'textual');
1.38 www 94: my $reopen=&Apache::lonmenu::reopenmenu();
1.40 www 95:
1.38 www 96: my $newmail='';
97: if (&Apache::lonmsg::newmail()) {
1.41 www 98: $newmail=($textual?
99: '<b><a href="/adm/communicate">You have new messages</a></b><br />':
1.40 www 100: 'swmenu.setstatus("you have","messages");');
1.38 www 101: }
1.40 www 102: my $timesync=($textual?'':'swmenu.syncclock(1000*'.time.');');
1.41 www 103: # =============================================================================
104: # ============================ This is for URLs that actually can be registered
1.38 www 105: if (($ENV{'REQUEST_URI'}!~/^\/(res\/)*adm\//) || ($forcereg)) {
1.40 www 106: # -- This applies to homework problems for users with grading privileges
1.38 www 107: my $hwkadd='';
1.40 www 108: if
109: ($ENV{'request.filename'}=~/\.(problem|exam|quiz|assess|survey|form)$/) {
1.38 www 110: if (&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'})) {
1.40 www 111: $hwkadd.=&switch('','',7,1,'subm.gif','view sub','missions',
112: "gocmd('/adm/grades','submission')",
113: 'View user submissions for this assessment resource');
1.38 www 114: }
115: if (&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'})) {
1.40 www 116: $hwkadd.=&switch('','',7,2,'pgrd.gif','problem','grades',
117: "gocmd('/adm/grades','gradingmenu')",
118: 'Modify user grades for this assessment resource');
1.38 www 119: }
120: if (&Apache::lonnet::allowed('opa',$ENV{'request.course.id'})) {
1.40 www 121: $hwkadd.=&switch('','',7,3,'pparm.gif','problem','parms',
122: "gocmd('/adm/parmset','set')",
123: 'Modify deadlines, etc, for this assessment resource');
1.38 www 124: }
125: }
1.40 www 126: # -- End Homework
1.38 www 127: ###
128: ### Determine whether or not to display the 'cstr' button for this
129: ### resource
130: ###
131: my $editbutton = '';
132: if ($ENV{'user.author'}) {
133: if ($ENV{'request.role'}=~/^(ca|au)/) {
134: # Set defaults for authors
135: my ($top,$bottom) = ('con-','struct');
136: my $action = "go('/priv/".$ENV{'user.name'}."');";
137: my $cadom = $ENV{'request.role.domain'};
138: my $caname = $ENV{'user.name'};
139: my $desc = "Enter my resource construction space";
140: # Set defaults for co-authors
141: if ($ENV{'request.role'} =~ /^ca/) {
142: ($cadom,$caname)=($ENV{'request.role'}=~/(\w+)\/(\w+)$/);
143: ($top,$bottom) = ('co con-','struct');
144: $action = "go('/priv/".$caname."');";
145: $desc = "Enter construction space as co-author";
146: }
147: # Check that we are on the correct machine
148: my $home = &Apache::lonnet::homeserver($caname,$cadom);
149: if ($home eq $Apache::lonnet::perlvar{'lonHostID'}) {
1.40 www 150: $editbutton=&switch
1.38 www 151: ('','',6,1,$top,,$bottom,$action,$desc);
152: }
153: }
154: ##
155: ## Determine if user can edit url.
156: ##
157: my $cfile='';
158: my $cfuname='';
159: my $cfudom='';
160: if ($ENV{'request.filename'}) {
161: my $file=&Apache::lonnet::declutter($ENV{'request.filename'});
162: $file=~s/^(\w+)\/(\w+)/\/priv\/$2/;
163: # Chech that the user has permission to edit this resource
164: ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$1);
165: if (defined($cfudom)) {
166: if (&Apache::lonnet::homeserver($cfuname,$cfudom)
167: eq $Apache::lonnet::perlvar{'lonHostID'}) {
168: $cfile=$file;
169: }
170: }
171: }
172: # Finally, turn the button on or off
173: if ($cfile) {
1.40 www 174: $editbutton=&switch
1.38 www 175: ('','',6,1,'cstr.gif','edit','resource',
176: "go('".$cfile."');","Edit this resource");
177: } elsif ($editbutton eq '') {
1.40 www 178: $editbutton=&clear(6,1);
1.38 www 179: }
180: }
181: ###
182: ###
1.41 www 183: # Prepare the rest of the buttons
184: my $menuitems=(<<ENDMENUITEMS);
185: c&3&1
186: s&2&1&back.gif&backward&&gopost('/adm/flip','back:'+currentURL)&Go to the previous resource in the course sequence&1
187: s&2&3&forw.gif&forward&&gopost('/adm/flip','forward:'+currentURL)&Go to the next resource in the course sequence&1
188: s&6&3&catalog.gif&catalog&info&catalog_info()&Show catalog information
189: s&8&1&eval.gif&evaluate&this&gopost('/adm/evaluate',currentURL)&Provide my evaluation of this resource
190: s&8&2&fdbk.gif&feedback&discuss&gopost('/adm/feedback',currentURL)&Provide feedback messages or contribute to the course discussion about this resource
191: s&8&3&prt.gif&prepare&printout&gopost('/adm/printout',currentURL)&Prepare a printable document
192: s&9&1&sbkm.gif&set&bookmark&set_bookmark()&Set a bookmark for this resource&2
193: s&9&2&vbkm.gif&view&bookmark&edit_bookmarks()&Use or edit my bookmark collection&2
194: s&9&3&anot.gif&anno-&tations&annotate()&Make notes and annotations about this resource&2
195: ENDMENUITEMS
196: my $buttons='';
197: foreach (split(/\n/,$menuitems)) {
198: my ($command,@rest)=split(/\&/,$_);
199: if ($command eq 's') {
200: $buttons.=&switch('','',@rest);
201: } else {
202: $buttons.=&clear(@rest);
203: }
204: }
205: if ($textual) {
206: # Registered, textual output
1.42 www 207: my $utility=&utilityfunctions();
208: my $form=&serverform();
1.41 www 209: $result =(<<ENDREGTEXT);
1.42 www 210: <script>
211: // BEGIN LON-CAPA Internal
212: $utility
213: </script>
1.41 www 214: $timesync
215: $newmail
216: $buttons
217: $hwkadd
218: $editbutton
1.42 www 219: $form
220: <script>
221: //END LON-CAPA Internal
222: </script>
223:
1.41 www 224: ENDREGTEXT
225: # Registered, graphical output
226: } else {
227: $result = (<<ENDREGTHIS);
1.38 www 228:
229: <script language="JavaScript">
230: // BEGIN LON-CAPA Internal
1.42 www 231: var swmenu=null;
1.38 www 232:
233: function LONCAPAreg() {
234: swmenu=$reopen;
235: swmenu.clearTimeout(swmenu.menucltim);
236: $timesync
237: $newmail
1.41 www 238: $buttons
1.38 www 239: swmenu.currentURL=window.location.pathname;
240: swmenu.reloadURL=window.location.pathname;
241: swmenu.currentSymb="$ENV{'request.symb'}";
242: swmenu.reloadSymb="$ENV{'request.symb'}";
243: swmenu.currentStale=0;
244: $hwkadd
245: $editbutton
246: }
247:
248: function LONCAPAstale() {
249: swmenu=$reopen
250: swmenu.currentStale=1;
251: if (swmenu.reloadURL!='' && swmenu.reloadURL!= null) {
252: swmenu.switchbutton
253: (3,1,'reload.gif','return','location','go(reloadURL)','Return to the last known location in the course sequence');
254: }
255: swmenu.clearbut(7,1);
256: swmenu.clearbut(7,2);
257: swmenu.clearbut(7,3);
258: swmenu.menucltim=swmenu.setTimeout(
259: 'clearbut(2,1);clearbut(2,3);clearbut(8,1);clearbut(8,2);clearbut(8,3);'+
260: 'clearbut(9,1);clearbut(9,2);clearbut(9,3);clearbut(6,3);clearbut(6,1)',
261: 2000);
262:
263: }
264:
265: // END LON-CAPA Internal
266: </script>
267: ENDREGTHIS
1.41 www 268: }
269: # =============================================================================
1.38 www 270: } else {
1.41 www 271: # ========================================== This can or will not be registered
272: if ($textual) {
273: # Not registered, textual
274: $result= (<<ENDDONOTREGTEXT);
275: ENDDONOTREGTEXT
276: } else {
277: # Not registered, graphical
278: $result = (<<ENDDONOTREGTHIS);
1.38 www 279:
280: <script language="JavaScript">
281: // BEGIN LON-CAPA Internal
1.42 www 282: var swmenu=null;
1.38 www 283:
284: function LONCAPAreg() {
285: swmenu=$reopen
286: $timesync
287: swmenu.currentStale=1;
288: swmenu.clearbut(2,1);
289: swmenu.clearbut(2,3);
290: swmenu.clearbut(8,1);
291: swmenu.clearbut(8,2);
292: swmenu.clearbut(8,3);
293: if (swmenu.currentURL) {
294: swmenu.switchbutton
295: (3,1,'reload.gif','return','location','go(currentURL)');
296: } else {
297: swmenu.clearbut(3,1);
298: }
299: }
300:
301: function LONCAPAstale() {
302: }
303:
304: // END LON-CAPA Internal
305: </script>
306: ENDDONOTREGTHIS
1.41 www 307: }
308: # =============================================================================
1.38 www 309: }
310: return $result;
311: }
312:
313: sub loadevents() {
314: return 'LONCAPAreg();';
315: }
316:
317: sub unloadevents() {
318: return 'LONCAPAstale();';
319: }
1.30 www 320:
1.32 www 321: # ============================================================= Start up remote
322:
323: sub startupremote {
324: my ($lowerurl)=@_;
1.34 www 325: if ($ENV{'browser.interface'} eq 'textual') {
326: return ('<meta HTTP-EQUIV="Refresh" CONTENT="0.5; url='.$lowerurl.'" />');
327: }
1.32 www 328: my $configmenu=&rawconfig();
329: return(<<ENDREMOTESTARTUP);
330: <script>
331:
1.35 www 332: function wheelswitch() {
333: if (window.status=='|') {
334: window.status='/';
335: } else {
336: if (window.status=='/') {
337: window.status='-';
338: } else {
339: if (window.status=='-') {
340: window.status='\\\\';
341: } else {
342: if (window.status=='\\\\') { window.status='|'; }
343: }
344: }
345: }
346: }
347:
1.32 www 348: // ---------------------------------------------------------- The wait function
349: var canceltim;
350: function wait() {
351: if ((menuloaded==1) || (tim==1)) {
1.35 www 352: window.status='Done.';
1.32 www 353: if (tim==0) {
354: clearTimeout(canceltim);
355: $configmenu
356: window.location='$lowerurl';
357: } else {
1.35 www 358: alert("Remote Control timed out. It is possible that it was blocked by pop-up window filters.");
1.32 www 359: }
360: } else {
1.35 www 361: wheelswitch();
362: setTimeout('wait();',200);
1.32 www 363: }
364: }
365:
366: function main() {
1.35 www 367: canceltim=setTimeout('tim=1;',60000);
368: window.status='-';
1.32 www 369: wait();
370: }
371:
372: </script>
373: ENDREMOTESTARTUP
374: }
375:
376: sub setflags() {
377: return(<<ENDSETFLAGS);
378: <script>
379: menuloaded=0;
380: tim=0;
381: </script>
382: ENDSETFLAGS
383: }
384:
385: sub maincall() {
1.34 www 386: if ($ENV{'browser.interface'} eq 'textual') { return ''; }
1.32 www 387: return(<<ENDMAINCALL);
388: <script>
389: main();
390: </script>
391: ENDMAINCALL
392: }
1.30 www 393: # ================================================================= Reopen menu
394:
395: sub reopenmenu {
396: my $nothing='';
1.34 www 397: if ($ENV{'browser.interface'} eq 'textual') { return ''; }
1.30 www 398: my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
399: if ($ENV{'browser.type'} eq 'explorer') { $nothing='javascript:void(0);'; }
400: return('window.open("'.$nothing.'","'.$menuname.'","",false);');
401: }
402:
1.1 www 403: # =============================================================== Open the menu
404:
405: sub open {
1.22 www 406: my $returnval='';
1.34 www 407: if ($ENV{'browser.interface'} eq 'textual') { return ''; }
1.30 www 408: my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
1.22 www 409: unless (shift eq 'unix') {
410: # resizing does not work on linux because of virtual desktop sizes
411: $returnval.=(<<ENDRESIZE);
412: if (window.screen) {
1.28 www 413: self.resizeTo(screen.availWidth-215,screen.availHeight-55);
1.22 www 414: self.moveTo(190,15);
415: }
416: ENDRESIZE
417: }
418: $returnval.=(<<ENDOPEN);
1.35 www 419: window.status='Opening LON-CAPA Remote Control';
1.30 www 420: var menu=window.open("/res/adm/pages/menu.html","$menuname",
1.14 www 421: "height=350,width=150,scrollbars=no,menubar=no,top=5,left=5,screenX=5,screenY=5");
1.1 www 422: ENDOPEN
1.22 www 423: return '<script>'.$returnval.'</script>';
1.1 www 424: }
425:
1.2 www 426:
427: # ================================================================== Raw Config
428:
1.3 www 429: sub clear {
430: my ($row,$col)=@_;
1.34 www 431: unless ($ENV{'browser.interface'} eq 'textual') {
1.35 www 432: return "\n".qq(window.status+='.';swmenu.clearbut($row,$col););
1.34 www 433: } else { return ''; }
1.3 www 434: }
435:
1.40 www 436: # ============================================ Switch a button or create a link
1.25 matthew 437: # Switch acts on the javascript that is executed when a button is clicked.
438: # The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
1.40 www 439:
1.2 www 440: sub switch {
1.40 www 441: my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$nobreak)=@_;
1.2 www 442: $act=~s/\$uname/$uname/g;
443: $act=~s/\$udom/$udom/g;
1.34 www 444: unless ($ENV{'browser.interface'} eq 'textual') {
445: return "\n".
1.35 www 446: qq(window.status+='.';swmenu.switchbutton($row,$col,"$img","$top","$bot","$act","$desc"););
1.34 www 447: } else {
1.41 www 448: if ($nobreak==2) { return ''; }
1.34 www 449: my $text=$top.' '.$bot;
450: $text=~s/\- //;
1.42 www 451: return "\n".($nobreak?' ':'<br />').
1.43 ! www 452: '<a href="javascript:'.$act.';" target="_top">'.$text.'</a> '.
! 453: ($nobreak?'':$desc);
1.34 www 454: }
1.2 www 455: }
456:
457: sub secondlevel {
458: my $output='';
459: my
1.27 www 460: ($uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc)=@_;
1.2 www 461: if ($prt eq 'any') {
1.27 www 462: $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
1.2 www 463: } elsif ($prt=~/^r(\w+)/) {
464: if ($rol eq $1) {
1.27 www 465: $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
1.2 www 466: }
467: }
468: return $output;
469: }
470:
1.18 www 471: sub openmenu {
1.30 www 472: my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
1.34 www 473: if ($ENV{'browser.interface'} eq 'textual') { return ''; }
1.18 www 474: if ($ENV{'browser.type'} eq 'explorer') {
1.30 www 475: return "window.open('javascript:void(0);','".$menuname."');";
1.18 www 476: } else {
1.30 www 477: return "window.open('','".$menuname."');";
1.18 www 478: }
479: }
480:
1.2 www 481: sub rawconfig {
1.34 www 482: my $textualoverride=shift;
483: my $output='';
484: unless ($ENV{'browser.interface'} eq 'textual') {
1.35 www 485: $output.=
486: "window.status='Opening Remote Control';var swmenu=".&openmenu().
487: "\nwindow.status='Configuring Remote Control ';";
1.34 www 488: } else {
489: unless ($textualoverride) { return ''; }
490: }
1.2 www 491: my $uname=$ENV{'user.name'};
492: my $udom=$ENV{'user.domain'};
493: my $adv=$ENV{'user.adv'};
1.4 www 494: my $author=$ENV{'user.author'};
1.5 www 495: my $crs='';
496: if ($ENV{'request.course.id'}) {
497: $crs='/'.$ENV{'request.course.id'};
1.7 www 498: if ($ENV{'request.course.sec'}) {
499: $crs.='_'.$ENV{'request.course.sec'};
500: }
1.8 www 501: $crs=~s/\_/\//g;
1.5 www 502: }
1.2 www 503: my $pub=($ENV{'request.state'} eq 'published');
504: my $con=($ENV{'request.state'} eq 'construct');
505: my $rol=$ENV{'request.role'};
1.25 matthew 506: my $requested_domain = $ENV{'request.role.domain'};
1.13 harris41 507: foreach (@desklines) {
1.27 www 508: my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc)=split(/\:/,$_);
1.3 www 509: $prt=~s/\$uname/$uname/g;
510: $prt=~s/\$udom/$udom/g;
1.5 www 511: $prt=~s/\$crs/$crs/g;
1.25 matthew 512: $prt=~s/\$requested_domain/$requested_domain/g;
1.3 www 513: if ($pro eq 'clear') {
1.4 www 514: $output.=&clear($row,$col);
1.3 www 515: } elsif ($pro eq 'any') {
1.2 www 516: $output.=&secondlevel(
1.27 www 517: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc);
1.2 www 518: } elsif ($pro eq 'smp') {
519: unless ($adv) {
520: $output.=&secondlevel(
1.27 www 521: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc);
1.2 www 522: }
523: } elsif ($pro eq 'adv') {
524: if ($adv) {
525: $output.=&secondlevel(
1.27 www 526: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc);
1.2 www 527: }
528: } elsif (($pro=~/p(\w+)/) && ($prt)) {
529: if (&Apache::lonnet::allowed($1,$prt)) {
1.27 www 530: $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
1.4 www 531: }
1.26 www 532: } elsif ($pro eq 'course') {
533: if ($ENV{'request.course.fn'}) {
1.27 www 534: $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
1.26 www 535: }
1.4 www 536: } elsif ($pro eq 'author') {
537: if ($author) {
1.29 matthew 538: if ((($prt eq 'rca') && ($ENV{'request.role'}=~/^ca/)) ||
539: (($prt eq 'rau') && ($ENV{'request.role'}=~/^au/))) {
1.19 matthew 540: # Check that we are on the correct machine
1.29 matthew 541: my $cadom=$requested_domain;
542: my $caname=$ENV{'user.name'};
543: if ($prt eq 'rca') {
544: ($cadom,$caname)=
1.6 www 545: ($ENV{'request.role'}=~/(\w+)\/(\w+)$/);
1.29 matthew 546: }
547: $act =~ s/\$caname/$caname/g;
1.19 matthew 548: my $home = &Apache::lonnet::homeserver($caname,$cadom);
1.32 www 549: if ($home eq $Apache::lonnet::perlvar{'lonHostID'}) {
1.19 matthew 550: $output.=switch($caname,$cadom,
1.27 www 551: $row,$col,$img,$top,$bot,$act,$desc);
1.19 matthew 552: }
1.6 www 553: }
1.2 www 554: }
555: }
1.13 harris41 556: }
1.34 www 557: unless ($ENV{'browser.interface'} eq 'textual') {
1.35 www 558: $output.="\nwindow.status='Synchronizing Time';swmenu.syncclock(1000*".time.");\nwindow.status='Remote Control Configured.';";
1.34 www 559: }
1.2 www 560: return $output;
561: }
562:
563: # ======================================================================= Close
1.1 www 564:
565: sub close {
1.35 www 566: if ($ENV{'browser.interface'} eq 'textual') { return ''; }
1.30 www 567: my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
1.1 www 568: return(<<ENDCLOSE);
569: <script>
1.35 www 570: window.status='Accessing Remote Control';
1.30 www 571: menu=window.open("/adm/rat/empty.html","$menuname",
1.1 www 572: "height=350,width=150,scrollbars=no,menubar=no");
1.35 www 573: window.status='Disabling Remote Control';
574: menu.active=0;
1.31 www 575: menu.autologout=0;
1.35 www 576: window.status='Closing Remote Control';
1.1 www 577: menu.close();
1.35 www 578: window.status='Done.';
1.1 www 579: </script>
580: ENDCLOSE
581: }
582:
583: # ====================================================================== Footer
584:
585: sub footer {
586:
1.33 www 587: }
588:
1.42 www 589: sub utilityfunctions {
590: unless ($ENV{'browser.interface'} eq 'textual') { return ''; }
591: my $currenturl=$ENV{'REQUEST_URI'};
592: my $currentsymb=$ENV{'request.symb'};
593: return (<<ENDUTILITY)
594:
595: var currentURL="$currenturl";
596: var reloadURL="$currenturl";
597: var currentSymb="$currentsymb";
598:
599: function go(url) {
600: if (url!='' && url!= null) {
601: currentURL = null;
602: currentSymb= null;
603: window.location.href=url;
604: }
605: }
606:
607: function gopost(url,postdata) {
608: if (url!='') {
609: this.document.server.action=url;
610: this.document.server.postdata.value=postdata;
611: this.document.server.command.value='';
612: this.document.server.url.value='';
613: this.document.server.symb.value='';
614: this.document.server.submit();
615: }
616: }
617:
618: function gocmd(url,cmd) {
619: if (url!='') {
620: this.document.server.action=url;
621: this.document.server.postdata.value='';
622: this.document.server.command.value=cmd;
623: this.document.server.url.value=currentURL;
624: this.document.server.symb.value=currentSymb;
625: this.document.server.submit();
626: }
627: }
628: ENDUTILITY
629: }
630:
631: sub serverform {
632: return(<<ENDSERVERFORM);
633:
634: <form name="server" action="/adm/logout" method="post">
635: <input type="hidden" name="postdata" value="none" />
636: <input type="hidden" name="command" value="none" />
637: <input type="hidden" name="url" value="none" />
638: <input type="hidden" name="symb" value="none" />
639: </form>
640: ENDSERVERFORM
641: }
1.33 www 642: # ================================================ Handler when called directly
643:
644:
645: sub handler {
646: my $r = shift;
647: $r->content_type('text/html');
648: $r->send_http_header;
649: return OK if $r->header_only;
650:
1.42 www 651: my $utility=&utilityfunctions();
652: my $form=&serverform();
1.34 www 653: my $bodytag=&Apache::loncommon::bodytag('Main Menu');
1.33 www 654: # ------------------------------------------------------------ Print the screen
1.36 www 655: $r->print(<<ENDHEADER);
656: <html><head>
657: <title>LON-CAPA Main Menu</title>
658: <script>
1.42 www 659: $utility
1.36 www 660: </script>
661: </head>
662: $bodytag
663: ENDHEADER
1.42 www 664: $r->print(&rawconfig(1).$form);
1.33 www 665: $r->print('</body></html>');
666: return OK;
1.1 www 667: }
668:
1.2 www 669: # ================================================================ Main Program
670:
1.16 harris41 671: BEGIN {
1.15 matthew 672: if (! defined($readdesk)) {
1.14 www 673: {
1.10 albertel 674: my $config=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}.
675: '/mydesk.tab');
676: while (my $configline=<$config>) {
1.14 www 677: $configline=(split(/\#/,$configline))[0];
678: $configline=~s/^\s+//;
1.10 albertel 679: chomp($configline);
1.14 www 680: if ($configline) {
681: $desklines[$#desklines+1]=$configline;
682: }
1.2 www 683: }
1.14 www 684: }
685: $readdesk='done';
1.10 albertel 686: }
1.2 www 687: }
1.30 www 688:
1.1 www 689: 1;
690: __END__
691:
692:
693:
694:
695:
696:
697:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>