--- loncom/interface/spreadsheet/lonspreadsheet.pm 2003/05/23 19:36:04 1.4 +++ loncom/interface/spreadsheet/lonspreadsheet.pm 2003/05/27 19:17:07 1.5 @@ -1,5 +1,5 @@ # -# $Id: lonspreadsheet.pm,v 1.4 2003/05/23 19:36:04 matthew Exp $ +# $Id: lonspreadsheet.pm,v 1.5 2003/05/27 19:17:07 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -58,6 +58,7 @@ use Apache::classcalc(); use Apache::studentcalc(); use Apache::assesscalc(); use Apache::Constants qw(:common :http); +use Apache::lonmenu(); use Apache::lonnet; use Apache::lonhtmlcommon; use HTML::Entities(); @@ -88,6 +89,94 @@ sub selectbox { return $selout.''; } +sub file_dialogs { + my ($spreadsheet) = @_; + my $bgcolor = "#FFFFFF"; + my $sheettype = $spreadsheet->{'type'}; + my $result = ''; + ## + ## Deal with saving the spreadsheet + if (exists($ENV{'form.save'}) && + exists($ENV{'form.savefilename'})) { + $spreadsheet->filename($ENV{'form.savefilename'}); + my $save_status = $spreadsheet->save(); + if ($save_status ne 'ok') { + $result .= "An error occurred while saving the spreadsheet". + "There error is:".$save_status; + return $result; + } else { + $result .= "Spreadsheet saved as ".$ENV{'form.savefilename'}; + } + } 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->save_tmp(); + # output that we are dealing with a temporary file + $result .=&hiddenfield('workcopy',$sheettype); + $result .='
'.$ENV{'form.cell'}.' = '.
+                  $ENV{'form.newformula'}."
\n"; + } + ## + ## Editing code + $result .=&hiddenfield('cell',''). + &hiddenfield('newformula',''); + ## + ## Create the save and load dialogs + my $filename = $spreadsheet->filename(); + $filename = '' if ($filename =~ /^default\.$sheettype/i); + $filename =~ s/_$sheettype$//; + my $save_dialog = ''. + ' '. + ''. + ''; + my $makedefault_dialog = ''; + # + my $link = 'Browse"; + my $load_dialog = < + + + + $link + +  +
'); ## ## Editing/loading/saving if ($allowed_to_edit) { - ## - ## Deal with saving the spreadsheet - if (exists($ENV{'form.save'}) && - exists($ENV{'form.savefilename'})) { - $spreadsheet->filename($ENV{'form.savefilename'}); - my $save_status = $spreadsheet->save(); - if ($save_status ne 'ok') { - $r->print("An error occurred while saving the spreadsheet". - "There error is:".$save_status); - } else { - $r->print("Spreadsheet saved as ".$ENV{'form.savefilename'}); - } - } 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->save_tmp(); - # output that we are dealing with a temporary file - $r->print(&hiddenfield('workcopy',$sheettype)); - $r->print('
'.$ENV{'form.cell'}.' = '.
-                      $ENV{'form.newformula'}.'
'."\n"); - } - ## - ## Editing code - $r->print(&hiddenfield('cell',''). - &hiddenfield('newformula','')); - ## - ## Create the save and load dialogs - $filename = $spreadsheet->filename(); - $filename = '' if ($filename =~ /^default\.$sheettype/i); - $filename =~ s/_$sheettype$//; - my $save_dialog = - ' '. - ''; - my $makedefault_dialog = - ''; - # - my $load_dialog = - ''. - '