Annotation of loncom/interface/lonmenu.pm, revision 1.38

1.1       www         1: # The LearningOnline Network with CAPA
                      2: # Routines to control the menu
                      3: #
1.38    ! www         4: # $Id: lonmenu.pm,v 1.37 2003/02/14 15:14:37 www Exp $
1.11      albertel    5: #
                      6: # Copyright Michigan State University Board of Trustees
                      7: #
                      8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                      9: #
                     10: # LON-CAPA is free software; you can redistribute it and/or modify
                     11: # it under the terms of the GNU General Public License as published by
                     12: # the Free Software Foundation; either version 2 of the License, or
                     13: # (at your option) any later version.
                     14: #
                     15: # LON-CAPA is distributed in the hope that it will be useful,
                     16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     18: # GNU General Public License for more details.
                     19: #
                     20: # You should have received a copy of the GNU General Public License
                     21: # along with LON-CAPA; if not, write to the Free Software
                     22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     23: #
                     24: # /home/httpd/html/adm/gpl.txt
                     25: #
                     26: # http://www.lon-capa.org/
                     27: #
1.1       www        28: # (TeX Conversion Module
                     29: #
                     30: # 05/29/00,05/30 Gerd Kortemeyer)
                     31: #
1.8       www        32: # 10/05,05/28,05/30,06/01,06/08,06/09,07/04,08/07 Gerd Kortemeyer
1.17      matthew    33: # 02/15/02 Matthew Hall
1.1       www        34: 
                     35: package Apache::lonmenu;
                     36: 
                     37: use strict;
1.2       www        38: use Apache::lonnet;
1.33      www        39: use Apache::Constants qw(:common);
                     40: use Apache::loncommon;
1.2       www        41: use Apache::File;
                     42: use vars qw(@desklines $readdesk);
