[LON-CAPA-cvs] cvs: loncom /interface lonhelper.pm
bowersj2
lon-capa-cvs@mail.lon-capa.org
Wed, 07 May 2003 18:13:13 -0000
bowersj2 Wed May 7 14:13:13 2003 EDT
Modified files:
/loncom/interface lonhelper.pm
Log:
File states now show problem statuses.
Index: loncom/interface/lonhelper.pm
diff -u loncom/interface/lonhelper.pm:1.19 loncom/interface/lonhelper.pm:1.20
--- loncom/interface/lonhelper.pm:1.19 Mon May 5 14:05:21 2003
+++ loncom/interface/lonhelper.pm Wed May 7 14:13:13 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# .helper XML handler to implement the LON-CAPA helper
#
-# $Id: lonhelper.pm,v 1.19 2003/05/05 18:05:21 bowersj2 Exp $
+# $Id: lonhelper.pm,v 1.20 2003/05/07 18:13:13 bowersj2 Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1876,7 +1876,7 @@
$result .= '<br /><font color="#FF0000">' . $self->{ERROR_MSG} . '</font><br /><br />';
}
- $result .= '<table border="0" cellpadding="1" cellspacing="1">';
+ $result .= '<table border="0" cellpadding="2" cellspacing="0">';
# Keeps track if there are no choices, prints appropriate error
# if there are none.
@@ -1893,14 +1893,16 @@
}
my $fileName = $subdir .'/'. $file;
if (&$filterFunc($file)) {
- $result .= '<tr><td align="right">' .
+ (my $status, my $color) = @{fileState($subdir, $file)};
+ $result .= '<tr><td align="right"' . " bgcolor='$color'>" .
"<input type='$type' name='" . $var
. ".forminput' value='" . HTML::Entities::encode($fileName) .
"'";
if (!$self->{'multichoice'} && $choices == 0) {
$result .= ' checked';
}
- $result .= "/></td><td>" . $file . "</td></tr>\n";
+ $result .= "/></td><td bgcolor='$color'>" . $file .
+ "</td><td bgcolor='$color'>$status</td></tr>\n";
$choices++;
}
}
@@ -1914,6 +1916,37 @@
$result .= $buttons;
return $result;
+}
+
+# Determine the state of the file: Published, unpublished, modified.
+# Return the color it should be in and a label as a two-element array
+# reference.
+# Logic lifted from lonpubdir.pm, even though I don't know that it's still
+# the most right thing to do.
+
+sub fileState {
+ my $constructionSpaceDir = shift;
+ my $file = shift;
+
+ my $docroot = $Apache::lonnet::perlvar{'lonDocRoot'};
+ my $subdirpart = $constructionSpaceDir;
+ $subdirpart =~ s/^\/home\/$ENV{'user.name'}\/public_html//;
+ my $resdir = $docroot . '/res/' . $ENV{'user.domain'} . '/' . $ENV{'user.name'} .
+ $subdirpart;
+
+ my @constructionSpaceFileStat = stat($constructionSpaceDir . '/' . $file);
+ my @resourceSpaceFileStat = stat($resdir . '/' . $file);
+ if (!@resourceSpaceFileStat) {
+ return ['Unpublished', '#FFCCCC'];
+ }
+
+ my $constructionSpaceFileModified = $constructionSpaceFileStat[9];
+ my $resourceSpaceFileModified = $resourceSpaceFileStat[9];
+
+ if ($constructionSpaceFileModified > $resourceSpaceFileModified) {
+ return ['Modified', '#FFFFCC'];
+ }
+ return ['Published', '#CCFFCC'];
}
sub postprocess {