File:  [LON-CAPA] / rat / lonratedt.pm
Revision 1.4: download - view: text, annotated - select for diffs
Sat Jun 30 14:05:57 2001 UTC (22 years, 9 months ago) by www
Branches: MAIN
CVS tags: stable_2001_fall, HEAD
Checks if directory exists

# The LearningOnline Network with CAPA
# Edit Handler for RAT Maps
# (TeX Content Handler
#
# 05/29/00,05/30 Gerd Kortemeyer)
# 7/1,6/30 Gerd Kortemeyer

package Apache::lonratedt;

use strict;
use Apache::Constants qw(:common);
use Apache::lonnet;

# --------------------------------------------------------- Build up RAT screen
sub ratedt {
  my ($r,$url)=@_;
  $r->print(<<ENDDOCUMENT);

<html>
<head>
<script language="JavaScript">
    var flag=0;
</script>
</head>
<frameset rows="1,50,*" border=0>
<frame name=server src="$url/loadonly/ratserver" noresize noscroll>
<frame name=code src="/adm/rat/code.html">
<frame name=mapout src="/adm/rat/map.html">
</frameset>
</html>

ENDDOCUMENT
}

sub smpedt {
   my ($r,$fn)=@_;
   $r->print(<<ENDSMPHEAD);
<html>
<body bgcolor='#FFFFFF'>
<form method=post>
<input type=submit name=forceadv 
value="Advanced Map Editing - Resource Assembly Tool"><hr>
ENDSMPHEAD
    $r->print(
      '<input type=submit name=forcesmp value="Store"></form></body></html>');
}

sub nodir {
   my ($r,$dir)=@_;
   $dir=~s/^\/home\/\w+\/public\_html//;
   $r->print(<<ENDNODIR);
<html>
<body bgcolor='#FFFFFF'>
<h1>No such directory: $dir</h1>
</body>
</html>
ENDNODIR
}

# ================================================================ Main Handler

sub handler {
  my $r=shift;
  $r->content_type('text/html');
  $r->send_http_header;

  return OK if $r->header_only;

  my $url=$r->uri;
  my $fn=&Apache::lonnet::filelocation('',$url);

  my ($dir)=($fn=~/^(.+)\/[^\/]+$/);
  unless (-e $dir) {
      &nodir($r,$dir);
      return OK;
  }
  my $adv=0;

  unless ($ENV{'form.forcesmp'}) {
     if ($ENV{'form.forceadv'}) {
        $adv=1;
     } elsif (my $fh=Apache::File->new($fn)) {
	 my $allmap=join('',<$fh>);
         $adv=($allmap=~/\<map[^\>]+mode\s*\=\s*(\'|\")rat/is);
     }
  }

  if ($adv) {
      &ratedt($r,$url);
  } else {
      &smpedt($r,$fn);
  }
  return OK;
}

1;
__END__








FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>