[LON-CAPA-cvs] cvs: loncom /interface/spreadsheet Spreadsheet.pm
matthew
lon-capa-cvs@mail.lon-capa.org
Wed, 14 Jan 2004 16:47:39 -0000
matthew Wed Jan 14 11:47:39 2004 EDT
Modified files:
/loncom/interface/spreadsheet Spreadsheet.pm
Log:
Fix loading of spreadsheet xml from published space. Commented out code
for xml output and fixed some for xml output. For inclusion in 1.1.x.
Index: loncom/interface/spreadsheet/Spreadsheet.pm
diff -u loncom/interface/spreadsheet/Spreadsheet.pm:1.32 loncom/interface/spreadsheet/Spreadsheet.pm:1.33
--- loncom/interface/spreadsheet/Spreadsheet.pm:1.32 Mon Dec 8 14:43:03 2003
+++ loncom/interface/spreadsheet/Spreadsheet.pm Wed Jan 14 11:47:39 2004
@@ -1,5 +1,5 @@
#
-# $Id: Spreadsheet.pm,v 1.32 2003/12/08 19:43:03 matthew Exp $
+# $Id: Spreadsheet.pm,v 1.33 2004/01/14 16:47:39 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -160,7 +160,8 @@
if ($newfilename !~ /\w/ || $newfilename =~ /^\W*$/) {
$newfilename = 'default_'.$self->{'type'};
}
- if ($newfilename !~ /^default\.$self->{'type'}$/ ) {
+ if ($newfilename !~ /^default\.$self->{'type'}$/ &&
+ $newfilename !~ /^\/res\/(.*)spreadsheet$/) {
if ($newfilename !~ /_$self->{'type'}$/) {
$newfilename =~ s/[\s_]*$//;
$newfilename .= '_'.$self->{'type'};
@@ -1209,6 +1210,9 @@
} elsif ($outputmode eq 'csv') {
$self->compute($r);
$self->outsheet_csv($r);
+ } elsif ($outputmode eq 'xml') {
+# $self->compute($r);
+ $self->outsheet_xml($r);
}
$self->cleanup();
return;
@@ -1356,6 +1360,8 @@
description => 'HTML'},
{value => 'excel',
description => 'Excel'},
+# {value => 'xml',
+# description => 'XML'},
{value => 'csv',
description => 'Comma Separated Values'},);
}
@@ -1555,13 +1561,16 @@
my $col = $1;
$Str .= '<template col="'.$col.'">'.$formula.'</template>'."\n";
} else {
- my ($row,$col) = ($cell =~ /^([A-z])(\d+)/);
+ my ($col,$row) = ($cell =~ /^([A-z])(\d+)/);
next if (! defined($row) || ! defined($col));
- $Str .= '<field row="'.$row.'" col="'.$col.'" >'.$formula.'</cell>'
+ next if ($row != 0);
+ $Str .=
+ '<field row="'.$row.'" col="'.$col.'" >'.$formula.'</field>'
."\n";
}
}
$Str.="</spreadsheet>";
+# $r->print("<pre>\n\n\n".$Str."\n\n\n</pre>");
return $Str;
}
@@ -1643,7 +1652,7 @@
# Not cached, need to read
if (! defined($filename)) {
$formulas = $self->load_system_default_sheet();
- } elsif($self->filename() =~ /^\/res\/.*\.spreadsheet$/) {
+ } elsif($filename =~ /^\/res\/.*\.spreadsheet$/) {
# Load a spreadsheet definition file
my $sheetxml=&Apache::lonnet::getfile
(&Apache::lonnet::filelocation('',$filename));