Annotation of rat/lonwrapper.pm, revision 1.28
1.1 www 1: # The LearningOnline Network with CAPA
2: # Wrapper for external and binary files as standalone resources
3: #
1.28 ! www 4: # $Id: lonwrapper.pm,v 1.27 2008/01/15 15:23: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:
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.28 ! www 71: if ($env{'environment.icons'} eq 'iconsonly') {
! 72: $layout{'rows'} = "100,*";
! 73: } else {
! 74: $layout{'rows'} = "200,*";
! 75: }
1.21 albertel 76: } else {
1.23 albertel 77: $layout{'rows'} = "1,*";
78: $topurl = "/adm/rat/empty.html";
79: }
80:
81: my $start_page =
82: &Apache::loncommon::start_page(undef,undef,
83: {'force_register' => 1,
84: 'frameset' => 1,
85: 'add_entries' => \%layout, });
86:
87: my $end_page =
88: &Apache::loncommon::end_page({'frameset' => 1});
1.24 albertel 89:
90: foreach my $url ($topurl,$bottomurl) {
91: if ($url !~ /^http:/) {
92: $url = &Apache::lonenc::check_encrypt($url);
93: }
94: }
1.9 www 95: #
96: # frame-based rendering for graphical interface
97: #
1.23 albertel 98: my $result =<<ENDDOCUMENT;
99: $start_page
100: test
101: <frame src="$topurl" />
102: <frame src="$bottomurl" />
103: $end_page
1.1 www 104: ENDDOCUMENT
1.21 albertel 105:
1.23 albertel 106: return $result;
1.21 albertel 107: }
108:
109: sub handler {
110: my $r=shift;
111: &Apache::loncommon::content_type($r,'text/html');
112: $r->send_http_header;
113:
114: return OK if $r->header_only;
115:
116: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
117: ['wrapperdisplay']);
118: if ($env{'form.wrapperdisplay'} eq 'menu') {
119: $r->print(&simple_menu());
120: return OK;
121: }
122:
123: my $orgurl=$r->uri;
124: my $url=$orgurl;
125: $orgurl.=(($orgurl=~/\?/)?'&':'?').$ENV{'QUERY_STRING'};
126: $orgurl.=(($orgurl=~/\?/)?'&':'?').'wrapperdisplay=menu';
127: $url=~s/^\/adm\/wrapper//;
128: my $is_ext = $url =~ m|^/ext/|;
1.26 albertel 129: $url=~s{^/ext/}{http://};
1.25 banghart 130: $url=~s|http://https://|https://|;
1.21 albertel 131: $url=~s|:|:|g;
132: #
133: # Actual URL
134: #
135: if ($url=~/\.(problem|exam|quiz|assess|survey|form|library)$/) {
136: #
137: # This is uploaded homework
138: #
139: $env{'request.state'}='uploaded';
140: &Apache::lonhomework::renderpage($r,$url);
141: } else {
142: #
143: # This is not homework
144: #
145: if ($is_ext) {
146: $ENV{'QUERY_STRING'}=~s/(^|\&)symb=[^\&]*/$1/;
147: }
148: $url.=(($url=~/\?/)?'&':'?').$ENV{'QUERY_STRING'};
149: # reappend the query arguments
150: $r->print(&wrapper($orgurl,$url));
151: } # not just the menu
152: return OK;
1.13 www 153: } # handler
1.1 www 154:
155: 1;
156: __END__
157:
158:
159:
160:
161:
162:
163:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>