--- loncom/interface/lonaboutme.pm 2006/08/04 19:42:55 1.48
+++ loncom/interface/lonaboutme.pm 2006/09/13 21:37:29 1.54
@@ -1,7 +1,7 @@
# The LearningOnline Network
# "About Me" Personal Information
#
-# $Id: lonaboutme.pm,v 1.48 2006/08/04 19:42:55 albertel Exp $
+# $Id: lonaboutme.pm,v 1.54 2006/09/13 21:37:29 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -37,6 +37,7 @@ use Apache::lonfeedback;
use Apache::lonrss();
use Apache::lonlocal;
use Apache::lonmsgdisplay();
+use HTML::Entities();
sub handler {
my $r = shift;
@@ -206,7 +207,7 @@ sub handler {
}
if ($allowed) {
$r->print('
');
}
@@ -277,12 +278,16 @@ sub print_portfiles_link {
$output .= ''.&mt('Display file listing').
'
';
- $output .= &mt('A total of [quant,_1,portfolio file] owned by [_2] are available.',$filecounts->{'both'},$name).'
';
+ if ($filecounts->{'both'} == 1) {
+ $output .= &mt('One portfolio file owned by [_2] is available.',$filecounts->{'both'},$name).'';
+ } else {
+ $output .= &mt('A total of [_1] portfolio files owned by [_2] are available.',$filecounts->{'both'},$name).'';
+ }
if ($filecounts->{'withoutpass'}) {
- $output .= '- '.&mt('[quant,_1,file] are publicly accessible.',$filecounts->{'withoutpass'}).'
';
+ $output .= '- '.&mt('[quant,_1,file is,files are] publicly accessible.',$filecounts->{'withoutpass'}).'
';
}
if ($filecounts->{'withpass'}) {
- $output .= '- '.&mt('[quant,_1,file] require a passphrase for access.',$filecounts->{'withpass'}).'
';
+ $output .= '- '.&mt('[quant,_1,file requires,files require] a passphrase for access.',$filecounts->{'withpass'}).'
';
}
$output .= '
';
}
@@ -327,19 +332,21 @@ sub display_portfolio_header {
&Apache::lonhtmlcommon::clear_breadcrumbs();
my $forcestudent='';
if ($env{'form.forcestudent'}) { $forcestudent='student'; };
- my $output =
+ my $output =
&Apache::loncommon::start_page('Viewable portfolio files',undef,
{'function' => $forcestudent,
'domain' => $cdom,});
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>"/adm/$cdom/$cnum/aboutme".$query_string,
- text=>"Personal information - $name",
- title=>"Go to personal information page for $name"},
- {href=>"/adm/$cdom/$cnum/aboutme/portfolio",
- text=>"Viewable files - $name",
- title=>"Viewable portfolio files for $name"}
-);
- $output .= &Apache::lonhtmlcommon::breadcrumbs(&mt('Viewable portfolio files.'));
+ if (!($env{'user.name'} eq 'public' && $env{'user.domain'} eq 'public')) {
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>"/adm/$cdom/$cnum/aboutme".$query_string,
+ text=>"Personal information - $name",
+ title=>"Go to personal information page for $name"},
+ {href=>"/adm/$cdom/$cnum/aboutme/portfolio",
+ text=>"Viewable files - $name",
+ title=>"Viewable portfolio files for $name"}
+ );
+ $output .= &Apache::lonhtmlcommon::breadcrumbs(&mt('Viewable portfolio files.'));
+ }
$output .= ''.&mt('Portfolio files for [_1]',$name).'
';
$r->print($output);
return;
@@ -366,7 +373,7 @@ sub display_portfolio_files {
if ($portaccess eq $type) {
$output .= 'selected="selected"';
}
- $output .= '>'.&mt($type).'';
+ $output .= '>'.$lt{$type}.'';
}
$output .= ''."\n".
''.
- &mt('Information about [_1]',$name).'');
+ if (!($env{'user.name'} eq 'public' && $env{'user.domain'} eq 'public')) {
+ my $query_string = &build_query_string();
+ $r->print('
'.
+ &mt('Information about [_1]',$name).'');
+ }
return;
}
@@ -447,7 +456,7 @@ sub portfolio_files {
my $output;
if (keys(%allfileshash) > 0) {
$output = &portfolio_table_start();
- $output .= &parse_directory($r,0,\%allfileshash);
+ $output .= &parse_directory($r,0,\%allfileshash,'');
$output .= '';
} else {
my $access_text;
@@ -476,10 +485,15 @@ sub portfolio_files {
}
sub parse_directory {
- my ($r,$depth,$currhash) = @_;
+ my ($r,$depth,$currhash,$path) = @_;
my ($cdom,$cnum,$name) = &aboutme_info($r);
$depth++;
my $output;
+
+ my $portfolio_root = &Apache::portfolio::get_portfolio_root($cdom,$cnum);
+ my %dirlist = map {
+ ((split('&',$_,2))[0],1)
+ } &Apache::lonnet::dirlist($path,$cdom,$cnum,$portfolio_root);
foreach my $item (sort(keys(%{$currhash}))) {
$output .= &portfolio_row_start();
$output .= '';
@@ -487,22 +501,41 @@ sub parse_directory {
my $title=&HTML::Entities::encode($item,'<>&"');
$output .= ' '.$title;
$output .= ' | | ';
- $output .= &parse_directory($r,$depth,$currhash->{$item});
+ $output .= &parse_directory($r,$depth,$currhash->{$item},
+ $path.'/'.$item);
} else {
- my $showname;
- if ($currhash->{$item} =~ m|/([^/]+)$|) {
- $showname = $1;
- } else {
- $showname = $currhash->{$item};
- }
- $showname=&HTML::Entities::encode($showname,'<>&"');
+
+
+ my $file_name;
+ if ($currhash->{$item} =~ m|/([^/]+)$|) {
+ $file_name = $1;
+ } else {
+ $file_name = $currhash->{$item};
+ }
+ my $have_meta = exists($dirlist{$file_name.'.meta'});
my $url = '/uploaded/'.$cdom.'/'.$cnum.'/portfolio/'.
$currhash->{$item};
- $output .= ' '.$showname.'';
- $output.='';
+ my $showname;
+ if ($have_meta) {
+ $showname = &Apache::lonnet::metadata($url,'title');
+ }
+ if ($showname eq '') {
+ $showname = $file_name;
+ } else {
+ $showname = $file_name.' ('.$showname.')';
+ }
+
+ $showname=&HTML::Entities::encode($showname,'<>&"');
+ $output .= ''.
+ ''.
+ ' '.$showname.'';
+ $output.=' | ';
+ if ($have_meta) {
+ $output.= '';
+ }
$output .= ' | ';
}
}