version 1.485, 2017/12/22 02:00:46
|
version 1.488, 2018/04/27 20:14:16
|
Line 99 It gets filled in the BEGIN block of thi
|
Line 99 It gets filled in the BEGIN block of thi
|
|
|
=over |
=over |
|
|
=item prep_menuitems(\@menuitem) |
=item prep_menuitems(\@menuitem,$ltitarget) |
|
|
This routine wraps a menuitem in proper HTML. It is used by primary_menu() and |
This routine wraps a menuitem in proper HTML. It is used by primary_menu() and |
secondary_menu(). |
secondary_menu(). |
Line 210 use Apache::lonenc();
|
Line 210 use Apache::lonenc();
|
use Apache::lonlocal; |
use Apache::lonlocal; |
use Apache::lonmsg(); |
use Apache::lonmsg(); |
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA qw(:DEFAULT :match); |
|
use LONCAPA::ltiutils; |
use HTML::Entities(); |
use HTML::Entities(); |
use Apache::lonwishlist(); |
use Apache::lonwishlist(); |
|
|
Line 219 use vars qw(@desklines %category_names %
|
Line 220 use vars qw(@desklines %category_names %
|
my @inlineremote; |
my @inlineremote; |
|
|
sub prep_menuitem { |
sub prep_menuitem { |
my ($menuitem) = @_; |
my ($menuitem,$ltitarget) = @_; |
return '' unless(ref($menuitem) eq 'ARRAY'); |
return '' unless(ref($menuitem) eq 'ARRAY'); |
my $link; |
my $link; |
if ($$menuitem[1]) { # graphical Link |
if ($$menuitem[1]) { # graphical Link |
Line 229 sub prep_menuitem {
|
Line 230 sub prep_menuitem {
|
} else { # textual Link |
} else { # textual Link |
$link = &mt($$menuitem[3]); |
$link = &mt($$menuitem[3]); |
} |
} |
|
my $target = ' target="_top"'; |
|
if ($ltitarget eq 'iframe') { |
|
$target =''; |
|
} |
return '<li><a' |
return '<li><a' |
# highlighting for new messages |
# highlighting for new messages |
. ( $$menuitem[4] eq 'newmsg' ? ' class="LC_new_message"' : '') |
. ( $$menuitem[4] eq 'newmsg' ? ' class="LC_new_message"' : '') |
. qq| href="$$menuitem[0]" target="_top">$link</a></li>|; |
. qq| href="$$menuitem[0]"$target>$link</a></li>|; |
} |
} |
|
|
# primary_menu() evaluates @primary_menu and returns a two item array, |
# primary_menu() evaluates @primary_menu and returns a two item array, |
Line 260 sub primary_menu {
|
Line 265 sub primary_menu {
|
my %roles_in_env; |
my %roles_in_env; |
$rolecount = &Apache::lonroles::roles_from_env(\%roles_in_env,$update); |
$rolecount = &Apache::lonroles::roles_from_env(\%roles_in_env,$update); |
} |
} |
|
my $ltitarget; |
|
if ($env{'request.lti.login'}) { |
|
$ltitarget = $env{'request.lti.target'}; |
|
} |
foreach my $menuitem (@primary_menu) { |
foreach my $menuitem (@primary_menu) { |
# evaluate conditions |
# evaluate conditions |
next if ref($menuitem) ne 'ARRAY'; # |
next if ref($menuitem) ne 'ARRAY'; # |
Line 293 sub primary_menu {
|
Line 302 sub primary_menu {
|
my ($link,$target); |
my ($link,$target); |
if ($menuitem->[0] ne '') { |
if ($menuitem->[0] ne '') { |
$link = $menuitem->[0]; |
$link = $menuitem->[0]; |
$target = '_top'; |
unless ($ltitarget eq 'iframe') { |
|
$target = '_top'; |
|
} |
} else { |
} else { |
$link = '#'; |
$link = '#'; |
} |
} |
Line 328 sub primary_menu {
|
Line 339 sub primary_menu {
|
'helpdeskmail', |
'helpdeskmail', |
$defdom,$origmail); |
$defdom,$origmail); |
if ($to ne '') { |
if ($to ne '') { |
$menu{$position} .= &prep_menuitem($menuitem); |
$menu{$position} .= &prep_menuitem($menuitem,$ltitarget); |
} |
} |
} else { |
} else { |
$menu{$position} .= '<li>'.&Apache::loncommon::top_nav_help('Help').'</li>'; |
$menu{$position} .= '<li>'.&Apache::loncommon::top_nav_help('Help').'</li>'; |
} |
} |
} else { |
} else { |
$menu{$position} .= prep_menuitem($menuitem); |
$menu{$position} .= prep_menuitem($menuitem,$ltitarget); |
} |
} |
} |
} |
my @output = ('',''); |
my @output = ('',''); |
Line 441 sub secondary_menu {
|
Line 452 sub secondary_menu {
|
$canmodifycoauthor = 1; |
$canmodifycoauthor = 1; |
} |
} |
} |
} |
my ($roleswitcher_js,$roleswitcher_form); |
my ($roleswitcher_js,$roleswitcher_form,$ltitarget); |
|
if ($env{'request.lti.login'}) { |
|
$ltitarget = $env{'request.lti.target'}; |
|
} |
|
|
foreach my $menuitem (@secondary_menu) { |
foreach my $menuitem (@secondary_menu) { |
# evaluate conditions |
# evaluate conditions |
Line 484 sub secondary_menu {
|
Line 498 sub secondary_menu {
|
my ($link,$target); |
my ($link,$target); |
if ($menuitem->[0] ne '') { |
if ($menuitem->[0] ne '') { |
$link = $menuitem->[0]; |
$link = $menuitem->[0]; |
$target = '_top'; |
unless ($ltitarget eq 'iframe') { |
|
$target = '_top'; |
|
} |
} else { |
} else { |
$link = '#'; |
$link = '#'; |
} |
} |
Line 517 sub secondary_menu {
|
Line 533 sub secondary_menu {
|
&roles_selector( |
&roles_selector( |
$env{'course.' . $env{'request.course.id'} . '.domain'}, |
$env{'course.' . $env{'request.course.id'} . '.domain'}, |
$env{'course.' . $env{'request.course.id'} . '.num'}, |
$env{'course.' . $env{'request.course.id'} . '.num'}, |
$httphost |
$httphost,$ltitarget |
); |
); |
$menu .= $switcher; |
$menu .= $switcher; |
} else { |
} else { |
Line 543 sub secondary_menu {
|
Line 559 sub secondary_menu {
|
} |
} |
$$menuitem[0] = &HTML::Entities::encode($$menuitem[0],'&<>"'); |
$$menuitem[0] = &HTML::Entities::encode($$menuitem[0],'&<>"'); |
} |
} |
$menu .= &prep_menuitem(\@$menuitem); |
$menu .= &prep_menuitem(\@$menuitem,$ltitarget); |
} |
} |
} |
} |
if ($menu =~ /\[url\].*\[symb\]/) { |
if ($menu =~ /\[url\].*\[symb\]/) { |
Line 649 sub build_submenu {
|
Line 665 sub build_submenu {
|
next unless (($env{'user.name'} ne '') && ($env{'user.domain'} ne '')); |
next unless (($env{'user.name'} ne '') && ($env{'user.domain'} ne '')); |
$href =~ s/\[domain\]/$env{'user.domain'}/g; |
$href =~ s/\[domain\]/$env{'user.domain'}/g; |
$href =~ s/\[user\]/$env{'user.name'}/g; |
$href =~ s/\[user\]/$env{'user.name'}/g; |
|
} elsif (($href =~ m{^/adm/preferences\?}) && ($href =~ /\[returnurl\]/)) { |
|
my $returnurl = $ENV{'REQUEST_URI'}; |
|
if ($ENV{'REQUEST_URI'} =~ m{/adm/preferences\?action=(?:changedomcoord|authorsettings)\&returnurl=([^\&]+)$}) { |
|
$returnurl = $1; |
|
} |
|
if (($returnurl =~ m{^/adm/createuser($|\?action=)}) || |
|
($returnurl =~ m{^/priv/$match_domain/$match_username}) || |
|
($returnurl =~ m{^/res(/?$|/$match_domain/$match_username)})) { |
|
$returnurl =~ s{\?.*$}{}; |
|
$returnurl = '&returnurl='.&HTML::Entities::encode($returnurl,'"<>&\''); |
|
} else { |
|
undef($returnurl); |
|
} |
|
$href =~ s/\[returnurl\]/$returnurl/; |
} |
} |
unless (($href eq '') || ($href =~ /^\#/)) { |
unless (($href eq '') || ($href =~ /^\#/)) { |
$target = ' target="_top"'; |
if ($target eq '_top') { |
|
$target = ' target="_top"'; |
|
} |
} |
} |
|
|
$menu .= '<li style="margin:0;padding:0;'. $bordertop . $borderbot .'">'; |
$menu .= '<li style="margin:0;padding:0;'. $bordertop . $borderbot .'">'; |
Line 674 sub innerregister {
|
Line 706 sub innerregister {
|
|
|
undef(@inlineremote); |
undef(@inlineremote); |
|
|
my ($mapurl,$resurl,$crstype,$navmap); |
my ($mapurl,$resurl,$crstype,$navmap,$ltiscope,$ltiuri); |
|
|
if ($env{'request.course.id'}) { |
if ($env{'request.course.id'}) { |
# |
# |
#course_type: Course, Community, or Placement |
#course_type: Course, Community, or Placement |
# |
# |
$crstype = &Apache::loncommon::course_type(); |
$crstype = &Apache::loncommon::course_type(); |
|
if (($env{'request.lti.login'}) && ($env{'request.lti.uri'})) { |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
($ltiscope,$ltiuri) = &LONCAPA::ltiutils::lti_provider_scope($env{'request.lti.uri'},$cdom,$cnum); |
|
} |
if ($env{'request.symb'}) { |
if ($env{'request.symb'}) { |
my $ignorenull; |
my $ignorenull; |
unless ($env{'request.noversionuri'} eq '/adm/navmaps') { |
unless ($env{'request.noversionuri'} eq '/adm/navmaps') { |
Line 695 sub innerregister {
|
Line 732 sub innerregister {
|
my (@crumbs,@mapcrumbs); |
my (@crumbs,@mapcrumbs); |
if (($env{'request.noversionuri'} ne '/adm/navmaps') && ($mapurl ne '') && |
if (($env{'request.noversionuri'} ne '/adm/navmaps') && ($mapurl ne '') && |
(!(($crstype eq 'Placement') && !$env{'request.role.adv'}))) { |
(!(($crstype eq 'Placement') && !$env{'request.role.adv'}))) { |
$navmap = Apache::lonnavmaps::navmap->new(); |
unless ($ltiscope eq 'resource') { |
if (ref($navmap)) { |
if (($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) && |
@mapcrumbs = $navmap->recursed_crumbs($mapurl,$restitle); |
!(($ltiscope eq 'map') && (&Apache::lonnet::clutter($resurl) eq $ltiuri))) { |
|
$navmap = Apache::lonnavmaps::navmap->new(); |
|
if (ref($navmap)) { |
|
@mapcrumbs = $navmap->recursed_crumbs($mapurl,$restitle); |
|
} |
|
} |
} |
} |
} |
} |
unless (($forcereg) && |
unless (($forcereg) && |
($env{'request.noversionuri'} eq '/adm/navmaps') && |
($env{'request.noversionuri'} eq '/adm/navmaps') && |
($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'}) || |
($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'}) || |
(($crstype eq 'Placement') && (!$env{'request.role.adv'}))) { |
(($crstype eq 'Placement') && (!$env{'request.role.adv'})) || |
|
($ltiscope eq 'map') || ($ltiscope eq 'resource')) { |
@crumbs = ({text => $crstype.' Contents', |
@crumbs = ({text => $crstype.' Contents', |
href => "Javascript:gopost('/adm/navmaps','')"}); |
href => "Javascript:gopost('/adm/navmaps','')"}); |
} |
} |
if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) { |
if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) { |
if (@mapcrumbs) { |
if (@mapcrumbs) { |
push(@crumbs,@mapcrumbs); |
push(@crumbs,@mapcrumbs); |
} elsif (!(($crstype eq 'Placement') && (!$env{'request.role.adv'}))) { |
} elsif (!(($crstype eq 'Placement') && (!$env{'request.role.adv'})) && |
|
($ltiscope ne 'map') && ($ltiscope ne 'resource')) { |
push(@crumbs, {text => '...', |
push(@crumbs, {text => '...', |
no_mt => 1}); |
no_mt => 1}); |
} |
} |
Line 718 sub innerregister {
|
Line 762 sub innerregister {
|
|
|
unless ((($crstype eq 'Placement') && (!$env{'request.role.adv'})) || (@mapcrumbs) || |
unless ((($crstype eq 'Placement') && (!$env{'request.role.adv'})) || (@mapcrumbs) || |
(!$maptitle) || ($maptitle eq 'default.sequence') || |
(!$maptitle) || ($maptitle eq 'default.sequence') || |
($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'})) { |
($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'}) || |
push @crumbs, {text => $maptitle, no_mt => 1, href => $mapurl}; |
($ltiscope eq 'resource')) { |
|
push @crumbs, {text => $maptitle, no_mt => 1, |
|
href => &Apache::lonnet::clutter($mapurl).'?navmap=1'}; |
} |
} |
if ($restitle && !@mapcrumbs) { |
if ($restitle && !@mapcrumbs) { |
push(@crumbs,{text => $restitle, no_mt => 1}); |
push(@crumbs,{text => $restitle, no_mt => 1}); |
Line 912 ENDMENUITEMS
|
Line 958 ENDMENUITEMS
|
# Should probably be in mydesk.tab |
# Should probably be in mydesk.tab |
# |
# |
$menuitems = "c&3&1"; |
$menuitems = "c&3&1"; |
if (($crstype ne 'Placement') || ($env{'request.role.adv'})) { |
if ($ltiscope eq 'resource') { |
|
# Suppress display of backward arrow for LTI Provider if scope is resource. |
|
# Suppress display of forward arrow for LTI Provider if scope is resource. |
|
} elsif ($ltiscope eq 'map') { |
|
# Suppress display of backward arrow for LTI Provider if scope is map and this is first resource. |
|
# Suppress display of forward arrow for LTI Provider if scope is map and this is the last resource. |
|
my $showforw = 1; |
|
my $showback = 1; |
|
my $navmap = Apache::lonnavmaps::navmap->new(); |
|
if (ref($navmap)) { |
|
my $mapres = $navmap->getResourceByUrl($ltiuri); |
|
if (ref($mapres)) { |
|
if ($navmap->isLastResource($mapres,$env{'request.symb'})) { |
|
$showforw = 0; |
|
} |
|
if ($navmap->isFirstResource($mapres,$env{'request.symb'})) { |
|
$showback = 0; |
|
} |
|
} |
|
} |
|
if ($showback) { |
|
$menuitems.=" |
|
s&2&1&back.png&&&gopost('/adm/flip','back:'+currentURL)&Previous content resource&&1"; |
|
} |
|
if ($showforw) { |
|
$menuitems.=" |
|
s&2&3&forw.png&&&gopost('/adm/flip','forward:'+currentURL)&Next content resource&&3"; |
|
} |
|
} elsif (($crstype ne 'Placement') || ($env{'request.role.adv'})) { |
$menuitems.=" |
$menuitems.=" |
s&2&1&back.png&&&gopost('/adm/flip','back:'+currentURL)&Previous content resource&&1 |
s&2&1&back.png&&&gopost('/adm/flip','back:'+currentURL)&Previous content resource&&1 |
s&2&3&forw.png&&&gopost('/adm/flip','forward:'+currentURL)&Next content resource&&3"; |
s&2&3&forw.png&&&gopost('/adm/flip','forward:'+currentURL)&Next content resource&&3"; |
Line 1993 sub utilityfunctions {
|
Line 2067 sub utilityfunctions {
|
|
|
my $countdown = &countdown_toggle_js(); |
my $countdown = &countdown_toggle_js(); |
|
|
|
my $ltitarget; |
|
if ($env{'request.lti.login'}) { |
|
$ltitarget = $env{'request.lti.target'}; |
|
} |
|
|
my $hostvar = ' |
my $hostvar = ' |
function setLCHost() { |
function setLCHost() { |
var lcHostname=""; |
var lcHostname=""; |
Line 2089 function golist(url) {
|
Line 2168 function golist(url) {
|
currentURL = null; |
currentURL = null; |
currentSymb= null; |
currentSymb= null; |
var lcHostname = setLCHost(); |
var lcHostname = setLCHost(); |
top.location.href=lcHostname+url; |
var ltitarget = '$ltitarget'; |
|
if (ltitarget == 'iframe') { |
|
document.location.href=lcHostname+url; |
|
} else { |
|
top.location.href=lcHostname+url; |
|
} |
} |
} |
} |
} |
|
|
Line 2168 ENDUTILITY
|
Line 2252 ENDUTILITY
|
} |
} |
|
|
sub serverform { |
sub serverform { |
|
my $target; |
|
unless (($env{'request.lti.login'}) && ($env{'request.lti.target'} eq 'iframe')) { |
|
$target = ' target="_top"'; |
|
} |
return(<<ENDSERVERFORM); |
return(<<ENDSERVERFORM); |
<form name="server" action="/adm/logout" method="post" target="_top"> |
<form name="server" action="/adm/logout" method="post"$target> |
<input type="hidden" name="postdata" value="none" /> |
<input type="hidden" name="postdata" value="none" /> |
<input type="hidden" name="command" value="none" /> |
<input type="hidden" name="command" value="none" /> |
<input type="hidden" name="url" value="none" /> |
<input type="hidden" name="url" value="none" /> |
Line 2179 ENDSERVERFORM
|
Line 2267 ENDSERVERFORM
|
} |
} |
|
|
sub constspaceform { |
sub constspaceform { |
|
my ($target,$printtarget); |
|
unless (($env{'request.lti.login'}) && ($env{'request.lti.target'} eq 'iframe')) { |
|
$target = ' target="_top"'; |
|
$printtarget = ' target="_parent"'; |
|
} |
return(<<ENDCONSTSPACEFORM); |
return(<<ENDCONSTSPACEFORM); |
<form name="constspace" action="/adm/logout" method="post" target="_top"> |
<form name="constspace" action="/adm/logout" method="post"$target> |
<input type="hidden" name="filename" value="" /> |
<input type="hidden" name="filename" value="" /> |
</form> |
</form> |
<form name="cstrdelete" action="/adm/cfile" method="post" target="_top"> |
<form name="cstrdelete" action="/adm/cfile" method="post"$target> |
<input type="hidden" name="action" value="delete" /> |
<input type="hidden" name="action" value="delete" /> |
<input type="hidden" name="filename" value="" /> |
<input type="hidden" name="filename" value="" /> |
</form> |
</form> |
<form name="cstrprint" action="/adm/printout" target="_parent" method="post"> |
<form name="cstrprint" action="/adm/printout" method="post"$printtarget> |
<input type="hidden" name="postdata" value="" /> |
<input type="hidden" name="postdata" value="" /> |
<input type="hidden" name="curseed" value="" /> |
<input type="hidden" name="curseed" value="" /> |
<input type="hidden" name="problemtype" value="" /> |
<input type="hidden" name="problemtype" value="" /> |
Line 2207 sub hidden_button_check {
|
Line 2300 sub hidden_button_check {
|
} |
} |
|
|
sub roles_selector { |
sub roles_selector { |
my ($cdom,$cnum,$httphost) = @_; |
my ($cdom,$cnum,$httphost,$ltitarget) = @_; |
my $crstype = &Apache::loncommon::course_type(); |
my $crstype = &Apache::loncommon::course_type(); |
my $now = time; |
my $now = time; |
my (%courseroles,%seccount,%courseprivs,%roledesc); |
my (%courseroles,%seccount,%courseprivs,%roledesc); |
Line 2369 sub roles_selector {
|
Line 2462 sub roles_selector {
|
} |
} |
} |
} |
if (@submenu > 0) { |
if (@submenu > 0) { |
$switcher = &create_submenu('','',&mt('Switch role'),\@submenu); |
$switcher = &create_submenu('','',&mt('Switch role'),\@submenu,'','',$ltitarget); |
} |
} |
} |
} |
return ($js,$form,$switcher); |
return ($js,$form,$switcher); |