1.38    ! www        43: 
        !            44: # ======================================================= Make the menu buttons
        !            45: 
        !            46: sub menubuttons {
        !            47:     my $forcereg=shift;
        !            48:     my $target  =shift;
        !            49:     unless ($ENV{'browser.interface'} eq 'textual') { return ''; }
        !            50:     return "Menu here<hr />";
        !            51: }
        !            52: 
        !            53: # ============================================== Register a URL with the remote
        !            54: 
        !            55: 
        !            56: sub registerurl {
        !            57:     my $forcereg=shift;
        !            58:     my $target = shift;
        !            59:     my $result = '';
        !            60:     
        !            61:     if ($target eq 'edit') {
        !            62:         $result .="<script type=\"text/javascrtipt\">\n".
        !            63:             "if (typeof swmenu != 'undefined') {swmenu.currentURL=null;}\n".
        !            64:             &Apache::loncommon::browser_and_searcher_javascript().
        !            65:                 "\n</script>\n";
        !            66:     }
        !            67:     if (($ENV{'browser.interface'} eq 'textual') ||
        !            68:         ((($ENV{'request.publicaccess'}) || 
        !            69:          (!&Apache::lonnet::is_on_map($ENV{'REQUEST_URI'}))) &&
        !            70:         (!$forcereg))) {
        !            71: 	return $result.
        !            72:          '<script type="text/javascript">function LONCAPAreg(){;} function LONCAPAstale(){}</script>';
        !            73:     }
        !            74:     if ($Apache::lonxml::registered && !$forcereg) { return ''; }
        !            75:     $Apache::lonxml::registered=1;
        !            76:     my $reopen=&Apache::lonmenu::reopenmenu();
        !            77:     my $newmail='';
        !            78:     if (&Apache::lonmsg::newmail()) { 
        !            79:        $newmail='swmenu.setstatus("you have","messages");';
        !            80:     }
        !            81:     my $timesync='swmenu.syncclock(1000*'.time.');';
        !            82:     if (($ENV{'REQUEST_URI'}!~/^\/(res\/)*adm\//) || ($forcereg)) {
        !            83:         my $hwkadd='';
        !            84:         if ($ENV{'request.filename'}=~/\.(problem|exam|quiz|assess|survey|form)$/) {
        !            85: 	    if (&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'})) {
        !            86: 		$hwkadd.=(<<ENDSUBM);
        !            87:                      swmenu.switchbutton(7,1,'subm.gif','view sub','missions','gocmd("/adm/grades","submission")',
        !            88:                      'View user submissions for this assessment resource');
        !            89: ENDSUBM
        !            90:             }
        !            91: 	    if (&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'})) {
        !            92: 		$hwkadd.=(<<ENDGRDS);
        !            93:                      swmenu.switchbutton(7,2,'pgrd.gif','problem','grades','gocmd("/adm/grades","gradingmenu")',
        !            94:                      'Modify user grades for this assessment resource');
        !            95: ENDGRDS
        !            96:             }
        !            97: 	    if (&Apache::lonnet::allowed('opa',$ENV{'request.course.id'})) {
        !            98: 		$hwkadd.=(<<ENDPARM);
        !            99:                      swmenu.switchbutton(7,3,'pparm.gif','problem','parms','gocmd("/adm/parmset","set")',
        !           100:                      'Modify deadlines, etc, for this assessment resource');
        !           101: ENDPARM
        !           102:             }
        !           103: 	}
        !           104:         ###
        !           105:         ### Determine whether or not to display the 'cstr' button for this
        !           106:         ### resource
        !           107:         ###
        !           108:         my $editbutton = '';
        !           109:         if ($ENV{'user.author'}) {
        !           110:             if ($ENV{'request.role'}=~/^(ca|au)/) {
        !           111:                 # Set defaults for authors
        !           112:                 my ($top,$bottom) = ('con-','struct');
        !           113:                 my $action = "go('/priv/".$ENV{'user.name'}."');";
        !           114:                 my $cadom  = $ENV{'request.role.domain'};
        !           115:                 my $caname = $ENV{'user.name'};
        !           116:                 my $desc = "Enter my resource construction space";
        !           117:                 # Set defaults for co-authors
        !           118:                 if ($ENV{'request.role'} =~ /^ca/) { 
        !           119:                     ($cadom,$caname)=($ENV{'request.role'}=~/(\w+)\/(\w+)$/);
        !           120:                     ($top,$bottom) = ('co con-','struct');
        !           121:                     $action = "go('/priv/".$caname."');";
        !           122:                     $desc = "Enter construction space as co-author";
        !           123:                 }
        !           124:                 # Check that we are on the correct machine
        !           125:                 my $home = &Apache::lonnet::homeserver($caname,$cadom);
        !           126:                 if ($home eq $Apache::lonnet::perlvar{'lonHostID'}) {
        !           127:                     $editbutton=&Apache::lonmenu::switch
        !           128:                         ('','',6,1,$top,,$bottom,$action,$desc);
        !           129:                 }
        !           130:             }
        !           131:             ##
        !           132:             ## Determine if user can edit url.
        !           133:             ##
        !           134:             my $cfile='';
        !           135:             my $cfuname='';
        !           136:             my $cfudom='';
        !           137:             if ($ENV{'request.filename'}) {
        !           138:                 my $file=&Apache::lonnet::declutter($ENV{'request.filename'});
        !           139:                 $file=~s/^(\w+)\/(\w+)/\/priv\/$2/;
        !           140:                 # Chech that the user has permission to edit this resource
        !           141:                 ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$1);
        !           142:                 if (defined($cfudom)) {
        !           143:                     if (&Apache::lonnet::homeserver($cfuname,$cfudom) 
        !           144:                         eq $Apache::lonnet::perlvar{'lonHostID'}) {
        !           145:                         $cfile=$file;
        !           146:                     }
        !           147:                 }
        !           148:             }        
        !           149:             # Finally, turn the button on or off
        !           150:             if ($cfile) {
        !           151:                 $editbutton=&Apache::lonmenu::switch
        !           152:                     ('','',6,1,'cstr.gif','edit','resource',
        !           153:                      "go('".$cfile."');","Edit this resource");
        !           154:             } elsif ($editbutton eq '') {
        !           155:                 $editbutton = '    swmenu.clearbut(6,1);';
        !           156:             }
        !           157:         }
        !           158:         ###
        !           159:         ###
        !           160: 	$result = (<<ENDREGTHIS);
        !           161:      
        !           162: <script language="JavaScript">
        !           163: // BEGIN LON-CAPA Internal
        !           164: 
        !           165:     function LONCAPAreg() {
        !           166: 	  swmenu=$reopen;
        !           167:           swmenu.clearTimeout(swmenu.menucltim);
        !           168:           $timesync
        !           169:           $newmail
        !           170: 	  swmenu.currentURL=window.location.pathname;
        !           171:           swmenu.reloadURL=window.location.pathname;
        !           172:           swmenu.currentSymb="$ENV{'request.symb'}";
        !           173:           swmenu.reloadSymb="$ENV{'request.symb'}";
        !           174:           swmenu.currentStale=0;
        !           175:           swmenu.clearbut(3,1);
        !           176:           swmenu.switchbutton
        !           177:        (6,3,'catalog.gif','catalog','info','catalog_info()','Show catalog information');
        !           178:           swmenu.switchbutton
        !           179:        (8,1,'eval.gif','evaluate','this','gopost("/adm/evaluate",currentURL)','Provide my evaluation of this resource');
        !           180:           swmenu.switchbutton
        !           181:     (8,2,'fdbk.gif','feedback','discuss','gopost("/adm/feedback",currentURL)','Provide feedback messages or contribute to the course discussion about this resource');
        !           182:           swmenu.switchbutton
        !           183:      (8,3,'prt.gif','prepare','printout','gopost("/adm/printout",currentURL)','Prepare a printable document');
        !           184:           swmenu.switchbutton
        !           185:        (2,1,'back.gif','backward','','gopost("/adm/flip","back:"+currentURL)','Go to the previous resource in the course sequence');
        !           186:           swmenu.switchbutton
        !           187:      (2,3,'forw.gif','forward','','gopost("/adm/flip","forward:"+currentURL)','Go to the next resource in the course sequence');
        !           188:           swmenu.switchbutton
        !           189:                             (9,1,'sbkm.gif','set','bookmark','set_bookmark()','Set a bookmark for this resource');
        !           190:           swmenu.switchbutton
        !           191:                          (9,2,'vbkm.gif','view','bookmark','edit_bookmarks()','Use or edit my bookmark collection');
        !           192:           swmenu.switchbutton
        !           193:                                (9,3,'anot.gif','anno-','tations','annotate()','Make notes and annotations about this resource');
        !           194:           $hwkadd
        !           195:           $editbutton
        !           196:     }
        !           197: 
        !           198:     function LONCAPAstale() {
        !           199: 	  swmenu=$reopen
        !           200:           swmenu.currentStale=1;
        !           201:           if (swmenu.reloadURL!='' && swmenu.reloadURL!= null) { 
        !           202:              swmenu.switchbutton
        !           203:              (3,1,'reload.gif','return','location','go(reloadURL)','Return to the last known location in the course sequence');
        !           204: 	  }
        !           205:           swmenu.clearbut(7,1);
        !           206:           swmenu.clearbut(7,2);
        !           207:           swmenu.clearbut(7,3);
        !           208:           swmenu.menucltim=swmenu.setTimeout(
        !           209:  'clearbut(2,1);clearbut(2,3);clearbut(8,1);clearbut(8,2);clearbut(8,3);'+
        !           210:  'clearbut(9,1);clearbut(9,2);clearbut(9,3);clearbut(6,3);clearbut(6,1)',
        !           211: 			  2000);
        !           212: 
        !           213:       }
        !           214: 
        !           215: // END LON-CAPA Internal
        !           216: </script>
        !           217: ENDREGTHIS
        !           218: 
        !           219:     } else {
        !           220:         $result = (<<ENDDONOTREGTHIS);
        !           221: 
        !           222: <script language="JavaScript">
        !           223: // BEGIN LON-CAPA Internal
        !           224: 
        !           225:     function LONCAPAreg() {
        !           226: 	  swmenu=$reopen
        !           227:           $timesync
        !           228:           swmenu.currentStale=1;
        !           229:           swmenu.clearbut(2,1);
        !           230:           swmenu.clearbut(2,3);
        !           231:           swmenu.clearbut(8,1);
        !           232:           swmenu.clearbut(8,2);
        !           233:           swmenu.clearbut(8,3);
        !           234:           if (swmenu.currentURL) {
        !           235:              swmenu.switchbutton
        !           236:               (3,1,'reload.gif','return','location','go(currentURL)');
        !           237:  	  } else {
        !           238: 	      swmenu.clearbut(3,1);
        !           239:           }
        !           240:     }
        !           241: 
        !           242:     function LONCAPAstale() {
        !           243:     }
        !           244: 
        !           245: // END LON-CAPA Internal
        !           246: </script>
        !           247: ENDDONOTREGTHIS
        !           248:     }
        !           249:     return $result;
        !           250: }
        !           251: 
        !           252: sub loadevents() {
        !           253:     return 'LONCAPAreg();';
        !           254: }
        !           255: 
        !           256: sub unloadevents() {
        !           257:     return 'LONCAPAstale();';
        !           258: }
