version 1.156, 2006/05/20 06:40:53
|
version 1.169, 2006/08/16 18:02:01
|
Line 39 use Apache::lonpublisher;
|
Line 39 use Apache::lonpublisher;
|
use Apache::lonlocal; |
use Apache::lonlocal; |
use Apache::lonmysql; |
use Apache::lonmysql; |
use Apache::lonmsg; |
use Apache::lonmsg; |
|
use lib '/home/httpd/lib/perl/'; |
|
use LONCAPA; |
|
|
|
|
############################################################ |
############################################################ |
Line 71 sub get_dynamic_metadata_from_sql {
|
Line 73 sub get_dynamic_metadata_from_sql {
|
if (! defined($authordom) || ! defined($author)) { |
if (! defined($authordom) || ! defined($author)) { |
return (); |
return (); |
} |
} |
my @Fields = ('url','count','course','course_list', |
my $query = 'SELECT * FROM metadata WHERE url LIKE "'.$url.'%"'; |
'goto','goto_list', |
|
'comefrom','comefrom_list', |
|
'sequsage','sequsage_list', |
|
'stdno','stdno_list', |
|
'dependencies', |
|
'avetries','avetries_list', |
|
'difficulty','difficulty_list', |
|
'disc','disc_list', |
|
'clear','technical','correct', |
|
'helpful','depth'); |
|
# |
|
my $query = 'SELECT '.join(',',@Fields). |
|
' FROM metadata WHERE url LIKE "'.$url.'%"'; |
|
my $server = &Apache::lonnet::homeserver($author,$authordom); |
my $server = &Apache::lonnet::homeserver($author,$authordom); |
my $reply = &Apache::lonnet::metadata_query($query,undef,undef, |
my $reply = &Apache::lonnet::metadata_query($query,undef,undef, |
,[$server]); |
,[$server]); |
Line 106 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 @Data = |
my %hash=&LONCAPA::lonmetadata::metadata_col_to_hash(map { &unescape($_) } split(/\,/,$result)); |
map { |
foreach my $key (keys(%hash)) { |
&Apache::lonnet::unescape($_); |
$ReturnHash{$hash{'url'}}->{$key}=$hash{$key}; |
} split(',',$result); |
|
my $url = $Data[0]; |
|
for (my $i=0;$i<=$#Fields;$i++) { |
|
$ReturnHash{$url}->{$Fields[$i]}=$Data[$i]; |
|
} |
} |
} |
} |
$finished = 1; |
$finished = 1; |
Line 185 sub authordisplay {
|
Line 170 sub authordisplay {
|
my ($aname,$adom)=@_; |
my ($aname,$adom)=@_; |
return &Apache::loncommon::aboutmewrapper |
return &Apache::loncommon::aboutmewrapper |
(&Apache::loncommon::plainname($aname,$adom), |
(&Apache::loncommon::plainname($aname,$adom), |
$aname,$adom,'preview').' <tt>['.$aname.'@'.$adom.']</tt>'; |
$aname,$adom,'preview').' <tt>['.$aname.':'.$adom.']</tt>'; |
} |
} |
|
|
# Pretty display |
# Pretty display |
Line 302 sub portfolio_linked_path {
|
Line 287 sub portfolio_linked_path {
|
if ($group) { |
if ($group) { |
$start = "groups/$group/".$start; |
$start = "groups/$group/".$start; |
} |
} |
my $result = &Apache::portfolio::make_anchor($port_path,$start,'/', |
my %anchor_fields = ( |
undef,undef,undef,$group); |
'selectfile' => $start, |
|
'currentpath' => '/' |
|
); |
|
my $result = &Apache::portfolio::make_anchor($port_path,\%anchor_fields,$start); |
my $fullpath = '/'; |
my $fullpath = '/'; |
my (undef,@tree) = split('/',$path); |
my (undef,@tree) = split('/',$path); |
my $filename = pop(@tree); |
my $filename = pop(@tree); |
foreach my $dir (@tree) { |
foreach my $dir (@tree) { |
$fullpath .= $dir.'/'; |
$fullpath .= $dir.'/'; |
$result .= '/'; |
$result .= '/'; |
$result .= &Apache::portfolio::make_anchor($port_path,$dir,$fullpath, |
my %anchor_fields = ( |
undef,undef,undef,$group); |
'selectfile' => $dir, |
|
'currentpath' => $fullpath |
|
); |
|
$result .= &Apache::portfolio::make_anchor($port_path,\%anchor_fields,$dir); |
} |
} |
$result .= "/$filename"; |
$result .= "/$filename"; |
return $result; |
return $result; |
Line 331 sub get_port_path_and_group {
|
Line 321 sub get_port_path_and_group {
|
} else { |
} else { |
$port_path = '/adm/portfolio'; |
$port_path = '/adm/portfolio'; |
} |
} |
|
if ($env{'form.group'} ne $group) { |
|
$env{'form.group'} = $group; |
|
} |
return ($port_path,$group); |
return ($port_path,$group); |
} |
} |
|
|
Line 372 sub pre_select_course {
|
Line 365 sub pre_select_course {
|
$r->print('<p>'.&mt('If you would like to associate this resource ([_1]) with a current or previous course, please select one from the list below, otherwise select, \'None\'','<tt>'.$res_uri.'</tt>').'</p>'); |
$r->print('<p>'.&mt('If you would like to associate this resource ([_1]) with a current or previous course, please select one from the list below, otherwise select, \'None\'','<tt>'.$res_uri.'</tt>').'</p>'); |
$output = &select_course(); |
$output = &select_course(); |
$r->print($output.'<br /><input type="submit" name="store" value="'. |
$r->print($output.'<br /><input type="submit" name="store" value="'. |
&mt('Associate Resource With Selected Course').'">'); |
&mt('Associate Resource With Selected Course').'" />'); |
|
$r->print('<input type="hidden" name="currentpath" value="'.$env{'form.currentpath'}.'" />'); |
|
$r->print('<input type="hidden" name="associate" value="true" />'); |
$r->print('</form>'); |
$r->print('</form>'); |
|
|
my ($port_path,$group) = &get_port_path_and_group($uri); |
my ($port_path,$group) = &get_port_path_and_group($uri); |
$r->print('<br /><br /><form method="POST" action="'.$port_path.'">'. |
my $group_input; |
|
if ($group) { |
|
$group_input = '<input type="hidden" name="group" value="'.$group.'" />'; |
|
} |
|
$r->print('<br /><br /><form method="post" action="'.$port_path.'">'. |
'<input type="hidden" name="currentpath" value="'.$path.'" />'. |
'<input type="hidden" name="currentpath" value="'.$path.'" />'. |
'<input type="hidden" name="group" value="'.$group.'" />'. |
$group_input. |
'<input type="submit" name="cancel" value="'.&mt('Cancel').'">'. |
'<input type="submit" name="cancel" value="'.&mt('Cancel').'" />'. |
'</form>'); |
'</form>'); |
|
|
return; |
return; |
Line 721 sub prettyinput {
|
Line 720 sub prettyinput {
|
sub handler { |
sub handler { |
my $r=shift; |
my $r=shift; |
# |
# |
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
|
['currentpath']); |
my $uri=$r->uri; |
my $uri=$r->uri; |
# |
# |
# Set document type |
# Set document type |
Line 730 sub handler {
|
Line 731 sub handler {
|
# |
# |
my ($resdomain,$resuser)= |
my ($resdomain,$resuser)= |
(&Apache::lonnet::declutter($uri)=~/^(\w+)\/(\w+)\//); |
(&Apache::lonnet::declutter($uri)=~/^(\w+)\/(\w+)\//); |
|
|
if ($uri=~m:/adm/bombs/(.*)$:) { |
if ($uri=~m:/adm/bombs/(.*)$:) { |
$r->print(&Apache::loncommon::start_page('Error Messages')); |
$r->print(&Apache::loncommon::start_page('Error Messages')); |
# Looking for all bombs? |
# Looking for all bombs? |
&report_bombs($r,$uri); |
&report_bombs($r,$uri); |
} elsif ($uri=~/\/portfolio\//) { |
} elsif ($uri=~m|^/editupload/[^/]+/[^/]+/portfolio/|) { |
($resdomain,$resuser)= |
($resdomain,$resuser)= |
(&Apache::lonnet::declutter($uri)=~m|^(\w+)/(\w+)/portfolio|); |
(&Apache::lonnet::declutter($uri)=~m|^(\w+)/(\w+)/portfolio|); |
$r->print(&Apache::loncommon::start_page('Edit Portfolio File Catalog Information', |
$r->print(&Apache::loncommon::start_page('Edit Portfolio File Catalog Information', |
undef, |
undef, |
{'domain' => $resdomain,})); |
{'domain' => $resdomain,})); |
Line 746 sub handler {
|
Line 746 sub handler {
|
} else { |
} else { |
&pre_select_course($r,$uri); |
&pre_select_course($r,$uri); |
} |
} |
} elsif ($uri=~/^\/\~/) { |
} elsif ($uri=~m|^/~|) { |
# Construction space |
# Construction space |
$r->print(&Apache::loncommon::start_page('Edit Catalog nformation', |
$r->print(&Apache::loncommon::start_page('Edit Catalog nformation', |
undef, |
undef, |
Line 812 ENDCLEAR
|
Line 812 ENDCLEAR
|
sub present_uneditable_metadata { |
sub present_uneditable_metadata { |
my ($r,$uri) = @_; |
my ($r,$uri) = @_; |
# |
# |
|
my $uploaded = ($uri =~ m|/uploaded/|); |
my %content=(); |
my %content=(); |
# Read file |
# Read file |
foreach (split(/\,/,&Apache::lonnet::metadata($uri,'keys'))) { |
foreach (split(/\,/,&Apache::lonnet::metadata($uri,'keys'))) { |
Line 824 sub present_uneditable_metadata {
|
Line 825 sub present_uneditable_metadata {
|
my $disuri=&Apache::lonnet::clutter($uri); |
my $disuri=&Apache::lonnet::clutter($uri); |
$disuri=~s/^\/adm\/wrapper//; |
$disuri=~s/^\/adm\/wrapper//; |
# version |
# version |
my $currentversion=&Apache::lonnet::getversion($disuri); |
|
my $versiondisplay=''; |
my $versiondisplay=''; |
if ($thisversion) { |
if (!$uploaded) { |
$versiondisplay=&mt('Version').': '.$thisversion. |
my $currentversion=&Apache::lonnet::getversion($disuri); |
' ('.&mt('most recent version').': '. |
if ($thisversion) { |
($currentversion>0 ? |
$versiondisplay=&mt('Version').': '.$thisversion. |
$currentversion : |
' ('.&mt('most recent version').': '. |
&mt('information not available')).')'; |
($currentversion>0 ? |
} else { |
$currentversion : |
$versiondisplay='Version: '.$currentversion; |
&mt('information not available')).')'; |
|
} else { |
|
$versiondisplay='Version: '.$currentversion; |
|
} |
} |
} |
# crumbify displayed URL uri target prefix form size |
# crumbify displayed URL uri target prefix form size |
$disuri=&Apache::lonhtmlcommon::crumbs($disuri,undef, undef, undef,'+1'); |
$disuri=&Apache::lonhtmlcommon::crumbs($disuri,undef, undef, undef,'+1'); |
Line 853 sub present_uneditable_metadata {
|
Line 856 sub present_uneditable_metadata {
|
if (! defined($title)) { |
if (! defined($title)) { |
$title = 'Untitled Resource'; |
$title = 'Untitled Resource'; |
} |
} |
foreach ('title', |
my @fields; |
'author', |
if ($uploaded) { |
'subject', |
@fields = ('title','author','subject','keywords','notes','abstract', |
'keywords', |
'lowestgradelevel','highestgradelevel','standards','mime', |
'notes', |
'owner'); |
'abstract', |
} else { |
'lowestgradelevel', |
@fields = ('title', |
'highestgradelevel', |
'author', |
'standards', |
'subject', |
'mime', |
'keywords', |
'language', |
'notes', |
'creationdate', |
'abstract', |
'lastrevisiondate', |
'lowestgradelevel', |
'owner', |
'highestgradelevel', |
'copyright', |
'standards', |
'customdistributionfile', |
'mime', |
'sourceavail', |
'language', |
'sourcerights', |
'creationdate', |
'obsolete', |
'lastrevisiondate', |
'obsoletereplacement') { |
'owner', |
$table.='<tr><td bgcolor="#AAAAAA">'.$lt{$_}. |
'copyright', |
|
'customdistributionfile', |
|
'sourceavail', |
|
'sourcerights', |
|
'obsolete', |
|
'obsoletereplacement'); |
|
} |
|
foreach my $field (@fields) { |
|
$table.='<tr><td bgcolor="#AAAAAA">'.$lt{$field}. |
'</td><td bgcolor="#CCCCCC">'. |
'</td><td bgcolor="#CCCCCC">'. |
&prettyprint($_,$content{$_}).'</td></tr>'; |
&prettyprint($field,$content{$field}).'</td></tr>'; |
delete $content{$_}; |
delete($content{$field}); |
} |
} |
# |
# |
$r->print(<<ENDHEAD); |
$r->print(<<ENDHEAD); |
Line 890 $versiondisplay
|
Line 901 $versiondisplay
|
$table |
$table |
</table> |
</table> |
ENDHEAD |
ENDHEAD |
if ($env{'user.adv'}) { |
if (!$uploaded && $env{'user.adv'}) { |
&print_dynamic_metadata($r,$uri,\%content); |
&print_dynamic_metadata($r,$uri,\%content); |
} |
} |
return; |
return; |
Line 1136 sub present_editable_metadata {
|
Line 1147 sub present_editable_metadata {
|
my $goback=&mt('Back to Source File'); |
my $goback=&mt('Back to Source File'); |
$r->print(<<ENDBOMBS); |
$r->print(<<ENDBOMBS); |
<h1>$disuri</h1> |
<h1>$disuri</h1> |
<form method="post" name="defaultmeta"> |
<form method="post" action="" name="defaultmeta"> |
ENDBOMBS |
ENDBOMBS |
if ($showdel) { |
if ($showdel) { |
$r->print(<<ENDDEL); |
$r->print(<<ENDDEL); |
Line 1166 ENDDEL
|
Line 1177 ENDDEL
|
} |
} |
$r->print(<<ENDEDIT); |
$r->print(<<ENDEDIT); |
<h1>$displayfile</h1> |
<h1>$displayfile</h1> |
<form method="post" name="defaultmeta"> |
<form method="post" action="" name="defaultmeta"> |
ENDEDIT |
ENDEDIT |
$r->print('<script language="JavaScript">'. |
$r->print('<script type="JavaScript">'. |
&Apache::loncommon::browser_and_searcher_javascript(). |
&Apache::loncommon::browser_and_searcher_javascript(). |
'</script>'); |
'</script>'); |
my %lt=&fieldnames($file_type); |
my %lt=&fieldnames($file_type); |
my $output; |
my $output; |
my @fields; |
my @fields; |
if ($file_type eq 'portfolio') { |
if ($file_type eq 'portfolio') { |
@fields = ('author','title','subject','keywords','abstract','notes','lowestgradelevel', |
@fields = ('author','title','subject','keywords','abstract', |
|
'notes','lowestgradelevel', |
'highestgradelevel','standards'); |
'highestgradelevel','standards'); |
} else { |
} else { |
@fields = ('author','title','subject','keywords','abstract','notes', |
@fields = ('author','title','subject','keywords','abstract','notes', |
Line 1194 ENDEDIT
|
Line 1206 ENDEDIT
|
} |
} |
if (! $Apache::lonpublisher::metadatafields{'copyright'}) { |
if (! $Apache::lonpublisher::metadatafields{'copyright'}) { |
$Apache::lonpublisher::metadatafields{'copyright'}= |
$Apache::lonpublisher::metadatafields{'copyright'}= |
'default'; |
'default'; |
} |
} |
if ($file_type eq 'portfolio') { |
if ($file_type eq 'portfolio') { |
|
if (! $Apache::lonpublisher::metadatafields{'mime'}) { |
|
($Apache::lonpublisher::metadatafields{'mime'}) = |
|
( $target=~/\.(\w+)$/ ); |
|
} |
|
if (! $Apache::lonpublisher::metadatafields{'owner'}) { |
|
$Apache::lonpublisher::metadatafields{'owner'} = |
|
$env{'user.name'}.':'.$env{'user.domain'}; |
|
} |
|
|
if ($Apache::lonpublisher::metadatafields{'courserestricted'} ne 'none') { |
if ($Apache::lonpublisher::metadatafields{'courserestricted'} ne 'none') { |
$r->print(&mt('Associated with course [_1]','<strong>'.$env{$Apache::lonpublisher::metadatafields{'courserestricted'}.".description"}. |
$r->print(&mt('Associated with course [_1]','<strong>'.$env{$Apache::lonpublisher::metadatafields{'courserestricted'}.".description"}. |
'</strong>').'<br />'); |
'</strong>').'<br />'); |
Line 1262 ENDEDIT
|
Line 1283 ENDEDIT
|
'<>&"'). |
'<>&"'). |
'</'.$tag.'>'; |
'</'.$tag.'>'; |
} |
} |
if ($fn =~ m|/portfolio/|) { |
if ($fn =~ m|^$Apache::lonnet::perlvar{'lonDocRoot'}/userfiles/portfolio/|) { |
my ($path, $new_fn) = ($fn =~ m|/(portfolio.*)/([^/]*)$|); |
my ($path, $new_fn) = ($fn =~ m|/(portfolio.*)/([^/]*)$|); |
$env{'form.'.$formname}=$file_content."\n"; |
$r->print(&store_portfolio_metadata($formname,$file_content,$path, |
$env{'form.'.$formname.'.filename'}=$new_fn; |
$new_fn)); |
my $result =&Apache::lonnet::userfileupload($formname,'', |
unless ($env{'form.associate'}) { |
$path); |
$r->print(&Apache::portfolio::done("return",'/adm/portfolio')); |
|
return; |
if ($result =~ /(error|notfound)/) { |
} |
$r->print('<p><font color="red">'. |
} elsif ($fn =~ m|^$Apache::lonnet::perlvar{'lonDocRoot'}/userfiles/groups/\w+/portfolio/|) { |
&mt('Could not write metadata').', '. |
my ($path, $new_fn) = ($fn =~ m|/(groups/\w+/portfolio.*)/([^/]*)$|); |
&mt('FAIL').'</font></p>'); |
$r->print(&store_portfolio_metadata($formname,$file_content,$path,$new_fn)); |
} else { |
unless ($env{'form.associate'}) { |
$r->print('<p><font color="blue">'.&mt('Wrote Metadata'). |
$r->print(&Apache::portfolio::done("return",'/adm/portfolio')); |
' '.&Apache::lonlocal::locallocaltime(time). |
return; |
'</font></p>'); |
} |
} |
|
} 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 1289 ENDEDIT
|
Line 1309 ENDEDIT
|
' '.&Apache::lonlocal::locallocaltime(time). |
' '.&Apache::lonlocal::locallocaltime(time). |
'</font></p>'); |
'</font></p>'); |
} |
} |
|
unless ($env{'form.associate'}) { |
|
$r->print(&Apache::portfolio::done("return",'/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').'" />'); |
|
|
if ($file_type eq 'portfolio') { |
if ($file_type eq 'portfolio') { |
my ($port_path,$group) = &get_port_path_and_group($uri); |
my ($port_path,$group) = &get_port_path_and_group($uri); |
|
if ($group) { |
|
$r->print('<input type="hidden" name="group" value="'.$group.'" />'); |
|
} |
|
$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.'">'. |
'<input type="hidden" name="group" value="'.$group.'" />'. |
'<input type="hidden" name="group" value="'.$group.'" />'. |
'<input type="hidden" name="currentpath" value="'.$path.'" />'. |
'<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').'" />'); |
} |
} |
} |
} |
|
|
Line 1310 ENDEDIT
|
Line 1338 ENDEDIT
|
return; |
return; |
} |
} |
|
|
|
sub store_portfolio_metadata { |
|
my ($formname,$content,$path,$new_fn) = @_; |
|
$env{'form.'.$formname}=$content."\n"; |
|
$env{'form.'.$formname.'.filename'}=$new_fn; |
|
my $result =&Apache::lonnet::userfileupload($formname,'',$path); |
|
if ($result =~ /(error|notfound)/) { |
|
return '<p><font color="red">'. |
|
&mt('Could not write metadata').', '. |
|
&mt('FAIL').'</font></p>'; |
|
} else { |
|
return '<p><font color="blue">'.&mt('Wrote Metadata'). |
|
' '.&Apache::lonlocal::locallocaltime(time).'</font></p>'; |
|
} |
|
} |
|
|
1; |
1; |
__END__ |
__END__ |
|
|
|
|