[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm lonhtmlcommon.pm lonmeta.pm
www
lon-capa-cvs@mail.lon-capa.org
Mon, 29 Dec 2003 17:11:53 -0000
This is a MIME encoded message
--www1072717913
Content-Type: text/plain
www Mon Dec 29 12:11:53 2003 EDT
Modified files:
/loncom/interface loncommon.pm lonhtmlcommon.pm lonmeta.pm
Log:
New prettyprint function to produce consistent metadata output.
--www1072717913
Content-Type: text/plain
Content-Disposition: attachment; filename="www-20031229121153.txt"
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.165 loncom/interface/loncommon.pm:1.166
--- loncom/interface/loncommon.pm:1.165 Sat Dec 27 18:55:10 2003
+++ loncom/interface/loncommon.pm Mon Dec 29 12:11:53 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.165 2003/12/27 23:55:10 raeburn Exp $
+# $Id: loncommon.pm,v 1.166 2003/12/29 17:11:53 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1508,8 +1508,9 @@
# ------------------------------------------------------------- Aboutme Wrapper
sub aboutmewrapper {
- my ($link,$username,$domain)=@_;
- return "<a href='/adm/$domain/$username/aboutme'>$link</a>";
+ my ($link,$username,$domain,$target)=@_;
+ return "<a href='/adm/$domain/$username/aboutme'".
+ ($target?" target='$target'":'').">$link</a>";
}
# ------------------------------------------------------------ Syllabus Wrapper
@@ -1587,7 +1588,7 @@
=cut
sub copyrightdescription {
- return $cprtag{shift(@_)};
+ return &mt($cprtag{shift(@_)});
}
=pod
@@ -1636,7 +1637,7 @@
=cut
sub filedescription {
- return $fd{lc(shift(@_))};
+ return &mt($fd{lc(shift(@_))});
}
=pod
@@ -1650,7 +1651,7 @@
sub filedescriptionex {
my $ex=shift;
- return '.'.$ex.' '.$fd{lc($ex)};
+ return '.'.$ex.' '.&mt($fd{lc($ex)});
}
# End of .tab access
Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.34 loncom/interface/lonhtmlcommon.pm:1.35
--- loncom/interface/lonhtmlcommon.pm:1.34 Mon Dec 22 14:30:25 2003
+++ loncom/interface/lonhtmlcommon.pm Mon Dec 29 12:11:53 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common html routines
#
-# $Id: lonhtmlcommon.pm,v 1.34 2003/12/22 19:30:25 www Exp $
+# $Id: lonhtmlcommon.pm,v 1.35 2003/12/29 17:11:53 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -841,11 +841,15 @@
sub crumbs {
my ($uri,$target,$prefix)=@_;
my $output='<br /><tt><b><font size="+2">'.$prefix.'/';
- my $path=$prefix.'/';
- foreach (split('/',$uri)) {
- unless ($_) { next; }
- $path.=$_.'/';
- $output.='<a href="'.$path.'"'.($target?' target="'.$target.'"':'').'>'.$_.'</a>/';
+ if ($ENV{'user.adv'}) {
+ my $path=$prefix.'/';
+ foreach (split('/',$uri)) {
+ unless ($_) { next; }
+ $path.=$_.'/';
+ $output.='<a href="'.$path.'"'.($target?' target="'.$target.'"':'').'>'.$_.'</a>/';
+ }
+ } else {
+ $output.=$uri;
}
return $output.'</font></b></tt><br />';
}
Index: loncom/interface/lonmeta.pm
diff -u loncom/interface/lonmeta.pm:1.45 loncom/interface/lonmeta.pm:1.46
--- loncom/interface/lonmeta.pm:1.45 Mon Dec 29 10:10:54 2003
+++ loncom/interface/lonmeta.pm Mon Dec 29 12:11:53 2003
@@ -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 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 @@
} else {
if (defined($sum{$cat})) {
if ($evaldata{$_}) {
- $sum{$cat}.='<hr>'.$evaldata{$_};
+ $sum{$cat}.='<hr />'.$evaldata{$_};
}
} else {
$sum{$cat}=''.$evaldata{$_};
@@ -105,7 +106,7 @@
### Apache->request->print("\n<hr />".$_.': '.$returnhash{$_}.'<br />'.$returnhash{$_.'_list'});
}
#
- # Deal with 'count' seperately
+ # Deal with 'count' separately
$returnhash{'count'} = &access_count($url,$aauthor,$adomain);
return %returnhash;
@@ -145,7 +146,7 @@
my ($aname,$adom)=@_;
return &Apache::loncommon::aboutmewrapper(
&Apache::loncommon::plainname($aname,$adom),
- $aname,$adom).' <tt>['.$aname.'@'.$adom.']</tt>';
+ $aname,$adom,'preview').' <tt>['.$aname.'@'.$adom.']</tt>';
}
# -------------------------------------------------------------- Pretty display
@@ -238,6 +239,84 @@
'difficulty' => 'Degree of difficulty'
);
}
+
+# =========================================== Pretty printing of metadata field
+
+sub prettyprint {
+ my ($type,$value)=@_;
+ unless (defined($value)) { return ' '; }
+# Title
+ if ($type eq 'title') {
+ return '<font size="+1" face="arial">'.$value.'</font>';
+ }
+# 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 '<img src="'.&Apache::loncommon::icon($value).'" /> '.
+ &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('<br />',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('<br />',map {
+ my %courseinfo=&Apache::lonnet::coursedescription($_);
+ '<a href="/public/'.
+ $courseinfo{'domain'}.'/'.$courseinfo{'num'}.'/syllabus" target="preview">'.
+ $courseinfo{'description'}.'</a>';
+ } 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 @@
}
# --------------------------------------------------------------- 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 @@
} else {
$versiondisplay='Version: '.$currentversion;
}
- if ($content{'customdistributionfile'}) {
- $content{'customdistributionfile'}='<a href="'.$content{'customdistributionfile'}.
- '"><tt>'.$content{'customdistributionfile'}.'</tt></a>';
- } else {
- $content{'customdistributionfile'}='';
- }
+# obsolete
my $obsolete=$content{'obsolete'};
my $obsoletewarning='';
if (($obsolete) && ($ENV{'user.adv'})) {
@@ -335,7 +403,7 @@
'obsoletereplacement') {
$table.='<tr><td bgcolor="#AAAAAA">'.$lt{$_}.
'</td><td bgcolor="#CCCCCC">'.
- $content{$_}.' </td></tr>';
+ &prettyprint($_,$content{$_}).'</td></tr>';
delete $content{$_};
}
--www1072717913--