1.30      www       259: 
1.32      www       260: # ============================================================= Start up remote
                    261: 
                    262: sub startupremote {
                    263:     my ($lowerurl)=@_;
1.34      www       264:     if ($ENV{'browser.interface'} eq 'textual') {
                    265:      return ('<meta HTTP-EQUIV="Refresh" CONTENT="0.5; url='.$lowerurl.'" />');
                    266:     }
1.32      www       267:     my $configmenu=&rawconfig();
                    268:     return(<<ENDREMOTESTARTUP);
                    269: <script>
                    270: 
1.35      www       271: function wheelswitch() {
                    272:    if (window.status=='|') { 
                    273:       window.status='/'; 
                    274:    } else {
                    275:       if (window.status=='/') {
                    276:          window.status='-';
                    277:       } else {
                    278:          if (window.status=='-') { 
                    279:             window.status='\\\\'; 
                    280:          } else {
                    281:             if (window.status=='\\\\') { window.status='|'; }
                    282:          }
                    283:       }
                    284:    } 
                    285: }
                    286: 
1.32      www       287: // ---------------------------------------------------------- The wait function
                    288: var canceltim;
                    289: function wait() {
                    290:    if ((menuloaded==1) || (tim==1)) {
1.35      www       291:       window.status='Done.';
1.32      www       292:       if (tim==0) {
                    293:          clearTimeout(canceltim);
                    294:          $configmenu
                    295:          window.location='$lowerurl';  
                    296:       } else {
1.35      www       297:          alert("Remote Control timed out. It is possible that it was blocked by pop-up window filters.");
1.32      www       298:       }
                    299:    } else {
1.35      www       300:       wheelswitch();
                    301:       setTimeout('wait();',200);
1.32      www       302:    }
                    303: }
                    304: 
                    305: function main() {
1.35      www       306:    canceltim=setTimeout('tim=1;',60000);
                    307:    window.status='-';
1.32      www       308:    wait();
                    309: }
                    310: 
                    311: </script>
                    312: ENDREMOTESTARTUP
                    313: }
                    314: 
                    315: sub setflags() {
                    316:     return(<<ENDSETFLAGS);
                    317: <script>
                    318:     menuloaded=0;
                    319:     tim=0;
                    320: </script>
                    321: ENDSETFLAGS
                    322: }
                    323: 
                    324: sub maincall() {
1.34      www       325:     if ($ENV{'browser.interface'} eq 'textual') { return ''; }
1.32      www       326:     return(<<ENDMAINCALL);
                    327: <script>
                    328:     main();
                    329: </script>
                    330: ENDMAINCALL
                    331: }
