Annotation of rat/lonwrapper.pm, revision 1.29
1.1 www 1: # The LearningOnline Network with CAPA
2: # Wrapper for external and binary files as standalone resources
3: #
1.29 ! jms 4: # $Id: lonwrapper.pm,v 1.28 2008/03/03 19:57:28 www Exp $
1.4 www 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: #
1.1 www 28:
1.29 ! jms 29: =pod
! 30:
! 31: =head1 NAME
! 32:
! 33: Apache::lonwrapper - External and binary file management.
! 34:
! 35: =head1 SYNOPSIS
! 36:
! 37: Wrapper for external and binary files as standalone resources. Edit handler for rat maps; TeX content handler.
! 38:
! 39: This is part of the LearningOnline Network with CAPA project
! 40: described at http://www.lon-capa.org.
! 41:
! 42: =head2 Subroutines
! 43:
! 44: =cut
! 45:
! 46:
1.1 www 47: package Apache::lonwrapper;
48:
49: use strict;
50: use Apache::Constants qw(:common);
1.18 albertel 51: use Apache::lonnet;
1.2 www 52: use Apache::lonxml();
1.24 albertel 53: use Apache::lonenc();
54: use Apache::lonmenu();
1.1 www 55:
56: # ================================================================ Main Handler
57:
1.21 albertel 58: sub simple_menu {
1.12 www 59: #
60: # Producing the menu buttons
61: #
1.22 albertel 62: return &Apache::loncommon::start_page('Menu',undef,
63: {'only_body' => 1,
64: 'bgcolor' => '#FFFFFF',}).
65: &Apache::lonmenu::menubuttons(1,'web',1).
66: &Apache::loncommon::end_page();
1.21 albertel 67: }
68:
69:
70: sub wrapper {
71: my ($topurl,$bottomurl) = @_;
1.12 www 72:
1.21 albertel 73: if ($env{'browser.interface'} eq 'textual') {
1.12 www 74: #
75: # ssi-based rendering for text-based interface
76: #
1.22 albertel 77: return
78: &Apache::loncommon::start_page('Menu',undef,
79: {'bgcolor' => '#FFFFFF',
80: 'force_register' => 1,
81: }).
82: &Apache::lonnet::ssi_body($bottomurl).
83: &Apache::loncommon::end_page();
1.21 albertel 84: }
85:
1.23 albertel 86:
87: my %layout = ('border' => 0);
1.21 albertel 88: if ($env{'environment.remote'} eq 'off') {
1.28 www 89: if ($env{'environment.icons'} eq 'iconsonly') {
90: $layout{'rows'} = "100,*";
91: } else {
92: $layout{'rows'} = "200,*";
93: }
1.21 albertel 94: } else {
1.23 albertel 95: $layout{'rows'} = "1,*";
96: $topurl = "/adm/rat/empty.html";
97: }
98:
99: my $start_page =
100: &Apache::loncommon::start_page(undef,undef,
101: {'force_register' => 1,
102: 'frameset' => 1,
103: 'add_entries' => \%layout, });
104:
105: my $end_page =
106: &Apache::loncommon::end_page({'frameset' => 1});
1.24 albertel 107:
108: foreach my $url ($topurl,$bottomurl) {
109: if ($url !~ /^http:/) {
110: $url = &Apache::lonenc::check_encrypt($url);
111: }
112: }
1.9 www 113: #
114: # frame-based rendering for graphical interface
115: #
1.23 albertel 116: my $result =<<ENDDOCUMENT;
117: $start_page
118: test
119: <frame src="$topurl" />
120: <frame src="$bottomurl" />
121: $end_page
1.1 www 122: ENDDOCUMENT
1.21 albertel 123:
1.23 albertel 124: return $result;
1.21 albertel 125: }
126:
127: sub handler {
128: my $r=shift;
129: &Apache::loncommon::content_type($r,'text/html');
130: $r->send_http_header;
131:
132: return OK if $r->header_only;
133:
134: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
135: ['wrapperdisplay']);
136: if ($env{'form.wrapperdisplay'} eq 'menu') {
137: $r->print(&simple_menu());
138: return OK;
139: }
140:
141: my $orgurl=$r->uri;
142: my $url=$orgurl;
143: $orgurl.=(($orgurl=~/\?/)?'&':'?').$ENV{'QUERY_STRING'};
144: $orgurl.=(($orgurl=~/\?/)?'&':'?').'wrapperdisplay=menu';
145: $url=~s/^\/adm\/wrapper//;
146: my $is_ext = $url =~ m|^/ext/|;
1.26 albertel 147: $url=~s{^/ext/}{http://};
1.25 banghart 148: $url=~s|http://https://|https://|;
1.21 albertel 149: $url=~s|:|:|g;
150: #
151: # Actual URL
152: #
153: if ($url=~/\.(problem|exam|quiz|assess|survey|form|library)$/) {
154: #
155: # This is uploaded homework
156: #
157: $env{'request.state'}='uploaded';
158: &Apache::lonhomework::renderpage($r,$url);
159: } else {
160: #
161: # This is not homework
162: #
163: if ($is_ext) {
164: $ENV{'QUERY_STRING'}=~s/(^|\&)symb=[^\&]*/$1/;
165: }
166: $url.=(($url=~/\?/)?'&':'?').$ENV{'QUERY_STRING'};
167: # reappend the query arguments
168: $r->print(&wrapper($orgurl,$url));
169: } # not just the menu
170: return OK;
1.13 www 171: } # handler
1.1 www 172:
173: 1;
174: __END__
175:
176:
177:
178:
179:
180:
181:
1.29 ! jms 182:
! 183:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>