version 1.174, 2006/09/11 22:48:47
|
version 1.183, 2006/10/16 21:39:37
|
Line 95 sub get_dynamic_metadata_from_sql {
|
Line 95 sub get_dynamic_metadata_from_sql {
|
while (my $result = <$fh>) { |
while (my $result = <$fh>) { |
chomp($result); |
chomp($result); |
next if (! $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)) { |
foreach my $key (keys(%hash)) { |
$ReturnHash{$hash{'url'}}->{$key}=$hash{$key}; |
$ReturnHash{$hash{'url'}}->{$key}=$hash{$key}; |
} |
} |
Line 468 sub prettyprint {
|
Line 469 sub prettyprint {
|
($type eq 'sequsage_list') || |
($type eq 'sequsage_list') || |
($type eq 'dependencies')) { |
($type eq 'dependencies')) { |
return '<font size="-1"><ul>'.join("\n",map { |
return '<font size="-1"><ul>'.join("\n",map { |
my $url = &Apache::lonnet::clutter($_); |
my $url = &Apache::lonnet::clutter_with_no_wrapper($_); |
my $title = &Apache::lonnet::gettitle($url); |
my $title = &Apache::lonnet::gettitle($url); |
if ($title eq '') { |
if ($title eq '') { |
$title = 'Untitled'; |
$title = 'Untitled'; |
Line 505 sub prettyprint {
|
Line 506 sub prettyprint {
|
if ($type=~/\_list/) { |
if ($type=~/\_list/) { |
my @Courses = split(/\s*\,\s*/,$value); |
my @Courses = split(/\s*\,\s*/,$value); |
my $Str='<font size="-1"><ul>'; |
my $Str='<font size="-1"><ul>'; |
|
my %descriptions; |
foreach my $course (@Courses) { |
foreach my $course (@Courses) { |
my %courseinfo = |
my %courseinfo = |
&Apache::lonnet::coursedescription($course, |
&Apache::lonnet::coursedescription($course, |
Line 512 sub prettyprint {
|
Line 514 sub prettyprint {
|
if (! exists($courseinfo{'num'}) || $courseinfo{'num'} eq '') { |
if (! exists($courseinfo{'num'}) || $courseinfo{'num'} eq '') { |
next; |
next; |
} |
} |
$Str .= '<li><a href="/public/'.$courseinfo{'domain'}.'/'. |
$descriptions{join('\0',@courseinfo{'domain','description'})} .= |
|
'<li><a href="/public/'.$courseinfo{'domain'}.'/'. |
$courseinfo{'num'}.'/syllabus" target="preview">'. |
$courseinfo{'num'}.'/syllabus" target="preview">'. |
$courseinfo{'description'}.'</a></li>'; |
$courseinfo{'description'}.' ('.$courseinfo{'domain'}. |
|
')</a></li>'; |
} |
} |
|
foreach my $course (sort {lc($a) cmp lc($b)} (keys(%descriptions))) { |
|
$Str .= $descriptions{$course}; |
|
} |
|
|
return $Str.'</ul></font>'; |
return $Str.'</ul></font>'; |
} |
} |
# No pretty print found |
# No pretty print found |
Line 605 sub prettyinput {
|
Line 613 sub prettyinput {
|
if (($type eq 'keywords') || ($type eq 'subject') |
if (($type eq 'keywords') || ($type eq 'subject') |
|| ($type eq 'author')||($type eq 'notes') |
|| ($type eq 'author')||($type eq 'notes') |
|| ($type eq 'abstract')|| ($type eq 'title')|| ($type eq 'standards') |
|| ($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 ($values) { |
if ($only_one) { |
if ($only_one) { |
$output .= (&Apache::loncommon::select_form($cur_values_inst[0],'new_'.$type,%meta_options)); |
$output .= (&Apache::loncommon::select_form($cur_values_inst[0],'new_'.$type,%meta_options)); |
Line 620 sub prettyinput {
|
Line 628 sub prettyinput {
|
$relatedvalue); |
$relatedvalue); |
} |
} |
return ($output); |
return ($output); |
} |
} |
if (($type eq 'lowestgradelevel') || |
if (($type eq 'lowestgradelevel') || |
($type eq 'highestgradelevel')) { |
($type eq 'highestgradelevel')) { |
return &Apache::loncommon::select_level_form($value,$fieldname). |
return &Apache::loncommon::select_level_form($value,$fieldname). |
Line 744 sub handler {
|
Line 752 sub handler {
|
$r->print(&Apache::loncommon::start_page('Edit Group Portfolio File Catalog Information', |
$r->print(&Apache::loncommon::start_page('Edit Group Portfolio File Catalog Information', |
undef, |
undef, |
{'domain' => $resdomain,})); |
{'domain' => $resdomain,})); |
|
|
&present_editable_metadata($r,$uri,'groups'); |
&present_editable_metadata($r,$uri,'groups'); |
} elsif ($uri=~m|^/~|) { |
} elsif ($uri=~m|^/~|) { |
# Construction space |
# Construction space |
Line 822 sub present_uneditable_metadata {
|
Line 829 sub present_uneditable_metadata {
|
# displayed url |
# displayed url |
my ($thisversion)=($uri=~/\.(\d+)\.(\w+)\.meta$/); |
my ($thisversion)=($uri=~/\.(\d+)\.(\w+)\.meta$/); |
$uri=~s/\.meta$//; |
$uri=~s/\.meta$//; |
my $disuri=&Apache::lonnet::clutter($uri); |
my $disuri=&Apache::lonnet::clutter_with_no_wrapper($uri); |
$disuri=~s/^\/adm\/wrapper//; |
|
# version |
# version |
my $versiondisplay=''; |
my $versiondisplay=''; |
if (!$uploaded) { |
if (!$uploaded) { |
Line 1186 ENDEDIT
|
Line 1192 ENDEDIT
|
my $output; |
my $output; |
my @fields; |
my @fields; |
my $added_metadata_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'})) { |
if(exists ($env{$Apache::lonpublisher::metadatafields{'courserestricted'}.'.metadata.fieldlist'})) { |
# retrieve fieldnames (in order) from the course restricted list |
# 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'}); |
Line 1238 ENDEDIT
|
Line 1244 ENDEDIT
|
$r->print("This resource is not associated with a course.<br />"); |
$r->print("This resource is not associated with a course.<br />"); |
} |
} |
} |
} |
|
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) { |
foreach my $field_name (@fields) { |
if (defined($env{'form.new_'.$field_name})) { |
if (defined($env{'form.new_'.$field_name})) { |
$Apache::lonpublisher::metadatafields{$field_name}= |
$Apache::lonpublisher::metadatafields{$field_name}= |
Line 1246 ENDEDIT
|
Line 1257 ENDEDIT
|
if ($Apache::lonpublisher::metadatafields{'courserestricted'} ne 'none' |
if ($Apache::lonpublisher::metadatafields{'courserestricted'} ne 'none' |
&& exists($env{$Apache::lonpublisher::metadatafields{'courserestricted'}.'.metadata.'.$field_name.'.options'})) { |
&& exists($env{$Apache::lonpublisher::metadatafields{'courserestricted'}.'.metadata.'.$field_name.'.options'})) { |
# handle restrictions here |
# handle restrictions here |
if (($env{$Apache::lonpublisher::metadatafields{'courserestricted'}.'.metadata.'.$field_name.'.options'} =~ m/active/) || |
if ((($env{$Apache::lonpublisher::metadatafields{'courserestricted'}.'.metadata.'.$field_name.'.options'} =~ m/active/) || |
($field_name eq 'courserestricted')){ |
($field_name eq 'courserestricted'))&& |
|
(!($env{$Apache::lonpublisher::metadatafields{'courserestricted'}.'.metadata.'.$field_name.'.options'} =~ m/deleted/))){ |
$output.=("\n".'<p>'.$lt{$field_name}.': '. |
$output.=("\n".'<p>'.$lt{$field_name}.': '. |
&prettyinput($field_name, |
&prettyinput($field_name, |
$Apache::lonpublisher::metadatafields{$field_name}, |
$Apache::lonpublisher::metadatafields{$field_name}, |
Line 1264 ENDEDIT
|
Line 1276 ENDEDIT
|
|
|
} |
} |
} |
} |
foreach my $field_name (keys(%$added_metadata_fields)) { |
|
my $course = $env{'request.course.id'}; |
|
$output.=('<p>'.$$added_metadata_fields{$field_name}.': '. |
|
&prettyinput($field_name,$env{'course.'.$env{'request.course.id'}.'metadata.'.$field_name.'.value'}, |
|
'new_'.$field_name,'addedmeta').'</p>') |
|
} |
|
if ($env{'form.store'}) { |
if ($env{'form.store'}) { |
my $mfh; |
my $mfh; |
my $formname='store'; |
my $formname='store'; |
Line 1278 ENDEDIT
|
Line 1284 ENDEDIT
|
$Apache::lonpublisher::metadatafields{'keywords'} = |
$Apache::lonpublisher::metadatafields{'keywords'} = |
join (',', &Apache::loncommon::get_env_multiple('form.new_keywords')); |
join (',', &Apache::loncommon::get_env_multiple('form.new_keywords')); |
} |
} |
|
|
foreach my $field (sort keys %Apache::lonpublisher::metadatafields) { |
foreach my $field (sort keys %Apache::lonpublisher::metadatafields) { |
next if ($field =~ /\./); |
next if ($field =~ /\./); |
my $unikey=$field; |
my $unikey=$field; |
$unikey=~/^([A-Za-z]+)/; |
$unikey=~/^([A-Za-z_]+)/; |
my $tag=$1; |
my $tag=$1; |
$tag=~tr/A-Z/a-z/; |
$tag=~tr/A-Z/a-z/; |
$file_content.= "\n\<$tag"; |
$file_content.= "\n\<$tag"; |
Line 1293 ENDEDIT
|
Line 1298 ENDEDIT
|
$Apache::lonpublisher::metadatafields{$unikey.'.'.$key}; |
$Apache::lonpublisher::metadatafields{$unikey.'.'.$key}; |
$value=~s/\"/\'\'/g; |
$value=~s/\"/\'\'/g; |
$file_content.=' '.$key.'="'.$value.'"' ; |
$file_content.=' '.$key.'="'.$value.'"' ; |
# print $mfh ' '.$key.'="'.$value.'"'; |
|
} |
} |
$file_content.= '>'. |
$file_content.= '>'. |
&HTML::Entities::encode |
&HTML::Entities::encode |
Line 1310 ENDEDIT
|
Line 1314 ENDEDIT
|
} |
} |
$r->print(&store_portfolio_metadata($formname,$file_content,$path, |
$r->print(&store_portfolio_metadata($formname,$file_content,$path, |
$new_fn)); |
$new_fn)); |
if (! $env{'form.associate'}) { |
|
$r->print(&Apache::portfolio::done("Return to Portfolio",'/adm/portfolio')); |
|
return; |
|
} |
|
} else { |
} else { |
if (! ($mfh=Apache::File->new('>'.$fn))) { |
if (! ($mfh=Apache::File->new('>'.$fn))) { |
$r->print('<p><font color="red">'. |
$r->print('<p><font color="red">'. |
Line 1325 ENDEDIT
|
Line 1325 ENDEDIT
|
' '.&Apache::lonlocal::locallocaltime(time). |
' '.&Apache::lonlocal::locallocaltime(time). |
'</font></p>'); |
'</font></p>'); |
} |
} |
if (! $env{'form.associate'}) { |
|
$r->print(&Apache::portfolio::done("Return to Portfolio",'/adm/portfolio')); |
|
return; |
|
} |
|
} |
} |
} |
} |
|
|
$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').'" />'); |
|
|
Line 1341 ENDEDIT
|
Line 1336 ENDEDIT
|
$r->print('<input type="hidden" name="group" value="'.$group.'" />'); |
$r->print('<input type="hidden" name="group" value="'.$group.'" />'); |
} |
} |
$r->print('<input type="hidden" name="currentpath" value="'.$env{'form.currentpath'}.'" />'); |
$r->print('<input type="hidden" name="currentpath" value="'.$env{'form.currentpath'}.'" />'); |
$r->print('</form> |
$r->print('</form><br /><br /><form method="post" action="'.$port_path.'">'); |
<br /><br /><form method="post" action="'.$port_path.'">'. |
if ($group) { |
'<input type="hidden" name="group" value="'.$group.'" />'. |
$r->print('<input type="hidden" name="group" value="'.$group.'" />'); |
'<input type="hidden" name="currentpath" value="'.$path.'" />'. |
} |
|
$r->print('<input type="hidden" name="currentpath" value="'.$path.'" />'. |
'<input type="submit" name="cancel" value="'.&mt('Discard Edits and Return to Portfolio').'" />'); |
'<input type="submit" name="cancel" value="'.&mt('Discard Edits and Return to Portfolio').'" />'); |
} |
} |
} |
} |