1.30      www       332: # ================================================================= Reopen menu
                    333: 
                    334: sub reopenmenu {
                    335:    my $nothing='';
1.34      www       336:    if ($ENV{'browser.interface'} eq 'textual') { return ''; }
1.30      www       337:    my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
                    338:    if ($ENV{'browser.type'} eq 'explorer') { $nothing='javascript:void(0);'; }
                    339:    return('window.open("'.$nothing.'","'.$menuname.'","",false);');
                    340: } 
                    341: 
1.1       www       342: # =============================================================== Open the menu
                    343: 
                    344: sub open {
1.22      www       345:     my $returnval='';
1.34      www       346:     if ($ENV{'browser.interface'} eq 'textual') { return ''; }
1.30      www       347:     my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
1.22      www       348:     unless (shift eq 'unix') {
                    349: # resizing does not work on linux because of virtual desktop sizes
                    350:        $returnval.=(<<ENDRESIZE);
                    351: if (window.screen) {
1.28      www       352:     self.resizeTo(screen.availWidth-215,screen.availHeight-55);
1.22      www       353:     self.moveTo(190,15);
                    354: }
                    355: ENDRESIZE
                    356:     }
                    357:     $returnval.=(<<ENDOPEN);
1.35      www       358: window.status='Opening LON-CAPA Remote Control';
1.30      www       359: var menu=window.open("/res/adm/pages/menu.html","$menuname",
1.14      www       360: "height=350,width=150,scrollbars=no,menubar=no,top=5,left=5,screenX=5,screenY=5");
1.1       www       361: ENDOPEN
1.22      www       362:     return '<script>'.$returnval.'</script>';
1.1       www       363: }
                    364: 
