--- loncom/interface/lonhtmlcommon.pm 2004/11/19 19:31:13 1.96 +++ loncom/interface/lonhtmlcommon.pm 2004/11/23 16:04:33 1.99 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common html routines # -# $Id: lonhtmlcommon.pm,v 1.96 2004/11/19 19:31:13 albertel Exp $ +# $Id: lonhtmlcommon.pm,v 1.99 2004/11/23 16:04:33 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -141,6 +141,30 @@ sub select_recent { return $return; } +sub get_recent { + my ($area, $n) = @_; + my %recent=&Apache::lonnet::dump(&recent_filename($area)); + +# Create hash with key as time and recent as value + my %time_hash = (); + foreach (keys %recent) { + my $thistime=(split(/\&/,$recent{$_}))[0]; + $time_hash{$thistime} = $_; + } + +# Sort by decreasing time and return key value pairs + my %return_hash = (); + my $idx = 1; + foreach (reverse sort keys %time_hash) { + $return_hash{$time_hash{$_}} = + &Apache::lonnet::unescape((split(/\&/,$recent{$_}))[1]); + if ($n && ($idx++ >= $n)) {last;} + } + + return %return_hash; +} + + =pod @@ -880,18 +904,20 @@ sub crumbs { $output.=''.$prefix.'/'; if ($ENV{'user.adv'}) { my $path=$prefix.'/'; - foreach (split('/',$uri)) { - unless ($_) { next; } - $path.=$_; + foreach my $dir (split('/',$uri)) { + if (! $dir) { next; } + $path .= $dir; unless ($path eq $uri) { $path.='/'; } - my $linkpath=$path; - if ($form) { - my $escaped_path = &Apache::loncommon::escape_single($path); - $linkpath="javascript:$form.action='$escaped_path';$form.submit();"; - } - my $escaped_linkpath = &Apache::loncommon::escape_single($linkpath); - my $escaped_target = &Apache::loncommon::escape_single($target); - $output.=''.$_.'/'; + my $linkpath = &Apache::loncommon::escape_single($path); + if ($form) { + $linkpath= + qq{javascript:$form.action='$linkpath';$form.submit();}; + } + if ($target) { + $target = ' target="'. + &Apache::loncommon::escape_single($target).'"'; + } + $output.=qq{$dir/}; } } else { $output.=$uri;