--- loncom/interface/lonmeta.pm 2006/07/19 19:29:20 1.161 +++ loncom/interface/lonmeta.pm 2006/08/28 00:13:22 1.168.2.1 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Metadata display handler # -# $Id: lonmeta.pm,v 1.161 2006/07/19 19:29:20 albertel Exp $ +# $Id: lonmeta.pm,v 1.168.2.1 2006/08/28 00:13:22 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -170,7 +170,7 @@ sub authordisplay { my ($aname,$adom)=@_; return &Apache::loncommon::aboutmewrapper (&Apache::loncommon::plainname($aname,$adom), - $aname,$adom,'preview').' ['.$aname.'@'.$adom.']'; + $aname,$adom,'preview').' ['.$aname.':'.$adom.']'; } # Pretty display @@ -287,15 +287,22 @@ sub portfolio_linked_path { if ($group) { $start = "groups/$group/".$start; } - my $result = &Apache::portfolio::make_anchor($port_path,$start,'/'); - + my %anchor_fields = ( + 'selectfile' => $start, + 'currentpath' => '/' + ); + my $result = &Apache::portfolio::make_anchor($port_path,\%anchor_fields,$start); my $fullpath = '/'; my (undef,@tree) = split('/',$path); my $filename = pop(@tree); foreach my $dir (@tree) { $fullpath .= $dir.'/'; $result .= '/'; - $result .= &Apache::portfolio::make_anchor($port_path,$dir,$fullpath); + my %anchor_fields = ( + 'selectfile' => $dir, + 'currentpath' => $fullpath + ); + $result .= &Apache::portfolio::make_anchor($port_path,\%anchor_fields,$dir); } $result .= "/$filename"; return $result; @@ -358,14 +365,18 @@ sub pre_select_course { $r->print('

'.&mt('If you would like to associate this resource ([_1]) with a current or previous course, please select one from the list below, otherwise select, \'None\'',''.$res_uri.'').'

'); $output = &select_course(); $r->print($output.'
'); + &mt('Associate Resource With Selected Course').'" />'); $r->print(''); my ($port_path,$group) = &get_port_path_and_group($uri); - $r->print('

'. + my $group_input; + if ($group) { + $group_input = ''; + } + $r->print('

