--- loncom/interface/spreadsheet/lonspreadsheet.pm 2003/09/05 01:06:45 1.23 +++ loncom/interface/spreadsheet/lonspreadsheet.pm 2009/04/22 17:19:14 1.53 @@ -1,5 +1,5 @@ # -# $Id: lonspreadsheet.pm,v 1.23 2003/09/05 01:06:45 matthew Exp $ +# $Id: lonspreadsheet.pm,v 1.53 2009/04/22 17:19:14 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -62,6 +62,8 @@ use Apache::assesscalc(); use Apache::Constants qw(:common :http); use Apache::lonnet; use Apache::lonhtmlcommon; +use Apache::lonlocal; +use Apache::loncoursedata(); use HTML::Entities(); ## @@ -70,22 +72,22 @@ use HTML::Entities(); sub textfield { my ($title,$name,$value)=@_; - return "\n

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

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

$title:
".''; foreach (sort keys(%options)) { $selout.=''; } return $selout.''; } @@ -98,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'}.'.'; } } ## @@ -138,29 +140,30 @@ sub file_dialogs { if ($spreadsheet->is_default()) { $filename = 'Default'; } - my $save_dialog = ''. - ' '. + 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 + $link   '. - ''); - } + $r->print(''. + ''); if ($allowed_to_view) { $r->print(''. &Apache::loncommon::help_open_topic("Spreadsheet_About", @@ -480,7 +549,7 @@ END # Keep track of the number of times we have been called, sort of. $r->print(&hiddenfield('not_first_run','whatever')); # - if (exists($ENV{'form.not_first_run'}) || $sheettype ne 'classcalc') { + if (exists($env{'form.not_first_run'}) || $sheettype ne 'classcalc') { $r->print($spreadsheet->get_html_title()); if ($allowed_to_view || $allowed_to_edit) { $r->print($spreadsheet->parent_link()); @@ -488,7 +557,8 @@ END $r->rflush(); $spreadsheet->display($r); } - $r->print(''); + $r->print(''.&Apache::loncommon::end_page()); + $spreadsheet->clear_package(); return OK; }