--- rat/lonratedt.pm 2004/04/24 15:05:16 1.55 +++ rat/lonratedt.pm 2004/09/02 13:21:53 1.60 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Edit Handler for RAT Maps # -# $Id: lonratedt.pm,v 1.55 2004/04/24 15:05:16 www Exp $ +# $Id: lonratedt.pm,v 1.60 2004/09/02 13:21:53 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -187,8 +187,10 @@ sub mapread { undef @links; undef @resources; undef @order; + undef @resparms; @resources=(''); @order=(); + @resparms=(); my ($outtext,$errtext)=&Apache::lonratsrv::loadmap($fn,''); if ($errtext) { return ($errtext,2); } @@ -536,6 +538,58 @@ sub storemap { &Apache::lonratsrv::loadmap($fn,&Apache::lonratsrv::savemap($fn,'')); } +# ------------------------------------------ Store and get parameters in global + +sub storeparameter { + my ($to,$name,$value,$ptype)=@_; + my $newentry=''; + my $nametype=''; + foreach (split('&&&',$resparms[$to])) { + my ($thistype,$thisname,$thisvalue)=split('___',$_); + if ($thisname) { + unless ($thisname eq $name) { + $newentry.=$_.'&&&'; + } else { + $nametype=$thistype; + } + } + } + unless ($ptype) { $ptype=$nametype; } + unless ($ptype) { $ptype='string'; } + $newentry.=$ptype.'___'.$name.'___'.$value; + $resparms[$to]=$newentry; +} + +sub delparameter { + my ($to,$name)=@_; + my $newentry=''; + my $nametype=''; + foreach (split('&&&',$resparms[$to])) { + my ($thistype,$thisname,$thisvalue)=split('___',$_); + if ($thisname) { + unless ($thisname eq $name) { + $newentry.=$_.'&&&'; + } + } + } + $resparms[$to]=$newentry; +} + +sub getparameter { + my ($to,$name)=@_; + my $value=undef; + my $ptype=undef; + foreach (split('&&&',$resparms[$to])) { + my ($thistype,$thisname,$thisvalue)=split('___',$_); + if ($thisname eq $name) { + $value=$thisvalue; + $ptype=$thistype; + } + } + return ($value,$ptype); +} + +# ----------------------------------------------------------------- Edit script sub editscript { my $mode=shift; my $resurl=&Apache::loncommon::lastresurl(); @@ -652,14 +706,18 @@ sub smpedt { my $tmpfn=&Apache::lonnet::filelocation('',$url).'.tmp'; my $targetmsg=''; if ($ENV{'form.save'}) { - $targetmsg='Saving ...
'; copy($tmpfn,&Apache::lonnet::filelocation('',$url)); unlink($tmpfn); my ($errtext,$fatal)= &mapread(&Apache::lonnet::filelocation('',$url),''); + unless ($fatal) { + $targetmsg=''.&mt('Saved.').'
'; + } else { + $targetmsg=''.&mt('An error occured while saving.').'
'; + } } if ($ENV{'form.revert'}) { - $targetmsg='Reverting ...
'; + $targetmsg=''.&mt('Reverted.').'
'; unlink($tmpfn); my ($errtext,$fatal)= &mapread(&Apache::lonnet::filelocation('',$url),''); @@ -920,9 +978,7 @@ sub smpedt { # ----------------------------------------------------- Start simple RAT screen my $editscript=&editscript('simple'); my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,1). - &Apache::loncommon::help_open_topic('Sequence_Simple_Editor_Creation'). - &Apache::loncommon::help_open_faq(6). - &Apache::loncommon::help_open_bug('RAT'); + &Apache::loncommon::help_open_menu('','Sequence_Simple_Editor_Creation','Sequence_Simple_Editor_Creation','',6,'RAT'); my %lt=&Apache::lonlocal::texthash( 'sa' => 'Save', 'nt' => 'New Title', @@ -1078,8 +1134,7 @@ sub viewmap { my ($r,$url,$adv,$errtext)=@_; $r->print(''. &Apache::loncommon::bodytag('Edit Content of a Map'). - &Apache::loncommon::help_open_faq(6). - &Apache::loncommon::help_open_bug('RAT'). + &Apache::loncommon::help_open_menu('','','','',6,'RAT'). &buttons($adv)); if ($errtext) { $r->print($errtext.'
');