version 1.133, 2005/11/22 23:20:40
|
version 1.137, 2005/12/13 11:52:37
|
Line 291 sub fieldnames {
|
Line 291 sub fieldnames {
|
} |
} |
|
|
sub select_course { |
sub select_course { |
my ($r)=@_; |
|
my %courses; |
my %courses; |
|
my $output; |
foreach my $key (keys (%env)) { |
foreach my $key (keys (%env)) { |
if ($key =~ m/\.metadata\./) { |
if ($key =~ m/\.metadata\./) { |
$key =~ m/^course\.(.+)(\.metadata.+$)/; |
$key =~ m/^course\.(.+)(\.metadata.+$)/; |
Line 302 sub select_course {
|
Line 302 sub select_course {
|
$courses{$coursekey} = $value; |
$courses{$coursekey} = $value; |
} |
} |
} |
} |
$r->print('<h3>Course Related Meta-Data</h3><br />'); |
$output = '<h3>Associate resource with a course</h3><br />'; |
$r->print('<form action="" method="post">'); |
$output .= '<form action="" method="post">'; |
$r->print('Select course restrictions<br />'); |
$output .= 'Select course <br />'; |
$r->print('<select name="metacourse" >'); |
$output .= '<select name="metacourse" >'; |
my $meta_not_found = 1; |
my $meta_not_found = 1; |
foreach my $key (keys (%courses)) { |
foreach my $key (keys (%courses)) { |
if ($meta_not_found) { |
if ($meta_not_found) { |
undef($meta_not_found); |
undef($meta_not_found); |
$r->print('<h3>Portfolio Meta-Data</h3><br />'); |
$output .= '<h3>Portfolio Meta-Data</h3><br />'; |
$r->print('<form action="" method="post">'); |
$output .= '<form action="" method="post">'; |
$r->print('Select your course<br />'); |
$output .= 'Select your course<br />'; |
$r->print('<select name="metacourse" >'); |
$output .= '<select name="metacourse" >'; |
} |
} |
$key =~ m/(^.+)\.description$/; |
$key =~ m/(^.+)\.description$/; |
$r->print('<option value="'.$1.'">'); |
$output .= '<option value="'.$1.'">'; |
$r->print($courses{$key}); |
$output .= $courses{$key}; |
$r->print('</option>'); |
$output .= '</option>'; |
} |
} |
unless ($meta_not_found) { |
unless ($meta_not_found) { |
$r->print('</select><br />'); |
$output .= '</select><br />'; |
$r->print('<input type="submit" value="Assign Portfolio Metadata" />'); |
$output .= '<input type="submit" value="Associate" />'; |
$r->print('</form>'); |
$output .= '</form>'; |
} |
} |
return 'ok'; |
return ($output); |
} |
} |
# Pretty printing of metadata field |
# Pretty printing of metadata field |
|
|
Line 523 sub prettyinput {
|
Line 523 sub prettyinput {
|
|| ($type eq 'abstract')|| ($type eq 'title')|| ($type eq 'standards')) { |
|| ($type eq 'abstract')|| ($type eq 'title')|| ($type eq 'standards')) { |
if ($values) { |
if ($values) { |
if ($only_one) { |
if ($only_one) { |
$output .= (&Apache::loncommon::select_form($value,'new_'.$type,%meta_options)); |
$output .= (&Apache::loncommon::select_form($cur_values_inst[0],'new_'.$type,%meta_options)); |
} else { |
} else { |
$output .= (&Apache::loncommon::multiple_select_form('new_'.$type,\@cur_values_inst,undef,\%meta_options)); |
$output .= (&Apache::loncommon::multiple_select_form('new_'.$type,\@cur_values_inst,undef,\%meta_options)); |
} |
} |
Line 603 sub prettyinput {
|
Line 603 sub prettyinput {
|
",'rights')\">".&mt('Select').'</a>'. |
",'rights')\">".&mt('Select').'</a>'. |
&relatedfield(0,$relatedsearchflag,$relatedsep); |
&relatedfield(0,$relatedsearchflag,$relatedsep); |
} |
} |
|
if ($type eq 'courserestricted') { |
|
return ('<input type="hidden" name="new_courserestricted" value="'.$course_key.'" />'); |
|
} |
|
|
# Dates |
# Dates |
if (($type eq 'creationdate') || |
if (($type eq 'creationdate') || |
($type eq 'lastrevisiondate')) { |
($type eq 'lastrevisiondate')) { |
Line 649 sub handler {
|
Line 653 sub handler {
|
$r->print(&Apache::loncommon::bodytag |
$r->print(&Apache::loncommon::bodytag |
('Edit Portfolio File Information','','','',$resdomain)); |
('Edit Portfolio File Information','','','',$resdomain)); |
&present_editable_metadata($r,$uri,'portfolio'); |
&present_editable_metadata($r,$uri,'portfolio'); |
&select_course($r); |
|
} elsif ($uri=~/^\/\~/) { |
} elsif ($uri=~/^\/\~/) { |
# Construction space |
# Construction space |
$r->print(&Apache::loncommon::bodytag |
$r->print(&Apache::loncommon::bodytag |
Line 999 sub present_editable_metadata {
|
Line 1002 sub present_editable_metadata {
|
# Header |
# Header |
my $disuri=$uri; |
my $disuri=$uri; |
my $fn=&Apache::lonnet::filelocation('',$uri); |
my $fn=&Apache::lonnet::filelocation('',$uri); |
|
my $metacourse; |
$disuri=~s/^\/\~/\/priv\//; |
$disuri=~s/^\/\~/\/priv\//; |
$disuri=~s/\.meta$//; |
$disuri=~s/\.meta$//; |
$disuri=~s|^/editupload||; |
$disuri=~s|^/editupload||; |
Line 1079 ENDEDIT
|
Line 1083 ENDEDIT
|
'lowestgradelevel','highestgradelevel','sourceavail','sourcerights', |
'lowestgradelevel','highestgradelevel','sourceavail','sourcerights', |
'obsolete','obsoletereplacement'); |
'obsolete','obsoletereplacement'); |
} |
} |
my $metacourse; |
|
if ($env{'form.metacourse'} ) { |
if ($env{'form.metacourse'} ) { |
$Apache::lonpublisher::metadatafields{'courserestricted'} = $env{'form.metacourse'}; |
$Apache::lonpublisher::metadatafields{'courserestricted'} = $env{'form.metacourse'}; |
$metacourse = $env{'form.metacourse'}; |
$metacourse = $env{'form.metacourse'}; |
Line 1097 ENDEDIT
|
Line 1100 ENDEDIT
|
'default'; |
'default'; |
} |
} |
if ($metacourse ne 'none') { |
if ($metacourse ne 'none') { |
$r->print('Document metadata restricted by :<strong> '.$env{$metacourse.".description"}."</strong><br />"); |
$r->print('Using: <strong> '.$env{$metacourse.".description"}. |
|
"</strong> metadata framework<br />"); |
|
} else { |
|
$r->print("This resources is not associated with a metadata framework<br />"); |
} |
} |
foreach my $field_name(@fields) { |
foreach my $field_name(@fields) { |
|
|
Line 1131 ENDEDIT
|
Line 1137 ENDEDIT
|
} |
} |
} |
} |
} |
} |
|
|
if ($env{'form.store'}) { |
if ($env{'form.store'}) { |
my $mfh; |
my $mfh; |
my $formname='store'; |
my $formname='store'; |
Line 1152 ENDEDIT
|
Line 1159 ENDEDIT
|
$Apache::lonpublisher::metadatakeys{$unikey}) |
$Apache::lonpublisher::metadatakeys{$unikey}) |
) { |
) { |
my $value= |
my $value= |
$Apache::lonpublisher::metadatafields{$unikey.'.'.$_}; |
$Apache::lonpublisher::metadatafields{$unikey.'.'.$_}; |
$value=~s/\"/\'\'/g; |
$value=~s/\"/\'\'/g; |
$file_content.=' '.$_.'="'.$value.'"' ; |
$file_content.=' '.$_.'="'.$value.'"' ; |
# print $mfh ' '.$_.'="'.$value.'"'; |
# print $mfh ' '.$_.'="'.$value.'"'; |
Line 1166 ENDEDIT
|
Line 1173 ENDEDIT
|
if ($fn =~ /\/portfolio\//) { |
if ($fn =~ /\/portfolio\//) { |
$fn =~ /\/portfolio\/(.*)$/; |
$fn =~ /\/portfolio\/(.*)$/; |
my $new_fn = '/'.$1; |
my $new_fn = '/'.$1; |
$env{'form.'.$formname}=$file_content; |
$env{'form.'.$formname}=$file_content."\n"; |
$env{'form.'.$formname.'.filename'}=$new_fn; |
$env{'form.'.$formname.'.filename'}=$new_fn; |
&Apache::lonnet::userfileupload('uploaddoc','', |
&Apache::lonnet::userfileupload('uploaddoc','', |
'portfolio'.$env{'form.currentpath'}); |
'portfolio'.$env{'form.currentpath'}); |
Line 1192 ENDEDIT
|
Line 1199 ENDEDIT
|
} |
} |
} |
} |
} |
} |
$r->print($output.'<br /><input type="submit" name="store" value="'. |
$r->print($output.'<br /><input type="submit" name="store" value="'. |
&mt('Store Catalog Information').'">'); |
&mt('Store Catalog Information').'">'); |
|
|
} |
} |
$r->print('</form>'); |
$r->print('</form>'); |
|
if ($metacourse eq 'none') { |
|
$r->print(&select_course()); |
|
} |
return; |
return; |
} |
} |
|
|