File:
[LON-CAPA] /
loncom /
interface /
lonmenu.pm
Revision
1.228:
download - view:
text,
annotated -
select for diffs
Thu Oct 11 22:49:49 2007 UTC (16 years, 8 months ago) by
albertel
Branches:
MAIN
CVS tags:
HEAD
- BUG#5397, eliminate the extra 'Return to last resource' link in prt mode
(and enable the standard 'return to resource link') preserver the
extra return link for use soley in construction space and update the text
to say this
1: # The LearningOnline Network with CAPA
2: # Routines to control the menu
3: #
4: # $Id: lonmenu.pm,v 1.228 2007/10/11 22:49:49 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::lonhtmlcommon();
44: use Apache::loncommon();
45: use Apache::lonenc();
46: use Apache::lonlocal;
47: use LONCAPA qw(:DEFAULT :match);
48:
49: use vars qw(@desklines %category_names %category_members %category_positions $readdesk);
50:
51:
52: my @inlineremote;
53:
54:
55:
56: # ================================================================ Little texts
57:
58: sub initlittle {
59: return &Apache::lonlocal::texthash('ret' => 'Return to Last Location',
60: 'nav' => 'Navigate Contents',
61: 'main' => 'Main Menu',
62: 'roles' => ($env{'user.adv'}?
63: 'Roles':'Courses'),
64: 'docs' => 'Edit Course',
65: 'exit' => 'Exit',
66: 'login' => 'Log In',
67: 'launch' => 'Launch Remote Control',
68: 'groups' => 'Groups',
69: 'gdoc' => 'Group Documents',
70: );
71: }
72:
73: # ============================= This gets called at the top of the body section
74:
75: sub menubuttons {
76: my $forcereg=shift;
77: my $registration=shift;
78: my $titletable=shift;
79: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
80: ['inhibitmenu']);
81: if (($env{'form.inhibitmenu'} eq 'yes') ||
82: ($ENV{'REQUEST_URI'} eq '/adm/logout')) { return ''; }
83:
84: if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
85:
86: my %lt=&initlittle();
87: my $navmaps='';
88: my $reloadlink='';
89: my $docs='';
90: my $groups='';
91: my $showgroups=0;
92: my $escurl=&escape(&Apache::lonenc::check_encrypt($env{'request.noversionuri'}));
93: my $escsymb=&escape(&Apache::lonenc::check_encrypt($env{'request.symb'}));
94:
95: my $logo=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/minilogo.gif");
96: $logo = '<td class="LC_top_nav_logo"><a href="/adm/about.html"><img src="'.
97: $logo.'" alt="LON-CAPA Logo" /></a></td>';
98:
99: if ($env{'request.state'} eq 'construct') {
100: if (($env{'request.noversionuri'} eq '') || (!defined($env{'request.noversionuri'}))) {
101: my $returnurl = $env{'request.filename'};
102: $returnurl =~ s:^/home/([^/]+)/public_html/(.*)$:/priv/$1/$2:;
103: $escurl = &escape($returnurl);
104: }
105: }
106: if ($env{'request.course.id'}) {
107: my %coursegroups;
108: my $viewgrps_permission =
109: &Apache::lonnet::allowed('vcg',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''));
110: if (!$viewgrps_permission) {
111: %coursegroups = &Apache::lonnet::get_active_groups($env{'user.domain'},$env{'user.name'},$env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'});
112: }
113: if ((keys(%coursegroups) > 0) || ($viewgrps_permission)) {
114: $showgroups = 1;
115: }
116: }
117:
118: if ($env{'browser.interface'} eq 'textual') {
119: # Textual display only
120: if ($env{'request.course.id'}) {
121: $navmaps=(<<ENDNAV);
122: <a href="/adm/navmaps?postdata=$escurl&postsymb=$escsymb" target="_top">$lt{'nav'}</a>
123: ENDNAV
124: if (&show_return_link()) {
125: my $escreload=&escape('return:');
126: $reloadlink=(<<ENDRELOAD);
127: <a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a>
128: ENDRELOAD
129: }
130: if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
131: $docs=(<<ENDDOCS);
132: <a href="/adm/coursedocs" target="_top">$lt{'docs'}</a>
133: ENDDOCS
134: }
135: if ($showgroups) {
136: $groups =(<<ENDGROUPS);
137: <a href="/adm/coursegroups" target="_top">$lt{'groups'}</a>
138: ENDGROUPS
139: }
140: }
141: my $form=&serverform();
142: my $utility=&utilityfunctions();
143: my $output=(<<ENDMAINMENU);
144: <script type="text/javascript">
145: // BEGIN LON-CAPA Internal
146: $utility
147: </script>
148: <div id="LC_top_nav">
149: <a href="/adm/menu" target="_top">$lt{'main'}</a>
150: $reloadlink $navmaps $docs $groups
151: <a href="/adm/roles" target="_top">$lt{'roles'}</a>
152: <a href="/adm/logout" target="_top">$lt{'exit'}</a>
153: </div>
154: <br />
155: <script type="text/javascript">
156: // END LON-CAPA Internal
157: </script>
158: $form
159: ENDMAINMENU
160: if ($registration) { $output.=&innerregister($forcereg); }
161: return $output."<hr />";
162: } elsif ($env{'environment.remote'} eq 'off') {
163: # Remote Control is switched off
164: # figure out colors
165: my %lt=&initlittle();
166:
167: my $domain=&Apache::loncommon::determinedomain();
168: my $function =&Apache::loncommon::get_users_function();
169: my $link=&Apache::loncommon::designparm($function.'.link',$domain);
170: my $alink=&Apache::loncommon::designparm($function.'.alink',$domain);
171: my $vlink=&Apache::loncommon::designparm($function.'.vlink',$domain);
172: my $sidebg=&Apache::loncommon::designparm($function.'.sidebg',$domain);
173: if ($env{'user.name'} eq 'public' && $env{'user.domain'} eq 'public') {
174: return (<<ENDINLINEMENU);
175: <table id="LC_top_nav">
176: <tr>
177: $logo
178: <td></td>
179: <td class="LC_top_nav_login">
180: <a href="/adm/roles" target="_top">$lt{'login'}</a>
181: </td>
182: </tr>
183: </table>
184: </font>
185: ENDINLINEMENU
186: }
187: # Do we have a NAV link?
188: if ($env{'request.course.id'}) {
189: my $link='/adm/navmaps?postdata='.$escurl.'&postsymb='.
190: $escsymb;
191: if ($env{'environment.remotenavmap'} eq 'on') {
192: $link="javascript:gonav('".$link."')";
193: }
194: $navmaps=(<<ENDNAV);
195: <td><a href="$link" target="_top">$lt{'nav'}</a></td>
196: ENDNAV
197: my $is_group = (&Apache::loncommon::course_type() eq 'Group');
198: if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
199: my $text = ($is_group) ? $lt{'gdoc'} : $lt{'docs'};
200: $docs=(<<ENDDOCS);
201: <td><a href="/adm/coursedocs" target="_top">$text</a></td>
202: ENDDOCS
203: }
204: if ($showgroups) {
205: $groups =(<<ENDGROUPS);
206: <td><a href="/adm/coursegroups" target="_top">$lt{'groups'}</a></td>
207: ENDGROUPS
208: }
209: foreach my $key (sort(keys(%env))) {
210: next if ($key !~ /^request/);
211: &Apache::lonnet::logthis("$key =>".$env{$key});
212: }
213: if (&show_return_link()) {
214: my $escreload=&escape('return:');
215: $reloadlink=(<<ENDRELOAD);
216: <td><a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a></td>
217: ENDRELOAD
218: }
219: }
220: if (($env{'request.state'} eq 'construct') && ($env{'request.course.id'})) {
221: my $escreload=&escape('return:');
222: $reloadlink=(<<ENDCRELOAD);
223: <td><a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a></td>
224: ENDCRELOAD
225: }
226: my $reg='';
227: if ($registration) {
228: $reg=&innerregister($forcereg,$titletable);
229: }
230: my $form=&serverform();
231: my $utility=&utilityfunctions();
232: my $remote;
233: if ($env{'user.adv'}) {
234: $remote = '<td><a href="/adm/remote?action=launch&url='.$escurl.'" target="_top">'.$lt{'launch'}.'</a></td>'
235: }
236:
237: my $helplink=&Apache::loncommon::top_nav_help('Help');
238: return (<<ENDINLINEMENU);
239: <script type="text/javascript">
240: // BEGIN LON-CAPA Internal
241: // <![CDATA[
242: $utility
243: // ]]>
244: </script>
245: <table id="LC_top_nav">
246: <tr>
247: $logo
248: <td><a href="/adm/menu" target="_top">$lt{'main'}</a></td>
249: $reloadlink
250: $navmaps
251: $docs
252: $groups
253: $remote
254: <td><a href="/adm/roles" target="_top">$lt{'roles'}</a></td>
255: <td class="LC_top_nav_help">$helplink</td>
256: <td class="LC_top_nav_exit"><a href="/adm/logout" target="_top">$lt{'exit'}</a></td>
257: </tr>
258: </table>
259: $form
260: <script type="text/javascript">
261: // END LON-CAPA Internal
262: </script>
263: $reg
264: ENDINLINEMENU
265: } else {
266: return '';
267: }
268: }
269:
270: sub show_return_link {
271: return (($env{'request.noversionuri'}=~m{^/(res|public)/} &&
272: $env{'request.symb'} eq '')
273: ||
274: ($env{'request.noversionuri'}=~ m{^/cgi-bin/printout.pl})
275: ||
276: (($env{'request.noversionuri'}=~/^\/adm\//) &&
277: ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) &&
278: ($env{'request.noversionuri'}!~
279: m[^/adm/.*/(smppg|bulletinboard|aboutme)($|\?)])
280: ));
281: }
282:
283: # ====================================== This gets called in the header section
284:
285: sub registerurl {
286: my ($forcereg) = @_;
287: my $result = '';
288: if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
289: my $force_title='';
290: if ($env{'request.state'} eq 'construct') {
291: $force_title=&Apache::lonxml::display_title();
292: }
293: if (($env{'browser.interface'} eq 'textual') ||
294: ($env{'environment.remote'} eq 'off') ||
295: ((($env{'request.publicaccess'}) ||
296: (!&Apache::lonnet::is_on_map(
297: &unescape($env{'request.noversionuri'})))) &&
298: (!$forcereg))) {
299: return $result.
300: '<script type="text/javascript">function LONCAPAreg(){;} function LONCAPAstale(){}</script>'.$force_title;
301: }
302: # Graphical display after login only
303: if ($env{'request.registered'} && !$forcereg) { return ''; }
304: $result.=&innerregister($forcereg);
305: return $result.$force_title;
306: }
307:
308: # =========== This gets called in order to register a URL, both with the Remote
309: # =========== and in the body of the document
310:
311: sub innerregister {
312: my ($forcereg, $titletable) = @_;
313: my $result = '';
314: my ($uname,$thisdisfn);
315: my $const_space = ($env{'request.state'} eq 'construct');
316: my $is_const_dir = 0;
317:
318: if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
319:
320: $env{'request.registered'} = 1;
321:
322: my $textinter=($env{'browser.interface'} eq 'textual');
323: my $noremote=($env{'environment.remote'} eq 'off');
324:
325: my $textual=($textinter || $noremote);
326:
327: undef(@inlineremote);
328:
329: my $reopen=&Apache::lonmenu::reopenmenu();
330:
331: my $newmail='';
332: if ($noremote) {
333: $newmail='<table id="LC_nav_location"><tr>';
334: }
335: if (&Apache::lonmsg::newmail()) {
336: if ($textual) {
337: $newmail.= '<td class="LC_new_mail">
338: <a href="/adm/communicate" target="_top">'.
339: &mt('You have new messages').'</a></td>';
340: } else {
341: $newmail= 'swmenu.setstatus("you have","messages");';
342: }
343: } elsif (($textual)
344: && ($env{'request.symb'})
345: && ($env{'request.course.id'})) {
346: $newmail.= '<td class="LC_current_location">';
347: my ($mapurl,$rid,$resurl)=
348: &Apache::lonnet::decode_symb(&Apache::lonnet::symbread());
349: $newmail.=$env{'course.'.$env{'request.course.id'}.'.description'};
350: my $maptitle=&Apache::lonnet::gettitle($mapurl);
351: my $restitle=&Apache::lonnet::gettitle(&Apache::lonnet::symbread());
352: if ($maptitle && $maptitle ne 'default.sequence') {
353: $newmail.=', '.$maptitle;
354: }
355: if ($restitle) {
356: $newmail.=': '.$restitle;
357: }
358: $newmail.=' </td>';
359: }
360: if ($env{'request.state'} eq 'construct') {
361: $newmail = $titletable;
362: } else {
363: if ($noremote) {
364: $newmail.='</tr></table>';
365: }
366: }
367: my $timesync=($textual?'':'swmenu.syncclock(1000*'.time.');');
368: my $tablestart=($noremote?'<table id="LC_menubuttons">':'').
369: ($textinter?'<br /><a href="#content">'.&mt('Skip to Content').'</a><br />':'');
370: my $tableend=($noremote?'</table>':'').($textinter?'<a name="content" />':'');
371: # =============================================================================
372: # ============================ This is for URLs that actually can be registered
373: if (($env{'request.noversionuri'}!~m|^/(res/)*adm/|) || ($forcereg)) {
374: # -- This applies to homework problems for users with grading privileges
375: my $crs='/'.$env{'request.course.id'};
376: if ($env{'request.course.sec'}) {
377: $crs.='_'.$env{'request.course.sec'};
378: }
379: $crs=~s/\_/\//g;
380:
381: my $hwkadd='';
382: if ($env{'request.symb'} ne '' &&
383: $env{'request.filename'}=~/\.(problem|exam|quiz|assess|survey|form|task)$/) {
384: if (&Apache::lonnet::allowed('mgr',$crs)) {
385: $hwkadd.=&switch('','',7,2,'pgrd.gif','problem[_1]','grades[_3]',
386: "gocmd('/adm/grades','gradingmenu')",
387: 'Modify user grades for this assessment resource');
388: } elsif (&Apache::lonnet::allowed('vgr',$crs)) {
389: $hwkadd.=&switch('','',7,2,'subm.gif','view sub-[_1]','missions[_1]',
390: "gocmd('/adm/grades','submission')",
391: 'View user submissions for this assessment resource');
392: }
393: }
394: if ($env{'request.symb'} ne '' &&
395: &Apache::lonnet::allowed('opa',$crs)) {
396: $hwkadd.=&switch('','',7,3,'pparm.gif','problem[_2]','parms[_2]',
397: "gocmd('/adm/parmset','set')",
398: 'Modify parameter settings for this resource');
399: }
400: # -- End Homework
401: ###
402: ### Determine whether or not to display the 'cstr' button for this
403: ### resource
404: ###
405: my $editbutton = '';
406: if ($env{'user.author'}) {
407: if ($env{'request.role'}=~/^(ca|au)/) {
408: # Set defaults for authors
409: my ($top,$bottom) = ('con-','struct');
410: my $action = "go('/priv/".$env{'user.name'}."');";
411: my $cadom = $env{'request.role.domain'};
412: my $caname = $env{'user.name'};
413: my $desc = "Enter my resource construction space";
414: # Set defaults for co-authors
415: if ($env{'request.role'} =~ /^ca/) {
416: ($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/);
417: ($top,$bottom) = ('co con-','struct');
418: $action = "go('/priv/".$caname."');";
419: $desc = "Enter construction space as co-author";
420: }
421: # Check that we are on the correct machine
422: my $home = &Apache::lonnet::homeserver($caname,$cadom);
423: my $allowed=0;
424: my @ids=&Apache::lonnet::current_machine_ids();
425: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
426: if (!$allowed) {
427: $editbutton=&switch('','',6,1,$top,,$bottom,$action,$desc);
428: }
429: }
430: ##
431: ## Determine if user can edit url.
432: ##
433: my $cfile='';
434: my $cfuname='';
435: my $cfudom='';
436: if ($env{'request.filename'}) {
437: my $file=&Apache::lonnet::declutter($env{'request.filename'});
438: $file=~s/^($match_domain)\/($match_username)/\/priv\/$2/;
439: # Check that the user has permission to edit this resource
440: ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$1);
441: if (defined($cfudom)) {
442: my $home=&Apache::lonnet::homeserver($cfuname,$cfudom);
443: my $allowed=0;
444: my @ids=&Apache::lonnet::current_machine_ids();
445: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
446: if ($allowed) {
447: $cfile=$file;
448: }
449: }
450: }
451: # Finally, turn the button on or off
452: if ($cfile && !$const_space) {
453: $editbutton=&switch
454: ('','',6,1,'pcstr.gif','edit[_1]','resource[_2]',
455: "go('".$cfile."');","Edit this resource");
456: } elsif ($editbutton eq '') {
457: $editbutton=&clear(6,1);
458: }
459: }
460: ###
461: ###
462: # Prepare the rest of the buttons
463: my $menuitems;
464: if ($const_space) {
465: my ($uname,$thisdisfn) =
466: ($env{'request.filename'}=~m|^/home/([^/]+)/public_html/(.*)|);
467: my $currdir = '/priv/'.$uname.'/'.$thisdisfn;
468: if ($currdir =~ m-/$-) {
469: $is_const_dir = 1;
470: } else {
471: $currdir =~ s#[^/]+$##;
472: my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn);
473: my $esc_currdir = &Apache::loncommon::escape_single($currdir);
474: $menuitems=(<<ENDMENUITEMS);
475: s&6&1&list.gif&list[_1]&dir[_1]&golist('$esc_currdir')&List current directory
476: s&6&2&rtrv.gif&retrieve[_1]&version[_1]&gocstr('/adm/retrieve','/~$uname/$cleandisfn')&Retrieve old version
477: s&6&3&pub.gif&publish[_1]&resource[_1]&gocstr('/adm/publish','/~$uname/$cleandisfn')&Publish this resource
478: s&7&1&del.gif&delete[_1]&resource[_2]&gocstr('/adm/cfile?action=delete','/~$uname/$cleandisfn')&Delete this resource
479: s&7&2&prt.gif&prepare[_1]&printout[_1]&gocstr('/adm/printout','/~$uname/$cleandisfn')&Prepare a printable document
480: ENDMENUITEMS
481: }
482: } elsif ( defined($env{'request.course.id'}) &&
483: $env{'request.symb'} ne '' ) {
484: $menuitems=(<<ENDMENUITEMS);
485: c&3&1
486: s&2&1&back.gif&backward[_1]&&gopost('/adm/flip','back:'+currentURL)&Go to the previous resource in the course sequence&&1
487: s&2&3&forw.gif&forward[_1]&&gopost('/adm/flip','forward:'+currentURL)&Go to the next resource in the course sequence&&3
488: c&6&3
489: c&8&1
490: c&8&2
491: s&8&3&prt.gif&prepare[_1]&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
492: s&9&1&sbkm.gif&set[_1]&bookmark[_2]&set_bookmark()&Set a bookmark for this resource&&1
493: s&9&3&anot.gif&anno-[_1]&tations[_1]&annotate()&Make notes and annotations about this resource&&1
494: ENDMENUITEMS
495:
496: unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) {
497: if (!$env{'request.enc'}) {
498: $menuitems.=(<<ENDREALRES);
499: s&6&3&catalog.gif&catalog[_1]&info[_1]&catalog_info()&Show catalog information
500: ENDREALRES
501: }
502: $menuitems.=(<<ENDREALRES);
503: s&8&1&eval.gif&evaluate[_1]&this[_1]&gopost('/adm/evaluate',currentURL,1)&Provide my evaluation of this resource
504: 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
505: ENDREALRES
506: }
507: }
508: if ($env{'request.uri'} =~ /^\/res/) {
509: $menuitems .= (<<ENDMENUITEMS);
510: s&8&3&prt.gif&prepare[_1]&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
511: ENDMENUITEMS
512: }
513: my $buttons='';
514: foreach (split(/\n/,$menuitems)) {
515: my ($command,@rest)=split(/\&/,$_);
516: my $idx=10*$rest[0]+$rest[1];
517: if (&hidden_button_check() eq 'yes') {
518: if ($idx == 21 ||$idx == 23) {
519: $buttons.=&switch('','',@rest);
520: } else {
521: $buttons.=&clear(@rest);
522: }
523: } else {
524: if ($command eq 's') {
525: $buttons.=&switch('','',@rest);
526: } else {
527: $buttons.=&clear(@rest);
528: }
529: }
530: }
531:
532: if ($textual) {
533: my $addremote=0;
534: foreach (@inlineremote) { if ($_ ne '') { $addremote=1; } }
535: my $inlinebuttons='';
536: if ($addremote) {
537: # Registered, textual output
538: if ($env{'browser.interface'} eq 'textual') {
539: $inlinebuttons=
540: join('',map { (defined($_)?$_:'') } @inlineremote);
541: } else {
542: if ($env{'environment.icons'} eq 'iconsonly') {
543: $inlinebuttons=(<<ENDARROWSINLINE);
544: <tr><td>
545: $inlineremote[21] $inlineremote[23]
546: ENDARROWSINLINE
547: if (&hidden_button_check() ne 'yes') {
548: $inlinebuttons .= (<<ENDINLINEICONS);
549: $inlineremote[61] $inlineremote[63]
550: $inlineremote[71] $inlineremote[72] $inlineremote[73]
551: $inlineremote[81] $inlineremote[82] $inlineremote[83]
552: $inlineremote[91] $inlineremote[92] $inlineremote[93]</td></tr>
553: ENDINLINEICONS
554: }
555: } else {
556: if ($inlineremote[21] ne '' || $inlineremote[23] ne '') {
557: $inlinebuttons=(<<ENDFIRSTLINE);
558: <tr><td>$inlineremote[21]</td><td> </td><td>$inlineremote[23]</td></tr>
559: ENDFIRSTLINE
560: }
561: if (&hidden_button_check() ne 'yes') {
562: foreach my $row (6..9) {
563: if ($inlineremote[${row}.'1'] ne ''
564: || $inlineremote[$row.'2'] ne ''
565: || $inlineremote[$row.'3'] ne '') {
566: $inlinebuttons .= <<"ENDLINE";
567: <tr><td>$inlineremote["${row}1"]</td><td>$inlineremote["${row}2"]</td><td>$inlineremote["${row}3"]</td></tr>
568: ENDLINE
569: }
570: }
571: }
572: }
573: }
574: }
575: $result =(<<ENDREGTEXT);
576: <script type="text/javascript">
577: // BEGIN LON-CAPA Internal
578: </script>
579: $timesync
580: $tablestart
581: $inlinebuttons
582: $tableend
583: $newmail
584: <script type="text/javascript">
585: // END LON-CAPA Internal
586: </script>
587:
588: ENDREGTEXT
589: # Registered, graphical output
590: } else {
591: my $requri=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
592: $requri=&Apache::lonenc::check_encrypt(&unescape($requri));
593: my $cursymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
594: my $navstatus=&get_nav_status();
595: my $clearcstr;
596:
597: if ($env{'user.adv'}) { $clearcstr='clearbut(6,1)'; }
598: $result = (<<ENDREGTHIS);
599:
600: <script type="text/javascript">
601: // BEGIN LON-CAPA Internal
602: var swmenu=null;
603:
604: function LONCAPAreg() {
605: swmenu=$reopen;
606: swmenu.clearTimeout(swmenu.menucltim);
607: $timesync
608: $newmail
609: $buttons
610: swmenu.currentURL="$requri";
611: swmenu.reloadURL=swmenu.currentURL+window.location.search;
612: swmenu.currentSymb="$cursymb";
613: swmenu.reloadSymb="$cursymb";
614: swmenu.currentStale=0;
615: $navstatus
616: $hwkadd
617: $editbutton
618: }
619:
620: function LONCAPAstale() {
621: swmenu=$reopen
622: swmenu.currentStale=1;
623: if (swmenu.reloadURL!='' && swmenu.reloadURL!= null) {
624: swmenu.switchbutton
625: (3,1,'reload.gif','return','location','go(reloadURL)','Return to the last known location in the course sequence');
626: }
627: swmenu.clearbut(7,2);
628: swmenu.clearbut(7,3);
629: swmenu.menucltim=swmenu.setTimeout(
630: 'clearbut(2,1);clearbut(2,3);clearbut(8,1);clearbut(8,2);clearbut(8,3);'+
631: 'clearbut(9,1);clearbut(9,3);clearbut(6,3);$clearcstr',
632: 2000);
633: }
634:
635: // END LON-CAPA Internal
636: </script>
637: ENDREGTHIS
638: }
639: # =============================================================================
640: } else {
641: # ========================================== This can or will not be registered
642: if ($textual) {
643: # Not registered, textual
644: $result= (<<ENDDONOTREGTEXT);
645: ENDDONOTREGTEXT
646: } else {
647: # Not registered, graphical
648: $result = (<<ENDDONOTREGTHIS);
649:
650: <script type="text/javascript">
651: // BEGIN LON-CAPA Internal
652: var swmenu=null;
653:
654: function LONCAPAreg() {
655: swmenu=$reopen
656: $timesync
657: swmenu.currentStale=1;
658: swmenu.clearbut(2,1);
659: swmenu.clearbut(2,3);
660: swmenu.clearbut(8,1);
661: swmenu.clearbut(8,2);
662: swmenu.clearbut(8,3);
663: if (swmenu.currentURL) {
664: swmenu.switchbutton
665: (3,1,'reload.gif','return','location','go(currentURL)');
666: } else {
667: swmenu.clearbut(3,1);
668: }
669: }
670:
671: function LONCAPAstale() {
672: }
673:
674: // END LON-CAPA Internal
675: </script>
676: ENDDONOTREGTHIS
677: }
678: # =============================================================================
679: }
680: return $result;
681: }
682:
683: sub loadevents() {
684: if ($env{'request.state'} eq 'construct' ||
685: $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
686: return 'LONCAPAreg();';
687: }
688:
689: sub unloadevents() {
690: if ($env{'request.state'} eq 'construct' ||
691: $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
692: return 'LONCAPAstale();';
693: }
694:
695: # ============================================================= Start up remote
696:
697: sub startupremote {
698: my ($lowerurl)=@_;
699: if (($env{'browser.interface'} eq 'textual') ||
700: ($env{'environment.remote'} eq 'off')) {
701: return ('<meta HTTP-EQUIV="Refresh" CONTENT="0.5; url='.$lowerurl.'" />');
702: }
703: #
704: # The Remote actually gets launched!
705: #
706: my $configmenu=&rawconfig();
707: my $esclowerurl=&escape($lowerurl);
708: my $message=&mt('"Waiting for Remote Control window to load: "+[_1]','waited');
709: return(<<ENDREMOTESTARTUP);
710: <script type="text/javascript">
711: var timestart;
712: function wheelswitch() {
713: if (typeof(document.wheel) != 'undefined') {
714: if (typeof(document.wheel.spin) != 'undefined') {
715: var date=new Date();
716: var waited=Math.round(30-((date.getTime()-timestart)/1000));
717: document.wheel.spin.value=$message;
718: }
719: }
720: if (window.status=='|') {
721: window.status='/';
722: } else {
723: if (window.status=='/') {
724: window.status='-';
725: } else {
726: if (window.status=='-') {
727: window.status='\\\\';
728: } else {
729: if (window.status=='\\\\') { window.status='|'; }
730: }
731: }
732: }
733: }
734:
735: // ---------------------------------------------------------- The wait function
736: var canceltim;
737: function wait() {
738: if ((menuloaded==1) || (tim==1)) {
739: window.status='Done.';
740: if (tim==0) {
741: clearTimeout(canceltim);
742: $configmenu
743: window.location='$lowerurl';
744: } else {
745: window.location='/adm/remote?action=collapse&url=$esclowerurl';
746: }
747: } else {
748: wheelswitch();
749: setTimeout('wait();',200);
750: }
751: }
752:
753: function main() {
754: canceltim=setTimeout('tim=1;',30000);
755: window.status='-';
756: var date=new Date();
757: timestart=date.getTime();
758: wait();
759: }
760:
761: </script>
762: ENDREMOTESTARTUP
763: }
764:
765: sub setflags() {
766: return(<<ENDSETFLAGS);
767: <script type="text/javascript">
768: menuloaded=0;
769: tim=0;
770: </script>
771: ENDSETFLAGS
772: }
773:
774: sub maincall() {
775: if (($env{'browser.interface'} eq 'textual') ||
776: ($env{'environment.remote'} eq 'off')) { return ''; }
777: return(<<ENDMAINCALL);
778: <script type="text/javascript">
779: main();
780: </script>
781: ENDMAINCALL
782: }
783:
784: sub load_remote_msg {
785: my ($lowerurl)=@_;
786:
787: if (($env{'browser.interface'} eq 'textual') ||
788: ($env{'environment.remote'} eq 'off')) { return ''; }
789:
790: my $esclowerurl=&escape($lowerurl);
791: my $link=&mt('<a href="[_1]">Continue</a> on in Inline Menu mode',
792: "/adm/remote?action=collapse&url=$esclowerurl");
793: return(<<ENDREMOTEFORM);
794: <p>
795: <form name="wheel">
796: <input name="spin" type="text" size="60" />
797: </form>
798: </p>
799: <p>$link</p>
800: ENDREMOTEFORM
801: }
802: # ================================================================= Reopen menu
803:
804: sub reopenmenu {
805: if (($env{'browser.interface'} eq 'textual') ||
806: ($env{'environment.remote'} eq 'off')) { return ''; }
807: my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
808: my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
809: return('window.open('.$nothing.',"'.$menuname.'","",false);');
810: }
811:
812: # =============================================================== Open the menu
813:
814: sub open {
815: my $returnval='';
816: if (($env{'browser.interface'} eq 'textual') ||
817: ($env{'environment.remote'} eq 'off')) {
818: return '<script type="text/javascript">self.name="loncapaclient";</script>';
819: }
820: my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
821:
822: # unless (shift eq 'unix') {
823: # resizing does not work on linux because of virtual desktop sizes
824: # $returnval.=(<<ENDRESIZE);
825: #if (window.screen) {
826: # self.resizeTo(screen.availWidth-215,screen.availHeight-55);
827: # self.moveTo(190,15);
828: #}
829: #ENDRESIZE
830: # }
831: $returnval.=(<<ENDOPEN);
832: window.status='Opening LON-CAPA Remote Control';
833: var menu=window.open("/res/adm/pages/menu.html","$menuname",
834: "height=375,width=150,scrollbars=no,menubar=no,top=5,left=5,screenX=5,screenY=5");
835: self.name='loncapaclient';
836: ENDOPEN
837: return '<script type="text/javascript">'.$returnval.'</script>';
838: }
839:
840:
841: # ================================================================== Raw Config
842:
843: sub clear {
844: my ($row,$col)=@_;
845: unless (($env{'browser.interface'} eq 'textual') ||
846: ($env{'environment.remote'} eq 'off')) {
847: return "\n".qq(window.status+='.';swmenu.clearbut($row,$col););
848: } else {
849: $inlineremote[10*$row+$col]='';
850: return '';
851: }
852: }
853:
854: # ============================================ Switch a button or create a link
855: # Switch acts on the javascript that is executed when a button is clicked.
856: # The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
857:
858: sub switch {
859: my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat,$nobreak)=@_;
860: $act=~s/\$uname/$uname/g;
861: $act=~s/\$udom/$udom/g;
862: $top=&mt($top);
863: $bot=&mt($bot);
864: $desc=&mt($desc);
865: $img=&mt($img);
866:
867: my $idx=10*$row+$col;
868: $category_members{$cat}.=':'.$idx;
869:
870: unless (($env{'browser.interface'} eq 'textual') ||
871: ($env{'environment.remote'} eq 'off')) {
872: # Remote
873: return "\n".
874: qq(window.status+='.';swmenu.switchbutton($row,$col,"$img","$top","$bot","$act","$desc"););
875: } elsif ($env{'browser.interface'} eq 'textual') {
876: # Accessibility
877: if ($nobreak==2) { return ''; }
878: my $text=$top.' '.$bot;
879: $text=~s/\s*\-\s*//gs;
880: if ($nobreak) {
881: $inlineremote[$idx]=
882: '<a href="javascript:'.$act.';">'.$text.'</a>';
883: } else {
884: $inlineremote[$idx]="\n<br />".
885: $desc.' <a href="javascript:'.$act.';">'.$text.'</a>';
886: }
887: } else {
888: # Inline Remote
889: if ($env{'environment.icons'} ne 'classic') {
890: $img=~s/\.gif$/\.png/;
891: }
892: if ($nobreak==2) { return ''; }
893: my $text=$top.' '.$bot;
894: $text=~s/\s*\-\s*//gs;
895:
896: my $pic=
897: '<img alt="'.$text.'" src="'.
898: &Apache::loncommon::lonhttpdurl('/res/adm/pages/'.$img).
899: '" align="'.($nobreak==3?'right':'left').'" />';
900: if ($env{'browser.interface'} eq 'faketextual') {
901: # Accessibility
902: if ($nobreak==3) {
903: $inlineremote[$idx]="\n".
904: '<td class="LC_menubuttons_text" align="right">'.$text.
905: '</td><td class="LC_menubuttons_img" align="left">'.
906: '<a href="javascript:'.$act.';">'.$pic.'</a></td></tr>';
907: } elsif ($nobreak) {
908: $inlineremote[$idx]="\n<tr>".
909: '<td class="LC_menubuttons_img" align="left">'.
910: '<a href="javascript:'.$act.';">'.$pic.'</a></td>
911: <td class="LC_menubuttons_text" align="left"><a class="LC_menubuttons_link" href="javascript:'.$act.';"><span class="LC_menubuttons_inline_text">'.$text.'</span></a></td>';
912: } else {
913: $inlineremote[$idx]="\n<tr>".
914: '<td class="LC_menubuttons_img" align="left">'.
915: '<a href="javascript:'.$act.';">'.$pic.
916: '</a></td><td class="LC_menubuttons_text" colspan="3">'.
917: '<a class="LC_menubuttons_link" href="javascript:'.$act.';"><span class="LC_menubuttons_inline_text">'.$desc.'</span></a></td></tr>';
918: }
919: } else {
920: # Inline Menu
921: if ($env{'environment.icons'} eq 'iconsonly') {
922: $inlineremote[$idx]='<a title="'.$desc.'" href="javascript:'.$act.';">'.$pic.'</a>';
923: } else {
924: $inlineremote[$idx]=
925: '<a class="LC_menubuttons_link" href="javascript:'.$act.';">'.$pic.
926: '<span class="LC_menubuttons_inline_text">'.$desc.'</span></a>';
927: }
928: }
929: }
930: return '';
931: }
932:
933: sub secondlevel {
934: my $output='';
935: my
936: ($uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat)=@_;
937: if ($prt eq 'any') {
938: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
939: } elsif ($prt=~/^r(\w+)/) {
940: if ($rol eq $1) {
941: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
942: }
943: }
944: return $output;
945: }
946:
947: sub openmenu {
948: my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
949: if (($env{'browser.interface'} eq 'textual') ||
950: ($env{'environment.remote'} eq 'off')) { return ''; }
951: my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
952: return "window.open(".$nothing.",'".$menuname."');";
953: }
954:
955: sub inlinemenu {
956: undef(@inlineremote);
957: undef(%category_members);
958: &rawconfig(1);
959: my $output='<table id="LC_mainmenu"><tr>';
960: for (my $col=1; $col<=2; $col++) {
961: $output.='<td class="LC_mainmenu_column">';
962: for (my $row=1; $row<=8; $row++) {
963: foreach my $cat (keys(%category_members)) {
964: if ($category_positions{$cat} ne "$col,$row") { next; }
965: $output.='<table id="LC_menubuttons_mainmenu"><tr><td colspan="4" class="LC_menubuttons_category">'.&mt($category_names{$cat}).'</td></tr>';
966: my %active=();
967: foreach my $menu_item (split(/\:/,$category_members{$cat})) {
968: if ($inlineremote[$menu_item]) {
969: $active{$menu_item}=1;
970: }
971: }
972: foreach my $item (sort(keys(%active))) {
973: $output.=$inlineremote[$item];
974: }
975: $output.='</table>';
976: }
977: }
978: $output.="</td>";
979: }
980: $output.="</tr></table>";
981: return $output;
982: }
983:
984: sub rawconfig {
985: my $textualoverride=shift;
986: my $output='';
987: unless (($env{'browser.interface'} eq 'textual') ||
988: ($env{'environment.remote'} eq 'off')) {
989: $output.=
990: "window.status='Opening Remote Control';var swmenu=".&openmenu().
991: "\nwindow.status='Configuring Remote Control ';";
992: } else {
993: unless ($textualoverride) { return ''; }
994: }
995: my $uname=$env{'user.name'};
996: my $udom=$env{'user.domain'};
997: my $adv=$env{'user.adv'};
998: my $author=$env{'user.author'};
999: my $crs='';
1000: if ($env{'request.course.id'}) {
1001: $crs='/'.$env{'request.course.id'};
1002: if ($env{'request.course.sec'}) {
1003: $crs.='_'.$env{'request.course.sec'};
1004: }
1005: $crs=~s/\_/\//g;
1006: }
1007: my $pub=($env{'request.state'} eq 'published');
1008: my $con=($env{'request.state'} eq 'construct');
1009: my $rol=$env{'request.role'};
1010: my $requested_domain = $env{'request.role.domain'};
1011: foreach my $line (@desklines) {
1012: my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc,$cat)=split(/\:/,$line);
1013: $prt=~s/\$uname/$uname/g;
1014: $prt=~s/\$udom/$udom/g;
1015: $prt=~s/\$crs/$crs/g;
1016: $prt=~s/\$requested_domain/$requested_domain/g;
1017: if ($category_names{$cat}!~/\w/) { $cat='oth'; }
1018: my $type = &Apache::loncommon::course_type();
1019: if ($type eq 'Group') {
1020: $desc = &convert_menu_function($desc,$type);
1021: }
1022: if ($pro eq 'clear') {
1023: $output.=&clear($row,$col);
1024: } elsif ($pro eq 'any') {
1025: $output.=&secondlevel(
1026: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1027: } elsif ($pro eq 'smp') {
1028: unless ($adv) {
1029: $output.=&secondlevel(
1030: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1031: }
1032: } elsif ($pro eq 'adv') {
1033: if ($adv) {
1034: $output.=&secondlevel(
1035: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1036: }
1037: } elsif (($pro=~/^p(\w+)/) && ($prt)) {
1038: if (&Apache::lonnet::allowed($1,$prt)) {
1039: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1040: }
1041: } elsif ($pro eq 'course') {
1042: if ($env{'request.course.fn'}) {
1043: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1044: }
1045: } elsif ($pro =~ /^courseenv_(.*)$/) {
1046: my $key = $1;
1047: if ($env{'course.'.$env{'request.course.id'}.'.'.$key}) {
1048: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1049: }
1050: } elsif ($pro =~ /^course_(.*)$/) {
1051: # Check for permissions inside of a course
1052: if (($env{'request.course.id'}) &&
1053: (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
1054: ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
1055: )) {
1056: $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1057: }
1058: } elsif ($pro eq 'author') {
1059: if ($author) {
1060: if ((($prt eq 'rca') && ($env{'request.role'}=~/^ca/)) ||
1061: (($prt eq 'rau') && ($env{'request.role'}=~/^au/))) {
1062: # Check that we are on the correct machine
1063: my $cadom=$requested_domain;
1064: my $caname=$env{'user.name'};
1065: if ($prt eq 'rca') {
1066: ($cadom,$caname)=
1067: ($env{'request.role'}=~/($match_domain)\/($match_username)$/);
1068: }
1069: $act =~ s/\$caname/$caname/g;
1070: my $home = &Apache::lonnet::homeserver($caname,$cadom);
1071: my $allowed=0;
1072: my @ids=&Apache::lonnet::current_machine_ids();
1073: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
1074: if ($allowed) {
1075: $output.=&switch($caname,$cadom,
1076: $row,$col,$img,$top,$bot,$act,$desc,$cat);
1077: }
1078: }
1079: }
1080: }
1081: }
1082: unless (($env{'browser.interface'} eq 'textual') ||
1083: ($env{'environment.remote'} eq 'off')) {
1084: $output.="\nwindow.status='Synchronizing Time';swmenu.syncclock(1000*".time.");\nwindow.status='Remote Control Configured.';";
1085: if (&Apache::lonmsg::newmail()) {
1086: $output.='swmenu.setstatus("you have","messages");';
1087: }
1088: }
1089:
1090: return $output;
1091: }
1092:
1093: # ======================================================================= Close
1094:
1095: sub close {
1096: if (($env{'browser.interface'} eq 'textual') ||
1097: ($env{'environment.remote'} eq 'off')) { return ''; }
1098: my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
1099: return(<<ENDCLOSE);
1100: <script type="text/javascript">
1101: window.status='Accessing Remote Control';
1102: menu=window.open("/adm/rat/empty.html","$menuname",
1103: "height=350,width=150,scrollbars=no,menubar=no");
1104: window.status='Disabling Remote Control';
1105: menu.active=0;
1106: menu.autologout=0;
1107: window.status='Closing Remote Control';
1108: menu.close();
1109: window.status='Done.';
1110: </script>
1111: ENDCLOSE
1112: }
1113:
1114: # ====================================================================== Footer
1115:
1116: sub footer {
1117:
1118: }
1119:
1120: sub nav_control_js {
1121: my $nav=($env{'environment.remotenavmap'} eq 'on');
1122: return (<<NAVCONTROL);
1123: var w_loncapanav_flag="$nav";
1124:
1125:
1126: function gonav(url) {
1127: if (w_loncapanav_flag != 1) {
1128: gopost(url,'');
1129: } else {
1130: navwindow=window.open(url,
1131: "loncapanav","height=600,width=400,scrollbars=1");
1132: }
1133: }
1134: NAVCONTROL
1135: }
1136:
1137: sub utilityfunctions {
1138: my $caller = shift;
1139: unless (($env{'browser.interface'} eq 'textual') ||
1140: ($env{'environment.remote'} eq 'off') || ($caller eq '/adm/menu')) { return ''; }
1141: my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
1142: $currenturl=&Apache::lonenc::check_encrypt(&unescape($currenturl));
1143:
1144: my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
1145: my $nav_control=&nav_control_js();
1146:
1147: my $start_page_annotate =
1148: &Apache::loncommon::start_page('Annotator',undef,
1149: {'only_body' => 1,
1150: 'js_ready' => 1,
1151: 'bgcolor' => '#BBBBBB',
1152: 'add_entries' => {
1153: 'onload' => 'javascript:document.goannotate.submit();'}});
1154:
1155: my $end_page_annotate =
1156: &Apache::loncommon::end_page({'js_ready' => 1});
1157:
1158: my $start_page_bookmark =
1159: &Apache::loncommon::start_page('Bookmarks',undef,
1160: {'only_body' => 1,
1161: 'js_ready' => 1,
1162: 'bgcolor' => '#BBBBBB',});
1163:
1164: my $end_page_bookmark =
1165: &Apache::loncommon::end_page({'js_ready' => 1});
1166:
1167: return (<<ENDUTILITY)
1168:
1169: var currentURL="$currenturl";
1170: var reloadURL="$currenturl";
1171: var currentSymb="$currentsymb";
1172:
1173: $nav_control
1174:
1175: function go(url) {
1176: if (url!='' && url!= null) {
1177: currentURL = null;
1178: currentSymb= null;
1179: window.location.href=url;
1180: }
1181: }
1182:
1183: function gopost(url,postdata) {
1184: if (url!='') {
1185: this.document.server.action=url;
1186: this.document.server.postdata.value=postdata;
1187: this.document.server.command.value='';
1188: this.document.server.url.value='';
1189: this.document.server.symb.value='';
1190: this.document.server.submit();
1191: }
1192: }
1193:
1194: function gocmd(url,cmd) {
1195: if (url!='') {
1196: this.document.server.action=url;
1197: this.document.server.postdata.value='';
1198: this.document.server.command.value=cmd;
1199: this.document.server.url.value=currentURL;
1200: this.document.server.symb.value=currentSymb;
1201: this.document.server.submit();
1202: }
1203: }
1204:
1205: function gocstr(url,filename) {
1206: if (url == '/adm/cfile?action=delete') {
1207: this.document.cstrdelete.filename.value = filename
1208: this.document.cstrdelete.submit();
1209: return;
1210: }
1211: if (url == '/adm/printout') {
1212: this.document.cstrprint.postdata.value = filename
1213: this.document.cstrprint.curseed.value = 0;
1214: this.document.cstrprint.problemtype.value = 0;
1215: if (this.document.lonhomework) {
1216: if ((this.document.lonhomework.rndseed) && (this.document.lonhomework.rndseed.value != null) && (this.document.lonhomework.rndseed.value != '')) {
1217: this.document.cstrprint.curseed.value = this.document.lonhomework.rndseed.value
1218: }
1219: if (this.document.lonhomework.problemtype) {
1220: if (this.document.lonhomework.problemtype.value) {
1221: this.document.cstrprint.problemtype.value =
1222: this.document.lonhomework.problemtype.value;
1223: } else if (this.document.lonhomework.problemtype.options) {
1224: for (var i=0; i<this.document.lonhomework.problemtype.options.length; i++) {
1225: if (this.document.lonhomework.problemtype.options[i].selected) {
1226: if (this.document.lonhomework.problemtype.options[i].value != null && this.document.lonhomework.problemtype.options[i].value != '') {
1227: this.document.cstrprint.problemtype.value = this.document.lonhomework.problemtype.options[i].value
1228: }
1229: }
1230: }
1231: }
1232: }
1233: }
1234: this.document.cstrprint.submit();
1235: return;
1236: }
1237: if (url !='') {
1238: this.document.constspace.filename.value = filename;
1239: this.document.constspace.action = url;
1240: this.document.constspace.submit();
1241: }
1242: }
1243:
1244: function golist(url) {
1245: if (url!='' && url!= null) {
1246: currentURL = null;
1247: currentSymb= null;
1248: top.location.href=url;
1249: }
1250: }
1251:
1252:
1253:
1254: function catalog_info() {
1255: loncatinfo=window.open(window.location.pathname+'.meta',"LONcatInfo",'height=320,width=280,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
1256: }
1257:
1258: function chat_win() {
1259: lonchat=window.open('/res/adm/pages/chatroom.html',"LONchat",'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no');
1260: }
1261:
1262: function group_chat(group) {
1263: var url = '/adm/groupchat?group='+group;
1264: var winName = 'LONchat_'+group;
1265: grpchat=window.open(url,winName,'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no');
1266: }
1267:
1268: function edit_bookmarks() {
1269: go('');
1270: w_BookmarkPal_flag=1;
1271: bookmarkpal=window.open("/adm/bookmarks",
1272: "BookmarkPal", "width=400,height=505,scrollbars=0");
1273: }
1274:
1275: function annotate() {
1276: w_Annotator_flag=1;
1277: annotator=window.open('','Annotator','width=365,height=265,scrollbars=0');
1278: annotator.document.write(
1279: '$start_page_annotate'
1280: +"<form name='goannotate' target='Annotator' method='post' "
1281: +"action='/adm/annotations'>"
1282: +"<input type='hidden' name='symbnew' value='"+currentSymb+"' />"
1283: +"<\\/form>"
1284: +'$end_page_annotate');
1285: annotator.document.close();
1286: }
1287:
1288: function set_bookmark() {
1289: go('');
1290: clienttitle=document.title;
1291: clienthref=location.pathname;
1292: w_bmquery_flag=1;
1293: bmquery=window.open('','bmquery','width=365,height=165,scrollbars=0');
1294: bmquery.document.write(
1295: '$start_page_bookmark'
1296: +"<center><form method='post'"
1297: +" name='newlink' action='/adm/bookmarks' target='bmquery' "
1298: +">\\n <table width=340 height=150 "
1299: +"bgcolor='ffffff' align=center><tr><td>Link Name:<br /><input "
1300: +"type='text' name='title' size=45 value='"+clienttitle+"' />"
1301: +"<br />Address:<br /><input type='text' name='address' size='45' "
1302: +"value='"+clienthref+"' /><br /><center><input type='submit' "
1303: +"value='Save' /> <input type='button' value='Close (no save)' "
1304: +"onclick='javascript:window.close();' /><\\/center><\\/td>"
1305: +"<\\/tr><\\/table><\\/form><\\/center>"
1306: +'$end_page_bookmark' );
1307: bmquery.document.close();
1308: }
1309:
1310: ENDUTILITY
1311: }
1312:
1313: sub serverform {
1314: return(<<ENDSERVERFORM);
1315: <form name="server" action="/adm/logout" method="post" target="_top">
1316: <input type="hidden" name="postdata" value="none" />
1317: <input type="hidden" name="command" value="none" />
1318: <input type="hidden" name="url" value="none" />
1319: <input type="hidden" name="symb" value="none" />
1320: </form>
1321: ENDSERVERFORM
1322: }
1323:
1324: sub constspaceform {
1325: return(<<ENDCONSTSPACEFORM);
1326: <form name="constspace" action="/adm/logout" method="post" target="_top">
1327: <input type="hidden" name="filename" value="" />
1328: </form>
1329: <form name="cstrdelete" action="/adm/cfile" method="post" target="_top">
1330: <input type="hidden" name="action" value="delete" />
1331: <input type="hidden" name="filename" value="" />
1332: </form>
1333: <form name="cstrprint" action="/adm/printout" target="_parent" method="post">
1334: <input type="hidden" name="postdata" value="" />
1335: <input type="hidden" name="curseed" value="" />
1336: <input type="hidden" name="problemtype" value="" />
1337: </form>
1338:
1339: ENDCONSTSPACEFORM
1340: }
1341:
1342:
1343: sub get_nav_status {
1344: my $navstatus="swmenu.w_loncapanav_flag=";
1345: if ($env{'environment.remotenavmap'} eq 'on') {
1346: $navstatus.="1";
1347: } else {
1348: $navstatus.="-1";
1349: }
1350: return $navstatus;
1351: }
1352:
1353: #FIXME this needs to move into mydesktab and the other locations
1354: # the text is generated
1355: sub convert_menu_function {
1356: my ($rolename,$type) = @_;
1357: if ($type eq 'Group') {
1358: $rolename =~ s/student/member/g;
1359: $rolename =~ s/group/team/g;
1360: $rolename =~ s/course/group/g;
1361: $rolename =~ s/Course/Group/g;
1362: }
1363: return $rolename;
1364: }
1365:
1366: sub hidden_button_check {
1367: my $hidden;
1368: if ($env{'request.course.id'} eq '') {
1369: return;
1370: }
1371: if ($env{'request.role.adv'}) {
1372: return;
1373: }
1374: return &Apache::lonnet::EXT('resource.0.buttonshide');
1375: }
1376:
1377: # ================================================================ Main Program
1378:
1379: BEGIN {
1380: if (! defined($readdesk)) {
1381: {
1382: my $tabfile = $Apache::lonnet::perlvar{'lonTabDir'}.'/mydesk.tab';
1383: if ( CORE::open( my $config,"<$tabfile") ) {
1384: while (my $configline=<$config>) {
1385: $configline=(split(/\#/,$configline))[0];
1386: $configline=~s/^\s+//;
1387: chomp($configline);
1388: if ($configline=~/^cat\:/) {
1389: my @entries=split(/\:/,$configline);
1390: $category_positions{$entries[2]}=$entries[1];
1391: $category_names{$entries[2]}=$entries[3];
1392: } elsif ($configline) {
1393: push(@desklines,$configline);
1394: }
1395: }
1396: CORE::close($config);
1397: }
1398: }
1399: $readdesk='done';
1400: }
1401: }
1402:
1403: 1;
1404: __END__
1405:
1406:
1407:
1408:
1409:
1410:
1411:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>