--- loncom/interface/lonmenu.pm 2011/05/27 19:33:45 1.315.2.11 +++ loncom/interface/lonmenu.pm 2010/09/09 19:33:18 1.339 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.315.2.11 2011/05/27 19:33:45 raeburn Exp $ +# $Id: lonmenu.pm,v 1.339 2010/09/09 19:33:18 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -28,8 +28,6 @@ # # There is one parameter controlling the action of this module: # -# environment.remote - if this is 'on', the routines controll the remote -# control, otherwise they render the main window controls; =head1 NAME @@ -111,34 +109,9 @@ Same as primary_menu() but operates on @ =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 +This gets called in order to register a URL in the body of the document =item clear() @@ -156,10 +129,6 @@ The javascript is usually similar to "go =item rawconfig() -=item close() - -=item footer() - =item utilityfunctions() =item serverform() @@ -205,9 +174,9 @@ sub prep_menuitem { } else { # textual Link $link = &mt($$menuitem[3]); } - return '
  • $link
  • |; } @@ -235,32 +204,23 @@ sub primary_menu { next if $$menuitem[4] !~ /public/ ##we've a public user, && $public; ##who should not see all ##links - next if $$menuitem[4] eq 'onlypublic'# hide links which are + next if $$menuitem[4] eq 'onlypublic'# hide links which are && !$public; # only visible to public # users next if $$menuitem[4] eq 'roles' ##show links depending on - && &Apache::loncommon::show_course(); ##term 'Courses' or + && &Apache::loncommon::show_course(); ##term 'Courses' or next if $$menuitem[4] eq 'courses' ##'Roles' wanted && !&Apache::loncommon::show_course(); ## - - + + if ($$menuitem[3] eq 'Help') { # special treatment for helplink - if ($public) { - my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'}; - my $defdom = &Apache::lonnet::default_login_domain(); - my $to = &Apache::loncommon::build_recipient_list(undef, - 'helpdeskmail', - $defdom,$origmail); - if ($to ne '') { - $menu .= &prep_menuitem($menuitem); - } - } else { - $menu .= '
  • '.&Apache::loncommon::top_nav_help('Help').'
  • '; - } + $menu .= '
  • '.&Apache::loncommon::top_nav_help('Help').'
  • '; } else { - $menu .= &prep_menuitem($menuitem); + $menu .= prep_menuitem($menuitem); } } + $menu =~ s/\[domain\]/$env{'user.domain'}/g; + $menu =~ s/\[user\]/$env{'user.name'}/g; return "
      $menu
    "; } @@ -290,16 +250,18 @@ sub getauthor{ return; } - sub secondary_menu { my $menu; my $crstype = &Apache::loncommon::course_type(); - my $crs_sec = $env{'request.course.id'} . ($env{'request.course.sec'} + my $crs_sec = $env{'request.course.id'} . ($env{'request.course.sec'} ? "/$env{'request.course.sec'}" : ''); my $canedit = &Apache::lonnet::allowed('mdc', $env{'request.course.id'}); - my $canviewgrps = &Apache::lonnet::allowed('vcg', $crs_sec); + my $canviewgrps = &Apache::lonnet::allowed('vcg', $crs_sec); + my $canmodifyuser = &Apache::lonnet::allowed('cst', $crs_sec); + my $canviewwnew = &Apache::lonnet::allowed('whn', $crs_sec); + my $canmodpara = &Apache::lonnet::allowed('opa', $crs_sec); my $author = getauthor(); my $showlink = &show_return_link(); @@ -307,6 +269,7 @@ sub secondary_menu { $env{'user.domain'}, $env{'user.name'}, $env{'course.' . $env{'request.course.id'} . '.domain'}, $env{'course.' . $env{'request.course.id'} . '.num'}); + foreach my $menuitem (@secondary_menu) { # evaluate conditions next if ref($menuitem) ne 'ARRAY'; @@ -322,14 +285,12 @@ sub secondary_menu { && $crstype eq 'Community'; next if $$menuitem[4] eq 'mdcCommunity' && $crstype ne 'Community'; - next if $$menuitem[4] =~ /^remotenav/ - && $env{'environment.remotenavmap'} ne 'on'; - next if $$menuitem[4] =~ /noremotenav/ - && $env{'environment.remotenavmap'} eq 'on'; - next if $$menuitem[4] =~ /^(no|)remotenav$/ - && $crstype eq 'Community'; - next if $$menuitem[4] =~ /^(no|)remotenavCommunity$/ - && $crstype ne 'Community'; + next if $$menuitem[4] eq 'cst' + && !$canmodifyuser; + next if $$menuitem[4] eq 'whn' + && !$canviewwnew; + next if $$menuitem[4] eq 'opa' + && !$canmodpara; next if $$menuitem[4] =~ /showgroups$/ && !$canviewgrps && !%groups; @@ -344,15 +305,6 @@ sub secondary_menu { $menu .= $roles_selector ? "
  • $roles_selector
  • " : ''; - } elsif ($env{'environment.remotenavmap'} eq 'on') { - # open link using javascript when remote navmap is activated - my @items = @{$menuitem}; - if ($menuitem->[4] eq 'remotenav') { - $items[0] = "javascript:gonav('$menuitem->[0]');"; - } else { - $items[0] = "javascript:go('$menuitem->[0]');"; - } - $menu .= &prep_menuitem(\@items); } else { $menu .= &prep_menuitem(\@$menuitem); } @@ -396,43 +348,12 @@ sub show_return_link { (($env{'request.noversionuri'}=~/^\/adm\//) && ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) && ($env{'request.noversionuri'}!~ - m[^/adm/.*/(smppg|bulletinboard)($|\?)]) - )); -} - - -sub registerurl { - my ($forcereg) = @_; - my $result = ''; - if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; } - my $force_title=''; - if ($env{'request.state'} eq 'construct') { - $force_title=&Apache::lonxml::display_title(); - } - if (($env{'environment.remote'} eq 'off') || - ((($env{'request.publicaccess'}) || - (!&Apache::lonnet::is_on_map( - &unescape($env{'request.noversionuri'})))) && - (!$forcereg))) { - return - $result - .'' - .$force_title; - } -# Graphical display after login only - if ($env{'request.registered'} && !$forcereg) { return ''; } - $result.=&innerregister($forcereg); - return $result.$force_title; + m{^/adm/.*/(smppg|bulletinboard)($|\?)}) + )); } sub innerregister { - my ($forcereg,$titletable,$bread_crumbs) = @_; - my $result = ''; - my ($uname,$thisdisfn); + my ($forcereg,$bread_crumbs) = @_; my $const_space = ($env{'request.state'} eq 'construct'); my $is_const_dir = 0; @@ -440,44 +361,25 @@ sub innerregister { $env{'request.registered'} = 1; - my $noremote = ($env{'environment.remote'} eq 'off'); - undef(@inlineremote); - my $reopen=&Apache::lonmenu::reopenmenu(); - - my $newmail=''; + if ( $env{'request.symb'} && $env{'request.course.id'} ) { - if (&Apache::lonmsg::newmail() && !$noremote) { - # We have new mail and remote is up - $newmail= 'swmenu.setstatus("you have","messages");'; - } - - my ($breadcrumb,$separator,$resurl); - if ($noremote - && ($env{'request.symb'}) - && ($env{'request.course.id'})) { - - (my $mapurl, my $rid,$resurl) = &Apache::lonnet::decode_symb(&Apache::lonnet::symbread()); + my ($mapurl,$rid,$resurl) = &Apache::lonnet::decode_symb(&Apache::lonnet::symbread()); my $coursetitle = $env{'course.'.$env{'request.course.id'}.'.description'}; my $maptitle = &Apache::lonnet::gettitle($mapurl); my $restitle = &Apache::lonnet::gettitle(&Apache::lonnet::symbread()); - my $contentstext; - if ($env{'course.'.$env{'request.course.id'}.'.type'} eq 'Community') { - $contentstext = &mt('Community Contents'); - } else { - $contentstext = &mt('Course Contents'); - } + +#SD +#course_type only Course and Community? +# my @crumbs; unless (($forcereg) && ($env{'request.noversionuri'} eq '/adm/navmaps') && ($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'})) { - my $navhref = "javascript:gopost('/adm/navmaps','')"; - if ($env{'environment.remotenavmap'} eq 'on') { - $navhref = "javascript:gonav('/adm/navmaps');"; - } - @crumbs = ({text => $contentstext, - href => $navhref}); + @crumbs = ({text => Apache::loncommon::course_type() + . ' Contents', + href => "Javascript:gopost('/adm/navmaps','')"}); } if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) { push(@crumbs, {text => '...', @@ -492,29 +394,17 @@ sub innerregister { &Apache::lonhtmlcommon::clear_breadcrumbs(); &Apache::lonhtmlcommon::add_breadcrumb(@crumbs); - - #$breadcrumb .= &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0); - unless (($env{'request.state'} eq 'edit') || ($newmail) || - ($env{'request.state'} eq 'construct') || - ($env{'form.register'})) { - $separator = &Apache::loncommon::head_subbox(); - } - # - } elsif (!$const_space){ - #a situation when we're looking at a resource outside of context of a + }elsif (! $const_space){ + #a situation when we're looking at a resource outside of context of a #course or construction space (e.g. with cumulative rights) &Apache::lonhtmlcommon::clear_breadcrumbs(); &Apache::lonhtmlcommon::add_breadcrumb({text => 'View Resource'}); } - if ($env{'request.state'} eq 'construct') { - $newmail = $titletable; - } - my $timesync = ( $noremote ? '' : 'swmenu.syncclock(1000*'.time.');' ); - my $tablestart = ( $noremote ? '' : ''); - my $tableend = ( $noremote ? '
    ' : ''); # ============================================================================= # ============================ This is for URLs that actually can be registered - if (($env{'request.noversionuri'}!~m{^/(res/)*adm/}) || ($forcereg)) { + return '' unless ( ($env{'request.noversionuri'}!~m{^/(res/)*adm/}) + || $forcereg ); + # -- This applies to homework problems for users with grading privileges my $crs='/'.$env{'request.course.id'}; if ($env{'request.course.sec'}) { @@ -526,18 +416,18 @@ sub innerregister { if ($env{'request.symb'} ne '' && $env{'request.filename'}=~/\.(problem|exam|quiz|assess|survey|form|task)$/) { if (&Apache::lonnet::allowed('mgr',$crs)) { - $hwkadd.=&switch('','',7,2,'pgrd.gif','problem[_1]','grades[_4]', + $hwkadd.=&switch('','',7,2,'pgrd.png','problem[_1]','grades[_4]', "gocmd('/adm/grades','gradingmenu')", 'Modify user grades for this assessment resource'); } elsif (&Apache::lonnet::allowed('vgr',$crs)) { - $hwkadd.=&switch('','',7,2,'subm.gif','view sub-[_1]','missions[_1]', + $hwkadd.=&switch('','',7,2,'subm.png','view sub-[_1]','missions[_1]', "gocmd('/adm/grades','submission')", 'View user submissions for this assessment resource'); } } if ($env{'request.symb'} ne '' && &Apache::lonnet::allowed('opa',$crs)) { - $hwkadd.=&switch('','',7,3,'pparm.gif','problem[_2]','parms[_2]', + $hwkadd.=&switch('','',7,3,'pparm.png','problem[_2]','parms[_2]', "gocmd('/adm/parmset','set')", 'Modify parameter settings for this resource'); } @@ -638,7 +528,6 @@ sub innerregister { my $bot = "go('$cfile')"; if ($switchserver) { if ( $env{'request.symb'} && $env{'request.course.id'} ) { - my ($mapurl,$rid,$resurl) = &Apache::lonnet::decode_symb(&Apache::lonnet::symbread()); $cfile = '/adm/switchserver?otherserver='.$home.'&role='. &HTML::Entities::encode($env{'request.role'},'"<>&').'&symb='. &HTML::Entities::encode($env{'request.symb'},'"<>&'); @@ -646,8 +535,8 @@ sub innerregister { } } $editbutton=&switch - ('','',6,1,'pcstr.gif','edit[_1]','resource[_2]', - $bot,"Edit this resource"); + ('','',6,1,'pcstr.png','edit[_1]','resource[_2]', + $bot,"Edit this resource"); $noeditbutton = 0; } } elsif ($editbutton eq '') { @@ -662,7 +551,7 @@ sub innerregister { my $cfile = &edit_course_upload($file,$cnum,$cdom); if ($cfile) { $editbutton=&switch - ('','',6,1,'pcstr.gif','edit[_1]', + ('','',6,1,'pcstr.png','edit[_1]', 'resource[_2]',"go('".$cfile."');", 'Edit this resource'); } @@ -670,18 +559,6 @@ sub innerregister { } } } - if ($env{'request.course.id'}) { - if ($resurl eq "public/$cdom/$cnum/syllabus") { - if ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ /\w/) { - if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { - $editbutton=&switch('','',6,1,'pcstr.png','Edit', - 'resource[_2]', - "go('/adm/courseprefs?phase=display&actions=courseinfo')", - 'Edit this resource'); - } - } - } - } ### ### # Prepare the rest of the buttons @@ -703,89 +580,76 @@ sub innerregister { # Probably should be in mydesk.tab # $menuitems=(< 'Notes', - bookmark => 'Bookmark', - catalog => 'Info', - evaluate => 'Evaluate', - feedback => 'Communicate', - printout => 'Print', - ); - } $menuitems=(< 0){ - $menuitems.="anot2.gif"; + $menuitems.="anot2.png"; }else{ - $menuitems.="anot.gif"; + $menuitems.="anot.png"; } $menuitems.="&anno-[_1]&tations[_1]&annotate()&"; -$menuitems.="Make notes and annotations about this resource&&1&$icon_text{'annotate'}\n"; +$menuitems.="Make notes and annotations about this resource&&1\n"; - unless ($noremote) { - my $showreqcrs = &check_for_rcrs(); - if ($showreqcrs) { - $menuitems.="s&8&1&rcrs.gif&request[_1]&course[_16]". - "&go('/adm/requestcourse')&Course requests\n"; - } - } unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme|viewclasslist|portfolio)(\?|$)/) { if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/})) { - my $tail; - unless ($env{'request.state'} eq 'construct') { - $tail = '&&&'.$icon_text{'catalog'}; - } $menuitems.=(< -#$inlineremote[21] $inlineremote[23] -#ENDARROWSINLINE -# if ( &hidden_button_check() ne 'yes' ) { -# $inlinebuttons .= (< -#ENDINLINEICONS -# } -# } else { # not iconsonly -# if ( $inlineremote[21] ne '' || $inlineremote[23] ne '' ) { -# $inlinebuttons = (<$inlineremote[21] $inlineremote[23] -#ENDFIRSTLINE -# } -# if ( &hidden_button_check() ne 'yes' ) { -# foreach my $row ( 6 .. 9 ) { -# if ( $inlineremote[ ${row} . '1' ] ne '' -# || $inlineremote[ $row . '2' ] ne '' -# || $inlineremote[ $row . '3' ] ne '' ) -# { -# $inlinebuttons .= <<"ENDLINE"; -#$inlineremote["${row}1"]$inlineremote["${row}2"]$inlineremote["${row}3"] -#ENDLINE -# } -# } -# } -# } - } - $breadcrumb = &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0); - $result =(< -// BEGIN LON-CAPA Internal - -$timesync -$breadcrumb - - - -$newmail - - - -ENDREGTEXT -# Registered, graphical output - } else { - my $requri=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0])); - $requri=&Apache::lonenc::check_encrypt(&unescape($requri)); - my $cursymb=&Apache::lonenc::check_encrypt($env{'request.symb'}); - my $navstatus=&get_nav_status(); - my $clearcstr; - - if ($env{'user.adv'}) { $clearcstr='clearbut(6,1)'; } - $result = (< -// - -ENDREGTHIS - } -# ============================================================================= - } else { -# ========================================== This can or will not be registered - if ($noremote) { -# Not registered - $result= (< -// - -ENDDONOTREGTHIS - } -# ============================================================================= } - return $result; + + return Apache::lonhtmlcommon::scripttag('', 'start') + . Apache::lonhtmlcommon::breadcrumbs(undef,undef,0) + . Apache::lonhtmlcommon::scripttag('', 'end'); } sub is_course_upload { @@ -1021,188 +740,12 @@ sub edit_course_upload { return $cfile; } -sub loadevents() { - if ($env{'request.state'} eq 'construct' || - $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; } - return 'LONCAPAreg();'; -} - -sub unloadevents() { - if ($env{'request.state'} eq 'construct' || - $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; } - return 'LONCAPAstale();'; -} - - -sub startupremote { - my ($lowerurl)=@_; - if ($env{'environment.remote'} eq 'off') { - return (''); - } -# -# 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 { my ($row,$col)=@_; - unless ($env{'environment.remote'} eq 'off') { - if (($row<1) || ($row>13)) { return ''; } - return "\n".qq(window.status+='.';swmenu.clearbut($row,$col);); - } else { - $inlineremote[10*$row+$col]=''; - return ''; - } + $inlineremote[10*$row+$col]=''; + return ''; } # ============================================ Switch a button or create a link @@ -1210,39 +753,25 @@ sub clear { # The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)". sub switch { - my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat,$nobreak,$inlinetools)=@_; + my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat,$nobreak)=@_; $act=~s/\$uname/$uname/g; $act=~s/\$udom/$udom/g; $top=&mt($top); $bot=&mt($bot); $desc=&mt($desc); - if (($env{'environment.remote'} ne 'off') || ($env{'environment.icons'} eq 'classic')) { - $img=&mt($img); - } my $idx=10*$row+$col; - if ($cat ne '') { - $category_members{$cat}.=':'.$idx; - } + $category_members{$cat}.=':'.$idx; - unless ($env{'environment.remote'} eq 'off') { - if (($row<1) || ($row>13)) { return ''; } -# Remote - return "\n". - qq(window.status+='.';swmenu.switchbutton($row,$col,"$img","$top","$bot","$act","$desc");); - } else { -# Inline Remote - if ($env{'environment.icons'} ne 'classic') { - $img=~s/\.gif$/\.png/; - } - if ($nobreak==2) { return ''; } - my $text=$top.' '.$bot; - $text=~s/\s*\-\s*//gs; +# Inline Menu + if ($nobreak==2) { return ''; } + my $text=$top.' '.$bot; + $text=~s/\s*\-\s*//gs; - my $pic= + my $pic= ''.$text.''; - if ($env{'browser.interface'} eq 'faketextual') { + if ($env{'browser.interface'} eq 'faketextual') { # Main Menu if ($nobreak==3) { $inlineremote[$idx]="\n". @@ -1261,21 +790,12 @@ sub switch { ''. ''.$desc.''; } - } else { + } else { # Inline Menu - if ($env{'environment.icons'} eq 'iconsonly') { - $inlineremote[$idx]=''.$pic.''; - } else { - my $icon_text = $desc; - if ($inlinetools) { - $icon_text = $inlinetools.' '; - } - $inlineremote[$idx]= - ''.$pic. - ''.$icon_text.' '; - } - } - } + $inlineremote[$idx]= + ''.$pic. + ''.$desc.''; + } return ''; } @@ -1293,13 +813,6 @@ sub secondlevel { return $output; } -sub openmenu { - my $menuname = &get_menu_name(); - if ($env{'environment.remote'} eq 'off') { return ''; } - my $nothing = &Apache::lonhtmlcommon::javascript_nothing(); - return "window.open(".$nothing.",'".$menuname."');"; -} - sub inlinemenu { undef(@inlineremote); undef(%category_members); @@ -1342,13 +855,7 @@ sub rawconfig { # my $textualoverride=shift; my $output=''; - unless ($env{'environment.remote'} eq 'off') { - $output.= - "window.status='Opening Remote Control';var swmenu=".&openmenu(). -"\nwindow.status='Configuring Remote Control ';"; - } else { - unless ($textualoverride) { return ''; } - } + return '' unless $textualoverride; my $uname=$env{'user.name'}; my $udom=$env{'user.domain'}; my $adv=$env{'user.adv'}; @@ -1372,13 +879,6 @@ sub rawconfig { my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc,$cat)=split(/\:/,$line); $prt=~s/\$uname/$uname/g; $prt=~s/\$udom/$udom/g; - if ($env{'environment.remotenavmap'} eq 'on') { - unless ($env{'environment.remote'} eq 'on') { - if ($img eq 'nav.gif') { - $act = "gonav('/adm/navmaps','')"; - } - } - } if ($prt =~ /\$crs/) { next unless ($env{'request.course.id'}); next if ($crstype eq 'Community'); @@ -1529,13 +1029,6 @@ sub rawconfig { $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat); } } - unless ($env{'environment.remote'} eq 'off') { - $output.="\nwindow.status='Synchronizing Time';swmenu.syncclock(1000*".time.");\nwindow.status='Remote Control Configured.';"; - if (&Apache::lonmsg::newmail()) { - $output.='swmenu.setstatus("you have","messages");'; - } - } - return $output; } @@ -1561,51 +1054,6 @@ sub check_for_rcrs { return $showreqcrs; } -# ======================================================================= Close - -sub close { - if ($env{'environment.remote'} eq 'off') { return ''; } - my $menuname = &get_menu_name(); - return(< -// - -ENDCLOSE -} - -# ====================================================================== Footer - -sub footer { - -} - -sub nav_control_js { - my $nav=($env{'environment.remotenavmap'} eq 'on'); - return (< '(More ...)', @@ -1632,21 +1080,14 @@ END } sub utilityfunctions { - my $caller = shift; - unless ($env{'environment.remote'} eq 'off' || - $caller eq '/adm/menu') { - return ''; } - my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0])); - if ($currenturl =~ m{^/adm/wrapper/ext/}) { - if ($env{'request.external.querystring'}) { + if ($currenturl =~ m{^/adm/wrapper/ext/} + && $env{'request.external.querystring'} ) { $currenturl .= ($currenturl=~/\?/)?'&':'?'.$env{'request.external.querystring'}; - } } $currenturl=&Apache::lonenc::check_encrypt(&unescape($currenturl)); my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'}); - my $nav_control=&nav_control_js(); my $dc_popup_cid; if ($env{'user.adv'} && exists($env{'user.role.dc./'. @@ -1666,17 +1107,55 @@ sub utilityfunctions { my $end_page_annotate = &Apache::loncommon::end_page({'js_ready' => 1}); - my $start_page_bookmark = - &Apache::loncommon::start_page('Bookmarks',undef, + my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'. + &mt('Switch server?'); + + my $start_page_wishlistlink = + &Apache::loncommon::start_page('Set link to wishlist',undef, {'only_body' => 1, 'js_ready' => 1, - 'bgcolor' => '#BBBBBB',}); + 'bgcolor' => '#FFFFFF',}); - my $end_page_bookmark = - &Apache::loncommon::end_page({'js_ready' => 1}); + my $warningLink = &mt('You must insert a title!'); - my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'. - &mt('Switch server?'); + # HTML-Markup for 'Set a link for this resource to wishlist' + # this is written via JavaScript document.write (function set_wishlistlink) + # it is split into 3 parts and the inputfields for title and path are left out + # these fields are inserted later to set the values for title and path + # automatically via JavaScript (document.title and location.pathname) + my %folders = &Apache::lonnet::get('wishlist',['folders']); + if ($folders{'folders'} eq '') { + $folders{'folders'} = ''; + } + my $in_page_wishlistlink1 = '

    '.&mt('Set a link to wishlist').'

    '. + '
    '. + &Apache::lonhtmlcommon::start_pick_box(). + &Apache::lonhtmlcommon::row_title(&mt('Link Title')); + + my $in_page_wishlistlink2 = &Apache::lonhtmlcommon::row_closure(). + &Apache::lonhtmlcommon::row_title(&mt('Path')); + + my $in_page_wishlistlink3 = &Apache::lonhtmlcommon::row_closure(). + &Apache::lonhtmlcommon::row_title(&mt('Note')). + ''. + &Apache::lonhtmlcommon::row_closure(1). + &Apache::lonhtmlcommon::end_pick_box(). + '

    '. + ''. + ''. + ''. + '
    '; + + # remove all \n for inserting on javascript document.write + $in_page_wishlistlink1 =~ s/\n//g; + $in_page_wishlistlink2 =~ s/\n//g; + $in_page_wishlistlink3 =~ s/\n//g; + + my $end_page_wishlistlink = + &Apache::loncommon::end_page({'js_ready' => 1}); return (<
    ' - +'
    Link Name:
    ' - +'
    Address:

    ' - +'$end_page_bookmark' ); - bmquery.document.close(); +function set_wishlistlink(title, path) { + if (!title) { + title=document.title; + } + if (!path) { + path=location.pathname; + } + title = title.replace(/^LON-CAPA /,''); + wishlistlink=window.open('','wishlistNewLink','width=560,height=350,scrollbars=0'); + wishlistlink.document.write( + '$start_page_wishlistlink' + +'