Annotation of loncom/interface/lonmenu.pm, revision 1.144
1.1 www 1: # The LearningOnline Network with CAPA
2: # Routines to control the menu
3: #
1.144 ! albertel 4: # $Id: lonmenu.pm,v 1.143 2005/02/02 19:24:45 albertel 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.115 albertel 42: use Apache::lonnet();
1.33 www 43: use Apache::Constants qw(:common);
1.47 matthew 44: use Apache::lonhtmlcommon();
1.115 albertel 45: use Apache::loncommon();
1.127 albertel 46: use Apache::lonenc();
1.88 www 47: use Apache::lonlocal;
48:
1.2 www 49: use vars qw(@desklines $readdesk);
1.88 www 50:
51:
1.56 www 52: my @inlineremote;
1.58 www 53: my $font;
54: my $tabbg;
55: my $pgbg;
1.38 www 56:
1.88 www 57: # ================================================================ Little texts
58:
59: sub initlittle {
60: return &Apache::lonlocal::texthash('ret' => 'Return to Last Location',
61: 'nav' => 'Navigate Contents',
62: 'main' => 'Main Menu',
63: 'launch' => 'Launch Remote Control');
64: }
65:
1.40 www 66: # ============================= This gets called at the top of the body section
1.38 www 67:
68: sub menubuttons {
69: my $forcereg=shift;
70: my $target =shift;
1.40 www 71: my $registration=shift;
1.131 raeburn 72: my $titletable=shift;
1.112 albertel 73: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
74: ['inhibitmenu']);
75: if ($ENV{'form.inhibitmenu'} eq 'yes') { return ''; }
76:
1.55 www 77: my $navmaps='';
1.59 www 78: my $reloadlink='';
1.126 albertel 79: my $escurl=&Apache::lonnet::escape(&Apache::lonenc::check_encrypt($ENV{'request.noversionuri'}));
80: my $escsymb=&Apache::lonnet::escape(&Apache::lonenc::check_encrypt($ENV{'request.symb'}));
1.134 raeburn 81: if ($ENV{'request.state'} eq 'construct') {
82: if (($ENV{'request.noversionuri'} eq '') || (!defined($ENV{'request.noversionuri'}))) {
83: my $returnurl = $ENV{'request.filename'};
84: $returnurl =~ s:^/home/([^/]+)/public_html/(.*)$:/priv/$1/$2:;
85: $escurl = &Apache::lonnet::escape($returnurl);
86: }
87: }
1.48 www 88: if ($ENV{'browser.interface'} eq 'textual') {
1.41 www 89: # Textual display only
1.88 www 90: my %lt=&initlittle();
1.101 www 91: $pgbg='#FFFFFF';
92: $tabbg='#FFFFFF';
93: $font='#000000';
1.55 www 94: if ($ENV{'request.course.id'}) {
95: $navmaps=(<<ENDNAV);
1.88 www 96: <a href="/adm/navmaps?postdata=$escurl&postsymb=$escsymb" target="_top">$lt{'nav'}</a>
1.55 www 97: ENDNAV
1.97 www 98: if (($ENV{'request.noversionuri'}=~/^\/adm\//) &&
99: ($ENV{'request.noversionuri'}!~/^\/adm\/wrapper\//) &&
100: ($ENV{'request.noversionuri'}!~/^\/adm\/.*\/(smppg|bulletinboard|aboutme)(\?|$)/)) {
1.59 www 101: my $escreload=&Apache::lonnet::escape('return:');
102: $reloadlink=(<<ENDRELOAD);
1.88 www 103: <a href="/adm/flip?postdata=$escreload" target="_top"><font color="$font">$lt{'ret'}</font></a>
1.59 www 104: ENDRELOAD
105: }
1.55 www 106: }
1.130 albertel 107: my $form=&serverform();
1.116 albertel 108: my $utility=&utilityfunctions();
1.48 www 109: my $output=(<<ENDMAINMENU);
1.129 albertel 110: <script type="text/javascript">
1.44 www 111: // BEGIN LON-CAPA Internal
1.116 albertel 112: $utility
1.44 www 113: </script>
1.88 www 114: <a href="/adm/menu" target="_top">$lt{'main'}</a>
1.59 www 115: $reloadlink $navmaps<br />
1.129 albertel 116: <script type="text/javascript">
1.44 www 117: // END LON-CAPA Internal
118: </script>
1.130 albertel 119: $form
1.44 www 120: ENDMAINMENU
1.48 www 121: if ($registration) { $output.=&innerregister($forcereg,$target); }
122: return $output."<hr />";
123: } elsif ($ENV{'environment.remote'} eq 'off') {
124: # Remote Control is switched off
1.58 www 125: # figure out colors
1.88 www 126: my %lt=&initlittle();
1.58 www 127: my $function='student';
128: if ($ENV{'request.role'}=~/^(cc|in|ta|ep)/) {
129: $function='coordinator';
130: }
131: if ($ENV{'request.role'}=~/^(su|dc|ad|li)/) {
132: $function='admin';
133: }
134: if (($ENV{'request.role'}=~/^(au|ca)/) ||
1.97 www 135: ($ENV{'request.noversionuri'}=~/^(\/priv|\~)/)) {
1.58 www 136: $function='author';
137: }
138: my $domain=&Apache::loncommon::determinedomain();
139: $pgbg=&Apache::loncommon::designparm($function.'.pgbg',$domain);
140: $tabbg=&Apache::loncommon::designparm($function.'.tabbg',$domain);
141: $font=&Apache::loncommon::designparm($function.'.font',$domain);
142: my $link=&Apache::loncommon::designparm($function.'.link',$domain);
143: my $alink=&Apache::loncommon::designparm($function.'.alink',$domain);
144: my $vlink=&Apache::loncommon::designparm($function.'.vlink',$domain);
145: my $sidebg=&Apache::loncommon::designparm($function.'.sidebg',$domain);
146: # Do we have a NAV link?
1.55 www 147: if ($ENV{'request.course.id'}) {
1.141 albertel 148: my $link='/adm/navmaps?postdata='.$escurl.'&postsymb='.
149: $escsymb;
150: if ($ENV{'environment.remotenavmap'} eq 'on') {
151: $link="javascript:gonav('".$link."')";
152: }
153: $navmaps=(<<ENDNAV);
1.58 www 154: <td bgcolor="$tabbg">
1.141 albertel 155: <a href="$link"><font color="$font">$lt{'nav'}</font></a></td>
1.114 albertel 156: ENDNAV
1.144 ! albertel 157: if (
! 158: ($ENV{'request.noversionuri'}=~m[^/(res|public)/] &&
! 159: $ENV{'request.symb'} ne '')
! 160: ||
! 161: (($ENV{'request.noversionuri'}=~/^\/adm\//) &&
! 162: ($ENV{'request.noversionuri'}!~/^\/adm\/wrapper\//) &&
! 163: ($ENV{'request.noversionuri'}!~
! 164: m[^/adm/.*/(smppg|bulletinboard|aboutme)($|\?)])
! 165: )
! 166: ) {
1.59 www 167: my $escreload=&Apache::lonnet::escape('return:');
168: $reloadlink=(<<ENDRELOAD);
169: <td bgcolor="$tabbg">
1.88 www 170: <a href="/adm/flip?postdata=$escreload" target="_top"><font color="$font">$lt{'ret'}</font></a></td>
1.59 www 171: ENDRELOAD
172: }
1.55 www 173: }
1.58 www 174: my $reg='';
175: if ($registration) {
1.131 raeburn 176: $reg=&innerregister($forcereg,$target,$titletable);
1.58 www 177: }
1.130 albertel 178: my $form=&serverform();
1.116 albertel 179: my $utility=&utilityfunctions();
1.58 www 180: return (<<ENDINLINEMENU);
1.129 albertel 181: <script type="text/javascript">
1.48 www 182: // BEGIN LON-CAPA Internal
1.116 albertel 183: $utility
1.48 www 184: </script>
1.99 www 185: <font face="Arial,Helvetica,sans-serif"><table bgcolor="$pgbg" width="100%" border="0" cellpadding="1" cellspacing="1">
1.58 www 186: <tr>
187: <td bgcolor="$tabbg">
1.88 www 188: <a href="/adm/menu" target="_top"><font color="$font">$lt{'main'}</font></a>
1.58 www 189: </td>
1.59 www 190: $reloadlink
1.55 www 191: $navmaps
1.58 www 192: <td bgcolor="$tabbg">
1.129 albertel 193: <a href="/adm/remote?action=launch&url=$escurl" target="_top">
1.88 www 194: <font color="$font">$lt{'launch'}</font></a></td>
1.65 www 195: <td bgcolor="$tabbg">
196: <img align="right" src="/adm/lonIcons/minilogo.gif" />
197: <b>LON-CAPA</b></td>
1.130 albertel 198: $form
1.58 www 199: </tr>
200: </table>
1.99 www 201: </font>
1.129 albertel 202: <script type="text/javascript">
1.48 www 203: // END LON-CAPA Internal
204: </script>
1.58 www 205: $reg
1.48 www 206: ENDINLINEMENU
207: } else {
208: return '';
209: }
1.72 www 210: }
211:
1.40 www 212: # ====================================== This gets called in the header section
1.38 www 213:
214: sub registerurl {
215: my $forcereg=shift;
216: my $target = shift;
217: my $result = '';
1.97 www 218: if ($ENV{'request.noversionuri'} eq '/res/adm/pages/menu.html') { return ''; }
1.66 albertel 219: my $force_title='';
220: if ($ENV{'request.state'} eq 'construct') {
221: $force_title=&Apache::lonxml::display_title();
222: }
1.38 www 223: if ($target eq 'edit') {
1.45 www 224: $result .="<script type=\"text/javascript\">\n".
1.38 www 225: "if (typeof swmenu != 'undefined') {swmenu.currentURL=null;}\n".
226: &Apache::loncommon::browser_and_searcher_javascript().
227: "\n</script>\n";
228: }
229: if (($ENV{'browser.interface'} eq 'textual') ||
1.53 www 230: ($ENV{'environment.remote'} eq 'off') ||
1.38 www 231: ((($ENV{'request.publicaccess'}) ||
1.83 www 232: (!&Apache::lonnet::is_on_map(
1.97 www 233: &Apache::lonnet::unescape($ENV{'request.noversionuri'})))) &&
1.38 www 234: (!$forcereg))) {
1.76 www 235: return $result.
236: '<script type="text/javascript">function LONCAPAreg(){;} function LONCAPAstale(){}</script>'.$force_title;
1.38 www 237: }
1.41 www 238: # Graphical display after login only
1.38 www 239: if ($Apache::lonxml::registered && !$forcereg) { return ''; }
1.96 albertel 240: if ($target ne 'edit') {
241: $result.=&innerregister($forcereg,$target);
242: }
1.66 albertel 243: return $result.$force_title;
1.40 www 244: }
245:
246: # =========== This gets called in order to register a URL, both with the Remote
247: # =========== and in the body of the document
248:
249: sub innerregister {
250: my $forcereg=shift;
251: my $target = shift;
1.131 raeburn 252: my $titletable = shift;
1.40 www 253: my $result = '';
1.120 raeburn 254: my ($uname,$thisdisfn);
1.128 albertel 255: my $const_space = ($ENV{'request.state'} eq 'construct');
1.131 raeburn 256: my $is_const_dir = 0;
1.120 raeburn 257:
1.97 www 258: if ($ENV{'request.noversionuri'} eq '/res/adm/pages/menu.html') { return ''; }
1.40 www 259:
1.38 www 260: $Apache::lonxml::registered=1;
1.40 www 261:
1.49 www 262: my $textinter=($ENV{'browser.interface'} eq 'textual');
263: my $noremote=($ENV{'environment.remote'} eq 'off');
264:
265: my $textual=($textinter || $noremote);
266:
1.56 www 267: @inlineremote=();
268: undef @inlineremote;
269:
1.38 www 270: my $reopen=&Apache::lonmenu::reopenmenu();
1.40 www 271:
1.38 www 272: my $newmail='';
1.65 www 273: if ($noremote) {
1.99 www 274: $newmail='<font face="Arial,Helvetica,sans-serif"><table bgcolor="'.$pgbg.'" border="0" cellspacing="1" cellpadding="1" width="100%"><tr><td bgcolor="'.$tabbg.'">';
1.65 www 275: }
1.61 www 276: if (($textual) && ($ENV{'request.symb'}) && ($ENV{'request.course.id'})) {
1.87 www 277: my ($mapurl,$rid,$resurl)=&Apache::lonnet::decode_symb($ENV{'request.symb'});
1.65 www 278: $newmail.=$ENV{'course.'.$ENV{'request.course.id'}.'.description'};
1.61 www 279: my $maptitle=&Apache::lonnet::gettitle($mapurl);
280: my $restitle=&Apache::lonnet::gettitle($resurl);
1.133 albertel 281: if ($maptitle && $maptitle ne 'default.sequence') {
1.61 www 282: $newmail.=', '.$maptitle;
283: }
284: if ($restitle) {
285: $newmail.=': '.$restitle;
286: }
287: $newmail.=' ';
1.60 www 288: }
1.38 www 289: if (&Apache::lonmsg::newmail()) {
1.41 www 290: $newmail=($textual?
1.80 www 291: '<b><a href="/adm/communicate" target="_top">You have new messages</a></b><br />':
1.40 www 292: 'swmenu.setstatus("you have","messages");');
1.65 www 293: }
1.131 raeburn 294: if ($ENV{'request.state'} eq 'construct') {
295: $newmail = $titletable;
296: }
1.65 www 297: if ($noremote) {
1.99 www 298: $newmail.='</td></tr></table></font>';
1.38 www 299: }
1.40 www 300: my $timesync=($textual?'':'swmenu.syncclock(1000*'.time.');');
1.100 www 301: my $tablestart=($noremote?'<font face="Arial,Helvetica,sans-serif"><table bgcolor="'.$pgbg.'" border="0" cellspacing="1" cellpadding="1" width="100%">':'').($textinter?'<br /><a href="#content">'.&mt('Skip to Content').'</a><br />':'');
302: my $tableend=($noremote?'</table></font>':'').($textinter?'<a name="content" />':'');
1.41 www 303: # =============================================================================
304: # ============================ This is for URLs that actually can be registered
1.97 www 305: if (($ENV{'request.noversionuri'}!~/^\/(res\/)*adm\//) || ($forcereg)) {
1.40 www 306: # -- This applies to homework problems for users with grading privileges
1.107 albertel 307: my $crs='/'.$ENV{'request.course.id'};
308: if ($ENV{'request.course.sec'}) {
309: $crs.='_'.$ENV{'request.course.sec'};
310: }
311: $crs=~s/\_/\//g;
312:
1.38 www 313: my $hwkadd='';
1.107 albertel 314: if ($ENV{'request.filename'}=~/\.(problem|exam|quiz|assess|survey|form)$/) {
1.79 www 315: if (&Apache::lonnet::allowed('vgr',$crs)) {
1.106 www 316: $hwkadd.=&switch('','',7,1,'subm.gif','view sub-[_1]','missions[_1]',
1.40 www 317: "gocmd('/adm/grades','submission')",
318: 'View user submissions for this assessment resource');
1.38 www 319: }
1.79 www 320: if (&Apache::lonnet::allowed('mgr',$crs)) {
1.106 www 321: $hwkadd.=&switch('','',7,2,'pgrd.gif','problem[_1]','grades[_3]',
1.40 www 322: "gocmd('/adm/grades','gradingmenu')",
323: 'Modify user grades for this assessment resource');
1.38 www 324: }
1.107 albertel 325: }
326: if (&Apache::lonnet::allowed('opa',$crs)) {
327: $hwkadd.=&switch('','',7,3,'pparm.gif','problem[_2]','parms[_2]',
328: "gocmd('/adm/parmset','set')",
329: 'Modify deadlines, etc, for this resource');
1.38 www 330: }
1.40 www 331: # -- End Homework
1.38 www 332: ###
333: ### Determine whether or not to display the 'cstr' button for this
334: ### resource
335: ###
336: my $editbutton = '';
337: if ($ENV{'user.author'}) {
338: if ($ENV{'request.role'}=~/^(ca|au)/) {
339: # Set defaults for authors
340: my ($top,$bottom) = ('con-','struct');
341: my $action = "go('/priv/".$ENV{'user.name'}."');";
342: my $cadom = $ENV{'request.role.domain'};
343: my $caname = $ENV{'user.name'};
344: my $desc = "Enter my resource construction space";
345: # Set defaults for co-authors
346: if ($ENV{'request.role'} =~ /^ca/) {
347: ($cadom,$caname)=($ENV{'request.role'}=~/(\w+)\/(\w+)$/);
348: ($top,$bottom) = ('co con-','struct');
349: $action = "go('/priv/".$caname."');";
350: $desc = "Enter construction space as co-author";
351: }
352: # Check that we are on the correct machine
353: my $home = &Apache::lonnet::homeserver($caname,$cadom);
1.109 albertel 354: my $allowed=0;
355: my @ids=&Apache::lonnet::current_machine_ids();
356: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
357: if (!$allowed) {
358: $editbutton=&switch('','',6,1,$top,,$bottom,$action,$desc);
1.38 www 359: }
360: }
361: ##
362: ## Determine if user can edit url.
363: ##
364: my $cfile='';
365: my $cfuname='';
366: my $cfudom='';
367: if ($ENV{'request.filename'}) {
368: my $file=&Apache::lonnet::declutter($ENV{'request.filename'});
369: $file=~s/^(\w+)\/(\w+)/\/priv\/$2/;
1.109 albertel 370: # Check that the user has permission to edit this resource
1.38 www 371: ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$1);
372: if (defined($cfudom)) {
1.109 albertel 373: my $home=&Apache::lonnet::homeserver($cfuname,$cfudom);
374: my $allowed=0;
375: my @ids=&Apache::lonnet::current_machine_ids();
376: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
377: if ($allowed) {
1.38 www 378: $cfile=$file;
379: }
380: }
381: }
382: # Finally, turn the button on or off
1.120 raeburn 383: if ($cfile && !$const_space) {
1.40 www 384: $editbutton=&switch
1.106 www 385: ('','',6,1,'cstr.gif','edit[_1]','resource[_2]',
1.38 www 386: "go('".$cfile."');","Edit this resource");
387: } elsif ($editbutton eq '') {
1.40 www 388: $editbutton=&clear(6,1);
1.38 www 389: }
390: }
391: ###
392: ###
1.41 www 393: # Prepare the rest of the buttons
1.120 raeburn 394: my $menuitems;
395: if ($const_space) {
1.128 albertel 396: my ($uname,$thisdisfn) =
397: ($ENV{'request.filename'}=~m|^/home/([^/]+)/public_html/(.*)|);
1.121 raeburn 398: my $currdir = '/priv/'.$uname.'/'.$thisdisfn;
1.131 raeburn 399: if ($currdir =~ m-/$-) {
400: $is_const_dir = 1;
401: } else {
402: $currdir =~ s#[^/]+$##;
403: $menuitems=(<<ENDMENUITEMS);
404: s&6&1&list.gif&list[_1]&dir[_1]&golist('$currdir')&List current directory
405: s&6&2&rtrv.gif&retrieve[_1]&version[_1]&gocstr('/adm/retrieve','/~$uname/$thisdisfn')&Retrieve old version
1.121 raeburn 406: s&6&3&pub.gif&publish[_1]&resource[_1]&gocstr('/adm/publish','/~$uname/$thisdisfn')&Publish this resource
407: s&7&1&del.gif&delete[_1]&resource[_2]&gocstr('/adm/cfile?action=delete','/~$uname/$thisdisfn')&Delete this resource
1.137 raeburn 408: s&7&2&prt.gif&prepare[_1]&printout[_1]&gocstr('/adm/printout','/~$uname/$thisdisfn')&Prepare a printable document
1.120 raeburn 409: ENDMENUITEMS
1.131 raeburn 410: }
1.136 albertel 411: } elsif (defined($ENV{'request.course.id'})) {
1.120 raeburn 412: $menuitems=(<<ENDMENUITEMS);
1.41 www 413: c&3&1
1.106 www 414: s&2&1&back.gif&backward[_1]&&gopost('/adm/flip','back:'+currentURL)&Go to the previous resource in the course sequence&1
415: s&2&3&forw.gif&forward[_1]&&gopost('/adm/flip','forward:'+currentURL)&Go to the next resource in the course sequence&3
1.77 www 416: c&6&3
417: c&8&1
418: c&8&2
1.106 www 419: s&8&3&prt.gif&prepare[_1]&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
420: s&9&1&sbkm.gif&set[_1]&bookmark[_2]&set_bookmark()&Set a bookmark for this resource&2
421: s&9&3&anot.gif&anno-[_1]&tations[_1]&annotate()&Make notes and annotations about this resource&2
1.41 www 422: ENDMENUITEMS
1.120 raeburn 423: unless ($ENV{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) {
424: $menuitems.=(<<ENDREALRES);
1.106 www 425: s&6&3&catalog.gif&catalog[_1]&info[_1]&catalog_info()&Show catalog information
426: s&8&1&eval.gif&evaluate[_1]&this[_1]&gopost('/adm/evaluate',currentURL,1)&Provide my evaluation of this resource
427: s&8&2&fdbk.gif&feedback[_1]&discuss[_1]&gopost('/adm/feedback',currentURL,1)&Provide feedback messages or contribute to the course discussion about this resource
1.77 www 428: ENDREALRES
1.120 raeburn 429: }
430: }
1.41 www 431: my $buttons='';
432: foreach (split(/\n/,$menuitems)) {
433: my ($command,@rest)=split(/\&/,$_);
434: if ($command eq 's') {
435: $buttons.=&switch('','',@rest);
436: } else {
437: $buttons.=&clear(@rest);
438: }
439: }
440: if ($textual) {
441: # Registered, textual output
1.103 www 442: my $inlinebuttons='';
443:
444: if ($ENV{'browser.interface'} eq 'textual') {
445: $inlinebuttons=
1.56 www 446: join('',map { (defined($_)?$_:'') } @inlineremote);
1.103 www 447: } else {
448: $inlinebuttons=(<<ENDINLINE);
1.129 albertel 449: <tr><td>$inlineremote[21]</td><td> </td><td>$inlineremote[23]</td></tr>
1.103 www 450: <tr><td>$inlineremote[61]</td><td>$inlineremote[62]</td><td>$inlineremote[63]</td></tr>
451: <tr><td>$inlineremote[71]</td><td>$inlineremote[72]</td><td>$inlineremote[73]</td></tr>
452: <tr><td>$inlineremote[81]</td><td>$inlineremote[82]</td><td>$inlineremote[83]</td></tr>
453: <tr><td>$inlineremote[91]</td><td>$inlineremote[92]</td><td>$inlineremote[93]</td></tr>
454: ENDINLINE
455: }
1.131 raeburn 456: if ($const_space && $is_const_dir) {
457: $inlinebuttons = '';
458: }
1.41 www 459: $result =(<<ENDREGTEXT);
1.129 albertel 460: <script type="text/javascript">
1.42 www 461: // BEGIN LON-CAPA Internal
462: </script>
1.41 www 463: $timesync
464: $newmail
1.58 www 465: $tablestart
1.56 www 466: $inlinebuttons
1.58 www 467: $tableend
1.129 albertel 468: <script type="text/javascript">
1.64 www 469: // END LON-CAPA Internal
1.42 www 470: </script>
471:
1.41 www 472: ENDREGTEXT
473: # Registered, graphical output
474: } else {
1.139 albertel 475: my $requri=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$ENV{'request.noversionuri'}))[0]));
1.126 albertel 476: $requri=&Apache::lonenc::check_encrypt(&Apache::lonnet::unescape($requri));
477: my $cursymb=&Apache::lonenc::check_encrypt($ENV{'request.symb'});
1.113 albertel 478: my $navstatus=&get_nav_status();
1.140 albertel 479: my $clearcstr;
480: if ($ENV{'user.adv'}) { $clearcstr='clearbut(6,1)'; }
1.41 www 481: $result = (<<ENDREGTHIS);
1.38 www 482:
1.129 albertel 483: <script type="text/javascript">
1.38 www 484: // BEGIN LON-CAPA Internal
1.42 www 485: var swmenu=null;
1.38 www 486:
487: function LONCAPAreg() {
488: swmenu=$reopen;
489: swmenu.clearTimeout(swmenu.menucltim);
490: $timesync
491: $newmail
1.41 www 492: $buttons
1.84 www 493: swmenu.currentURL="$requri";
1.85 www 494: swmenu.reloadURL=swmenu.currentURL+window.location.search;
1.125 albertel 495: swmenu.currentSymb="$cursymb";
496: swmenu.reloadSymb="$cursymb";
1.38 www 497: swmenu.currentStale=0;
1.113 albertel 498: $navstatus
1.38 www 499: $hwkadd
500: $editbutton
501: }
502:
503: function LONCAPAstale() {
504: swmenu=$reopen
505: swmenu.currentStale=1;
506: if (swmenu.reloadURL!='' && swmenu.reloadURL!= null) {
507: swmenu.switchbutton
508: (3,1,'reload.gif','return','location','go(reloadURL)','Return to the last known location in the course sequence');
509: }
510: swmenu.clearbut(7,1);
511: swmenu.clearbut(7,2);
512: swmenu.clearbut(7,3);
513: swmenu.menucltim=swmenu.setTimeout(
514: 'clearbut(2,1);clearbut(2,3);clearbut(8,1);clearbut(8,2);clearbut(8,3);'+
1.140 albertel 515: 'clearbut(9,1);clearbut(9,3);clearbut(6,3);$clearcstr',
1.38 www 516: 2000);
517: }
518:
519: // END LON-CAPA Internal
520: </script>
521: ENDREGTHIS
1.41 www 522: }
523: # =============================================================================
1.38 www 524: } else {
1.41 www 525: # ========================================== This can or will not be registered
526: if ($textual) {
527: # Not registered, textual
528: $result= (<<ENDDONOTREGTEXT);
529: ENDDONOTREGTEXT
530: } else {
531: # Not registered, graphical
532: $result = (<<ENDDONOTREGTHIS);
1.38 www 533:
1.129 albertel 534: <script type="text/javascript">
1.38 www 535: // BEGIN LON-CAPA Internal
1.42 www 536: var swmenu=null;
1.38 www 537:
538: function LONCAPAreg() {
539: swmenu=$reopen
540: $timesync
541: swmenu.currentStale=1;
542: swmenu.clearbut(2,1);
543: swmenu.clearbut(2,3);
544: swmenu.clearbut(8,1);
545: swmenu.clearbut(8,2);
546: swmenu.clearbut(8,3);
547: if (swmenu.currentURL) {
548: swmenu.switchbutton
549: (3,1,'reload.gif','return','location','go(currentURL)');
550: } else {
551: swmenu.clearbut(3,1);
552: }
553: }
554:
555: function LONCAPAstale() {
556: }
557:
558: // END LON-CAPA Internal
559: </script>
560: ENDDONOTREGTHIS
1.41 www 561: }
562: # =============================================================================
1.38 www 563: }
564: return $result;
565: }
566:
567: sub loadevents() {
1.135 albertel 568: if ($ENV{'request.state'} eq 'construct' ||
569: $ENV{'request.noversionuri'} eq '/res/adm/pages/menu.html') { return ''; }
1.38 www 570: return 'LONCAPAreg();';
571: }
572:
573: sub unloadevents() {
1.135 albertel 574: if ($ENV{'request.state'} eq 'construct' ||
575: $ENV{'request.noversionuri'} eq '/res/adm/pages/menu.html') { return ''; }
1.38 www 576: return 'LONCAPAstale();';
577: }
1.30 www 578:
1.32 www 579: # ============================================================= Start up remote
580:
581: sub startupremote {
582: my ($lowerurl)=@_;
1.49 www 583: if (($ENV{'browser.interface'} eq 'textual') ||
584: ($ENV{'environment.remote'} eq 'off')) {
1.34 www 585: return ('<meta HTTP-EQUIV="Refresh" CONTENT="0.5; url='.$lowerurl.'" />');
586: }
1.49 www 587: #
588: # The Remote actually gets launched!
589: #
1.32 www 590: my $configmenu=&rawconfig();
1.52 www 591: my $esclowerurl=&Apache::lonnet::escape($lowerurl);
1.119 www 592: my $message=&mt('"Waiting for Remote Control window to load: "+[_1]','waited');
1.32 www 593: return(<<ENDREMOTESTARTUP);
1.129 albertel 594: <script type="text/javascript">
1.118 albertel 595: var timestart;
1.35 www 596: function wheelswitch() {
1.118 albertel 597: if (typeof(document.wheel) != 'undefined') {
598: if (typeof(document.wheel.spin) != 'undefined') {
599: var date=new Date();
600: var waited=Math.round(30-((date.getTime()-timestart)/1000));
601: document.wheel.spin.value=$message;
602: }
603: }
1.35 www 604: if (window.status=='|') {
605: window.status='/';
606: } else {
607: if (window.status=='/') {
608: window.status='-';
609: } else {
610: if (window.status=='-') {
611: window.status='\\\\';
612: } else {
613: if (window.status=='\\\\') { window.status='|'; }
614: }
615: }
616: }
617: }
618:
1.32 www 619: // ---------------------------------------------------------- The wait function
620: var canceltim;
621: function wait() {
622: if ((menuloaded==1) || (tim==1)) {
1.35 www 623: window.status='Done.';
1.32 www 624: if (tim==0) {
625: clearTimeout(canceltim);
626: $configmenu
627: window.location='$lowerurl';
628: } else {
1.52 www 629: window.location='/adm/remote?action=collapse&url=$esclowerurl';
1.32 www 630: }
631: } else {
1.35 www 632: wheelswitch();
633: setTimeout('wait();',200);
1.32 www 634: }
635: }
636:
637: function main() {
1.52 www 638: canceltim=setTimeout('tim=1;',30000);
1.35 www 639: window.status='-';
1.118 albertel 640: var date=new Date();
641: timestart=date.getTime();
1.32 www 642: wait();
643: }
644:
645: </script>
646: ENDREMOTESTARTUP
647: }
648:
649: sub setflags() {
650: return(<<ENDSETFLAGS);
1.129 albertel 651: <script type="text/javascript">
1.32 www 652: menuloaded=0;
653: tim=0;
654: </script>
655: ENDSETFLAGS
656: }
657:
658: sub maincall() {
1.49 www 659: if (($ENV{'browser.interface'} eq 'textual') ||
660: ($ENV{'environment.remote'} eq 'off')) { return ''; }
1.32 www 661: return(<<ENDMAINCALL);
1.129 albertel 662: <script type="text/javascript">
1.32 www 663: main();
664: </script>
665: ENDMAINCALL
666: }
1.118 albertel 667:
668: sub load_remote_msg {
669: my ($lowerurl)=@_;
670:
671: if (($ENV{'browser.interface'} eq 'textual') ||
672: ($ENV{'environment.remote'} eq 'off')) { return ''; }
673:
674: my $esclowerurl=&Apache::lonnet::escape($lowerurl);
1.119 www 675: my $link=&mt('<a href="[_1]">Continue</a> on in Inline Menu mode',
1.118 albertel 676: "/adm/remote?action=collapse?url=$esclowerurl");
677: return(<<ENDREMOTEFORM);
678: <p>
679: <form name="wheel">
1.119 www 680: <input name="spin" type="text" size="60" />
1.118 albertel 681: </form>
682: </p>
683: <p>$link</p>
684: ENDREMOTEFORM
685: }
1.30 www 686: # ================================================================= Reopen menu
687:
688: sub reopenmenu {
1.49 www 689: if (($ENV{'browser.interface'} eq 'textual') ||
690: ($ENV{'environment.remote'} eq 'off')) { return ''; }
1.30 www 691: my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
1.47 matthew 692: my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
693: return('window.open('.$nothing.',"'.$menuname.'","",false);');
1.30 www 694: }
695:
1.1 www 696: # =============================================================== Open the menu
697:
698: sub open {
1.22 www 699: my $returnval='';
1.49 www 700: if (($ENV{'browser.interface'} eq 'textual') ||
1.111 albertel 701: ($ENV{'environment.remote'} eq 'off')) {
702: return '<script type="text/javascript">self.name="loncapaclient";</script>';
703: }
1.30 www 704: my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
1.22 www 705: unless (shift eq 'unix') {
706: # resizing does not work on linux because of virtual desktop sizes
707: $returnval.=(<<ENDRESIZE);
708: if (window.screen) {
1.28 www 709: self.resizeTo(screen.availWidth-215,screen.availHeight-55);
1.22 www 710: self.moveTo(190,15);
711: }
712: ENDRESIZE
713: }
714: $returnval.=(<<ENDOPEN);
1.35 www 715: window.status='Opening LON-CAPA Remote Control';
1.30 www 716: var menu=window.open("/res/adm/pages/menu.html","$menuname",
1.14 www 717: "height=350,width=150,scrollbars=no,menubar=no,top=5,left=5,screenX=5,screenY=5");
1.71 www 718: self.name='loncapaclient';
1.1 www 719: ENDOPEN
1.129 albertel 720: return '<script type="text/javascript">'.$returnval.'</script>';
1.1 www 721: }
722:
1.2 www 723:
724: # ================================================================== Raw Config
725:
1.3 www 726: sub clear {
727: my ($row,$col)=@_;
1.49 www 728: unless (($ENV{'browser.interface'} eq 'textual') ||
729: ($ENV{'environment.remote'} eq 'off')) {
1.35 www 730: return "\n".qq(window.status+='.';swmenu.clearbut($row,$col););
1.56 www 731: } else {
732: $inlineremote[10*$row+$col]='';
733: return '';
734: }
1.3 www 735: }
736:
1.40 www 737: # ============================================ Switch a button or create a link
1.25 matthew 738: # Switch acts on the javascript that is executed when a button is clicked.
739: # The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
1.40 www 740:
1.2 www 741: sub switch {
1.40 www 742: my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$nobreak)=@_;
1.2 www 743: $act=~s/\$uname/$uname/g;
744: $act=~s/\$udom/$udom/g;
1.88 www 745: $top=&mt($top);
746: $bot=&mt($bot);
747: $desc=&mt($desc);
1.105 www 748: $img=&mt($img);
1.49 www 749: unless (($ENV{'browser.interface'} eq 'textual') ||
750: ($ENV{'environment.remote'} eq 'off')) {
1.50 www 751: # Remote
1.34 www 752: return "\n".
1.35 www 753: qq(window.status+='.';swmenu.switchbutton($row,$col,"$img","$top","$bot","$act","$desc"););
1.50 www 754: } elsif ($ENV{'browser.interface'} eq 'textual') {
755: # Accessibility
756: if ($nobreak==2) { return ''; }
757: my $text=$top.' '.$bot;
1.78 www 758: $text=~s/\s*\-\s*//gs;
1.94 www 759: if ($nobreak) {
760: $inlineremote[10*$row+$col]=
761: '<a href="javascript:'.$act.';">'.$text.'</a>';
762: } else {
763: $inlineremote[10*$row+$col]="\n<br />".
1.100 www 764: $desc.' <a href="javascript:'.$act.';">'.$text.'</a>';
1.94 www 765: }
1.34 www 766: } else {
1.50 www 767: # Inline Remote
1.41 www 768: if ($nobreak==2) { return ''; }
1.34 www 769: my $text=$top.' '.$bot;
1.78 www 770: $text=~s/\s*\-\s*//gs;
1.105 www 771:
772: my $lonhttpdPort=$Apache::lonnet::perlvar{'lonhttpdPort'};
773: if (!defined($lonhttpdPort)) { $lonhttpdPort='8080'; }
1.99 www 774: my $pic=
1.105 www 775: '<img border="0" alt="'.$text.'" src="http://'.$ENV{'HTTP_HOST'}.
776: ':'.$lonhttpdPort.'/res/adm/pages/'.$img.'" align="'.
1.103 www 777: ($nobreak==3?'right':'left').'" />';
778: if (($ENV{'browser.interface'} eq 'textual') || ($ENV{'browser.interface'} eq 'faketextual')) {
779: # Accessibility
780: if ($nobreak==3) {
781: $inlineremote[10*$row+$col]="\n".
782: '<td width="40%" align="right"><font color="'.$font.'" size="+1">'.$text.
783: '</font></td><td width="10%" align="right" bgcolor="'.$tabbg.'">'.
784: '<a href="javascript:'.$act.';">'.$pic.'</a></td></tr>';
785: } elsif ($nobreak) {
786: $inlineremote[10*$row+$col]="\n<tr>".
787: '<td width="10%" align="left" bgcolor="'.$tabbg.'">'.
788: '<a href="javascript:'.$act.';">'.$pic.
789: '</a></td><td width="40%" align="left"><font color="'.$font.'" size="+1">'.$text.'</font></td>';
790: } else {
791: $inlineremote[10*$row+$col]="\n<tr>".
792: '<td width="10%" align="left" bgcolor="'.$tabbg.'">'.
793: '<a href="javascript:'.$act.';">'.$pic.
794: '</a></td><td colspan="3"><font color="'.$font.'">'.$desc.
795: '</font></td></tr>';
796: }
1.94 www 797: } else {
1.103 www 798: # Inline Menu
799: $inlineremote[10*$row+$col]=
800: '<a href="javascript:'.$act.';">'.$pic.
801: '</a><font color="'.$font.'" size="2">'.$desc.
802: '</font>';
1.94 www 803: }
1.34 www 804: }
1.56 www 805: return '';
1.2 www 806: }
807:
808: sub secondlevel {
809: my $output='';
810: my
1.27 www 811: ($uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc)=@_;
1.2 www 812: if ($prt eq 'any') {
1.27 www 813: $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
1.2 www 814: } elsif ($prt=~/^r(\w+)/) {
815: if ($rol eq $1) {
1.27 www 816: $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
1.2 www 817: }
818: }
819: return $output;
820: }
821:
1.18 www 822: sub openmenu {
1.30 www 823: my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
1.49 www 824: if (($ENV{'browser.interface'} eq 'textual') ||
825: ($ENV{'environment.remote'} eq 'off')) { return ''; }
1.47 matthew 826: my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
827: return "window.open(".$nothing.",'".$menuname."');";
1.18 www 828: }
829:
1.56 www 830: sub inlinemenu {
831: @inlineremote=();
832: undef @inlineremote;
833: &rawconfig(1);
834: return join('',map { (defined($_)?$_:'') } @inlineremote);
835: }
836:
1.2 www 837: sub rawconfig {
1.34 www 838: my $textualoverride=shift;
839: my $output='';
1.49 www 840: unless (($ENV{'browser.interface'} eq 'textual') ||
841: ($ENV{'environment.remote'} eq 'off')) {
1.35 www 842: $output.=
843: "window.status='Opening Remote Control';var swmenu=".&openmenu().
844: "\nwindow.status='Configuring Remote Control ';";
1.34 www 845: } else {
846: unless ($textualoverride) { return ''; }
847: }
1.2 www 848: my $uname=$ENV{'user.name'};
849: my $udom=$ENV{'user.domain'};
850: my $adv=$ENV{'user.adv'};
1.4 www 851: my $author=$ENV{'user.author'};
1.5 www 852: my $crs='';
853: if ($ENV{'request.course.id'}) {
854: $crs='/'.$ENV{'request.course.id'};
1.7 www 855: if ($ENV{'request.course.sec'}) {
856: $crs.='_'.$ENV{'request.course.sec'};
857: }
1.8 www 858: $crs=~s/\_/\//g;
1.5 www 859: }
1.2 www 860: my $pub=($ENV{'request.state'} eq 'published');
861: my $con=($ENV{'request.state'} eq 'construct');
862: my $rol=$ENV{'request.role'};
1.25 matthew 863: my $requested_domain = $ENV{'request.role.domain'};
1.13 harris41 864: foreach (@desklines) {
1.27 www 865: my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc)=split(/\:/,$_);
1.3 www 866: $prt=~s/\$uname/$uname/g;
867: $prt=~s/\$udom/$udom/g;
1.5 www 868: $prt=~s/\$crs/$crs/g;
1.25 matthew 869: $prt=~s/\$requested_domain/$requested_domain/g;
1.3 www 870: if ($pro eq 'clear') {
1.4 www 871: $output.=&clear($row,$col);
1.3 www 872: } elsif ($pro eq 'any') {
1.2 www 873: $output.=&secondlevel(
1.27 www 874: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc);
1.2 www 875: } elsif ($pro eq 'smp') {
876: unless ($adv) {
877: $output.=&secondlevel(
1.27 www 878: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc);
1.2 www 879: }
880: } elsif ($pro eq 'adv') {
881: if ($adv) {
882: $output.=&secondlevel(
1.27 www 883: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc);
1.2 www 884: }
1.81 matthew 885: } elsif (($pro=~/^p(\w+)/) && ($prt)) {
1.2 www 886: if (&Apache::lonnet::allowed($1,$prt)) {
1.27 www 887: $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
1.4 www 888: }
1.26 www 889: } elsif ($pro eq 'course') {
890: if ($ENV{'request.course.fn'}) {
1.27 www 891: $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
1.81 matthew 892: }
1.124 matthew 893: } elsif ($pro =~ /^courseenv_(.*)$/) {
894: my $key = $1;
895: if ($ENV{'course.'.$ENV{'request.course.id'}.'.'.$key}) {
896: $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
897: }
1.81 matthew 898: } elsif ($pro =~ /^course_(.*)$/) {
899: # Check for permissions inside of a course
900: if (($ENV{'request.course.id'}) &&
901: (&Apache::lonnet::allowed($1,$ENV{'request.course.id'}.
902: ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))
903: )) {
904: $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
1.26 www 905: }
1.4 www 906: } elsif ($pro eq 'author') {
907: if ($author) {
1.29 matthew 908: if ((($prt eq 'rca') && ($ENV{'request.role'}=~/^ca/)) ||
909: (($prt eq 'rau') && ($ENV{'request.role'}=~/^au/))) {
1.19 matthew 910: # Check that we are on the correct machine
1.29 matthew 911: my $cadom=$requested_domain;
912: my $caname=$ENV{'user.name'};
913: if ($prt eq 'rca') {
914: ($cadom,$caname)=
1.6 www 915: ($ENV{'request.role'}=~/(\w+)\/(\w+)$/);
1.29 matthew 916: }
917: $act =~ s/\$caname/$caname/g;
1.19 matthew 918: my $home = &Apache::lonnet::homeserver($caname,$cadom);
1.109 albertel 919: my $allowed=0;
920: my @ids=&Apache::lonnet::current_machine_ids();
921: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
922: if ($allowed) {
1.19 matthew 923: $output.=switch($caname,$cadom,
1.27 www 924: $row,$col,$img,$top,$bot,$act,$desc);
1.19 matthew 925: }
1.6 www 926: }
1.2 www 927: }
928: }
1.13 harris41 929: }
1.49 www 930: unless (($ENV{'browser.interface'} eq 'textual') ||
931: ($ENV{'environment.remote'} eq 'off')) {
1.35 www 932: $output.="\nwindow.status='Synchronizing Time';swmenu.syncclock(1000*".time.");\nwindow.status='Remote Control Configured.';";
1.123 www 933: if (&Apache::lonmsg::newmail()) {
934: $output.='swmenu.setstatus("you have","messages");';
935: }
1.34 www 936: }
1.123 www 937:
1.2 www 938: return $output;
939: }
940:
941: # ======================================================================= Close
1.1 www 942:
943: sub close {
1.49 www 944: if (($ENV{'browser.interface'} eq 'textual') ||
945: ($ENV{'environment.remote'} eq 'off')) { return ''; }
1.30 www 946: my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
1.1 www 947: return(<<ENDCLOSE);
1.129 albertel 948: <script type="text/javascript">
1.35 www 949: window.status='Accessing Remote Control';
1.30 www 950: menu=window.open("/adm/rat/empty.html","$menuname",
1.1 www 951: "height=350,width=150,scrollbars=no,menubar=no");
1.35 www 952: window.status='Disabling Remote Control';
953: menu.active=0;
1.31 www 954: menu.autologout=0;
1.35 www 955: window.status='Closing Remote Control';
1.1 www 956: menu.close();
1.35 www 957: window.status='Done.';
1.1 www 958: </script>
959: ENDCLOSE
960: }
961:
962: # ====================================================================== Footer
963:
964: sub footer {
965:
1.33 www 966: }
967:
1.122 albertel 968: sub nav_control_js {
969: my $nav=($ENV{'environment.remotenavmap'} eq 'on');
970: return (<<NAVCONTROL);
971: var w_loncapanav_flag="$nav";
972:
973:
974: function gonav(url) {
975: if (w_loncapanav_flag != 1) {
976: gopost(url,'');
977: } else {
978: navwindow=window.open(url,
979: "loncapanav","height=600,width=400,scrollbars=1");
980: }
981: }
982: NAVCONTROL
983: }
984:
1.42 www 985: sub utilityfunctions {
1.132 raeburn 986: my $caller = shift;
1.51 www 987: unless (($ENV{'browser.interface'} eq 'textual') ||
1.132 raeburn 988: ($ENV{'environment.remote'} eq 'off') || ($caller eq '/adm/menu')) { return ''; }
1.143 albertel 989: my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$ENV{'request.noversionuri'}))[0]));
990: $currenturl=&Apache::lonenc::check_encrypt(&Apache::lonnet::unescape($currenturl));
1.125 albertel 991:
1.126 albertel 992: my $currentsymb=&Apache::lonenc::check_encrypt($ENV{'request.symb'});
1.122 albertel 993: my $nav_control=&nav_control_js();
1.42 www 994: return (<<ENDUTILITY)
995:
996: var currentURL="$currenturl";
997: var reloadURL="$currenturl";
998: var currentSymb="$currentsymb";
999:
1.114 albertel 1000: $nav_control
1001:
1.42 www 1002: function go(url) {
1003: if (url!='' && url!= null) {
1004: currentURL = null;
1005: currentSymb= null;
1006: window.location.href=url;
1007: }
1008: }
1009:
1010: function gopost(url,postdata) {
1011: if (url!='') {
1012: this.document.server.action=url;
1013: this.document.server.postdata.value=postdata;
1014: this.document.server.command.value='';
1015: this.document.server.url.value='';
1016: this.document.server.symb.value='';
1017: this.document.server.submit();
1018: }
1019: }
1020:
1021: function gocmd(url,cmd) {
1022: if (url!='') {
1023: this.document.server.action=url;
1024: this.document.server.postdata.value='';
1025: this.document.server.command.value=cmd;
1026: this.document.server.url.value=currentURL;
1027: this.document.server.symb.value=currentSymb;
1028: this.document.server.submit();
1029: }
1.57 www 1030: }
1031:
1.121 raeburn 1032: function gocstr(url,filename) {
1033: if (url == '/adm/cfile?action=delete') {
1034: this.document.cstrdelete.filename.value = filename
1035: this.document.cstrdelete.submit();
1036: return;
1037: }
1.137 raeburn 1038: if (url == '/adm/printout') {
1039: this.document.cstrprint.postdata.value = filename
1040: this.document.cstrprint.curseed.value = 0;
1041: this.document.cstrprint.problemtype.value = 0;
1.138 raeburn 1042: if (this.document.lonhomework) {
1043: if ((this.document.lonhomework.rndseed) && (this.document.lonhomework.rndseed.value != null) && (this.document.lonhomework.rndseed.value != '')) {
1044: this.document.cstrprint.curseed.value = this.document.lonhomework.rndseed.value
1045: }
1046: if (this.document.lonhomework.problemtype) {
1047: for (var i=0; i<this.document.lonhomework.problemtype.options.length; i++) {
1048: if (this.document.lonhomework.problemtype.options[i].selected) {
1049: if (this.document.lonhomework.problemtype.options[i].value != null && this.document.lonhomework.problemtype.options[i].value != '') {
1050: this.document.cstrprint.problemtype.value = this.document.lonhomework.problemtype.options[i].value
1051: }
1052: }
1.137 raeburn 1053: }
1054: }
1055: }
1056: this.document.cstrprint.submit();
1057: return;
1058: }
1.121 raeburn 1059: if (url !='') {
1060: this.document.constspace.filename.value = filename;
1061: this.document.constspace.action = url;
1062: this.document.constspace.submit();
1063: }
1064: }
1065:
1.131 raeburn 1066: function golist(url) {
1067: if (url!='' && url!= null) {
1068: currentURL = null;
1069: currentSymb= null;
1070: top.location.href=url;
1071: }
1072: }
1073:
1074:
1.121 raeburn 1075:
1.57 www 1076: function catalog_info() {
1.102 albertel 1077: loncatinfo=window.open(window.location.pathname+'.meta',"LONcatInfo",'height=320,width=280,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
1.57 www 1078: }
1079:
1080: function chat_win() {
1.102 albertel 1081: lonchat=window.open('/res/adm/pages/chatroom.html',"LONchat",'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no');
1.42 www 1082: }
1083: ENDUTILITY
1084: }
1085:
1086: sub serverform {
1087: return(<<ENDSERVERFORM);
1088:
1.62 www 1089: <form name="server" action="/adm/logout" method="post" target="_top">
1.42 www 1090: <input type="hidden" name="postdata" value="none" />
1091: <input type="hidden" name="command" value="none" />
1092: <input type="hidden" name="url" value="none" />
1093: <input type="hidden" name="symb" value="none" />
1094: </form>
1095: ENDSERVERFORM
1096: }
1.113 albertel 1097:
1.121 raeburn 1098: sub constspaceform {
1099: return(<<ENDCONSTSPACEFORM);
1100: <form name="constspace" action="/adm/logout" method="post" target="_top">
1101: <input type="hidden" name="filename" value="" />
1102: </form>
1103: <form name="cstrdelete" action="/adm/cfile" method="post" target="_top">
1104: <input type="hidden" name="action" value="delete" />
1105: <input type="hidden" name="filename" value="" />
1106: </form>
1.137 raeburn 1107: <form name="cstrprint" action="/adm/printout" target="_parent" method="post">
1108: <input type="hidden" name="postdata" value="" />
1109: <input type="hidden" name="curseed" value="" />
1110: <input type="hidden" name="problemtype" value="" />
1111: </form>
1112:
1.121 raeburn 1113: ENDCONSTSPACEFORM
1114: }
1115:
1116:
1.113 albertel 1117: sub get_nav_status {
1118: my $navstatus="swmenu.w_loncapanav_flag=";
1119: if ($ENV{'environment.remotenavmap'} eq 'on') {
1120: $navstatus.="1";
1121: } else {
1122: $navstatus.="-1";
1123: }
1124: return $navstatus;
1125: }
1126:
1.33 www 1127: # ================================================ Handler when called directly
1128:
1129:
1130: sub handler {
1131: my $r = shift;
1.93 www 1132: &Apache::loncommon::content_type($r,'text/html');
1.33 www 1133: $r->send_http_header;
1134: return OK if $r->header_only;
1135:
1.130 albertel 1136: my $form;
1137: if ($ENV{'environment.remote'} ne 'off' &&
1138: $ENV{'browser.interface'} ne 'textual') {
1139: $form=&serverform();
1140: }
1.34 www 1141: my $bodytag=&Apache::loncommon::bodytag('Main Menu');
1.58 www 1142: my $function='student';
1143: if ($ENV{'request.role'}=~/^(cc|in|ta|ep)/) {
1144: $function='coordinator';
1145: }
1146: if ($ENV{'request.role'}=~/^(su|dc|ad|li)/) {
1147: $function='admin';
1148: }
1149: if (($ENV{'request.role'}=~/^(au|ca)/) ||
1.97 www 1150: ($ENV{'request.noversionuri'}=~/^(\/priv|\~)/)) {
1.58 www 1151: $function='author';
1152: }
1153: my $domain=&Apache::loncommon::determinedomain();
1154: $pgbg=&Apache::loncommon::designparm($function.'.pgbg',$domain);
1155: $tabbg=&Apache::loncommon::designparm($function.'.tabbg',$domain);
1156: $font=&Apache::loncommon::designparm($function.'.font',$domain);
1.132 raeburn 1157: my $script_tag;
1.142 albertel 1158: if ($ENV{'environment.remote'} ne 'off') {
1.132 raeburn 1159: my $utility=&utilityfunctions('/adm/menu');
1160: $script_tag=(<<ENDSCRIPT);
1161: <script type="text/javascript">
1162: $utility
1163: </script>
1164: ENDSCRIPT
1165: }
1166: # ---- Print the screen, pretend to be in text mode to generate text-based menu
1.103 www 1167: unless ($ENV{'browser.interface'} eq 'textual') {
1168: $ENV{'browser.interface'}='faketextual';
1.53 www 1169: $ENV{'environment.remote'}='off';
1170: }
1.36 www 1171: $r->print(<<ENDHEADER);
1172: <html><head>
1173: <title>LON-CAPA Main Menu</title>
1.132 raeburn 1174: $script_tag
1.36 www 1175: </head>
1176: $bodytag
1177: ENDHEADER
1.58 www 1178: $r->print('<table>'.&inlinemenu().'</table>'.$form);
1.33 www 1179: $r->print('</body></html>');
1180: return OK;
1.1 www 1181: }
1182:
1.2 www 1183: # ================================================================ Main Program
1184:
1.16 harris41 1185: BEGIN {
1.15 matthew 1186: if (! defined($readdesk)) {
1.14 www 1187: {
1.104 raeburn 1188: my $tabfile = $Apache::lonnet::perlvar{'lonTabDir'}.'/mydesk.tab';
1189: if ( CORE::open( my $config,"<$tabfile") ) {
1190: while (my $configline=<$config>) {
1191: $configline=(split(/\#/,$configline))[0];
1192: $configline=~s/^\s+//;
1193: chomp($configline);
1194: if ($configline) {
1195: $desklines[$#desklines+1]=$configline;
1196: }
1197: }
1198: CORE::close($config);
1.2 www 1199: }
1.14 www 1200: }
1201: $readdesk='done';
1.10 albertel 1202: }
1.2 www 1203: }
1.30 www 1204:
1.1 www 1205: 1;
1206: __END__
1207:
1208:
1209:
1210:
1211:
1212:
1213:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>