'. ''. - ''. - ''. + $group_input. + ''. '
'); return; @@ -713,17 +724,15 @@ sub handler { &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; return OK if $r->header_only; - # my ($resdomain,$resuser)= (&Apache::lonnet::declutter($uri)=~/^(\w+)\/(\w+)\//); - if ($uri=~m:/adm/bombs/(.*)$:) { $r->print(&Apache::loncommon::start_page('Error Messages')); # Looking for all bombs? &report_bombs($r,$uri); - } elsif ($uri=~/\/portfolio\//) { + } elsif ($uri=~m|^/editupload/[^/]+/[^/]+/portfolio/|) { ($resdomain,$resuser)= - (&Apache::lonnet::declutter($uri)=~m|^(\w+)/(\w+)/portfolio|); + (&Apache::lonnet::declutter($uri)=~m|^(\w+)/(\w+)/portfolio|); $r->print(&Apache::loncommon::start_page('Edit Portfolio File Catalog Information', undef, {'domain' => $resdomain,})); @@ -732,7 +741,12 @@ sub handler { } else { &pre_select_course($r,$uri); } - } elsif ($uri=~/^\/\~/) { + } elsif ($uri=~m|^/editupload/[^/]+/[^/]+/groups/|) { + $r->print(&Apache::loncommon::start_page('Edit Group Portfolio File Catalog Information', + undef, + {'domain' => $resdomain,})); + &present_editable_metadata($r,$uri,'portfolio'); + } elsif ($uri=~m|^/~|) { # Construction space $r->print(&Apache::loncommon::start_page('Edit Catalog nformation', undef, @@ -798,6 +812,7 @@ ENDCLEAR sub present_uneditable_metadata { my ($r,$uri) = @_; # + my $uploaded = ($uri =~ m|/uploaded/|); my %content=(); # Read file foreach (split(/\,/,&Apache::lonnet::metadata($uri,'keys'))) { @@ -810,16 +825,18 @@ sub present_uneditable_metadata { my $disuri=&Apache::lonnet::clutter($uri); $disuri=~s/^\/adm\/wrapper//; # version - my $currentversion=&Apache::lonnet::getversion($disuri); my $versiondisplay=''; - if ($thisversion) { - $versiondisplay=&mt('Version').': '.$thisversion. - ' ('.&mt('most recent version').': '. - ($currentversion>0 ? - $currentversion : - &mt('information not available')).')'; - } else { - $versiondisplay='Version: '.$currentversion; + if (!$uploaded) { + my $currentversion=&Apache::lonnet::getversion($disuri); + if ($thisversion) { + $versiondisplay=&mt('Version').': '.$thisversion. + ' ('.&mt('most recent version').': '. + ($currentversion>0 ? + $currentversion : + &mt('information not available')).')'; + } else { + $versiondisplay='Version: '.$currentversion; + } } # crumbify displayed URL uri target prefix form size $disuri=&Apache::lonhtmlcommon::crumbs($disuri,undef, undef, undef,'+1'); @@ -839,30 +856,38 @@ sub present_uneditable_metadata { if (! defined($title)) { $title = 'Untitled Resource'; } - foreach ('title', - 'author', - 'subject', - 'keywords', - 'notes', - 'abstract', - 'lowestgradelevel', - 'highestgradelevel', - 'standards', - 'mime', - 'language', - 'creationdate', - 'lastrevisiondate', - 'owner', - 'copyright', - 'customdistributionfile', - 'sourceavail', - 'sourcerights', - 'obsolete', - 'obsoletereplacement') { - $table.=''.$lt{$_}. + my @fields; + if ($uploaded) { + @fields = ('title','author','subject','keywords','notes','abstract', + 'lowestgradelevel','highestgradelevel','standards','mime', + 'owner'); + } else { + @fields = ('title', + 'author', + 'subject', + 'keywords', + 'notes', + 'abstract', + 'lowestgradelevel', + 'highestgradelevel', + 'standards', + 'mime', + 'language', + 'creationdate', + 'lastrevisiondate', + 'owner', + 'copyright', + 'customdistributionfile', + 'sourceavail', + 'sourcerights', + 'obsolete', + 'obsoletereplacement'); + } + foreach my $field (@fields) { + $table.=''.$lt{$field}. ''. - &prettyprint($_,$content{$_}).''; - delete $content{$_}; + &prettyprint($field,$content{$field}).''; + delete($content{$field}); } # $r->print(< ENDHEAD - if ($env{'user.adv'}) { + if (!$uploaded && $env{'user.adv'}) { &print_dynamic_metadata($r,$uri,\%content); } return; @@ -1161,7 +1186,8 @@ ENDEDIT my $output; my @fields; if ($file_type eq 'portfolio') { - @fields = ('author','title','subject','keywords','abstract','notes','lowestgradelevel', + @fields = ('author','title','subject','keywords','abstract', + 'notes','lowestgradelevel', 'highestgradelevel','standards'); } else { @fields = ('author','title','subject','keywords','abstract','notes', @@ -1180,9 +1206,18 @@ ENDEDIT } if (! $Apache::lonpublisher::metadatafields{'copyright'}) { $Apache::lonpublisher::metadatafields{'copyright'}= - 'default'; + 'default'; } if ($file_type eq 'portfolio') { + if (! $Apache::lonpublisher::metadatafields{'mime'}) { + ($Apache::lonpublisher::metadatafields{'mime'}) = + ( $target=~/\.(\w+)$/ ); + } + if (! $Apache::lonpublisher::metadatafields{'owner'}) { + $Apache::lonpublisher::metadatafields{'owner'} = + $env{'user.name'}.':'.$env{'user.domain'}; + } + if ($Apache::lonpublisher::metadatafields{'courserestricted'} ne 'none') { $r->print(&mt('Associated with course [_1]',''.$env{$Apache::lonpublisher::metadatafields{'courserestricted'}.".description"}. '').'
');