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