File:  [LON-CAPA] / loncom / interface / lonmenu.pm
Revision 1.17: download - view: text, annotated - select for diffs
Fri Feb 15 20:06:42 2002 UTC (22 years, 3 months ago) by matthew
Branches: MAIN
CVS tags: HEAD
Commented out window resizing code.

    1: # The LearningOnline Network with CAPA
    2: # Routines to control the menu
    3: #
    4: # $Id: lonmenu.pm,v 1.17 2002/02/15 20:06:42 matthew 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: # (TeX Conversion Module
   29: #
   30: # 05/29/00,05/30 Gerd Kortemeyer)
   31: #
   32: # 10/05,05/28,05/30,06/01,06/08,06/09,07/04,08/07 Gerd Kortemeyer
   33: # 02/15/02 Matthew Hall
   34: 
   35: package Apache::lonmenu;
   36: 
   37: use strict;
   38: use Apache::lonnet;
   39: use Apache::File;
   40: use vars qw(@desklines $readdesk);
   41:  
   42: # =============================================================== Open the menu
   43: 
   44: sub open {
   45: #    return(<<ENDOPEN);
   46: #if (window.screen) {
   47: #    self.resizeTo(screen.availWidth-215,screen.availHeight-30);
   48: #    self.moveTo(190,15);
   49: #}
   50:     return(<<ENDOPEN);
   51: <script>
   52: menu=window.open("/res/adm/pages/menu.html","LONCAPAmenu",
   53: "height=350,width=150,scrollbars=no,menubar=no,top=5,left=5,screenX=5,screenY=5");
   54: </script>
   55: ENDOPEN
   56: }
   57: 
   58: # ============================================================ Switch Menu Item
   59: 
   60: sub switchmenu {
   61:     my ($row,$col,$imgsrc,$texttop,$textbot,$action)=@_;
   62:     return(<<ENDSMENU);
   63: <script>
   64:    swmenu=window.open('','LONCAPAmenu');
   65:    swmenu.switchbutton($row,$col,"$imgsrc","$texttop","$textbot","$action");
   66: </script>
   67: ENDSMENU
   68: }
   69: 
   70: # ================================================================== Raw Config
   71: 
   72: sub clear {
   73:     my ($row,$col)=@_;
   74:     return qq(swmenu.clearbut($row,$col););
   75: }
   76: 
   77: sub switch {
   78:     my ($uname,$udom,$row,$col,$img,$top,$bot,$act)=@_;
   79:     $act=~s/\$uname/$uname/g;
   80:     $act=~s/\$udom/$udom/g;
   81:     return "\n".
   82:  qq(swmenu.switchbutton($row,$col,"$img","$top","$bot","$act"););
   83: }
   84: 
   85: sub secondlevel {
   86:     my $output='';
   87:     my 
   88:     ($uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act)=@_;
   89:     if ($prt eq 'any') {
   90: 	   $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act);
   91:     } elsif ($prt=~/^r(\w+)/) {
   92:         if ($rol eq $1) {
   93:            $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act);
   94:         }
   95:     }
   96:     return $output;
   97: }
   98: 
   99: sub rawconfig {
  100:     my $output="swmenu=window.open('','LONCAPAmenu');";
  101:     my $uname=$ENV{'user.name'};
  102:     my $udom=$ENV{'user.domain'};
  103:     my $adv=$ENV{'user.adv'};
  104:     my $author=$ENV{'user.author'};
  105:     my $crs='';
  106:     if ($ENV{'request.course.id'}) {
  107:        $crs='/'.$ENV{'request.course.id'};
  108:        if ($ENV{'request.course.sec'}) {
  109: 	   $crs.='_'.$ENV{'request.course.sec'};
  110:        }
  111:        $crs=~s/\_/\//g;
  112:     }
  113:     my $pub=($ENV{'request.state'} eq 'published');
  114:     my $con=($ENV{'request.state'} eq 'construct');
  115:     my $rol=$ENV{'request.role'};
  116:     foreach (@desklines) {
  117:         my ($row,$col,$pro,$prt,$img,$top,$bot,$act)=split(/\:/,$_);
  118:         $prt=~s/\$uname/$uname/g;
  119:         $prt=~s/\$udom/$udom/g;
  120:         $prt=~s/\$crs/$crs/g; 
  121:         if ($pro eq 'clear') {
  122: 	    $output.=&clear($row,$col);
  123:         } elsif ($pro eq 'any') {
  124:                $output.=&secondlevel(
  125: 	  $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act);
  126: 	} elsif ($pro eq 'smp') {
  127:             unless ($adv) {
  128:                $output.=&secondlevel(
  129:           $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act);
  130:             }
  131:         } elsif ($pro eq 'adv') {
  132:             if ($adv) {
  133:                $output.=&secondlevel(
  134: 	  $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act);
  135:             }
  136:         } elsif (($pro=~/p(\w+)/) && ($prt)) {
  137: 	    if (&Apache::lonnet::allowed($1,$prt)) {
  138:                $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act);
  139:             }
  140:         } elsif ($pro eq 'author') {
  141:             if ($author) {
  142:                 if (($prt eq 'rca') && ($ENV{'request.role'}=~/^ca/)) {
  143: 		    my ($cadom,$caname)=
  144:                                ($ENV{'request.role'}=~/(\w+)\/(\w+)$/);
  145:                     $output.=switch($caname,$cadom,
  146:                                     $row,$col,$img,$top,$bot,$act);
  147:                 } elsif ($prt eq 'any') {
  148:                     $output.=switch($ENV{'user.name'},$ENV{'user.domain'},
  149: 				    $row,$col,$img,$top,$bot,$act);
  150:                 }
  151:             }
  152:         }
  153:     }
  154:     return $output;
  155: }
  156: 
  157: # ======================================================================= Close
  158: 
  159: sub close {
  160:     return(<<ENDCLOSE);
  161: <script>
  162: menu=window.open("/adm/rat/empty.html","LONCAPAmenu",
  163:                  "height=350,width=150,scrollbars=no,menubar=no");
  164: menu.close();
  165: </script>
  166: ENDCLOSE
  167: }
  168: 
  169: # ====================================================================== Footer
  170: 
  171: sub footer {
  172: 
  173: }
  174: 
  175: # ================================================================ Main Program
  176: 
  177: BEGIN {
  178:   if (! defined($readdesk)) {
  179:    {
  180:     my $config=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}.
  181: 				  '/mydesk.tab');
  182:     while (my $configline=<$config>) {
  183:        $configline=(split(/\#/,$configline))[0];
  184:        $configline=~s/^\s+//;
  185:        chomp($configline);
  186:        if ($configline) {
  187:           $desklines[$#desklines+1]=$configline;
  188:        }
  189:     }
  190:    }
  191:    $readdesk='done';
  192:   }
  193: }
  194: 1;
  195: __END__
  196: 
  197: 
  198: 
  199: 
  200: 
  201: 
  202: 

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