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