1.2       www       365: 
                    366: # ================================================================== Raw Config
                    367: 
1.3       www       368: sub clear {
                    369:     my ($row,$col)=@_;
1.34      www       370:     unless ($ENV{'browser.interface'} eq 'textual') {
1.35      www       371:        return "\n".qq(window.status+='.';swmenu.clearbut($row,$col););
1.34      www       372:    } else { return ''; }
1.3       www       373: }
                    374: 
1.25      matthew   375: # Switch acts on the javascript that is executed when a button is clicked.  
                    376: # The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
1.2       www       377: sub switch {
1.27      www       378:     my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc)=@_;
1.2       www       379:     $act=~s/\$uname/$uname/g;
                    380:     $act=~s/\$udom/$udom/g;
1.34      www       381:     unless ($ENV{'browser.interface'} eq 'textual') {
                    382:        return "\n".
1.35      www       383:  qq(window.status+='.';swmenu.switchbutton($row,$col,"$img","$top","$bot","$act","$desc"););
1.34      www       384:    } else {
                    385:        my $text=$top.' '.$bot;
                    386:        $text=~s/\- //;
1.36      www       387:        return '<br /><a href="javascript:'.$act.';">'.$text.'</a> '.$desc;
1.34      www       388:    }
1.2       www       389: }
                    390: 
                    391: sub secondlevel {
                    392:     my $output='';
                    393:     my 
1.27      www       394:     ($uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc)=@_;
1.2       www       395:     if ($prt eq 'any') {
1.27      www       396: 	   $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
1.2       www       397:     } elsif ($prt=~/^r(\w+)/) {
                    398:         if ($rol eq $1) {
1.27      www       399:            $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
1.2       www       400:         }
                    401:     }
                    402:     return $output;
                    403: }
                    404: 
