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