Annotation of loncom/interface/lonsource.pm, revision 1.2
1.1 taceyjo1 1: # The LearningOnline Network with CAPA
1.2 ! albertel 2: # Souce Code handler
1.1 taceyjo1 3: #
1.2 ! albertel 4: # $Id: lonsource.pm,v 1.1 2004/06/12 01:08:11 taceyjo1 Exp $
1.1 taceyjo1 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 {
1.2 ! albertel 45: my ($filename) = @_;
! 46: my $sourcelink = "http://".$ENV{'SERVER_NAME'}.
! 47: "/adm/source/?filename=".$filename;
! 48:
! 49: return $sourcelink;
1.1 taceyjo1 50: }
51:
52: sub stage_2 {
1.2 ! albertel 53: my ($r, $filename) = @_;
! 54: $r->print("Coming Soon");
! 55: return OK;
1.1 taceyjo1 56: }
57:
58: sub print_item {
1.2 ! albertel 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;
1.1 taceyjo1 66:
67: }
68:
69:
70: sub handler {
1.2 ! albertel 71: my $r=shift;
! 72: if($ENV{'form.action'} eq 'stage2') {
! 73: &stage_2($r, $ENV{'form.filename'});
! 74: } else {
1.1 taceyjo1 75: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.2 ! albertel 76: ['filename']);
! 77: if (!&Apache::lonnet::allowed('cre',$ENV{'form.filename'})) {
! 78: return FORBIDDEN;
! 79: }
1.1 taceyjo1 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'});
1.2 ! albertel 91: }
! 92: return OK;
1.1 taceyjo1 93: }
94:
95: 1;
96:
1.2 ! albertel 97:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>