1.18      www       405: sub openmenu {
1.30      www       406:     my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
1.34      www       407:     if ($ENV{'browser.interface'} eq 'textual') { return ''; }
1.18      www       408:     if ($ENV{'browser.type'} eq 'explorer') {
1.30      www       409:        return "window.open('javascript:void(0);','".$menuname."');";
1.18      www       410:    } else {
1.30      www       411:        return "window.open('','".$menuname."');";
1.18      www       412:    }
                    413: }
                    414: 
1.2       www       415: sub rawconfig {
1.34      www       416:     my $textualoverride=shift;
                    417:     my $output='';
                    418:     unless ($ENV{'browser.interface'} eq 'textual') {
1.35      www       419:        $output.=
                    420:  "window.status='Opening Remote Control';var swmenu=".&openmenu().
                    421: "\nwindow.status='Configuring Remote Control ';";
1.34      www       422:     } else {
                    423:        unless ($textualoverride) { return ''; }
                    424:     }
1.2       www       425:     my $uname=$ENV{'user.name'};
                    426:     my $udom=$ENV{'user.domain'};
                    427:     my $adv=$ENV{'user.adv'};
1.4       www       428:     my $author=$ENV{'user.author'};
1.5       www       429:     my $crs='';
                    430:     if ($ENV{'request.course.id'}) {
                    431:        $crs='/'.$ENV{'request.course.id'};
1.7       www       432:        if ($ENV{'request.course.sec'}) {
                    433: 	   $crs.='_'.$ENV{'request.course.sec'};
                    434:        }
1.8       www       435:        $crs=~s/\_/\//g;
1.5       www       436:     }
1.2       www       437:     my $pub=($ENV{'request.state'} eq 'published');
                    438:     my $con=($ENV{'request.state'} eq 'construct');
                    439:     my $rol=$ENV{'request.role'};
1.25      matthew   440:     my $requested_domain = $ENV{'request.role.domain'};
1.13      harris41  441:     foreach (@desklines) {
1.27      www       442:         my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc)=split(/\:/,$_);
1.3       www       443:         $prt=~s/\$uname/$uname/g;
                    444:         $prt=~s/\$udom/$udom/g;
1.5       www       445:         $prt=~s/\$crs/$crs/g; 
1.25      matthew   446:         $prt=~s/\$requested_domain/$requested_domain/g;
1.3       www       447:         if ($pro eq 'clear') {
1.4       www       448: 	    $output.=&clear($row,$col);
1.3       www       449:         } elsif ($pro eq 'any') {
1.2       www       450:                $output.=&secondlevel(
1.27      www       451: 	  $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc);
1.2       www       452: 	} elsif ($pro eq 'smp') {
                    453:             unless ($adv) {
                    454:                $output.=&secondlevel(
1.27      www       455:           $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc);
1.2       www       456:             }
                    457:         } elsif ($pro eq 'adv') {
                    458:             if ($adv) {
                    459:                $output.=&secondlevel(
1.27      www       460: 	  $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc);
1.2       www       461:             }
                    462:         } elsif (($pro=~/p(\w+)/) && ($prt)) {
                    463: 	    if (&Apache::lonnet::allowed($1,$prt)) {
1.27      www       464:                $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
1.4       www       465:             }
1.26      www       466:         } elsif ($pro eq 'course') {
                    467:             if ($ENV{'request.course.fn'}) {
1.27      www       468:                $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
1.26      www       469: 	    }
1.4       www       470:         } elsif ($pro eq 'author') {
                    471:             if ($author) {
1.29      matthew   472:                 if ((($prt eq 'rca') && ($ENV{'request.role'}=~/^ca/)) ||
                    473:                     (($prt eq 'rau') && ($ENV{'request.role'}=~/^au/))) {
1.19      matthew   474:                     # Check that we are on the correct machine
1.29      matthew   475:                     my $cadom=$requested_domain;
                    476:                     my $caname=$ENV{'user.name'};
                    477:                     if ($prt eq 'rca') {
                    478: 		       ($cadom,$caname)=
1.6       www       479:                                ($ENV{'request.role'}=~/(\w+)\/(\w+)$/);
1.29      matthew   480:                     }                       
                    481:                     $act =~ s/\$caname/$caname/g;
1.19      matthew   482:                     my $home = &Apache::lonnet::homeserver($caname,$cadom);
1.32      www       483:                     if ($home eq $Apache::lonnet::perlvar{'lonHostID'}) {
1.19      matthew   484:                         $output.=switch($caname,$cadom,
1.27      www       485:                                         $row,$col,$img,$top,$bot,$act,$desc);
1.19      matthew   486:                     }
1.6       www       487:                 }
1.2       www       488:             }
                    489:         }
1.13      harris41  490:     }
1.34      www       491:     unless ($ENV{'browser.interface'} eq 'textual') {
1.35      www       492:        $output.="\nwindow.status='Synchronizing Time';swmenu.syncclock(1000*".time.");\nwindow.status='Remote Control Configured.';";
1.34      www       493:     }
1.2       www       494:     return $output;
                    495: }
                    496: 
                    497: # ======================================================================= Close
