'.$env{$metacourse.".description"}.
+ if ($Apache::lonpublisher::metadatafields{'courserestricted'} ne 'none') {
+ $r->print('Using: '.$env{$Apache::lonpublisher::metadatafields{'courserestricted'}.".description"}.
" metadata framework
");
} else {
- $r->print("This resources is not associated with a metadata framework
");
+ $r->print("This resource is not associated with a metadata framework
");
}
foreach my $field_name(@fields) {
@@ -1111,102 +1163,32 @@ ENDEDIT
$Apache::lonpublisher::metadatafields{$field_name}=
join(',',&Apache::loncommon::get_env_multiple('form.new_'.$field_name));
}
- if ($metacourse ne 'none') {
+ if ($Apache::lonpublisher::metadatafields{'courserestricted'} ne 'none') {
# handle restrictions here
- if ($env{$metacourse.'.metadata.'.$field_name.'.options'} =~ m/active/){
+ if (($env{$Apache::lonpublisher::metadatafields{'courserestricted'}.'.metadata.'.$field_name.'.options'} =~ m/active/) ||
+ ($field_name eq 'courserestricted')){
$output.=(''.$lt{$field_name}.': '.
&prettyinput($field_name,
$Apache::lonpublisher::metadatafields{$field_name},
- 'new_'.$field_name,'defaultmeta',undef,undef,undef,undef,$metacourse).'
');
- } elsif ($field_name eq 'courserestricted') {
- $output.=(
- &prettyinput($field_name,
- $Apache::lonpublisher::metadatafields{$field_name},
- 'new_'.$field_name,'defaultmeta',undef,undef,undef,undef,$metacourse));
+ 'new_'.$field_name,'defaultmeta',
+ undef,undef,undef,undef,
+ $Apache::lonpublisher::metadatafields{'courserestricted'}).'');
}
} else {
- if ($field_name ne 'courserestricted') {
+
$output.=(''.$lt{$field_name}.': '.
&prettyinput($field_name,
$Apache::lonpublisher::metadatafields{$field_name},
'new_'.$field_name,'defaultmeta').'
');
- } else {
- $output.=&prettyinput($field_name,
- $Apache::lonpublisher::metadatafields{$field_name},
- 'new_'.$field_name,'defaultmeta');
- }
+
}
}
- if ($env{'form.store'}) {
- my $mfh;
- my $formname='store';
- my $file_content;
- foreach my $meta_field (keys %env) {
- if (&Apache::loncommon::get_env_multiple('form.new_keywords')) {
- $Apache::lonpublisher::metadatafields{'keywords'} =
- join (',', &Apache::loncommon::get_env_multiple('form.new_keywords'));
- }
- }
- foreach (sort keys %Apache::lonpublisher::metadatafields) {
- next if ($_ =~ /\./);
- my $unikey=$_;
- $unikey=~/^([A-Za-z]+)/;
- my $tag=$1;
- $tag=~tr/A-Z/a-z/;
- $file_content.= "\n\<$tag";
- foreach (split(/\,/,
- $Apache::lonpublisher::metadatakeys{$unikey})
- ) {
- my $value=
- $Apache::lonpublisher::metadatafields{$unikey.'.'.$_};
- $value=~s/\"/\'\'/g;
- $file_content.=' '.$_.'="'.$value.'"' ;
- # print $mfh ' '.$_.'="'.$value.'"';
- }
- $file_content.= '>'.
- &HTML::Entities::encode
- ($Apache::lonpublisher::metadatafields{$unikey},
- '<>&"').
- ''.$tag.'>';
- }
- if ($fn =~ /\/portfolio\//) {
- $fn =~ /\/portfolio\/(.*)$/;
- my $new_fn = '/'.$1;
- $env{'form.'.$formname}=$file_content."\n";
- $env{'form.'.$formname.'.filename'}=$new_fn;
- &Apache::lonnet::userfileupload('uploaddoc','',
- 'portfolio'.$env{'form.currentpath'});
- if (&Apache::lonnet::userfileupload($formname,'','portfolio') eq 'error: no uploaded file') {
- $r->print(''.
- &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.'
');
}
$r->print('