--- loncom/interface/loncommon.pm 2022/02/18 00:41:09 1.1075.2.161.2.5 +++ loncom/interface/loncommon.pm 2022/05/30 13:30:03 1.1075.2.161.2.6 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.1075.2.161.2.5 2022/02/18 00:41:09 raeburn Exp $ +# $Id: loncommon.pm,v 1.1075.2.161.2.6 2022/05/30 13:30:03 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1221,7 +1221,7 @@ END =pod -=item * &help_open_topic($topic,$text,$stayOnPage,$width,$height,$imgid) +=item * &help_open_topic($topic,$text,$stayOnPage,$width,$height,$imgid,$links_target) Returns a string corresponding to an HTML link to the given help $topic, where $topic corresponds to the name of a .tex file in @@ -1245,10 +1245,12 @@ $imgid is the id of the img tag used for used in a javascript call to switch the image src. See lonhtmlcommon::htmlareaselectactive() for an example. +$links_target will optionally be set to a target (_top, _parent or _self). + =cut sub help_open_topic { - my ($topic, $text, $stayOnPage, $width, $height, $imgid) = @_; + my ($topic, $text, $stayOnPage, $width, $height, $imgid, $links_target) = @_; $text = "" if (not defined $text); $stayOnPage = 0 if (not defined $stayOnPage); $width = 500 if (not defined $width); @@ -1274,9 +1276,15 @@ sub help_open_topic { } # Add the text + my $target = ' target="_top"'; + if ($links_target) { + $target = ' target="'.$links_target.'"'; + } elsif (($env{'request.deeplink.login'}) && ($env{'request.deeplink.target'} eq '_self')) { + $target = ''; + } if ($text ne "") { $template.='' - .'' + .'' .$text.''; } @@ -1286,7 +1294,7 @@ sub help_open_topic { if ($imgid ne '') { $imgid = ' id="'.$imgid.'"'; } - $template.=' ' + $template.=' ' .''.&mt('Help: [_1]',$topic).''; + $width,$height,'',$links_target).''; } } my $banner_link = &update_help_link($topic,$component_help,$faq,$bug,$stayOnPage); @@ -1481,19 +1489,26 @@ sub help_open_bug { { $link = $url; } + + my $target = '_top'; + if ((($env{'request.lti.login'}) && ($env{'request.lti.target'} eq 'iframe')) || + (($env{'request.deeplink.login'}) && ($env{'request.deeplink.target'} eq '_self'))) { + $target = '_blank'; + } + # Add the text if ($text ne "") { $template .= "". - "
$text"; + "$text"; } # Add the graphic my $title = &mt('Report a Bug'); my $bugicon=&lonhttpdurl("/adm/lonMisc/smallBug.gif"); $template .= <<"ENDTEMPLATE"; - (Bug: $topic) + (Bug: $topic) ENDTEMPLATE if ($text ne '') { $template.='
' }; return $template; @@ -5752,6 +5767,10 @@ sub head_subbox { Input: (optional) filename from which breadcrumb trail is built. In most cases no input as needed, as $env{'request.filename'} is appropriate for use in building the breadcrumb trail. + frameset flag + If page header is being requested for use in a frameset, then + the second (option) argument -- frameset will be true, and + the target attribute set for links should be target="_parent". Returns: HTML div with CSTR path and recent box To be included on Authoring Space pages @@ -5759,7 +5778,7 @@ Returns: HTML div with CSTR path and rec =cut sub CSTR_pageheader { - my ($trailfile) = @_; + my ($trailfile,$frameset) = @_; if ($trailfile eq '') { $trailfile = $env{'request.filename'}; } @@ -5782,13 +5801,21 @@ sub CSTR_pageheader { $lastitem = $thisdisfn; } + my ($target,$crumbtarget) = (' target="_top"','_top'); + if ($frameset) { + $target = ' target="_parent"'; + $crumbtarget = '_parent'; + } elsif (($env{'request.deeplink.login'}) && ($env{'request.deeplink.target'})) { + $target = ' target="'.$env{'request.deeplink.target'}.'"'; + $crumbtarget = $env{'request.deeplink.target'}; + } + my $output = '
' .&Apache::loncommon::help_open_menu('','',3,'Authoring') #FIXME: Broken? Where is it? .''.&mt('Authoring Space:').' ' - .'
' #FIXME lonpubdir: target="_parent" - .&Apache::lonhtmlcommon::crumbs($uname.'/'.$parentpath,'_top','/priv/'.$udom,undef,undef); + .'' + .&Apache::lonhtmlcommon::crumbs($uname.'/'.$parentpath,$crumbtarget,'/priv/'.$udom,undef,undef); if ($lastitem) { $output .= @@ -5798,10 +5825,10 @@ sub CSTR_pageheader { } $output .= '
' - #FIXME lonpubdir: &Apache::lonhtmlcommon::crumbs($uname.$thisdisfn.'/','_top','/priv','','+1',1)."
" + #FIXME lonpubdir: &Apache::lonhtmlcommon::crumbs($uname.$thisdisfn.'/',$crumbtarget,'/priv','','+1',1)."
" .&Apache::lonhtmlcommon::select_recent('construct','recent','this.form.action=this.form.recent.value;this.form.submit()') .'
' - .&Apache::lonmenu::constspaceform() + .&Apache::lonmenu::constspaceform($frameset) .'
'; return $output; @@ -6036,7 +6063,8 @@ sub bodytag { unless ($args->{'no_primary_menu'}) { my ($left,$right) = Apache::lonmenu::primary_menu($crstype,$ltimenu,$menucoll,$menuref, - $args->{'links_disabled'}); + $args->{'links_disabled'}, + $args->{'links_target'}); if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { if ($dc_info) { $dc_info = qq|$dc_info|; @@ -6068,7 +6096,8 @@ sub bodytag { $bodytag .= Apache::lonmenu::secondary_menu($httphost,$ltiscope,$ltimenu, $args->{'no_primary_menu'}, $menucoll,$menuref, - $args->{'links_disabled'}); + $args->{'links_disabled'}, + $args->{'links_target'}); } $bodytag .= Apache::lonmenu::serverform(); $bodytag .= Apache::lonhtmlcommon::scripttag('', 'end'); @@ -8702,6 +8731,7 @@ $args - additional optional args support links_disabled -> Links in primary and secondary menus are disabled (Can enable them once page has loaded - see lonroles.pm for an example). + links_target -> Target for links, e.g., _parent (optional). =back @@ -8933,7 +8963,7 @@ sub menucoll_in_effect { } } if ($deeplink ne '') { - my ($state,$others,$listed,$scope,$protect,$display) = split(/,/,$deeplink); + my ($state,$others,$listed,$scope,$protect,$display,$target) = split(/,/,$deeplink); if ($display =~ /^\d+$/) { $deeplinkmenu = 1; $menucoll = $display;