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