1.1       www       498: 
                    499: sub close {
1.35      www       500:     if ($ENV{'browser.interface'} eq 'textual') { return ''; }
1.30      www       501:     my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
1.1       www       502:     return(<<ENDCLOSE);
                    503: <script>
1.35      www       504: window.status='Accessing Remote Control';
1.30      www       505: menu=window.open("/adm/rat/empty.html","$menuname",
1.1       www       506:                  "height=350,width=150,scrollbars=no,menubar=no");
1.35      www       507: window.status='Disabling Remote Control';
                    508: menu.active=0;
1.31      www       509: menu.autologout=0;
1.35      www       510: window.status='Closing Remote Control';
1.1       www       511: menu.close();
1.35      www       512: window.status='Done.';
1.1       www       513: </script>
                    514: ENDCLOSE
                    515: }
                    516: 
                    517: # ====================================================================== Footer
                    518: 
                    519: sub footer {
                    520: 
1.33      www       521: }
                    522: 
                    523: # ================================================ Handler when called directly
                    524: 
                    525: 
                    526: sub handler {
                    527:     my $r = shift;
                    528:     $r->content_type('text/html');
                    529:     $r->send_http_header;
                    530:     return OK if $r->header_only;
                    531: 
1.34      www       532:     my $bodytag=&Apache::loncommon::bodytag('Main Menu');
1.33      www       533: # ------------------------------------------------------------ Print the screen
1.36      www       534:     $r->print(<<ENDHEADER);
                    535: <html><head>
                    536: <title>LON-CAPA Main Menu</title>
                    537: <script>
                    538: function go(url) {
                    539:     window.location=url;
                    540: }
                    541: function gopost(url) {
                    542:     window.location=url;
                    543: }
                    544: </script>
                    545: </head>
                    546: $bodytag
                    547: ENDHEADER
1.34      www       548:     $r->print(&rawconfig(1));
1.33      www       549:     $r->print('</body></html>');
                    550:     return OK;
1.1       www       551: }
                    552: 
1.2       www       553: # ================================================================ Main Program
                    554: 
1.16      harris41  555: BEGIN {
1.15      matthew   556:   if (! defined($readdesk)) {
1.14      www       557:    {
1.10      albertel  558:     my $config=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}.
                    559: 				  '/mydesk.tab');
                    560:     while (my $configline=<$config>) {
1.14      www       561:        $configline=(split(/\#/,$configline))[0];
                    562:        $configline=~s/^\s+//;
1.10      albertel  563:        chomp($configline);
1.14      www       564:        if ($configline) {
                    565:           $desklines[$#desklines+1]=$configline;
                    566:        }
1.2       www       567:     }
1.14      www       568:    }
                    569:    $readdesk='done';
1.10      albertel  570:   }
1.2       www       571: }
1.30      www       572: 
1.1       www       573: 1;
                    574: __END__
                    575: 
                    576: 
                    577: 
                    578: 
                    579: 
                    580: 
                    581: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>