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