--- loncom/interface/lonmeta.pm 2006/10/23 20:53:46 1.184
+++ loncom/interface/lonmeta.pm 2006/11/20 20:58:30 1.189
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Metadata display handler
#
-# $Id: lonmeta.pm,v 1.184 2006/10/23 20:53:46 banghart Exp $
+# $Id: lonmeta.pm,v 1.189 2006/11/20 20:58:30 banghart Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -724,7 +724,7 @@ sub prettyinput {
sub handler {
my $r=shift;
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['currentpath']);
+ ['currentpath','changecourse']);
my $uri=$r->uri;
#
# Set document type
@@ -746,7 +746,18 @@ sub handler {
if ($env{'form.store'}) {
&present_editable_metadata($r,$uri,'portfolio');
} else {
- &pre_select_course($r,$uri);
+ my $fn=&Apache::lonnet::filelocation('',$uri);
+ %Apache::lonpublisher::metadatafields=();
+ %Apache::lonpublisher::metadatakeys=();
+ my $result=&Apache::lonnet::getfile($fn);
+ &Apache::lonpublisher::metaeval($result);
+ &Apache::lonnet::logthis("restricted is: ".$Apache::lonpublisher::metadatafields{'courserestricted'});
+ if ((!$Apache::lonpublisher::metadatafields{'courserestricted'}) ||
+ ($env{'form.changecourse'} eq 'true')) {
+ &pre_select_course($r,$uri);
+ } else {
+ &present_editable_metadata($r,$uri,'portfolio');
+ }
}
} elsif ($uri=~m|^/editupload/[^/]+/[^/]+/groups/|) {
$r->print(&Apache::loncommon::start_page('Edit Group Portfolio File Catalog Information',
@@ -1196,7 +1207,7 @@ ENDEDIT
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'});
+ @fields = (split(/,/,$env{$Apache::lonpublisher::metadatafields{'courserestricted'}.'.metadata.fieldlist'}));
} else {
# no saved field list, use default list
@fields = ('author','title','subject','keywords','abstract',
@@ -1204,16 +1215,16 @@ ENDEDIT
'highestgradelevel','standards');
$added_metadata_fields = &Apache::lonparmset::get_added_meta_fieldnames();
if ($env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'}) {
- @added_order = split /,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'};
+ @added_order = split(/,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'});
}
- $env{$Apache::lonpublisher::metadatafields{'courserestricted'}.'.metadata.fieldlist'} = join (",",@fields);
+ $env{$Apache::lonpublisher::metadatafields{'courserestricted'}.'.metadata.fieldlist'} = join(",",@fields);
}
} else {
@fields = ('author','title','subject','keywords','abstract','notes',
- 'copyright','customdistributionfile','language',
- 'standards',
- 'lowestgradelevel','highestgradelevel','sourceavail','sourcerights',
- 'obsolete','obsoletereplacement');
+ 'copyright','customdistributionfile','language',
+ 'standards',
+ 'lowestgradelevel','highestgradelevel','sourceavail','sourcerights',
+ 'obsolete','obsoletereplacement');
}
if ($file_type eq 'groups') {
$Apache::lonpublisher::metadatafields{'courserestricted'}=
@@ -1242,23 +1253,28 @@ ENDEDIT
}
if ($Apache::lonpublisher::metadatafields{'courserestricted'} ne 'none') {
- $r->print(&mt('Associated with course [_1]',''.$env{$Apache::lonpublisher::metadatafields{'courserestricted'}.".description"}.
- '').'
');
+ $r->print(&mt('Associated with course [_1]',
+ ''.
+ $env{$Apache::lonpublisher::metadatafields{'courserestricted'}.
+ ".description"}.
+ '').'
');
} else {
- $r->print("This resource is not associated with a course.
");
+ $r->print('This resource is not associated with a course.
');
}
}
if (@added_order) {
- foreach my $field_name(@added_order) {
- push (@fields,$field_name);
+ foreach my $field_name (@added_order) {
+ push(@fields,$field_name);
$lt{$field_name} = $$added_metadata_fields{$field_name};
}
} else {
- foreach my $field_name(keys (%$added_metadata_fields)) {
- push (@fields,$field_name);
+ foreach my $field_name (keys(%$added_metadata_fields)) {
+ push(@fields,$field_name);
$lt{$field_name} = $$added_metadata_fields{$field_name};
}
}
+ $output .= &Apache::loncommon::start_data_table();
+ my $row_alt = 1;
foreach my $field_name (@fields) {
if (defined($env{'form.new_'.$field_name})) {
$Apache::lonpublisher::metadatafields{$field_name}=
@@ -1270,22 +1286,26 @@ ENDEDIT
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}.': '. + + $output .= "\n".&Apache::loncommon::start_data_table_row(); + $output .= ('
'.$lt{$field_name}.': '. - &prettyinput($field_name, - $Apache::lonpublisher::metadatafields{$field_name}, - 'new_'.$field_name,'defaultmeta').'
'); + $output.=(&Apache::loncommon::start_data_table_row().''. &mt('Could not write metadata').', '. &mt('FAIL').'
'); } else { - print $mfh $file_content; + print $mfh ($file_content); $r->print(''.&mt('Wrote Metadata'). ' '.&Apache::lonlocal::locallocaltime(time). '
');