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