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