1: # The LearningOnline Network with CAPA
2: # Wrapper for external and binary files as standalone resources
3: #
4: # $Id: lonwrapper.pm,v 1.29 2008/11/10 13:22:23 jms 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: =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:
47: package Apache::lonwrapper;
48:
49: use strict;
50: use Apache::Constants qw(:common);
51: use Apache::lonnet;
52: use Apache::lonxml();
53: use Apache::lonenc();
54: use Apache::lonmenu();
55:
56: # ================================================================ Main Handler
57:
58: sub simple_menu {
59: #
60: # Producing the menu buttons
61: #
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();
67: }
68:
69:
70: sub wrapper {
71: my ($topurl,$bottomurl) = @_;
72:
73: if ($env{'browser.interface'} eq 'textual') {
74: #
75: # ssi-based rendering for text-based interface
76: #
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();
84: }
85:
86:
87: my %layout = ('border' => 0);
88: if ($env{'environment.remote'} eq 'off') {
89: if ($env{'environment.icons'} eq 'iconsonly') {
90: $layout{'rows'} = "100,*";
91: } else {
92: $layout{'rows'} = "200,*";
93: }
94: } else {
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});
107:
108: foreach my $url ($topurl,$bottomurl) {
109: if ($url !~ /^http:/) {
110: $url = &Apache::lonenc::check_encrypt($url);
111: }
112: }
113: #
114: # frame-based rendering for graphical interface
115: #
116: my $result =<<ENDDOCUMENT;
117: $start_page
118: test
119: <frame src="$topurl" />
120: <frame src="$bottomurl" />
121: $end_page
122: ENDDOCUMENT
123:
124: return $result;
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/|;
147: $url=~s{^/ext/}{http://};
148: $url=~s|http://https://|https://|;
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;
171: } # handler
172:
173: 1;
174: __END__
175:
176:
177:
178:
179:
180:
181:
182:
183:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>