--- rat/lonratedt.pm 2004/04/26 16:56:26 1.57 +++ rat/lonratedt.pm 2005/03/23 22:54:18 1.64 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Edit Handler for RAT Maps # -# $Id: lonratedt.pm,v 1.57 2004/04/26 16:56:26 www Exp $ +# $Id: lonratedt.pm,v 1.64 2005/03/23 22:54:18 raeburn 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); } @@ -391,6 +393,10 @@ sub attemptread { # --------------------------------------------------------- Build up RAT screen sub ratedt { my ($r,$url)=@_; + my $frameset = '<frameset rows="1,70,*" border="0">'; + if ($ENV{'environment.remote'} eq 'off') { + $frameset = '<frameset rows="1,250,*" border="0">'; + } $r->print(<<ENDDOCUMENT); <html> @@ -399,9 +405,9 @@ sub ratedt { var flag=0; </script> </head> -<frameset rows="1,50,*" border=0> +$frameset <frame name=server src="$url/loadonly/ratserver" noresize noscroll> -<frame name=code src="/adm/rat/code.html"> +<frame name=code src="$url/loadonly/adveditmenu"> <frame name=mapout src="/adm/rat/map.html"> </frameset> </html> @@ -574,7 +580,7 @@ sub delparameter { } sub getparameter { - my ($to,$name); + my ($to,$name)=@_; my $value=undef; my $ptype=undef; foreach (split('&&&',$resparms[$to])) { @@ -704,14 +710,18 @@ sub smpedt { my $tmpfn=&Apache::lonnet::filelocation('',$url).'.tmp'; my $targetmsg=''; if ($ENV{'form.save'}) { - $targetmsg='<b>Saving ...</b><br>'; copy($tmpfn,&Apache::lonnet::filelocation('',$url)); unlink($tmpfn); my ($errtext,$fatal)= &mapread(&Apache::lonnet::filelocation('',$url),''); + unless ($fatal) { + $targetmsg='<b>'.&mt('Saved.').'</b><br />'; + } else { + $targetmsg='<b>'.&mt('An error occured while saving.').'</b><br />'; + } } if ($ENV{'form.revert'}) { - $targetmsg='<b>Reverting ...</b><br>'; + $targetmsg='<b>'.&mt('Reverted.').'</b><br />'; unlink($tmpfn); my ($errtext,$fatal)= &mapread(&Apache::lonnet::filelocation('',$url),''); @@ -971,10 +981,9 @@ 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'); + my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef, + ($ENV{'environment.remote'} ne 'off')). + &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', @@ -1130,8 +1139,7 @@ sub viewmap { my ($r,$url,$adv,$errtext)=@_; $r->print('<html>'. &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.'<hr />'); @@ -1141,22 +1149,52 @@ sub viewmap { if ($adv) { $r->print('<p><b><font color="red">'.&mt('Map contents are not shown in order.').'</font></b></p><br />'); } + $r->print( '<table border="0" cellspacing="2" cellpadding="4">'. + '<tr bgcolor="#DDDDDD"><th>'.&mt('Type').'</th>'. + '<th>'.&mt('Title in map').'</th>'. + '<th>'.&mt('Filename of resource').'</th>'. + '<th>'.&mt('Link to published resource').'</th>'. + '<th>'.&mt('Link to resource in Construction Space').'</th>'. + '</tr>'); + my @backgroundColors = ("#FFFFFF", "#F6F6F6"); foreach (&attemptread(&Apache::lonnet::filelocation('',$url))) { if (defined($_)) { $idx++; - my ($title,$url)=split(/\:/,$_); + my ($title,$url,$cond)=split(/\:/,$_); + if ($cond eq 'cond') { next; } $title=~s/\&colon\;/\:/g; $url=~s/\&colon\;/\:/g; unless ($title) { $title=(split(/\//,$url))[-1] }; - unless ($title) { $title='<i>Empty</i>'; } + unless ($title) { $title='<i>'.&mt('Empty').'</i>'; } + my $resurl = &Apache::lonratsrv::qtescape($url); + my $resfilepath = $Apache::lonnet::perlvar{'lonDocRoot'}.$resurl; + my $filename; + if ($resurl =~ m#/([^/]+)$#) { + $filename = $1; + } + my $cstrurl = $resurl; + $cstrurl =~ s#^/res/[^/]+/([^/]+)/#/priv/$1/#; + my $bgcol = $idx%2; + $r->print('<tr bgcolor='.$backgroundColors[$bgcol].'><td>'. + '<img src="'.&Apache::loncommon::icon($resfilepath). + '" /></td><td>'.&Apache::lonratsrv::qtescape($title). + '</td><td>'.$filename.'</td><td>'); + if ($url) { + if (-e $resfilepath) { + $r->print('<a href="'.$resurl.'">'.&mt('Resource space').'</a>'); + } else { + $r->print(&mt('unpublished')); + } + } + $r->print('</td><td>'); if ($url) { - $r->print('<a href="'.&Apache::lonratsrv::qtescape($url).'">'); + $r->print('<a href="'.$cstrurl.'">'. + &mt('Construction space').'</a>'); } - $r->print(&Apache::lonratsrv::qtescape($title)); - if ($url) { $r->print('</a>'); } - $r->print('<br>'); + $r->print('</td></tr>'."\n"); } } + $r->print('</table>'); $r->print('</body></html>'); }