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