--- loncom/interface/lonmenu.pm 2017/06/22 02:11:27 1.369.2.71.4.2 +++ loncom/interface/lonmenu.pm 2017/11/01 09:01:39 1.369.2.71.4.5 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.369.2.71.4.2 2017/06/22 02:11:27 raeburn Exp $ +# $Id: lonmenu.pm,v 1.369.2.71.4.5 2017/11/01 09:01:39 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -699,21 +699,31 @@ sub innerregister { $newmail= 'swmenu.setstatus("you have","messages");'; } - my ($mapurl,$resurl); + my ($mapurl,$resurl,$navmap); if ($env{'request.course.id'}) { +# +#course_type: Course or Community +# if ($env{'request.symb'}) { - ($mapurl, my $rid, $resurl) = &Apache::lonnet::decode_symb(&Apache::lonnet::symbread()); + my $ignorenull; + unless ($env{'request.noversionuri'} eq '/adm/navmaps') { + $ignorenull = 1; + } + my $symb = &Apache::lonnet::symbread('','',$ignorenull); + ($mapurl, my $rid, $resurl) = &Apache::lonnet::decode_symb($symb); my $coursetitle = $env{'course.'.$env{'request.course.id'}.'.description'}; my $maptitle = &Apache::lonnet::gettitle($mapurl); - my $restitle = &Apache::lonnet::gettitle(&Apache::lonnet::symbread()); - + my $restitle = &Apache::lonnet::gettitle($symb); -#SD -#course_type only Course and Community? -# - my @crumbs; + my (@crumbs,@mapcrumbs); + if (($env{'request.noversionuri'} ne '/adm/navmaps') && ($mapurl ne '')) { + $navmap = Apache::lonnavmaps::navmap->new(); + if (ref($navmap)) { + @mapcrumbs = $navmap->recursed_crumbs($mapurl,$restitle); + } + } unless (($forcereg) && ($env{'request.noversionuri'} eq '/adm/navmaps') && ($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'})) { @@ -722,15 +732,21 @@ sub innerregister { href => "Javascript:gopost('/adm/navmaps','')"}); } if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) { - push(@crumbs, {text => '...', - no_mt => 1}); + if (@mapcrumbs) { + push(@crumbs,@mapcrumbs); + } else { + push(@crumbs, {text => '...', + no_mt => 1}); + } } - push @crumbs, {text => $maptitle, no_mt => 1} if ($maptitle - && $maptitle ne 'default.sequence' - && $maptitle ne $coursetitle); - - push @crumbs, {text => $restitle, no_mt => 1} if $restitle; + unless ((@mapcrumbs) || (!$maptitle) || ($maptitle eq 'default.sequence') || + ($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'})) { + push @crumbs, {text => $maptitle, no_mt => 1, href => $mapurl}; + } + if ($restitle && !@mapcrumbs) { + push(@crumbs,{text => $restitle, no_mt => 1}); + } my @tools; if ($env{'request.filename'} =~ /\.page$/) { my %breadcrumb_tools = &Apache::lonhtmlcommon::current_breadcrumb_tools(); @@ -1469,8 +1485,9 @@ sub prepare_functions { } my $editbutton = ''; + my $viewsrcbutton = ''; # -# Determine whether or not to display 'Edit' icon/button +# Determine whether or not to display 'Edit' or 'View Source' icon/button # if ($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) { my $file=&Apache::lonnet::declutter($env{'request.filename'}); @@ -1502,7 +1519,8 @@ sub prepare_functions { # if (($perms{'mdc'}) && (($resurl =~ m{^/?public/$cdom/$cnum/syllabus}) || - ($resurl =~ m{^/?uploaded/$cdom/$cnum/portfolio/syllabus/}))) { + ($resurl =~ m{^/?uploaded/$cdom/$cnum/portfolio/syllabus/}) || + (($resurl =~ m{^/?uploaded/$cdom/$cnum/default_\d+\.sequence$}) && ($env{'form.navmap'})))) { if ($resurl =~ m{^/}) { $cfile = $resurl; } else { @@ -1514,8 +1532,16 @@ sub prepare_functions { } else { $forceedit = 1; } - $editbutton = &get_editbutton($cfile,$home,$switchserver, - $forceedit,$forceview,$forcereg); + if ($cfile =~ m{^/uploaded/$cdom/$cnum/default_\d+\.sequence$}) { + my $text = 'Edit Folder'; + &switch('','',7,4,'docs-22x22.png','Edit Folder','parms[_2]', + "gocmd('/adm/coursedocs','direct')", + 'Folder/Page Content'); + $editbutton = 1; + } else { + $editbutton = &get_editbutton($cfile,$home,$switchserver, + $forceedit,$forceview,$forcereg); + } } elsif (($resurl eq '/adm/extresedit') && (($env{'form.symb'}) || ($env{'form.folderpath'}))) { ($cfile,$home,$switchserver,$forceedit,$forceview) = @@ -1544,6 +1570,29 @@ sub prepare_functions { $editbutton = &get_editbutton($cfile,$home,$switchserver, $forceedit,$forceview,$forcereg); } + if ((($cfile eq '') || (!$editbutton)) && + ($resurl =~ /$LONCAPA::assess_re/)) { + my $showurl = &Apache::lonnet::clutter($resurl); + if ((&Apache::lonnet::allowed('cre','/')) && + (&Apache::lonnet::metadata($resurl,'sourceavail') eq 'open')) { + $viewsrcbutton = 1; + } elsif (&Apache::lonnet::allowed('vxc',$env{'request.course.id'})) { + if ($showurl =~ m{^\Q/res/$cdom/\E($match_username)/}) { + my $auname = $1; + if (($env{'request.course.adhocsrcaccess'} ne '') && + (grep(/^\Q$auname\E$/,split(/,/,$env{'request.course.adhocsrcaccess'})))) { + $viewsrcbutton = 1; + } elsif ((&Apache::lonnet::metadata($resurl,'sourceavail') eq 'open') && + (&Apache::lonnet::allowed('bre','/'))) { + $viewsrcbutton = 1; + } + } + } + if ($viewsrcbutton) { + &switch('','',6,1,'pcstr.png','View Source','resource[_2]','open_source()', + 'View source code'); + } + } } } } @@ -1617,7 +1666,7 @@ sub prepare_functions { &advtools_crumbs(@inlineremote); return $editbutton; } elsif (($env{'request.registered'}) && (!ref($forbodytag))) { - return $editbutton; + return $editbutton || $viewsrcbutton; } else { if (ref($bread_crumbs) eq 'ARRAY') { if (@inlineremote > 0) { @@ -2495,6 +2544,12 @@ function open_StoredLinks_Import(rat) { newWin.focus(); } +function open_source() { + var url = escape(window.location.pathname); + sourcewin=window.open('/adm/source?inhibitmenu=yes&viewonly=1&filename='+url,'LONsource', + 'height=500,width=600,resizable=yes,location=no,menubar=no,toolbar=no,scrollbars=yes'); +} + (function (\$) { \$(document).ready(function () { \$.single=function(a){return function(b){a[0]=b;return a}}(\$([1]));