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