--- loncom/interface/lonmeta.pm 2003/12/29 15:10:54 1.45
+++ loncom/interface/lonmeta.pm 2003/12/29 17:11:53 1.46
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Metadata display handler
#
-# $Id: lonmeta.pm,v 1.45 2003/12/29 15:10:54 www Exp $
+# $Id: lonmeta.pm,v 1.46 2003/12/29 17:11:53 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -32,6 +32,7 @@ use strict;
use Apache::Constants qw(:common);
use Apache::lonnet();
use Apache::loncommon();
+use Apache::lonhtmlcommon();
use Apache::lonmsg;
use Apache::lonpublisher;
use Apache::lonlocal;
@@ -85,7 +86,7 @@ sub dynamicmeta {
} else {
if (defined($sum{$cat})) {
if ($evaldata{$_}) {
- $sum{$cat}.='
'.$evaldata{$_};
+ $sum{$cat}.='
'.$evaldata{$_};
}
} else {
$sum{$cat}=''.$evaldata{$_};
@@ -105,7 +106,7 @@ sub dynamicmeta {
### Apache->request->print("\n
".$_.': '.$returnhash{$_}.'
'.$returnhash{$_.'_list'});
}
#
- # Deal with 'count' seperately
+ # Deal with 'count' separately
$returnhash{'count'} = &access_count($url,$aauthor,$adomain);
return %returnhash;
@@ -145,7 +146,7 @@ sub authordisplay {
my ($aname,$adom)=@_;
return &Apache::loncommon::aboutmewrapper(
&Apache::loncommon::plainname($aname,$adom),
- $aname,$adom).' ['.$aname.'@'.$adom.']';
+ $aname,$adom,'preview').' ['.$aname.'@'.$adom.']';
}
# -------------------------------------------------------------- Pretty display
@@ -238,6 +239,84 @@ sub fieldnames {
'difficulty' => 'Degree of difficulty'
);
}
+
+# =========================================== Pretty printing of metadata field
+
+sub prettyprint {
+ my ($type,$value)=@_;
+ unless (defined($value)) { return ' '; }
+# Title
+ if ($type eq 'title') {
+ return ''.$value.'';
+ }
+# Dates
+ if (($type eq 'creationdate') ||
+ ($type eq 'lastrevisiondate')) {
+ return &Apache::lonlocal::locallocaltime(
+ &Apache::lonmysql::unsqltime($value));
+ }
+# Language
+ if ($type eq 'language') {
+ return &Apache::loncommon::languagedescription($value);
+ }
+# Copyright
+ if ($type eq 'copyright') {
+ return &Apache::loncommon::copyrightdescription($value);
+ }
+# MIME
+ if ($type eq 'mime') {
+ return ' '.
+ &Apache::loncommon::filedescription($value);
+ }
+# Person
+ if (($type eq 'author') ||
+ ($type eq 'owner') ||
+ ($type eq 'modifyinguser') ||
+ ($type eq 'authorspace')) {
+ $value=~s/(\w+)(\:|\@)(\w+)/&authordisplay($1,$3)/gse;
+ return $value;
+ }
+# File
+ if (($type eq 'customdistributionfile') ||
+ ($type eq 'obsoletereplacement') ||
+ ($type eq 'goto_list') ||
+ ($type eq 'comefrom_list') ||
+ ($type eq 'sequsage_list')) {
+ return join('
',map {
+ &Apache::lonnet::gettitle($_).' ['.
+ &Apache::lonhtmlcommon::crumbs(&Apache::lonnet::clutter($_),'preview').']';
+ } split(/\s*\,\s*/,$value));
+ }
+# Evaluations
+ if (($type eq 'clear') ||
+ ($type eq 'depth') ||
+ ($type eq 'helpful') ||
+ ($type eq 'correct') ||
+ ($type eq 'technical')) {
+ return &evalgraph($value);
+ }
+# Difficulty
+ if ($type eq 'difficulty') {
+ return &diffgraph($value);
+ }
+# List of courses
+ if ($type=~/\_list/) {
+ return join('
',map {
+ my %courseinfo=&Apache::lonnet::coursedescription($_);
+ ''.
+ $courseinfo{'description'}.'';
+ } split(/\s*\,\s*/,$value));
+ }
+# No pretty print found
+ return $value;
+}
+# ============================================== Pretty input of metadata field
+
+sub prettyinput {
+ my ($type,$value,$fieldname)=@_;
+}
+
# ================================================================ Main Handler
sub handler {
@@ -281,19 +360,13 @@ sub handler {
}
# --------------------------------------------------------------- Render Output
+# displayed url
my ($thisversion)=($uri=~/\.(\d+)\.(\w+)\.meta$/);
- $content{'creationdate'}=&Apache::lonlocal::locallocaltime(
- &Apache::lonmysql::unsqltime($content{'creationdate'}));
- $content{'lastrevisiondate'}=&Apache::lonlocal::locallocaltime(
- &Apache::lonmysql::unsqltime($content{'lastrevisiondate'}));
- $content{'language'}=&Apache::loncommon::languagedescription($content{'language'});
- $content{'mime'}=&Apache::loncommon::filedescription($content{'mime'});
- my $disuri=&Apache::lonnet::declutter($uri);
+ my $disuri=&Apache::lonnet::clutter($uri);
$disuri=~s/\.meta$//;
+ $disuri=&Apache::lonhtmlcommon::crumbs($disuri);
+# version
my $currentversion=&Apache::lonnet::getversion($disuri);
- my $author=$content{'author'};
- $content{'author'}=~s/(\w+)(\:|\@)(\w+)/&authordisplay($1,$3)/gse;
- $content{'owner'}=~s/(\w+)(\:|\@)(\w+)/&authordisplay($1,$3)/gse;
my $versiondisplay='';
if ($thisversion) {
$versiondisplay=&mt('Version').': '.$thisversion.
@@ -301,12 +374,7 @@ sub handler {
} else {
$versiondisplay='Version: '.$currentversion;
}
- if ($content{'customdistributionfile'}) {
- $content{'customdistributionfile'}=''.$content{'customdistributionfile'}.'';
- } else {
- $content{'customdistributionfile'}='';
- }
+# obsolete
my $obsolete=$content{'obsolete'};
my $obsoletewarning='';
if (($obsolete) && ($ENV{'user.adv'})) {
@@ -335,7 +403,7 @@ sub handler {
'obsoletereplacement') {
$table.=''.$lt{$_}.
' | '.
- $content{$_}.' |
';
+ &prettyprint($_,$content{$_}).'';
delete $content{$_};
}