--- loncom/interface/lonmenu.pm 2012/05/21 16:25:37 1.369.2.4 +++ loncom/interface/lonmenu.pm 2012/05/24 23:30:16 1.376 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.369.2.4 2012/05/21 16:25:37 raeburn Exp $ +# $Id: lonmenu.pm,v 1.376 2012/05/24 23:30:16 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -115,6 +115,18 @@ entries from mydesk.tab Same as primary_menu() but operates on @secondary_menu. +=item create_submenu() + +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 +(no hover psuedo class) via LC_hoverable class for
  • tag for top- +level item, which employs jQuery to handle behavior on mouseover. + +Inputs: 4 - (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. + =item innerregister() This gets called in order to register a URL in the body of the document @@ -137,6 +149,9 @@ The javascript is usually similar to "go =item utilityfunctions() +Output from this routine is a number of javascript functions called by +items in the inline menu, and in some cases items in the Main Menu page. + =item serverform() =item constspaceform() @@ -164,6 +179,7 @@ use Apache::lonlocal; use Apache::lonmsg(); use LONCAPA qw(:DEFAULT :match); use HTML::Entities(); +use Apache::lonwishlist(); use vars qw(@desklines %category_names %category_members %category_positions $readdesk @primary_menu %primary_submenu @secondary_menu); @@ -221,51 +237,32 @@ sub primary_menu { my $title = $menuitem->[3]; if (defined($primary_submenu{$title})) { - my ($link,$target,$numsub); + my ($link,$target); if ($menuitem->[0] ne '') { $link = $menuitem->[0]; $target = '_top'; } else { $link = '#'; } + my @primsub; if (ref($primary_submenu{$title}) eq 'ARRAY') { - $numsub = @{$primary_submenu{$title}}; - if ($numsub) { - $title = - ''.$title. - ''. - '▼'; - } - } - $menu .= '
  • '. - ''.$title.''; - if ($numsub) { - $menu .= ''; } - $menu .= '
  • '; } elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink if ($public) { my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'}; @@ -322,6 +319,7 @@ sub secondary_menu { ? "/$env{'request.course.sec'}" : ''); my $canedit = &Apache::lonnet::allowed('mdc', $env{'request.course.id'}); + my $canviewroster = $env{'course.'.$env{'request.course.id'}.'.student_classlist_view'}; my $canviewgrps = &Apache::lonnet::allowed('vcg', $crs_sec); my $canmodifyuser = &Apache::lonnet::allowed('cst', $crs_sec); my $canviewwnew = &Apache::lonnet::allowed('whn', $crs_sec); @@ -350,7 +348,7 @@ sub secondary_menu { next if $$menuitem[4] eq 'cst' && !$canmodifyuser; next if $$menuitem[4] eq 'ncst' - && $canmodifyuser; + && ($canmodifyuser || !$canviewroster); next if $$menuitem[4] eq 'mgr' && !$canmgr; next if $$menuitem[4] eq 'nmgr' @@ -401,6 +399,33 @@ sub secondary_menu { return ""; } +sub create_submenu { + my ($link,$target,$title,$submenu) = @_; + return unless (ref($submenu) eq 'ARRAY'); + my $menu = '
  • '. + ''. + ''.$title. + ''. + ' ▼'. + '
  • '; + return $menu; +} + sub innerregister { my ($forcereg,$bread_crumbs) = @_; my $const_space = ($env{'request.state'} eq 'construct'); @@ -681,9 +706,14 @@ c&6&3 c&8&1 c&8&2 s&8&3&prt.png&Print&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document -s&9&1&sbkm.png&Bookmark&set[_1]bookmark[_2]&set_bookmark()&Set a bookmark for this resource&&1 - ENDMENUITEMS + if (&Apache::lonnet::allowed('bre', $env{'request.course.id'}) eq 'F' && $env{'request.uri'} =~ /^\/res/) { + # wishlist is only available for users with access to resource-pool + # and links can only be set for resources within the resource-pool + $menuitems .= (<'); - } -# -# The Remote actually gets launched! -# - my $configmenu=&rawconfig(); - my $esclowerurl=&escape($lowerurl); - my $message=&mt('"Waiting for Remote Control window to load: "+[_1]','waited'); - return(< -// - -ENDREMOTESTARTUP -} - -sub setflags() { - return(< -// - -ENDSETFLAGS -} - -sub maincall() { - if ($env{'environment.remote'} eq 'off') { return ''; } - return(< -// - -ENDMAINCALL -} - -sub load_remote_msg { - my ($lowerurl)=@_; - - if ($env{'environment.remote'} eq 'off') { return ''; } - - my $esclowerurl=&escape($lowerurl); - my $link=&mt('[_1]Continue[_2] on in Inline Menu mode' - ,'' - ,''); - return(< -
    - -
    -

    -

    $link

    -ENDREMOTEFORM -} - -sub get_menu_name { - my $hostid = $Apache::lonnet::perlvar{'lonHostID'}; - $hostid =~ s/\W//g; - return 'LCmenu'.$hostid; -} - - -sub reopenmenu { - if ($env{'environment.remote'} eq 'off') { return ''; } - my $menuname = &get_menu_name(); - my $nothing = &Apache::lonhtmlcommon::javascript_nothing(); - return('window.open('.$nothing.',"'.$menuname.'","",false);'); -} - - -sub open { - my $returnval=''; - if ($env{'environment.remote'} eq 'off') { - return - ''; - } - my $menuname = &get_menu_name(); - -# unless (shift eq 'unix') { -# resizing does not work on linux because of virtual desktop sizes -# $returnval.=(< -ENDOPEN - return ''; -} - - # ================================================================== Raw Config sub clear { @@ -1276,28 +1154,6 @@ sub check_for_rcrs { return $showreqcrs; } -# ======================================================================= Close - -sub close { - if ($env{'environment.remote'} eq 'off') { return ''; } - my $menuname = &get_menu_name(); - return(< -// - -ENDCLOSE -} - sub dc_popup_js { my %lt = &Apache::lonlocal::texthash( more => '(More ...)', @@ -1351,15 +1207,6 @@ sub utilityfunctions { my $end_page_annotate = &Apache::loncommon::end_page({'js_ready' => 1}); - my $start_page_bookmark = - &Apache::loncommon::start_page('Bookmarks',undef, - {'only_body' => 1, - 'js_ready' => 1, - 'bgcolor' => '#BBBBBB',}); - - my $end_page_bookmark = - &Apache::loncommon::end_page({'js_ready' => 1}); - my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'. &mt('Switch server?'); @@ -1476,13 +1323,6 @@ function group_chat(group) { grpchat=window.open(url,winName,'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no'); } -function edit_bookmarks() { - go(''); - w_BookmarkPal_flag=1; - bookmarkpal=window.open("/adm/bookmarks", - "BookmarkPal", "width=500,height=505,scrollbars=0"); -} - function annotate() { w_Annotator_flag=1; annotator=window.open('','Annotator','width=365,height=265,scrollbars=0'); @@ -1496,6 +1336,19 @@ function annotate() { annotator.document.close(); } +function open_StoredLinks_Import(rat) { + var newWin; + if (rat) { + newWin = window.open('/adm/wishlist?inhibitmenu=yes&mode=import&rat='+rat, + 'wishlistImport','scrollbars=1,resizable=1,menubar=0'); + } + else { + newWin = window.open('/adm/wishlist?inhibitmenu=yes&mode=import', + 'wishlistImport','scrollbars=1,resizable=1,menubar=0'); + } + newWin.focus(); +} + (function (\$) { \$(document).ready(function () { \$.single=function(a){return function(b){a[0]=b;return a}}(\$([1])); @@ -1510,28 +1363,6 @@ function annotate() { }); }(jQuery)); -function set_bookmark() { - go(''); - clienttitle=document.title; - clienthref=location.pathname; - w_bmquery_flag=1; - bmquery=window.open('','bmquery','width=365,height=165,scrollbars=0'); - bmquery.document.write( - '$start_page_bookmark' - +'
    ' - +'
    Link Name:
    ' - +'
    Address:

    ' - +'$end_page_bookmark' ); - bmquery.document.close(); -} - ENDUTILITY }