--- loncom/interface/spreadsheet/lonspreadsheet.pm 2003/06/19 16:04:06 1.13 +++ loncom/interface/spreadsheet/lonspreadsheet.pm 2006/04/10 22:52:36 1.45 @@ -1,5 +1,5 @@ # -# $Id: lonspreadsheet.pm,v 1.13 2003/06/19 16:04:06 matthew Exp $ +# $Id: lonspreadsheet.pm,v 1.45 2006/04/10 22:52:36 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -54,12 +54,16 @@ built-in functions. package Apache::lonspreadsheet; use strict; +use warnings FATAL=>'all'; +no warnings 'uninitialized'; use Apache::classcalc(); use Apache::studentcalc(); use Apache::assesscalc(); use Apache::Constants qw(:common :http); use Apache::lonnet; use Apache::lonhtmlcommon; +use Apache::lonlocal; +use Apache::loncoursedata(); use HTML::Entities(); ## @@ -68,8 +72,8 @@ use HTML::Entities(); sub textfield { my ($title,$name,$value)=@_; - return "\n

$title:
". - ''; + return "\n

$title:
". + ''; } sub hiddenfield { @@ -79,11 +83,11 @@ sub hiddenfield { sub selectbox { my ($title,$name,$value,%options)=@_; - my $selout="\n

$title:
".''; foreach (sort keys(%options)) { $selout.=''; } return $selout.''; } @@ -96,33 +100,33 @@ sub file_dialogs { my $message = ''; ## ## Deal with saving the spreadsheet - if ((exists($ENV{'form.save'}) || exists($ENV{'form.makedefault'})) && - exists($ENV{'form.savefilename'})) { - $spreadsheet->filename($ENV{'form.savefilename'}); + $spreadsheet->check_formulas_loaded(); + if ((exists($env{'form.save'}) || exists($env{'form.makedefault'})) && + exists($env{'form.savefilename'})) { + $spreadsheet->filename($env{'form.savefilename'}); my $save_status = $spreadsheet->save(); if ($save_status ne 'ok') { $message .= "An error occurred while saving the spreadsheet". "There error is:".$save_status; - return $result; } else { - $message .= "Spreadsheet saved as ".$ENV{'form.savefilename'}; + $message .= "Spreadsheet saved as ".$spreadsheet->filename(); } - } elsif (exists($ENV{'form.newformula'}) && - exists($ENV{'form.cell'}) && - $ENV{'form.cell'} ne '' ) { + } elsif (exists($env{'form.newformula'}) && + exists($env{'form.cell'}) && + $env{'form.cell'} ne '' ) { ## ## Make any requested modifications to the spreadsheet - $spreadsheet->modify_cell($ENV{'form.cell'}, - $ENV{'form.newformula'}); + $spreadsheet->modify_cell($env{'form.cell'}, + $env{'form.newformula'}); $spreadsheet->save_tmp(); # output that we are dealing with a temporary file $result .=&hiddenfield('workcopy',$sheettype); - if ($ENV{'form.newformula'} !~ /^\s*$/) { + if ($env{'form.newformula'} !~ /^\s*$/) { $message .=''. - ''. - '
Cell '.$ENV{'form.cell'}.' = 
'.$ENV{'form.newformula'}."
\n"; + '

'.&mt('Cell').' '.$env{'form.cell'}.' = 
'. + '
'.$env{'form.newformula'}."
\n"; } else { - $message .= 'Deleted contents of cell '.$ENV{'form.cell'}.'.'; + $message .= &mt('Deleted contents of cell').' '.$env{'form.cell'}.'.'; } } ## @@ -137,18 +141,19 @@ sub file_dialogs { $filename = 'Default'; } my $save_dialog = ''. - ' '. + ' '. ''. ''; my $makedefault_dialog = ''; + 'value="'.&mt('Save as & Make This Sheet the Default').'"/>'; # my $link = 'Select Spreadsheet File"; + "('sheet','loadfilename','spreadsheet')\">".&mt('Select Spreadsheet File').""; + my $load=&mt('Load:'); my $load_dialog = < - + $link @@ -158,16 +163,20 @@ sub file_dialogs { END my $default_filename_set = 0; foreach my $sheetfilename ($spreadsheet->othersheets()) { - $load_dialog .= '