--- loncom/interface/lonmenu.pm 2009/05/13 03:26:11 1.239.4.4
+++ loncom/interface/lonmenu.pm 2008/12/17 13:02:37 1.250
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.239.4.4 2009/05/13 03:26:11 raeburn Exp $
+# $Id: lonmenu.pm,v 1.250 2008/12/17 13:02:37 harmsja Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -36,6 +36,105 @@
# browser.interface is 'textual'
#
+=head1 NAME
+
+Apache::lonmenu
+
+=head1 SYNOPSIS
+
+Coordinates the response to clicking an image.
+
+This is part of the LearningOnline Network with CAPA project
+described at http://www.lon-capa.org.
+
+=head1 SUBROUTINES
+
+=over
+
+=item show_course()
+
+Little texts
+
+=item initlittle()
+
+=item menubuttons()
+
+This gets called at the top of the body section
+
+=item show_return_link()
+
+=item registerurl()
+
+This gets called in the header section
+
+=item innerregister()
+
+This gets called in order to register a URL, both with the Remote
+and 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()
+
+Switch a button or create a link
+Switch acts on the javascript that is executed when a button is clicked.
+The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
+
+=item secondlevel()
+
+=item openmenu()
+
+=item inlinemenu()
+
+=item rawconfig()
+
+=item close()
+
+=item footer()
+
+=item utilityfunctions()
+
+=item serverform()
+
+=item constspaceform()
+
+=item get_nav_status()
+
+=item convert_menu_function()
+
+FIXME this needs to move into mydesktab and the other locations
+the text is generated
+
+=item hidden_button_check()
+
+=item roles_selector()
+
+=item jump_to_role()
+
+=back
+
+=cut
+
package Apache::lonmenu;
use strict;
@@ -53,7 +152,6 @@ my @inlineremote;
-# ================================================================ Little texts
sub show_course {
my $course = !$env{'user.adv'};
if (!$env{'user.adv'}) {
@@ -84,8 +182,6 @@ sub initlittle {
);
}
-# ============================= This gets called at the top of the body section
-
sub menubuttons {
my $forcereg=shift;
my $registration=shift;
@@ -111,7 +207,7 @@ sub menubuttons {
my $logo=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/minilogo.gif");
$logo = '
';
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.=' ';
+ #$output.=' ';
+ $output.='';
+ $output.=' '.&mt($category_names{$cat}).'';
+ $output.=' ';
my %active=();
foreach my $menu_item (split(/\:/,$category_members{$cat})) {
if ($inlineremote[$menu_item]) {
@@ -1015,6 +1107,7 @@ sub inlinemenu {
$output.=$inlineremote[$item];
}
$output.=' ';
+ $output.=' ';
}
}
$output.="";
@@ -1444,7 +1537,7 @@ sub hidden_button_check {
sub roles_selector {
my ($cdom,$cnum) = @_;
my $now = time;
- my (%courseroles,%seccount);
+ my (%courseroles,%seccount,%gotnosection);
my $is_cc;
my $role_selector;
if ($env{'user.role.cc./'.$cdom.'/'.$cnum}) {
@@ -1459,7 +1552,6 @@ sub roles_selector {
}
}
if ($is_cc) {
- &get_all_courseroles($cdom,$cnum,\%courseroles,\%seccount);
my %adv_roles =
&Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
foreach my $role (keys(%adv_roles)) {
@@ -1489,7 +1581,6 @@ sub roles_selector {
push(@{$courseroles{'st'}},keys(%sections_count));
}
} else {
- my %gotnosection;
foreach my $item (keys(%env)) {
if ($item =~ m-^user\.role\.([^.]+)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) {
my $role = $1;
@@ -1547,61 +1638,6 @@ sub roles_selector {
return $role_selector;
}
-sub get_all_courseroles {
- my ($cdom,$cnum,$courseroles,$seccount) = @_;
- unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH')) {
- return;
- }
- my ($result,$cached) =
- &Apache::lonnet::is_cached_new('getcourseroles',$cdom.'_'.$cnum);
- if (defined($cached)) {
- if (ref($result) eq 'HASH') {
- if ((ref($result->{'roles'}) eq 'HASH') &&
- (ref($result->{'seccount'}) eq 'HASH')) {
- %{$courseroles} = %{$result->{'roles'}};
- %{$seccount} = %{$result->{'seccount'}};
- return;
- }
- }
- }
- my %gotnosection;
- my %adv_roles =
- &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
- foreach my $role (keys(%adv_roles)) {
- my ($urole,$usec) = split(/:/,$role);
- if (!$gotnosection{$urole}) {
- $seccount->{$urole} ++;
- $gotnosection{$urole} = 1;
- }
- if (ref($courseroles->{$urole}) eq 'ARRAY') {
- if ($usec ne '') {
- if (!grep(/^\Q$usec\E$/,@{$courseroles->{$urole}})) {
- push(@{$courseroles->{$urole}},$usec);
- $seccount->{$urole} ++;
- }
- }
- } else {
- @{$courseroles->{$urole}} = ();
- if ($usec ne '') {
- $seccount->{$urole} ++;
- push(@{$courseroles->{$urole}},$usec);
- }
- }
- }
- my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum,['st']);
- @{$courseroles->{'st'}} = ();
- if (keys(%sections_count) > 0) {
- push(@{$courseroles->{'st'}},keys(%sections_count));
- $seccount->{'st'} = scalar(keys(%sections_count));
- }
- my $rolehash = {
- 'roles' => $courseroles,
- 'seccount' => $seccount,
- };
- &Apache::lonnet::do_cache_new('getcourseroles',$cdom.'_'.$cnum,$rolehash);
- return;
-}
-
sub jump_to_role {
my ($cdom,$cnum,$seccount,$courseroles) = @_;
my %lt = &Apache::lonlocal::texthash(
|