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