--- loncom/interface/lonhtmlcommon.pm 2012/11/16 23:37:16 1.331 +++ loncom/interface/lonhtmlcommon.pm 2013/01/03 20:02:12 1.340 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common html routines # -# $Id: lonhtmlcommon.pm,v 1.331 2012/11/16 23:37:16 raeburn Exp $ +# $Id: lonhtmlcommon.pm,v 1.340 2013/01/03 20:02:12 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -209,10 +209,19 @@ dependencies for a web page uploaded dir =cut sub dependencycheck_js { - my ($symb,$title,$url) = @_; - my $link = '/adm/dependencies?symb='.&HTML::Entities::encode($symb,'<>&"'). - '&title='.&HTML::Entities::encode($title,'<>&"'). - '&url='.&HTML::Entities::encode($url,'<>&"'); + my ($symb,$title,$url,$folderpath,$uri) = @_; + my $link; + if ($symb) { + $link = '/adm/dependencies?symb='.&HTML::Entities::encode($symb,'<>&"'); + } elsif ($folderpath) { + $link = '/adm/dependencies?folderpath='.&HTML::Entities::encode($folderpath,'<>&"'); + $url = $uri; + } + $link .= (($link=~/\?/)?'&':'?').'title='. + &HTML::Entities::encode($title,'<>&"'); + if ($url) { + $link .= '&url='.&HTML::Entities::encode($url,'<>&"'); + } return < // "); + my $dueDateLayout = &mt('Due in: {dn} {dl} {hnn}{sep}{mnn}{sep}{snn} [_1]', + ""); my $early = '- '.&mt('Submit Early').''; my $pastdue = '- '.&mt('Past Due').''; $output .= < "LC_breadcrumbs" }) unless ($CourseBreadcrumbs) ; - &render_advtools(\$links); + my $nav_and_tools = 0; + foreach my $item ('navigation','tools') { + if (ref($tools{$item}) eq 'ARRAY') { + $nav_and_tools += scalar(@{$tools{$item}}) + } + } + if (($links ne '') || ($nav_and_tools)) { + &render_tools(\$links); + $links = &htmltag('div', $links, + { id => "LC_breadcrumbs" }) unless ($CourseBreadcrumbs) ; + } + my $adv_tools = 0; + if (ref($tools{'advtools'}) eq 'ARRAY') { + $adv_tools = scalar(@{$tools{'advtools'}}); + } + if (($links ne '') || ($adv_tools)) { + &render_advtools(\$links); + } # Return the @Crumbs stack to what we started with push(@Crumbs,$last); @@ -1883,16 +1907,13 @@ returns: nothing } # End of scope for @Crumbs sub docs_breadcrumbs { - my ($allowed,$crstype,$contenteditor)=@_; + my ($allowed,$crstype,$contenteditor,$title,$precleared)=@_; my ($folderpath,@folders); - if ($env{'form.pagepath'}) { - @folders = split('&',$env{'form.pagepath'}); - } else { - @folders=split('&',$env{'form.folderpath'}); - } + @folders = split('&',$env{'form.folderpath'}); my $plain=''; + my $container = 'sequence'; my ($randompick,$isencrypted,$ishidden,$is_random_order) = (-1,0,0,0); - &clear_breadcrumbs(); + my @docs_crumbs; while (@folders) { my $folder=shift(@folders); my $foldername=shift(@folders); @@ -1906,9 +1927,9 @@ sub docs_breadcrumbs { } $url .= &escape($folderpath); my $name=&unescape($foldername); -# each of randompick number, hidden, encrypted, random order are -# appended with ":"s to the foldername - $name=~s/\:(\d*)\:(\w*)\:(\w*):(\d*)$//; +# each of randompick number, hidden, encrypted, random order, is_page +# are appended with ":"s to the foldername + $name=~s/\:(\d*)\:(\w*)\:(\w*):(\d*)\:?(\d*)$//; if ($contenteditor) { if ($1 ne '') { $randompick=$1; @@ -1918,30 +1939,47 @@ sub docs_breadcrumbs { if ($2) { $ishidden=1; } if ($3) { $isencrypted=1; } if ($4 ne '') { $is_random_order = 1; } + if ($5 == 1) {$container = 'page'; } } if ($folder eq 'supplemental') { - $name = &mt('Supplemental '.$crstype.' Content'); + $name = &mt('Supplemental '.$crstype.' Contents'); } if ($contenteditor) { $plain.=$name.' > '; } - &add_breadcrumb( + push(@docs_crumbs, {'href' => $url, 'title' => $name, 'text' => $name, 'no_mt' => 1, }); } - unless ($contenteditor) { - if ($env{'httpref.'.$env{'request.noversionuri'}} ne '') { - &add_breadcrumb({text => 'View Resource'}); + if ($title) { + push(@docs_crumbs, + {'title' => $title, + 'text' => $title, + 'no_mt' => 1,} + ); + } + if (wantarray) { + unless ($precleared) { + &clear_breadcrumbs(); } + &add_breadcrumb(@docs_crumbs); + if ($contenteditor) { + $plain=~s/\>\;\s*$//; + } + my $menulink = 0; + if (!$allowed && !$contenteditor) { + $menulink = 1; + } + return (&breadcrumbs(undef,undef,$menulink,'nohelp',undef,undef, + $contenteditor), + $randompick,$ishidden,$isencrypted,$plain, + $is_random_order,$container); } else { - $plain=~s/\>\;\s*$//; + return \@docs_crumbs; } - return (&breadcrumbs(undef,undef,0,'nohelp',undef,undef,$contenteditor), - $randompick,$ishidden,$isencrypted,$plain, - $is_random_order); } ############################################################ @@ -3001,7 +3039,10 @@ PARAMSONE } if ((chkh == 1) || (listwchange)) { var primaryheight = document.getElementById('LC_nav_bar').offsetHeight; - var secondaryheight = document.getElementById('LC_secondary_menu').offsetHeight; + var secondaryheight; + if (document.getElementById('LC_secondary_menu') != null) { + secondaryheight = document.getElementById('LC_secondary_menu').offsetHeight; + } var crumbsheight = document.getElementById('LC_breadcrumbs').offsetHeight; var dccidheight = 0; if (document.getElementById('dccid') != null) { @@ -3091,13 +3132,18 @@ ENDUTILITY } sub jump_to_editres { - my ($cfile,$home,$switchserver,$forceedit,$forcereg,$symb) = @_; + my ($cfile,$home,$switchserver,$forceedit,$forcereg,$symb,$folderpath, + $title,$idx,$suppurl,$todocs) = @_; my $jscall; if ($switchserver) { - if ($symb && $home) { + if ($home) { $cfile = '/adm/switchserver?otherserver='.$home.'&role='. - &HTML::Entities::encode($env{'request.role'},'"<>&'). - '&symb='.&HTML::Entities::encode($symb,'"<>&'); + &HTML::Entities::encode($env{'request.role'},'"<>&'); + if ($symb) { + $cfile .= '&symb='.&HTML::Entities::encode($symb,'"<>&'); + } elsif ($folderpath) { + $cfile .= '&folderpath='.&HTML::Entities::encode($folderpath,'"<>&'); + } if ($forceedit) { $cfile .= '&forceedit=1'; } @@ -3109,7 +3155,21 @@ sub jump_to_editres { } else { unless ($cfile =~ m{^/priv/}) { if ($symb) { - $cfile .= (($cfile=~/\?/)?'&':'?')."symb=$symb"; + $cfile .= (($cfile=~/\?/)?'&':'?')."symb=$symb"; + } elsif ($folderpath) { + $cfile .= (($cfile=~/\?/)?'&':'?'). + 'folderpath='.&HTML::Entities::encode(&escape($folderpath),'"<>&'); + if ($title) { + $cfile .= (($cfile=~/\?/)?'&':'?'). + 'title='.&HTML::Entities::encode(&escape($title),'"<>&'); + } + if ($idx) { + $cfile .= (($cfile=~/\?/)?'&':'?').'idx='.$idx; + } + if ($suppurl) { + $cfile .= (($cfile=~/\?/)?'&':'?'). + 'suppurl='.&HTML::Entities::encode(&escape($suppurl)); + } } if ($forceedit) { $cfile .= (($cfile=~/\?/)?'&':'?').'forceedit=1'; @@ -3117,6 +3177,9 @@ sub jump_to_editres { if ($forcereg) { $cfile .= (($cfile=~/\?/)?'&':'?').'register=1'; } + if ($todocs) { + $cfile .= (($cfile=~/\?/)?'&':'?').'todocs=1'; + } } $jscall = "go('$cfile')"; } @@ -3489,6 +3552,40 @@ sub funclist_from_array { { listattr => {class => 'LC_funclist'} }); } +=pod + +=item &actionbox( \@array ) + +Constructs a XHTML list from \@array with the first item being visually +highlighted and set to the value 'Actions'. The list is wrapped in a division. + +The actionlist is used to offer contextual actions, mostly at the bottom +of a page, on which the outcome of an processed action is shown, +e.g. a file operation in Construction Space. + +=over + +=item \@array + +A reference to the array containing text. Details: sub funclist_from_array + +=back + +Returns: XHTML div as string. + +=back + +=cut + +sub actionbox { + my ($items) = @_; + return unless(ref($items) eq 'ARRAY'); + return + '
' + .&funclist_from_array($items, {legend => &mt('Actions')}) + .'
'; +} + 1; __END__