1: # The LearningOnline Network with CAPA
2: # Edit Handler for RAT Maps
3: #
4: # $Id: lonratedt.pm,v 1.5 2001/11/29 19:23:49 www Exp $
5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
28: # (TeX Content Handler
29: #
30: # 05/29/00,05/30 Gerd Kortemeyer)
31: # 7/1,6/30 Gerd Kortemeyer
32:
33: package Apache::lonratedt;
34:
35: use strict;
36: use Apache::Constants qw(:common);
37: use Apache::lonnet;
38:
39: # --------------------------------------------------------- Build up RAT screen
40: sub ratedt {
41: my ($r,$url)=@_;
42: $r->print(<<ENDDOCUMENT);
43:
44: <html>
45: <head>
46: <script language="JavaScript">
47: var flag=0;
48: </script>
49: </head>
50: <frameset rows="1,50,*" border=0>
51: <frame name=server src="$url/loadonly/ratserver" noresize noscroll>
52: <frame name=code src="/adm/rat/code.html">
53: <frame name=mapout src="/adm/rat/map.html">
54: </frameset>
55: </html>
56:
57: ENDDOCUMENT
58: }
59:
60: sub smpedt {
61: my ($r,$fn)=@_;
62: $r->print(<<ENDSMPHEAD);
63: <html>
64: <body bgcolor='#FFFFFF'>
65: <form method=post>
66: <input type=submit name=forceadv
67: value="Advanced Map Editing - Resource Assembly Tool"><hr>
68: ENDSMPHEAD
69: $r->print(
70: '<input type=submit name=forcesmp value="Store"></form></body></html>');
71: }
72:
73: sub nodir {
74: my ($r,$dir)=@_;
75: $dir=~s/^\/home\/\w+\/public\_html//;
76: $r->print(<<ENDNODIR);
77: <html>
78: <body bgcolor='#FFFFFF'>
79: <h1>No such directory: $dir</h1>
80: </body>
81: </html>
82: ENDNODIR
83: }
84:
85: # ================================================================ Main Handler
86:
87: sub handler {
88: my $r=shift;
89: $r->content_type('text/html');
90: $r->send_http_header;
91:
92: return OK if $r->header_only;
93:
94: my $url=$r->uri;
95: my $fn=&Apache::lonnet::filelocation('',$url);
96:
97: my ($dir)=($fn=~/^(.+)\/[^\/]+$/);
98: unless (-e $dir) {
99: &nodir($r,$dir);
100: return OK;
101: }
102: my $adv=0;
103:
104: unless ($ENV{'form.forcesmp'}) {
105: if ($ENV{'form.forceadv'}) {
106: $adv=1;
107: } elsif (my $fh=Apache::File->new($fn)) {
108: my $allmap=join('',<$fh>);
109: $adv=($allmap=~/\<map[^\>]+mode\s*\=\s*(\'|\")rat/is);
110: }
111: }
112:
113: if ($adv) {
114: &ratedt($r,$url);
115: } else {
116: &smpedt($r,$fn);
117: }
118: return OK;
119: }
120:
121: 1;
122: __END__
123:
124:
125:
126:
127:
128:
129:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>