--- rat/lonratedt.pm 2002/08/26 12:38:40 1.33 +++ rat/lonratedt.pm 2002/08/31 00:42:30 1.34 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Edit Handler for RAT Maps # -# $Id: lonratedt.pm,v 1.33 2002/08/26 12:38:40 www Exp $ +# $Id: lonratedt.pm,v 1.34 2002/08/31 00:42:30 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -37,6 +37,8 @@ use Apache::Constants qw(:common); use Apache::lonnet; use Apache::lonratsrv; use Apache::lonsequence; +use Apache::loncommon; +use File::Copy; use vars qw(@order @resources); @@ -328,7 +330,11 @@ sub startfinish { # ------------------------------------------------------------------- Store map sub storemap { - my $fn=shift; + my $realfn=shift; + my $fn=$realfn.'.tmp'; + unless (-e $fn) { + copy($realfn,$fn); + } &startfinish(); my $output='graphdef<:>no'; my $k=1; @@ -462,7 +468,22 @@ ENDSCRIPT sub smpedt { my ($r,$url,$errtext)=@_; my $buttons=&buttons(2); - + my $tmpfn=&Apache::lonnet::filelocation('',$url).'.tmp'; + my $targetmsg=''; + if ($ENV{'form.save'}) { + $targetmsg='Saving ...'; + copy($tmpfn,&Apache::lonnet::filelocation('',$url)); + unlink($tmpfn); + } + if ($ENV{'form.revert'}) { + $targetmsg='Reverting ...'; + unlink($tmpfn); + } + if (-e $tmpfn) { + $targetmsg= + 'You are working with an unsaved version of your map.'; + my ($errtext,$fatal)=&mapread($tmpfn,''); + } # ---------------------------------------------------------- Process form input my @importselect=(); @@ -654,6 +675,8 @@ sub smpedt { # ------------------------------------------------------------ Assemble windows my $idx=-1; + $importdetail='&'.$importdetail; + $importdetail=~s/^\&+/\&/; my $importwindow= ' ---- Import and Paste Area ---- '. join("\n",map { @@ -682,6 +705,7 @@ sub smpedt { # ----------------------------------------------------- Start simple RAT screen my $editscript=&editscript('simple'); + my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,1); $r->print(< @@ -699,17 +723,17 @@ sub smpedt { function viewtarget() { openview((document.forms.simpleedit.targetdetail.value.split('&')) - [document.forms.simpleedit.target.selectedIndex+1]); + [document.forms.simpleedit.target.selectedIndex]); } function viewimport() { openview((document.forms.simpleedit.curimpdetail.value.split('&')) - [document.forms.simpleedit.importsel.selectedIndex+1]); + [document.forms.simpleedit.importsel.selectedIndex]); } - +$bodytag $buttons $errtext $url @@ -739,7 +763,10 @@ value="Browse"> after selected - +$targetmsg + + + @@ -786,11 +813,14 @@ ENDNODIR sub viewmap { my ($r,$url,$adv,$errtext)=@_; - $r->print(''.&buttons($adv)); + $r->print(''. + &Apache::loncommon::bodytag('Edit Content of a Map'). + &buttons($adv)); if ($errtext) { $r->print($errtext.''); } my $idx=0; + $r->print(''.$url.''); foreach (&attemptread(&Apache::lonnet::filelocation('',$url))) { if (defined($_)) { $idx++;