--- loncom/interface/lonmeta.pm 2006/09/11 22:48:47 1.174
+++ loncom/interface/lonmeta.pm 2006/10/06 19:12:22 1.182
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Metadata display handler
#
-# $Id: lonmeta.pm,v 1.174 2006/09/11 22:48:47 banghart Exp $
+# $Id: lonmeta.pm,v 1.182 2006/10/06 19:12:22 banghart Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -95,7 +95,8 @@ sub get_dynamic_metadata_from_sql {
while (my $result = <$fh>) {
chomp($result);
next if (! $result);
- my %hash=&LONCAPA::lonmetadata::metadata_col_to_hash(map { &unescape($_) } split(/\,/,$result));
+ my %hash=&LONCAPA::lonmetadata::metadata_col_to_hash('metadata',
+ map { &unescape($_) } split(/\,/,$result));
foreach my $key (keys(%hash)) {
$ReturnHash{$hash{'url'}}->{$key}=$hash{$key};
}
@@ -505,6 +506,7 @@ sub prettyprint {
if ($type=~/\_list/) {
my @Courses = split(/\s*\,\s*/,$value);
my $Str='';
+ my %descriptions;
foreach my $course (@Courses) {
my %courseinfo =
&Apache::lonnet::coursedescription($course,
@@ -512,10 +514,16 @@ sub prettyprint {
if (! exists($courseinfo{'num'}) || $courseinfo{'num'} eq '') {
next;
}
- $Str .= '
';
}
# No pretty print found
@@ -605,7 +613,7 @@ sub prettyinput {
if (($type eq 'keywords') || ($type eq 'subject')
|| ($type eq 'author')||($type eq 'notes')
|| ($type eq 'abstract')|| ($type eq 'title')|| ($type eq 'standards')
- || (exists($env{'course.'.$env{'request.course.id'}.'metadata.'.$type.'.added'}))) {
+ || (exists($env{'course.'.$env{'request.course.id'}.'.metadata.'.$type.'.added'}))) {
if ($values) {
if ($only_one) {
$output .= (&Apache::loncommon::select_form($cur_values_inst[0],'new_'.$type,%meta_options));
@@ -620,7 +628,7 @@ sub prettyinput {
$relatedvalue);
}
return ($output);
- }
+ }
if (($type eq 'lowestgradelevel') ||
($type eq 'highestgradelevel')) {
return &Apache::loncommon::select_level_form($value,$fieldname).
@@ -744,7 +752,6 @@ sub handler {
$r->print(&Apache::loncommon::start_page('Edit Group Portfolio File Catalog Information',
undef,
{'domain' => $resdomain,}));
-
&present_editable_metadata($r,$uri,'groups');
} elsif ($uri=~m|^/~|) {
# Construction space
@@ -1186,7 +1193,7 @@ ENDEDIT
my $output;
my @fields;
my $added_metadata_fields;
- if ($file_type eq 'portfolio') {
+ if ($file_type eq 'portfolio' || $file_type eq 'groups') {
if(exists ($env{$Apache::lonpublisher::metadatafields{'courserestricted'}.'.metadata.fieldlist'})) {
# retrieve fieldnames (in order) from the course restricted list
@fields = (split /,/,$env{$Apache::lonpublisher::metadatafields{'courserestricted'}.'.metadata.fieldlist'});
@@ -1238,6 +1245,11 @@ ENDEDIT
$r->print("This resource is not associated with a course.
");
}
}
+ foreach my $field_name(keys (%$added_metadata_fields)) {
+
+ push (@fields,$field_name);
+ $lt{$field_name} = $$added_metadata_fields{$field_name};
+ }
foreach my $field_name (@fields) {
if (defined($env{'form.new_'.$field_name})) {
$Apache::lonpublisher::metadatafields{$field_name}=
@@ -1246,8 +1258,9 @@ ENDEDIT
if ($Apache::lonpublisher::metadatafields{'courserestricted'} ne 'none'
&& exists($env{$Apache::lonpublisher::metadatafields{'courserestricted'}.'.metadata.'.$field_name.'.options'})) {
# handle restrictions here
- if (($env{$Apache::lonpublisher::metadatafields{'courserestricted'}.'.metadata.'.$field_name.'.options'} =~ m/active/) ||
- ($field_name eq 'courserestricted')){
+ if ((($env{$Apache::lonpublisher::metadatafields{'courserestricted'}.'.metadata.'.$field_name.'.options'} =~ m/active/) ||
+ ($field_name eq 'courserestricted'))&&
+ (!($env{$Apache::lonpublisher::metadatafields{'courserestricted'}.'.metadata.'.$field_name.'.options'} =~ m/deleted/))){
$output.=("\n".'
'.$lt{$field_name}.': '. &prettyinput($field_name, $Apache::lonpublisher::metadatafields{$field_name}, @@ -1264,12 +1277,6 @@ ENDEDIT } } - foreach my $field_name (keys(%$added_metadata_fields)) { - my $course = $env{'request.course.id'}; - $output.=('
'.$$added_metadata_fields{$field_name}.': '. - &prettyinput($field_name,$env{'course.'.$env{'request.course.id'}.'metadata.'.$field_name.'.value'}, - 'new_'.$field_name,'addedmeta').'
') - } if ($env{'form.store'}) { my $mfh; my $formname='store'; @@ -1278,11 +1285,10 @@ ENDEDIT $Apache::lonpublisher::metadatafields{'keywords'} = join (',', &Apache::loncommon::get_env_multiple('form.new_keywords')); } - foreach my $field (sort keys %Apache::lonpublisher::metadatafields) { next if ($field =~ /\./); my $unikey=$field; - $unikey=~/^([A-Za-z]+)/; + $unikey=~/^([A-Za-z_]+)/; my $tag=$1; $tag=~tr/A-Z/a-z/; $file_content.= "\n\<$tag"; @@ -1293,7 +1299,6 @@ ENDEDIT $Apache::lonpublisher::metadatafields{$unikey.'.'.$key}; $value=~s/\"/\'\'/g; $file_content.=' '.$key.'="'.$value.'"' ; - # print $mfh ' '.$key.'="'.$value.'"'; } $file_content.= '>'. &HTML::Entities::encode @@ -1310,10 +1315,6 @@ ENDEDIT } $r->print(&store_portfolio_metadata($formname,$file_content,$path, $new_fn)); - if (! $env{'form.associate'}) { - $r->print(&Apache::portfolio::done("Return to Portfolio",'/adm/portfolio')); - return; - } } else { if (! ($mfh=Apache::File->new('>'.$fn))) { $r->print(''. @@ -1325,13 +1326,8 @@ ENDEDIT ' '.&Apache::lonlocal::locallocaltime(time). '
'); } - if (! $env{'form.associate'}) { - $r->print(&Apache::portfolio::done("Return to Portfolio",'/adm/portfolio')); - return; - } } } - $r->print($output.'