--- loncom/interface/lonmenu.pm 2023/10/06 02:16:46 1.369.2.83.2.11
+++ loncom/interface/lonmenu.pm 2020/10/06 21:28:33 1.503
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.369.2.83.2.11 2023/10/06 02:16:46 raeburn Exp $
+# $Id: lonmenu.pm,v 1.503 2020/10/06 21:28:33 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -99,7 +99,7 @@ It gets filled in the BEGIN block of thi
=over
-=item prep_menuitems(\@menuitem,$target,$listclass,$linkattr)
+=item prep_menuitems(\@menuitem,$ltitarget)
This routine wraps a menuitem in proper HTML. It is used by primary_menu() and
secondary_menu().
@@ -118,72 +118,51 @@ Same as primary_menu() but operates on @
=item create_submenu()
-Creates XHTML for unordered list of sub-menu items which belong to a
+Creates XHTML for unordered list of sub-menu items which belong to a
particular top-level menu item. Uses hover pseudo class in css to display
-dropdown list when mouse hovers over top-level item. Support for IE6
+dropdown list when mouse hovers over top-level item. Support for IE6
(no hover psuedo class) via LC_hoverable class for
tag for top-
level item, which employs jQuery to handle behavior on mouseover.
Inputs: 6 - (a) link and (b) target for anchor href in top level item,
- (c) title for text wrapped by anchor tag in top level item.
- (d) reference to array of arrays of sub-menu items.
- (e) boolean to indicate whether to call &mt() to translate
+ (c) title for text wrapped by anchor tag in top level item,
+ (d) reference to array of arrays of sub-menu items,
+ (e) boolean to indicate whether to call &mt() to translate
name of menu item,
(f) optional class for
element in primary menu, for which
sub menu is being generated.
-The underlying datastructure used in (d) contains data from mydesk.tab.
-It consists of an array which has an array for each item appearing in
-the menu (e.g. [["link", "title", "condition"]] for a single-item menu).
-create_submenu() supports also the creation of XHTML for nested dropdown
-menus represented by unordered lists. This is done by replacing the
-scalar used for the link with an arrayreference containing the menuitems
-for the nested menu. This can be done recursively so that the next menu
-may also contain nested submenus.
+ The underlying datastructure used in (d) contains data from mydesk.tab.
+ It consists of an array which has an array for each item appearing in
+ the menu (e.g. [["link", "title", "condition"]] for a single-item menu).
+ create_submenu() supports also the creation of XHTML for nested dropdown
+ menus represented by unordered lists. This is done by replacing the
+ scalar used for the link with an arrayreference containing the menuitems
+ for the nested menu. This can be done recursively so that the next menu
+ may also contain nested submenus.
Example:
- [ # begin of datastructure
- ["/home/", "Home", "condition1"], # 1st item of the 1st layer menu
- [ # 2nd item of the 1st layer menu
- [ # anon. array for nested menu
- ["/path1", "Path1", undef], # 1st item of the 2nd layer menu
- ["/path2", "Path2", undef], # 2nd item of the 2nd layer menu
- [ # 3rd item of the 2nd layer menu
- [[...], [...], ..., [...]], # containing another menu layer
- "Sub-Sub-Menu", # title for this container
- undef
- ]
- ], # end of array/nested menu
- "Sub-Menu", # title for the container item
- undef
- ] # end of 2nd item of the 1st layer menu
+ [ # begin of datastructure
+ ["/home/", "Home", "condition1"], # 1st item of the 1st layer menu
+ [ # 2nd item of the 1st layer menu
+ [ # anon. array for nested menu
+ ["/path1", "Path1", undef], # 1st item of the 2nd layer menu
+ ["/path2", "Path2", undef], # 2nd item of the 2nd layer menu
+ [ # 3rd item of the 2nd layer menu
+ [[...], [...], ..., [...]], # containing another menu layer
+ "Sub-Sub-Menu", # title for this container
+ undef
+ ]
+ ], # end of array/nested menu
+ "Sub-Menu", # title for the container item
+ undef
+ ] # end of 2nd item of the 1st layer menu
]
-
=item innerregister()
This gets called in order to register a URL in the body of the document
-=item loadevents()
-
-=item unloadevents()
-
-=item startupremote()
-
-=item setflags()
-
-=item maincall()
-
-=item load_remote_msg()
-
-=item get_menu_name()
-
-=item reopenmenu()
-
-=item open()
-
-Open the menu
-
=item clear()
=item switch()
@@ -231,6 +210,7 @@ use Apache::lonenc();
use Apache::lonlocal;
use Apache::lonmsg();
use LONCAPA qw(:DEFAULT :match);
+use LONCAPA::ltiutils;
use HTML::Entities();
use Apache::lonwishlist();
@@ -240,9 +220,9 @@ use vars qw(@desklines %category_names %
my @inlineremote;
sub prep_menuitem {
- my ($menuitem,$target,$listclass,$linkattr) = @_;
+ my ($menuitem,$ltitarget) = @_;
return '' unless(ref($menuitem) eq 'ARRAY');
- my ($link,$targetattr);
+ my $link;
if ($$menuitem[1]) { # graphical Link
$link = "':'
';
}
}
} elsif ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) {
# special treatment for role selector
- my ($switcher,$has_opa_priv);
- ($roleswitcher_js,$roleswitcher_form,$switcher,$has_opa_priv) =
+ ($roleswitcher_js,$roleswitcher_form,my $switcher) =
&roles_selector(
- $env{'course.' . $env{'request.course.id'} . '.domain'},
- $env{'course.' . $env{'request.course.id'} . '.num'},
- $httphost,$target,$menucoll,$menuref
+ $env{'course.' . $env{'request.course.id'} . '.domain'},
+ $env{'course.' . $env{'request.course.id'} . '.num'},
+ $httphost,$ltitarget
);
- if (($$menuitem[5]) && (!$menuopts{$$menuitem[5]})) {
- next unless ($has_opa_priv);
- }
$menu .= $switcher;
+ } elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink
+ next if ($crstype eq 'Placement');
+ $menu .= '
'.&Apache::loncommon::top_nav_help('Help').'
';
} else {
if ($$menuitem[3] eq 'Syllabus' && $env{'request.course.id'}) {
my $url = $$menuitem[0];
@@ -697,7 +604,7 @@ sub secondary_menu {
}
if ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://}) {
if (($ENV{'SERVER_PORT'} == 443) || ($env{'request.use_absolute'} =~ m{^https://})) {
- unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl())) {
+ unless (&Apache::lonnet::uses_sts()) {
unless ($$menuitem[0] =~ m{^https?://}) {
$$menuitem[0] = 'http://'.$ENV{'SERVER_NAME'}.$$menuitem[0];
}
@@ -709,7 +616,7 @@ sub secondary_menu {
}
$$menuitem[0] = &HTML::Entities::encode($$menuitem[0],'&<>"');
}
- $menu .= &prep_menuitem(\@$menuitem,$target,$listclass,$linkattr);
+ $menu .= &prep_menuitem(\@$menuitem,$ltitarget);
}
}
if ($menu =~ /\[url\].*\[symb\]/) {
@@ -733,7 +640,7 @@ sub secondary_menu {
$menu =~ s/\[uname\]/$$author{user}/g;
$menu =~ s/\[udom\]/$$author{dom}/g;
$menu =~ s/\[javascript\]/javascript:/g;
- if ($env{'request.course.id'}) {
+ if ($env{'request.course.id'}) {
$menu =~ s/\[cnum\]/$cnum/g;
$menu =~ s/\[cdom\]/$cdom/g;
}
@@ -747,14 +654,14 @@ sub secondary_menu {
}
sub create_submenu {
- my ($link,$target,$title,$submenu,$translate,$addclass,$listclass,$linkattr) = @_;
+ my ($link,$target,$title,$submenu,$translate,$addclass) = @_;
return unless (ref($submenu) eq 'ARRAY');
- my $targetattr;
- if (($target ne '') && ($link ne '#')) {
- $targetattr = ' target="'.$target.'"';
+ my $disptarget;
+ if ($target ne '') {
+ $disptarget = ' target="'.$target.'"';
}
my $menu = '
'.
- ''.
+ ''.
''.$title.
''.
' ▼'.
@@ -762,7 +669,7 @@ sub create_submenu {
# $link and $title are only used in the initial string written in $menu
# as seen above, not needed for nested submenus
- $menu .= &build_submenu($target, $submenu, $translate, '1', $listclass, $linkattr);
+ $menu .= &build_submenu($target, $submenu, $translate, '1');
$menu .= '
';
return $menu;
@@ -772,7 +679,7 @@ sub create_submenu {
# build the dropdown (and nested submenus) recursively
# see perldoc create_submenu documentation for further information
sub build_submenu {
- my ($target, $submenu, $translate, $first_level, $listclass, $linkattr) = @_;
+ my ($target, $submenu, $translate, $first_level) = @_;
unless (@{$submenu}) {
return '';
}
@@ -805,11 +712,11 @@ sub build_submenu {
if (ref($href) eq 'ARRAY') {
$menu .= '
';
+ $menu .= '';
} else { # href is the actual hyperlink and does not represent another submenu
# for the current menu title
if ($href =~ /(aboutme|rss\.html)$/) {
@@ -831,17 +738,14 @@ sub build_submenu {
}
$href =~ s/\[returnurl\]/$returnurl/;
}
- my $targetattr;
unless (($href eq '') || ($href =~ /^\#/)) {
- if ($target ne '') {
- $targetattr = ' target="'.$target.'"';
+ if ($target eq '_top') {
+ $target = ' target="_top"';
}
}
- $menu .= '