version 1.6, 2001/08/10 17:16:06
|
version 1.42, 2003/12/26 16:27:20
|
Line 1
|
Line 1
|
# The LearningOnline Network with CAPA |
# The LearningOnline Network with CAPA |
# |
|
# Metadata display handler |
# Metadata display handler |
# |
# |
|
# $Id$ |
|
# |
|
# Copyright Michigan State University Board of Trustees |
|
# |
|
# This file is part of the LearningOnline Network with CAPA (LON-CAPA). |
|
# |
|
# LON-CAPA is free software; you can redistribute it and/or modify |
|
# it under the terms of the GNU General Public License as published by |
|
# the Free Software Foundation; either version 2 of the License, or |
|
# (at your option) any later version. |
|
# |
|
# LON-CAPA is distributed in the hope that it will be useful, |
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
# GNU General Public License for more details. |
|
# |
|
# You should have received a copy of the GNU General Public License |
|
# along with LON-CAPA; if not, write to the Free Software |
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
# |
|
# /home/httpd/html/adm/gpl.txt |
|
# |
|
# http://www.lon-capa.org/ |
|
# |
# (TeX Content Handler |
# (TeX Content Handler |
# |
# |
# 05/29/00,05/30,10/11 Gerd Kortemeyer) |
# 05/29/00,05/30,10/11 Gerd Kortemeyer) |
# |
# |
# 10/19,10/21,10/23,11/27 Gerd Kortemeyer |
# 10/19,10/21,10/23,11/27,08/09/01,12/22,12/24,12/25 Gerd Kortemeyer |
|
|
package Apache::lonmeta; |
package Apache::lonmeta; |
|
|
use strict; |
use strict; |
use Apache::Constants qw(:common); |
use Apache::Constants qw(:common); |
use Apache::lonnet(); |
use Apache::lonnet(); |
|
use Apache::loncommon(); |
|
use Apache::lonmsg; |
|
use Apache::lonpublisher; |
|
use Apache::lonlocal; |
|
|
|
# ----------------------------------------- Fetch and evaluate dynamic metadata |
|
|
|
sub dynamicmeta { |
|
my $url=&Apache::lonnet::declutter(shift); |
|
$url=~s/\.meta$//; |
|
my ($adomain,$aauthor)=($url=~/^(\w+)\/(\w+)\//); |
|
my $regexp=$url; |
|
$regexp=~s/(\W)/\\$1/g; |
|
$regexp='___'.$regexp.'___'; |
|
my %evaldata=&Apache::lonnet::dump('nohist_resevaldata',$adomain, |
|
$aauthor,$regexp); |
|
my %sum=(); |
|
my %cnt=(); |
|
my %concat=(); |
|
my %listitems=( |
|
'course' => 'add', |
|
'goto' => 'add', |
|
'comefrom' => 'add', |
|
'avetries' => 'avg', |
|
'stdno' => 'add', |
|
'difficulty' => 'avg', |
|
'clear' => 'avg', |
|
'technical' => 'avg', |
|
'helpful' => 'avg', |
|
'correct' => 'avg', |
|
'depth' => 'avg', |
|
'comments' => 'app', |
|
'usage' => 'cnt' |
|
); |
|
while ($_=each(%evaldata)) { |
|
my ($item,$purl,$cat)=split(/___/,$_); |
|
### Apache->request->print("\n".$_.' - '.$item.'<br />'); |
|
if (defined($cnt{$cat})) { $cnt{$cat}++; } else { $cnt{$cat}=1; } |
|
unless ($listitems{$cat} eq 'app') { |
|
if (defined($sum{$cat})) { |
|
$sum{$cat}+=$evaldata{$_}; |
|
$concat{$cat}.=','.$item; |
|
} else { |
|
$sum{$cat}=$evaldata{$_}; |
|
$concat{$cat}=$item; |
|
} |
|
} else { |
|
if (defined($sum{$cat})) { |
|
if ($evaldata{$_}) { |
|
$sum{$cat}.='<hr>'.$evaldata{$_}; |
|
} |
|
} else { |
|
$sum{$cat}=''.$evaldata{$_}; |
|
} |
|
} |
|
} |
|
my %returnhash=(); |
|
while ($_=each(%cnt)) { |
|
if ($listitems{$_} eq 'avg') { |
|
$returnhash{$_}=int(($sum{$_}/$cnt{$_})*100.0+0.5)/100.0; |
|
} elsif ($listitems{$_} eq 'cnt') { |
|
$returnhash{$_}=$cnt{$_}; |
|
} else { |
|
$returnhash{$_}=$sum{$_}; |
|
} |
|
$returnhash{$_.'_list'}=$concat{$_}; |
|
### Apache->request->print("\n<hr />".$_.': '.$returnhash{$_}.'<br />'.$returnhash{$_.'_list'}); |
|
} |
|
# |
|
# Deal with 'count' seperately |
|
$returnhash{'count'} = &access_count($url,$aauthor,$adomain); |
|
|
|
return %returnhash; |
|
} |
|
|
|
sub access_count { |
|
my ($src,$author,$adomain) = @_; |
|
my %countdata=&Apache::lonnet::dump('nohist_accesscount',$adomain, |
|
$author,$src); |
|
if (! exists($countdata{$src})) { |
|
return 'Not Available'; |
|
} else { |
|
return $countdata{$src}; |
|
} |
|
} |
|
|
|
# ------------------------------------- Try to make an alt tag if there is none |
|
|
|
sub alttag { |
|
my ($base,$src)=@_; |
|
my $fullpath=&Apache::lonnet::hreflocation($base,$src); |
|
my $alttag=&Apache::lonnet::metadata($fullpath,'title').' '. |
|
&Apache::lonnet::metadata($fullpath,'subject').' '. |
|
&Apache::lonnet::metadata($fullpath,'abstract'); |
|
$alttag=~s/\s+/ /gs; |
|
$alttag=~s/\"//gs; |
|
$alttag=~s/\'//gs; |
|
$alttag=~s/\s+$//gs; |
|
$alttag=~s/^\s+//gs; |
|
if ($alttag) { return $alttag; } else |
|
{ return 'No information available'; } |
|
} |
|
|
|
# -------------------------------------------------------------- Author display |
|
|
|
sub authordisplay { |
|
my ($aname,$adom)=@_; |
|
return &Apache::loncommon::aboutmewrapper( |
|
&Apache::loncommon::plainname($aname,$adom), |
|
$aname,$adom).' <tt>['.$aname.'@'.$adom.']</tt>'; |
|
} |
|
|
|
# -------------------------------------------------------------- Pretty display |
|
|
|
sub evalgraph { |
|
my $value=shift; |
|
unless ($value) { return ''; } |
|
my $val=int($value*10.+0.5)-10; |
|
my $output='<table border=0 cellpadding=0 cellspacing=0><tr>'; |
|
if ($val>=20) { |
|
$output.='<td width=20 bgcolor="#555555">  </td>'; |
|
} else { |
|
$output.='<td width='.($val).' bgcolor="#555555"> </td>'. |
|
'<td width='.(20-$val).' bgcolor="#FF3333"> </td>'; |
|
} |
|
$output.='<td bgcolor="#FFFF33"> </td>'; |
|
if ($val>20) { |
|
$output.='<td width='.($val-20).' bgcolor="#33FF33"> </td>'. |
|
'<td width='.(40-$val).' bgcolor="#555555"> </td>'; |
|
} else { |
|
$output.='<td width=20 bgcolor="#555555">  </td>'; |
|
} |
|
$output.='<td> ('.$value.') </td></tr></table>'; |
|
return $output; |
|
} |
|
|
|
sub diffgraph { |
|
my $value=shift; |
|
unless ($value) { return ''; } |
|
my $val=int(40.0*$value+0.5); |
|
my @colors=('#FF9933','#EEAA33','#DDBB33','#CCCC33', |
|
'#BBDD33','#CCCC33','#DDBB33','#EEAA33'); |
|
my $output='<table border=0 cellpadding=0 cellspacing=0><tr>'; |
|
for (my $i=0;$i<8;$i++) { |
|
if ($val>$i*5) { |
|
$output.='<td width=5 bgcolor="'.$colors[$i].'"> </td>'; |
|
} else { |
|
$output.='<td width=5 bgcolor="#555555"> </td>'; |
|
} |
|
} |
|
$output.='<td> ('.$value.') </td></tr></table>'; |
|
return $output; |
|
} |
|
|
# ================================================================ Main Handler |
# ================================================================ Main Handler |
|
|
sub handler { |
sub handler { |
my $r=shift; |
my $r=shift; |
|
|
|
my $loaderror=&Apache::lonnet::overloaderror($r); |
|
if ($loaderror) { return $loaderror; } |
|
|
|
|
|
my $uri=$r->uri; |
|
|
|
unless ($uri=~/^\/\~/) { |
|
# =========================================== This is not in construction space |
|
my ($resdomain,$resuser)= |
|
(&Apache::lonnet::declutter($uri)=~/^(\w+)\/(\w+)\//); |
|
|
|
$loaderror= |
|
&Apache::lonnet::overloaderror($r, |
|
&Apache::lonnet::homeserver($resuser,$resdomain)); |
|
if ($loaderror) { return $loaderror; } |
|
|
my %content=(); |
my %content=(); |
|
|
# ----------------------------------------------------------- Set document type |
# ----------------------------------------------------------- Set document type |
|
|
$r->content_type('text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
$r->send_http_header; |
$r->send_http_header; |
|
|
return OK if $r->header_only; |
return OK if $r->header_only; |
|
|
# ------------------------------------------------------------------- Read file |
# ------------------------------------------------------------------- Read file |
|
foreach (split(/\,/,&Apache::lonnet::metadata($uri,'keys'))) { |
my $uri=$r->uri; |
|
map { |
|
$content{$_}=&Apache::lonnet::metadata($uri,$_); |
$content{$_}=&Apache::lonnet::metadata($uri,$_); |
} split(/\,/,&Apache::lonnet::metadata($uri,'keys')); |
} |
|
|
# ------------------------------------------------------------------ Hide stuff |
# ------------------------------------------------------------------ Hide stuff |
if (!$ENV{'user.adv'}) { |
|
map { |
unless ($ENV{'user.adv'}) { |
$content{$_}='<i>- not displayed -</i>'; |
foreach ('keywords','notes','abstract','subject') { |
} ('keywords','notes','abstract','subject'); |
$content{$_}='<i>- '.&mt('not displayed').' -</i>'; |
|
} |
} |
} |
|
|
# --------------------------------------------------------------- Render Output |
# --------------------------------------------------------------- Render Output |
|
my ($thisversion)=($uri=~/\.(\d+)\.(\w+)\.meta$/); |
|
my $creationdate=&Apache::lonlocal::locallocaltime( |
|
&Apache::loncommon::unsqltime($content{'creationdate'})); |
|
my $lastrevisiondate=&Apache::lonlocal::locallocaltime( |
|
&Apache::loncommon::unsqltime($content{'lastrevisiondate'})); |
|
my $language=&Apache::loncommon::languagedescription($content{'language'}); |
|
my $mime=&Apache::loncommon::filedescription($content{'mime'}); |
|
my $disuri=&Apache::lonnet::declutter($uri); |
|
$disuri=~s/\.meta$//; |
|
my $currentversion=&Apache::lonnet::getversion($disuri); |
|
my $author=$content{'author'}; |
|
$author=~s/(\w+)(\:|\@)(\w+)/&authordisplay($1,$3)/gse; |
|
my $owner=$content{'owner'}; |
|
$owner=~s/(\w+)(\:|\@)(\w+)/&authordisplay($1,$3)/gse; |
|
my $versiondisplay=''; |
|
if ($thisversion) { |
|
$versiondisplay=&mt('Version').': '.$thisversion. |
|
' ('.&mt('most recent version').': '.$currentversion.')'; |
|
} else { |
|
$versiondisplay='Version: '.$currentversion; |
|
} |
|
my $customdistributionfile=''; |
|
if ($content{'customdistributionfile'}) { |
|
$customdistributionfile='<a href="'.$content{'customdistributionfile'}. |
|
'"><tt>'.$content{'customdistributionfile'}.'</tt></a>'; |
|
} |
|
|
|
my $obsolete=$content{'obsolete'}; |
|
my $obsoletereplace=$content{'obsoletereplacement'}; |
|
my $obsoletewarning=''; |
|
if (($obsolete) && ($ENV{'user.adv'})) { |
|
$obsoletewarning='<p><font color="red">'.&mt('This resource has been marked obsolete by the author(s)').'</font></p>'; |
|
} |
|
|
my $creationdate=localtime($content{'creationdate'}); |
my %lt=&Apache::lonlocal::texthash( |
my $lastrevisiondate=localtime($content{'lastrevisiondate'}); |
'au' =>'Author(s)', |
|
'sb' => 'Subject', |
|
'kw' => 'Keyword(s)', |
|
'no' => 'Notes', |
|
'ab' => 'Abstract', |
|
'lg' => 'Lowest Grade Level', |
|
'hg' => 'Highest Grade Level', |
|
'st' => 'Standards', |
|
'mi' => 'MIME Type', |
|
'la' => 'Language', |
|
'cd' => 'Creation Date', |
|
'pu' => 'Publisher/Owner', |
|
'co' => 'Copyright/Distribution', |
|
'cf' => 'Custom Distribution File', |
|
'ob' => 'Obsolete', |
|
'or' => |
|
'Suggested Replacement for Obsolete File'); |
|
my $bodytag=&Apache::loncommon::bodytag |
|
('Catalog Information','','','',$resdomain); |
$r->print(<<ENDHEAD); |
$r->print(<<ENDHEAD); |
<html><head><title>Catalog Information</title></head> |
<html><head><title>Catalog Information</title></head> |
<body bgcolor="#FFFFFF"> |
$bodytag |
<h1>Catalog Information</h1> |
|
<h2>$content{'title'}</h2> |
<h2>$content{'title'}</h2> |
<h3>Author(s): $content{'author'}</h3> |
<h3><tt>$disuri</tt></h3> |
<b>Subject:</b> $content{'subject'}<br> |
$obsoletewarning |
<b>Keyword(s):</b> $content{'keywords'}<br> |
$versiondisplay<br /> |
<b>Notes:</b> $content{'notes'}<br> |
<table cellspacing=2 border=0> |
<b>Abstract:</b> |
<tr><td bgcolor='#AAAAAA'>$lt{'au'}</td> |
<blockquote>$content{'abstract'}</blockquote> |
<td bgcolor="#CCCCCC">$author </td></tr> |
<hr> |
<tr><td bgcolor='#AAAAAA'>$lt{'sb'}</td> |
<b>MIME Type:</b> $content{'mime'}<br> |
<td bgcolor="#CCCCCC">$content{'subject'} </td></tr> |
<b>Language:</b> $content{'language'}<br> |
<tr><td bgcolor='#AAAAAA'>$lt{'kw'}</td> |
<b>Creation Date:</b> $creationdate<br> |
<td bgcolor="#CCCCCC">$content{'keywords'} </td></tr> |
<b>Last Revision Date:</b> $lastrevisiondate<br> |
<tr><td bgcolor='#AAAAAA'>$lt{'no'}</td> |
<b>Publisher/Owner:</b> $content{'owner'}<br> |
<td bgcolor="#CCCCCC">$content{'notes'} </td></tr> |
<b>Copyright/Distribution:</b> $content{'copyright'} |
<tr><td bgcolor='#AAAAAA'>$lt{'ab'}</td> |
<hr> |
<td bgcolor="#CCCCCC">$content{'abstract'} </td></tr> |
|
<tr><td bgcolor='#AAAAAA'>$lt{'lg'}</td> |
|
<td bgcolor="#CCCCCC">$content{'lowestgradelevel'} </td></tr> |
|
<tr><td bgcolor='#AAAAAA'>$lt{'hg'}</td> |
|
<td bgcolor="#CCCCCC">$content{'highestgradelevel'} </td></tr> |
|
<tr><td bgcolor='#AAAAAA'>$lt{'st'}</td> |
|
<td bgcolor="#CCCCCC">$content{'standards'} </td></tr> |
|
<tr><td bgcolor='#AAAAAA'>$lt{'mi'}</td> |
|
<td bgcolor="#CCCCCC">$mime ($content{'mime'}) </td></tr> |
|
<tr><td bgcolor='#AAAAAA'>$lt{'la'}</td> |
|
<td bgcolor="#CCCCCC">$language </td></tr> |
|
<tr><td bgcolor='#AAAAAA'>$lt{'cd'}</td> |
|
<td bgcolor="#CCCCCC">$creationdate </td></tr> |
|
<tr><td bgcolor='#AAAAAA'> |
|
Last Revision Date</td><td bgcolor="#CCCCCC">$lastrevisiondate </td></tr> |
|
<tr><td bgcolor='#AAAAAA'>$lt{'pu'}</td> |
|
<td bgcolor="#CCCCCC">$owner </td></tr> |
|
<tr><td bgcolor='#AAAAAA'>$lt{'co'}</td> |
|
<td bgcolor="#CCCCCC">$content{'copyright'} </td></tr> |
|
<tr><td bgcolor='#AAAAAA'>$lt{'cf'}</td> |
|
<td bgcolor="#CCCCCC">$customdistributionfile </td></tr> |
|
<tr><td bgcolor='#AAAAAA'>$lt{'ob'}</td> |
|
<td bgcolor="#CCCCCC">$obsolete </td></tr> |
|
<tr><td bgcolor='#AAAAAA'>$lt{'or'}</td> |
|
<td bgcolor="#CCCCCC">$obsoletereplace </td></tr> |
|
</table> |
ENDHEAD |
ENDHEAD |
delete($content{'title'}); |
delete($content{'title'}); |
delete($content{'author'}); |
delete($content{'author'}); |
Line 79 ENDHEAD
|
Line 343 ENDHEAD
|
delete($content{'lastrevisiondate'}); |
delete($content{'lastrevisiondate'}); |
delete($content{'owner'}); |
delete($content{'owner'}); |
delete($content{'copyright'}); |
delete($content{'copyright'}); |
map { |
delete($content{'customdistributionfile'}); |
|
delete($content{'obsolete'}); |
|
delete($content{'obsoletereplacement'}); |
|
if ($ENV{'user.adv'}) { |
|
# ------------------------------------------------------------ Dynamic Metadata |
|
$r->print( |
|
'<h3>'.&mt('Dynamic Metadata').' ('. |
|
&mt('updated periodically').')</h3>'.&mt('Processing'). |
|
' ...<br>'); |
|
$r->rflush(); |
|
my %items=&Apache::lonlocal::texthash( |
|
'count' => 'Network-wide number of accesses (hits)', |
|
'course' => 'Network-wide number of courses using resource', |
|
'usage' => 'Number of resources using or importing resource', |
|
'goto' => 'Number of resources that follow this resource in maps', |
|
'comefrom' => 'Number of resources that lead up to this resource in maps', |
|
'clear' => 'Material presented in clear way', |
|
'depth' => 'Material covered with sufficient depth', |
|
'helpful' => 'Material is helpful', |
|
'correct' => 'Material appears to be correct', |
|
'technical' => 'Resource is technically correct', |
|
'avetries' => 'Average number of tries till solved', |
|
'stdno' => 'Total number of students who have worked on this problem', |
|
'difficulty' => 'Degree of difficulty'); |
|
my %dynmeta=&dynamicmeta($uri); |
|
$r->print( |
|
'</table><h4>'.&mt('Access and Usage Statistics').'</h4><table cellspacing=2 border=0>'); |
|
foreach ('count') { |
|
$r->print( |
|
'<tr><td bgcolor="#AAAAAA">'.$items{$_}.'</td><td bgcolor="#CCCCCC">'. |
|
$dynmeta{$_}." </td></tr>\n"); |
|
} |
|
foreach my $cat ('usage','comefrom','goto') { |
|
$r->print( |
|
'<tr><td bgcolor="#AAAAAA">'.$items{$cat}.'</td><td bgcolor="#CCCCCC">'. |
|
$dynmeta{$cat}.'<font size="-1"><ul>'.join("\n", |
|
map { my $murl=$_; |
|
'<li><a href="'.&Apache::lonnet::clutter($murl).'" target="preview">'. |
|
&Apache::lonnet::gettitle($murl).' [<tt>'.$murl |
|
.'</tt>]</a></li>' } |
|
split(/\,/,$dynmeta{$cat.'_list'}))."</ul></font></td></tr>\n"); |
|
} |
|
foreach my $cat ('course') { |
|
$r->print( |
|
'<tr><td bgcolor="#AAAAAA">'.$items{$cat}.'</td><td bgcolor="#CCCCCC">'. |
|
$dynmeta{$cat}.'<font size="-1"><ul>'.join("\n", |
|
map { my %courseinfo=&Apache::lonnet::coursedescription($_); |
|
'<li><a href="/public/'. |
|
$courseinfo{'domain'}.'/'.$courseinfo{'num'}.'/syllabus" target="preview">'. |
|
$courseinfo{'description'}.'</a></li>' } |
|
split(/\,/,$dynmeta{$cat.'_list'}))."</ul></font></td></tr>\n"); |
|
} |
|
$r->print('</table>'); |
|
if ($uri=~/\.(problem|exam|quiz|assess|survey|form)\.meta$/) { |
|
$r->print( |
|
'<h4>'.&mt('Assessment Statistical Data').'</h4><table cellspacing=2 border=0>'); |
|
foreach ('stdno','avetries') { |
|
$r->print( |
|
'<tr><td bgcolor="#AAAAAA">'.$items{$_}.'</td><td bgcolor="#CCCCCC">'. |
|
$dynmeta{$_}." </td></tr>\n"); |
|
} |
|
foreach ('difficulty') { |
|
$r->print( |
|
'<tr><td bgcolor="#AAAAAA">'.$items{$_}.'</td><td bgcolor="#CCCCCC">'. |
|
&diffgraph($dynmeta{$_})."</td></tr>\n"); |
|
} |
|
$r->print('</table>'); |
|
} |
|
$r->print('<h4>'.&mt('Evaluation Data').'</h4><table cellspacing=2 border=0>'); |
|
foreach ('clear','depth','helpful','correct','technical') { |
|
$r->print( |
|
'<tr><td bgcolor="#AAAAAA">'.$items{$_}.'</td><td bgcolor="#CCCCCC">'. |
|
&evalgraph($dynmeta{$_})."</td></tr>\n"); |
|
} |
|
$r->print('</table>'); |
|
$disuri=~/^(\w+)\/(\w+)\//; |
|
if ((($ENV{'user.domain'} eq $1) && ($ENV{'user.name'} eq $2)) |
|
|| ($ENV{'user.role.ca./'.$1.'/'.$2})) { |
|
$r->print( |
|
'<h4>'.&mt('Evaluation Comments').' ('.&mt('visible to author and co-authors only').')</h4>'. |
|
'<blockquote>'.$dynmeta{'comments'}.'</blockquote>'); |
|
$r->print( |
|
'<h4>'.&mt('Error Messages').' ('. |
|
&mt('visible to author and co-authors only').')</h4>'); |
|
my %errormsgs=&Apache::lonnet::dump('nohist_res_msgs',$1,$2); |
|
foreach (keys %errormsgs) { |
|
if ($_=~/^\Q$disuri\E\_\d+$/) { |
|
my %content=&Apache::lonmsg::unpackagemsg($errormsgs{$_}); |
|
$r->print('<b>'.$content{'time'}.'</b>: '.$content{'message'}. |
|
'<br />'); |
|
} |
|
} |
|
} |
|
# ------------------------------------------------------------- All other stuff |
|
$r->print( |
|
'<h3>'.&mt('Additional Metadata (non-standard, parameters, exports)').'</h3>'); |
|
foreach (sort keys %content) { |
my $name=$_; |
my $name=$_; |
my $display=&Apache::lonnet::metadata($uri,$name.'.display'); |
unless ($name=~/\.display$/) { |
unless ($display) { $display=$name; }; |
my $display=&Apache::lonnet::metadata($uri,$name.'.display'); |
my $otherinfo=''; |
unless ($display) { $display=$name; }; |
map { |
my $otherinfo=''; |
if (defined(&Apache::lonnet::metadata($uri,$name.'.'.$_))) { |
foreach ('name','part','type','default') { |
$otherinfo.=' '.$_.'='. |
if (defined(&Apache::lonnet::metadata($uri,$name.'.'.$_))) { |
&Apache::lonnet::metadata($uri,$name.'.'.$_).'; '; |
$otherinfo.=' '.$_.'='. |
} |
&Apache::lonnet::metadata($uri,$name.'.'.$_).'; '; |
} ('name','part','type','default'); |
} |
$r->print('<b>'.$display.':</b> '.$content{$name}); |
} |
if ($otherinfo) { |
$r->print('<b>'.$display.':</b> '.$content{$name}); |
$r->print(' ('.$otherinfo.')'); |
if ($otherinfo) { |
|
$r->print(' ('.$otherinfo.')'); |
|
} |
|
$r->print("<br>\n"); |
} |
} |
$r->print("<br>\n"); |
} |
} sort keys %content; |
} |
$r->print('</body></html>'); |
# ===================================================== End Resource Space Call |
return OK; |
} else { |
|
# ===================================================== Construction Space Call |
|
|
|
# ----------------------------------------------------------- Set document type |
|
|
|
$r->content_type('text/html'); |
|
$r->send_http_header; |
|
|
|
return OK if $r->header_only; |
|
# ---------------------------------------------------------------------- Header |
|
my $bodytag=&Apache::loncommon::bodytag('Edit Catalog Information'); |
|
my $disuri=$uri; |
|
my $fn=&Apache::lonnet::filelocation('',$uri); |
|
$disuri=~s/^\/\~\w+//; |
|
$disuri=~s/\.meta$//; |
|
my $displayfile='Catalog Information for '.$disuri; |
|
if ($disuri=~/\/default$/) { |
|
my $dir=$disuri; |
|
$dir=~s/default$//; |
|
$displayfile=&mt('Default Cataloging Information for Directory').' '. |
|
$dir; |
|
} |
|
%Apache::lonpublisher::metadatafields=(); |
|
%Apache::lonpublisher::metadatakeys=(); |
|
&Apache::lonpublisher::metaeval(&Apache::lonnet::getfile($fn)); |
|
$r->print(<<ENDEDIT); |
|
<html><head><title>Edit Catalog Information</title></head> |
|
$bodytag |
|
<h1>$displayfile</h1> |
|
<form method="post"> |
|
ENDEDIT |
|
foreach ('author','title','subject','keywords','abstract','notes', |
|
'copyright','customdistributionfile','language', |
|
'obsolete','obsoletereplacement') { |
|
if ($ENV{'form.new_'.$_}) { |
|
$Apache::lonpublisher::metadatafields{$_}=$ENV{'form.new_'.$_}; |
|
} |
|
if (m/copyright/) { |
|
$r->print(&Apache::lonpublisher::selectbox($_,'new_'.$_, |
|
($Apache::lonpublisher::metadatafields{$_}? |
|
$Apache::lonpublisher::metadatafields{$_}:'default'), |
|
\&Apache::loncommon::copyrightdescription, |
|
(&Apache::loncommon::copyrightids))); |
|
} elsif (m/language/) { |
|
$r->print(&Apache::lonpublisher::selectbox($_,'new_'.$_, |
|
$Apache::lonpublisher::metadatafields{$_}, |
|
\&Apache::loncommon::languagedescription, |
|
(&Apache::loncommon::languageids))); |
|
} else { |
|
$r->print(&Apache::lonpublisher::textfield($_,'new_'.$_, |
|
$Apache::lonpublisher::metadatafields{$_})); |
|
} |
|
} |
|
if ($ENV{'form.store'}) { |
|
my $mfh; |
|
unless ($mfh=Apache::File->new('>'.$fn)) { |
|
$r->print( |
|
'<p><font color=red>'.&mt('Could not write metadata').', '. |
|
&mt('FAIL').'</font>'); |
|
} else { |
|
foreach (sort keys %Apache::lonpublisher::metadatafields) { |
|
unless ($_=~/\./) { |
|
my $unikey=$_; |
|
$unikey=~/^([A-Za-z]+)/; |
|
my $tag=$1; |
|
$tag=~tr/A-Z/a-z/; |
|
print $mfh "\n\<$tag"; |
|
foreach |
|
(split(/\,/,$Apache::lonpublisher::metadatakeys{$unikey})) { |
|
my $value= |
|
$Apache::lonpublisher::metadatafields{$unikey.'.'.$_}; |
|
$value=~s/\"/\'\'/g; |
|
print $mfh ' '.$_.'="'.$value.'"'; |
|
} |
|
print $mfh '>'. |
|
&HTML::Entities::encode($Apache::lonpublisher::metadatafields{$unikey}) |
|
.'</'.$tag.'>'; |
|
} |
|
} |
|
$r->print('<p>'.&mt('Wrote Metadata')); |
|
} |
|
} |
|
$r->print( |
|
'<br /><input type="submit" name="store" value="'. |
|
&mt('Store Catalog Information').'"></form></body></html>'); |
|
return OK; |
|
} |
} |
} |
|
|
1; |
1; |