--- loncom/interface/lonmeta.pm 2005/12/19 16:00:05 1.140 +++ loncom/interface/lonmeta.pm 2005/12/19 21:13:45 1.143 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Metadata display handler # -# $Id: lonmeta.pm,v 1.140 2005/12/19 16:00:05 banghart Exp $ +# $Id: lonmeta.pm,v 1.143 2005/12/19 21:13:45 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -289,23 +289,38 @@ sub fieldnames { } return &Apache::lonlocal::texthash(%fields); } + +sub portfolio_display_uri { + my ($uri)=@_; + $uri =~ s|.*/portfolio(/.*)$|$1|; + my ($res_uri,$meta_uri) = ($uri,$uri); + + if ($uri =~ /\.meta$/) { + $res_uri =~ s/\.meta//; + } else { + $meta_uri .= '.meta'; + } + return ($res_uri,$meta_uri); +} + sub pre_select_course { my ($r,$uri) = @_; my $output; my $fn=&Apache::lonnet::filelocation('',$uri); - my $disuri=$uri; + my ($res_uri,$meta_uri) = &portfolio_display_uri($uri); %Apache::lonpublisher::metadatafields=(); %Apache::lonpublisher::metadatakeys=(); my $result=&Apache::lonnet::getfile($fn); if ($result == -1){ - $r->print('Creating new '.$disuri); + $r->print(&mt('Creating new file [_1]'),$meta_uri); } else { &Apache::lonpublisher::metaeval($result); } - $r->print('
'); return; } @@ -1028,7 +1043,10 @@ sub present_editable_metadata { my $fn=&Apache::lonnet::filelocation('',$uri); $disuri=~s/^\/\~/\/priv\//; $disuri=~s/\.meta$//; - $disuri=~s|^/editupload||; + my $meta_uri = $disuri; + if ($disuri =~ m|/portfolio/|) { + ($disuri, $meta_uri) = &portfolio_display_uri($disuri); + } my $target=$uri; $target=~s/^\/\~/\/res\/$env{'request.role.domain'}\//; $target=~s/\.meta$//; @@ -1082,7 +1100,7 @@ ENDDEL %Apache::lonpublisher::metadatakeys=(); my $result=&Apache::lonnet::getfile($fn); if ($result == -1){ - $r->print('Creating new '.$disuri); + $r->print(&mt('Creating new file [_1]'),$meta_uri); } else { &Apache::lonpublisher::metaeval($result); } @@ -1119,12 +1137,12 @@ ENDEDIT 'default'; } if ($Apache::lonpublisher::metadatafields{'courserestricted'} ne 'none') { - $r->print('Using: '.$env{$Apache::lonpublisher::metadatafields{'courserestricted'}.".description"}. - " metadata framework'.$lt{$field_name}.': '. + $output.=("\n".'
'.$lt{$field_name}.': '. &prettyinput($field_name, $Apache::lonpublisher::metadatafields{$field_name}, 'new_'.$field_name,'defaultmeta', undef,undef,undef,undef, - $Apache::lonpublisher::metadatafields{'courserestricted'}).'
'); + $Apache::lonpublisher::metadatafields{'courserestricted'}).''."\n"); } } else { @@ -1150,73 +1168,74 @@ ENDEDIT } } - - $r->print($output.''. + &mt('Could not write metadata').', '. + &mt('FAIL').'
'); + } else { + $r->print(''.&mt('Wrote Metadata'). + ' '.&Apache::lonlocal::locallocaltime(time). + '
'); + } + } else { + if (! ($mfh=Apache::File->new('>'.$fn))) { + $r->print(''. + &mt('Could not write metadata').', '. + &mt('FAIL').'
'); + } else { + print $mfh $file_content; + $r->print(''.&mt('Wrote Metadata'). + ' '.&Apache::lonlocal::locallocaltime(time). + '
'); + } + } + } + + $r->print($output.''. - &mt('Could not write metadata').', '. - &mt('FAIL').'
'); - } else { - $r->print(''.&mt('Wrote Metadata'). - ' '.&Apache::lonlocal::locallocaltime(time). - '
'); - } - } else { - if (! ($mfh=Apache::File->new('>'.$fn))) { - $r->print(''. - &mt('Could not write metadata').', '. - &mt('FAIL').'
'); - } else { - print $mfh $file_content; - $r->print(''.&mt('Wrote Metadata'). - ' '.&Apache::lonlocal::locallocaltime(time). - '
'); - } - } - } + return; }