1: # The LearningOnline Network with CAPA
2: # Souce Code handler
3: #
4: # $Id: lonsource.pm,v 1.2 2004/06/12 04:44:31 albertel 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: ###
29:
30:
31: package Apache::lonsource;
32:
33: use strict;
34: use Apache::lonnet();
35: use Apache::loncommon();
36: use Apache::lonhtmlcommon();
37: use Apache::lonsequence();
38: use Apache::Constants qw(:common :http);
39: use Apache::lonmeta;
40: use Apache::File;
41: use Apache::lonlocal;
42: use HTML::Entities;
43:
44: sub make_link {
45: my ($filename) = @_;
46: my $sourcelink = "http://".$ENV{'SERVER_NAME'}.
47: "/adm/source/?filename=".$filename;
48:
49: return $sourcelink;
50: }
51:
52: sub stage_2 {
53: my ($r, $filename) = @_;
54: $r->print("Coming Soon");
55: return OK;
56: }
57:
58: sub print_item {
59: my ($r, $filename) = @_;
60: $filename = "/home/httpd/html".$filename;
61: my $file_output = &Apache::lonnet::getfile($filename);
62: my ($rows,$cols) = &Apache::edit::textarea_sizes(\$file_output);
63: $r->print('<textarea rows="'.$rows.'" cols="'.$cols.'" name="editxmltext">'.
64: &HTML::Entities::encode($file_output,'<>&"').'</textarea>');
65: return OK;
66:
67: }
68:
69:
70: sub handler {
71: my $r=shift;
72: if($ENV{'form.action'} eq 'stage2') {
73: &stage_2($r, $ENV{'form.filename'});
74: } else {
75: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
76: ['filename']);
77: if (!&Apache::lonnet::allowed('cre',$ENV{'form.filename'})) {
78: return FORBIDDEN;
79: }
80: &Apache::loncommon::content_type($r,'text/html');
81: my $filename = $ENV{'form.filename'};
82: $r->send_http_header;
83: $r->print(' <form name="copy" action="/adm/source/" target="_parent" method="post">
84: <input type="button" value="Close Window" name="close" onClick="window.close()">
85: <input type="hidden" name="filename" value="'.$filename.'" />
86: <input type="hidden" name="action" value="stage2" />
87: <input type="submit" value="Copy to CSTR" />
88: </form>');
89: $r->print('<hr />');
90: &print_item($r, $ENV{'form.filename'});
91: }
92: return OK;
93: }
94:
95: 1;
96:
97:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>