1: # The LearningOnline Network with CAPA
2: # Wrapper for external and binary files as standalone resources
3: #
4: # $Id: lonwrapper.pm,v 1.41 2011/11/07 20:06:29 www 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:
30: package Apache::lonwrapper;
31:
32: use strict;
33: use Apache::Constants qw(:common);
34: use Apache::lonenc();
35: use Apache::lonnet;
36:
37: # ================================================================ Main Handler
38: sub wrapper {
39: my $url = shift;
40:
41: my $startpage = Apache::loncommon::start_page('Menu',undef,
42: { 'force_register' =>1, 'bgcolor' => '#FFFFFF',}) ;
43: my $endpage = Apache::loncommon::end_page();
44:
45: my $script = Apache::lonhtmlcommon::scripttag(<<SCRIPT );
46: \$(document).ready( function() {
47: \$(window).unbind('resize').resize(function(){
48: var header = \$('.LC_head_subbox')[0] ? \$('.LC_head_subbox')
49: : \$('#LC_breadcrumbs');
50: var pos = header.height() + header.position().top + 5;
51: \$('.LC_iframecontainer').css('top', pos);
52: });
53: });
54: window.onload = function(){ \$(window).trigger('resize') };
55: SCRIPT
56:
57: # javascript will position the iframe if window was resized (or zoomed)
58: return <<ENDFRAME;
59: $startpage
60: $script
61: <div class="LC_iframecontainer">
62: <iframe src="$url">No iframe support!</iframe>
63: </div>
64: $endpage
65: ENDFRAME
66: }
67:
68: sub handler {
69: my $r=shift;
70: &Apache::loncommon::content_type($r,'text/html');
71: $r->send_http_header;
72:
73: return OK if $r->header_only;
74:
75: my $url = $r->uri;
76: my $is_ext;
77:
78: for ($url){
79: s|^/adm/wrapper||;
80: $is_ext = $_ =~ s|^/ext/|http://|;
81: s|http://https://|https://|;
82: s|:|:|g;
83: }
84:
85: #
86: # Actual URL
87: #
88: if ($url=~/$LONCAPA::assess_re/) {
89: #
90: # This is uploaded homework
91: #
92: $env{'request.state'}='uploaded';
93: &Apache::lonhomework::renderpage($r,$url);
94: } else {
95: #
96: # This is not homework
97: #
98: if ($is_ext) {
99: $ENV{'QUERY_STRING'} =~ s/(^|\&)symb=[^\&]*/$1/;
100: $ENV{'QUERY_STRING'} =~ s/\&$//;
101: }
102:
103: unless ($ENV{'QUERY_STRING'} eq '') {
104: $url.=(($url=~/\?/)?'&':'?').$ENV{'QUERY_STRING'};
105: }
106:
107: # encrypt url if not external
108: &Apache::lonenc::check_encrypt(\$url) if $url !~ /^https?\:/ ;
109:
110: $r->print( wrapper($url) );
111:
112: } # not just the menu
113:
114: return OK;
115: } # handler
116:
117: 1;
118: __END__
119:
120: =pod
121:
122: =head1 NAME
123:
124: Apache::lonwrapper - External and binary file management.
125:
126: =head1 SYNOPSIS
127:
128: Wrapper for external and binary files as standalone resources. Edit handler for rat maps; TeX content handler.
129:
130: This is part of the LearningOnline Network with CAPA project
131: described at http://www.lon-capa.org.
132:
133: =head1 Subroutines
134:
135: =over
136:
137: =item wrapper($url)
138:
139: Wraps $url in an iframe and generates a page for it.
140: Returns markup for the entire page.
141:
142: =item handler()
143:
144: =back
145:
146: =cut
147:
148:
149:
150:
151:
152:
153:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>