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