--- loncom/interface/lonmenu.pm 2006/07/01 00:39:54 1.191 +++ loncom/interface/lonmenu.pm 2007/07/16 01:57:38 1.220 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.191 2006/07/01 00:39:54 www Exp $ +# $Id: lonmenu.pm,v 1.220 2007/07/16 01:57:38 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -44,14 +44,15 @@ use Apache::lonhtmlcommon(); use Apache::loncommon(); use Apache::lonenc(); use Apache::lonlocal; -use lib '/home/httpd/lib/perl/'; -use LONCAPA; +use LONCAPA qw(:DEFAULT :match); -use vars qw(@desklines $readdesk); +use vars qw(@desklines %category_names %category_members %category_positions $readdesk); my @inlineremote; + + # ================================================================ Little texts sub initlittle { @@ -60,12 +61,12 @@ sub initlittle { 'main' => 'Main Menu', 'roles' => ($env{'user.adv'}? 'Roles':'Courses'), - 'docs' => 'Course Documents', + 'docs' => 'Edit Course', 'exit' => 'Exit', + 'login' => 'Log In', 'launch' => 'Launch Remote Control', 'groups' => 'Groups', 'gdoc' => 'Group Documents', - 'teams' => 'Teams', ); } @@ -91,6 +92,10 @@ sub menubuttons { my $escurl=&escape(&Apache::lonenc::check_encrypt($env{'request.noversionuri'})); my $escsymb=&escape(&Apache::lonenc::check_encrypt($env{'request.symb'})); + my $logo=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/minilogo.gif"); + $logo = 'LON-CAPA Logo'; + if ($env{'request.state'} eq 'construct') { if (($env{'request.noversionuri'} eq '') || (!defined($env{'request.noversionuri'}))) { my $returnurl = $env{'request.filename'}; @@ -101,7 +106,7 @@ sub menubuttons { if ($env{'request.course.id'}) { my %coursegroups; my $viewgrps_permission = - &Apache::lonnet::allowed('vcg',$env{'request.course.id'}); + &Apache::lonnet::allowed('vcg',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')); if (!$viewgrps_permission) { %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'}); } @@ -118,7 +123,7 @@ sub menubuttons { ENDNAV if (($env{'request.noversionuri'}=~/^\/adm\//) && ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) && - ($env{'request.noversionuri'}!~/^\/adm\/.*\/(smppg|grppg|bulletinboard|aboutme)(\?|$)/)) { + ($env{'request.noversionuri'}!~/^\/adm\/.*\/(smppg|bulletinboard|aboutme)(\?|$)/)) { my $escreload=&escape('return:'); $reloadlink=(<$lt{'ret'} @@ -131,7 +136,7 @@ ENDDOCS } if ($showgroups) { $groups =(<$lt{'groups'} +$lt{'groups'} ENDGROUPS } } @@ -168,14 +173,14 @@ ENDMAINMENU my $vlink=&Apache::loncommon::designparm($function.'.vlink',$domain); my $sidebg=&Apache::loncommon::designparm($function.'.sidebg',$domain); if ($env{'user.name'} eq 'public' && $env{'user.domain'} eq 'public') { - my $logo=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/minilogo.gif"); return (< - - $lt{'exit'} + $logo + + + $lt{'login'} - LON-CAPALogo @@ -199,9 +204,8 @@ my $is_group = (&Apache::loncommon::cour ENDDOCS } if ($showgroups) { - my $text = ($is_group) ? $lt{'teams'} : $lt{'groups'}; $groups =(<$text +$lt{'groups'} ENDGROUPS } if ( @@ -211,7 +215,7 @@ ENDGROUPS (($env{'request.noversionuri'}=~/^\/adm\//) && ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) && ($env{'request.noversionuri'}!~ - m[^/adm/.*/(smppg|grppg|bulletinboard|aboutme)($|\?)]) + m[^/adm/.*/(smppg|bulletinboard|aboutme)($|\?)]) ) ) { my $escreload=&escape('return:'); @@ -232,11 +236,12 @@ ENDCRELOAD } my $form=&serverform(); my $utility=&utilityfunctions(); - my $logo=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/minilogo.gif"); my $remote; if ($env{'user.adv'}) { $remote = ''.$lt{'launch'}.'' } + + my $helplink=&Apache::loncommon::top_nav_help('Help'); return (< // BEGIN LON-CAPA Internal @@ -246,6 +251,7 @@ $utility +$logo $reloadlink $navmaps @@ -253,8 +259,8 @@ $docs $groups $remote - - + +
$lt{'main'}$lt{'roles'}$lt{'exit'}$helplink$lt{'exit'}
$form @@ -383,7 +389,7 @@ sub innerregister { &Apache::lonnet::allowed('opa',$crs)) { $hwkadd.=&switch('','',7,3,'pparm.gif','problem[_2]','parms[_2]', "gocmd('/adm/parmset','set')", - 'Modify deadlines, etc, for this resource'); + 'Modify parameter settings for this resource'); } # -- End Homework ### @@ -401,7 +407,7 @@ sub innerregister { my $desc = "Enter my resource construction space"; # Set defaults for co-authors if ($env{'request.role'} =~ /^ca/) { - ($cadom,$caname)=($env{'request.role'}=~/(\w+)\/(\w+)$/); + ($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/); ($top,$bottom) = ('co con-','struct'); $action = "go('/priv/".$caname."');"; $desc = "Enter construction space as co-author"; @@ -423,7 +429,7 @@ sub innerregister { my $cfudom=''; if ($env{'request.filename'}) { my $file=&Apache::lonnet::declutter($env{'request.filename'}); - $file=~s/^(\w+)\/(\w+)/\/priv\/$2/; + $file=~s/^($match_domain)\/($match_username)/\/priv\/$2/; # Check that the user has permission to edit this resource ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$1); if (defined($cfudom)) { @@ -439,7 +445,7 @@ sub innerregister { # Finally, turn the button on or off if ($cfile && !$const_space) { $editbutton=&switch - ('','',6,1,'cstr.gif','edit[_1]','resource[_2]', + ('','',6,1,'pcstr.gif','edit[_1]','resource[_2]', "go('".$cfile."');","Edit this resource"); } elsif ($editbutton eq '') { $editbutton=&clear(6,1); @@ -457,42 +463,63 @@ sub innerregister { $is_const_dir = 1; } else { $currdir =~ s#[^/]+$##; + my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn); + my $esc_currdir = &Apache::loncommon::escape_single($currdir); $menuitems=(< +$inlineremote[21] $inlineremote[23] +ENDARROWSINLINE + if (&hidden_button_check() ne 'yes') { + $inlinebuttons .= (< +ENDINLINEICONS + } + } else { + $inlinebuttons=(<$inlineremote[21] $inlineremote[23] +ENDFIRSTLINE + if (&hidden_button_check() ne 'yes') { + $inlinebuttons .= (<$inlineremote[61]$inlineremote[62]$inlineremote[63] $inlineremote[71]$inlineremote[72]$inlineremote[73] $inlineremote[81]$inlineremote[82]$inlineremote[83] $inlineremote[91]$inlineremote[92]$inlineremote[93] ENDINLINE + } + } } } $result =(<'.$text.''; } else { - $inlineremote[10*$row+$col]="\n
". + $inlineremote[$idx]="\n
". $desc.' '.$text.''; } } else { # Inline Remote + if ($env{'environment.icons'} ne 'classic') { + $img=~s/\.gif$/\.png/; + } if ($nobreak==2) { return ''; } my $text=$top.' '.$bot; $text=~s/\s*\-\s*//gs; @@ -839,27 +890,31 @@ sub switch { if ($env{'browser.interface'} eq 'faketextual') { # Accessibility if ($nobreak==3) { - $inlineremote[10*$row+$col]="\n". + $inlineremote[$idx]="\n". ''.$text. ''. ''.$pic.''; } elsif ($nobreak) { - $inlineremote[10*$row+$col]="\n". + $inlineremote[$idx]="\n". ''. ''.$pic.' - '.$text.''; + '.$text.''; } else { - $inlineremote[10*$row+$col]="\n". + $inlineremote[$idx]="\n". ''. ''.$pic. ''. - $desc.''; + ''.$desc.''; } } else { # Inline Menu - $inlineremote[10*$row+$col]= - ''.$pic. - ''.$desc.''; + if ($env{'environment.icons'} eq 'iconsonly') { + $inlineremote[$idx]=''.$pic.''; + } else { + $inlineremote[$idx]= + ''.$pic. + ''.$desc.''; + } } } return ''; @@ -868,12 +923,12 @@ sub switch { sub secondlevel { my $output=''; my - ($uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc)=@_; + ($uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat)=@_; if ($prt eq 'any') { - $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc); + $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); } elsif ($prt=~/^r(\w+)/) { if ($rol eq $1) { - $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc); + $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); } } return $output; @@ -888,10 +943,32 @@ sub openmenu { } sub inlinemenu { - @inlineremote=(); - undef @inlineremote; + undef(@inlineremote); + undef(%category_members); &rawconfig(1); - return join('',map { (defined($_)?$_:'') } @inlineremote); + my $output=''; + for (my $col=1; $col<=2; $col++) { + $output.='"; + } + $output.="
'; + for (my $row=1; $row<=8; $row++) { + foreach my $cat (keys(%category_members)) { + if ($category_positions{$cat} ne "$col,$row") { next; } + $output.=''; + my %active=(); + foreach my $menu_item (split(/\:/,$category_members{$cat})) { + if ($inlineremote[$menu_item]) { + $active{$menu_item}=1; + } + } + foreach my $item (sort(keys(%active))) { + $output.=$inlineremote[$item]; + } + $output.='
'.&mt($category_names{$cat}).'
'; + } + } + $output.="
"; + return $output; } sub rawconfig { @@ -922,11 +999,12 @@ sub rawconfig { my $rol=$env{'request.role'}; my $requested_domain = $env{'request.role.domain'}; foreach my $line (@desklines) { - my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc)=split(/\:/,$line); + my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc,$cat)=split(/\:/,$line); $prt=~s/\$uname/$uname/g; $prt=~s/\$udom/$udom/g; $prt=~s/\$crs/$crs/g; $prt=~s/\$requested_domain/$requested_domain/g; + if ($category_names{$cat}!~/\w/) { $cat='oth'; } my $type = &Apache::loncommon::course_type(); if ($type eq 'Group') { $desc = &convert_menu_function($desc,$type); @@ -935,29 +1013,29 @@ sub rawconfig { $output.=&clear($row,$col); } elsif ($pro eq 'any') { $output.=&secondlevel( - $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc); + $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat); } elsif ($pro eq 'smp') { unless ($adv) { $output.=&secondlevel( - $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc); + $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat); } } elsif ($pro eq 'adv') { if ($adv) { $output.=&secondlevel( - $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc); + $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat); } } elsif (($pro=~/^p(\w+)/) && ($prt)) { if (&Apache::lonnet::allowed($1,$prt)) { - $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc); + $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); } } elsif ($pro eq 'course') { if ($env{'request.course.fn'}) { - $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc); + $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); } } elsif ($pro =~ /^courseenv_(.*)$/) { my $key = $1; if ($env{'course.'.$env{'request.course.id'}.'.'.$key}) { - $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc); + $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); } } elsif ($pro =~ /^course_(.*)$/) { # Check for permissions inside of a course @@ -965,7 +1043,7 @@ sub rawconfig { (&Apache::lonnet::allowed($1,$env{'request.course.id'}. ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')) )) { - $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc); + $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); } } elsif ($pro eq 'author') { if ($author) { @@ -976,7 +1054,7 @@ sub rawconfig { my $caname=$env{'user.name'}; if ($prt eq 'rca') { ($cadom,$caname)= - ($env{'request.role'}=~/(\w+)\/(\w+)$/); + ($env{'request.role'}=~/($match_domain)\/($match_username)$/); } $act =~ s/\$caname/$caname/g; my $home = &Apache::lonnet::homeserver($caname,$cadom); @@ -984,8 +1062,8 @@ sub rawconfig { my @ids=&Apache::lonnet::current_machine_ids(); foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } } if ($allowed) { - $output.=switch($caname,$cadom, - $row,$col,$img,$top,$bot,$act,$desc); + $output.=&switch($caname,$cadom, + $row,$col,$img,$top,$bot,$act,$desc,$cat); } } } @@ -1064,13 +1142,16 @@ sub utilityfunctions { 'add_entries' => { 'onload' => 'javascript:document.goannotate.submit();'}}); + my $end_page_annotate = + &Apache::loncommon::end_page({'js_ready' => 1}); + my $start_page_bookmark = &Apache::loncommon::start_page('Bookmarks',undef, {'only_body' => 1, 'js_ready' => 1, 'bgcolor' => '#BBBBBB',}); - my $end_page = + my $end_page_bookmark = &Apache::loncommon::end_page({'js_ready' => 1}); return (<" - +"" + +"" +"<\\/form>" - +'$end_page'); + +'$end_page_annotate'); annotator.document.close(); } @@ -1212,7 +1293,7 @@ function set_bookmark() { +"value='Save' /> <\\/center><\\/td>" +"<\\/tr><\\/table><\\/form><\\/center>" - +'$end_page' ); + +'$end_page_bookmark' ); bmquery.document.close(); } @@ -1272,6 +1353,16 @@ sub convert_menu_function { return $rolename; } +sub hidden_button_check { + my $hidden; + if ($env{'request.course.id'} eq '') { + return; + } + if ($env{'request.role.adv'}) { + return; + } + return(&Apache::lonnet::EXT('resource.0.buttonshide')); +} # ================================================================ Main Program @@ -1284,7 +1375,11 @@ BEGIN { $configline=(split(/\#/,$configline))[0]; $configline=~s/^\s+//; chomp($configline); - if ($configline) { + if ($configline=~/^cat\:/) { + my @entries=split(/\:/,$configline); + $category_positions{$entries[2]}=$entries[1]; + $category_names{$entries[2]}=$entries[3]; + } elsif ($configline) { push(@desklines,$configline); } }