File:
[LON-CAPA] /
rat /
lonwrapper.pm
Revision
1.23:
download - view:
text,
annotated -
select for diffs
Tue Apr 11 19:42:32 2006 UTC (18 years, 5 months ago) by
albertel
Branches:
MAIN
CVS tags:
version_2_2_X,
version_2_2_2,
version_2_2_1,
version_2_2_0,
version_2_1_99_3,
version_2_1_99_2,
version_2_1_99_1,
version_2_1_99_0,
HEAD
- start_page + frameset
1: # The LearningOnline Network with CAPA
2: # Wrapper for external and binary files as standalone resources
3: #
4: # $Id: lonwrapper.pm,v 1.23 2006/04/11 19:42:32 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 &Apache::loncommon::start_page('Menu',undef,
44: {'only_body' => 1,
45: 'bgcolor' => '#FFFFFF',}).
46: &Apache::lonmenu::menubuttons(1,'web',1).
47: &Apache::loncommon::end_page();
48: }
49:
50:
51: sub wrapper {
52: my ($topurl,$bottomurl) = @_;
53:
54: if ($env{'browser.interface'} eq 'textual') {
55: #
56: # ssi-based rendering for text-based interface
57: #
58: return
59: &Apache::loncommon::start_page('Menu',undef,
60: {'bgcolor' => '#FFFFFF',
61: 'force_register' => 1,
62: }).
63: &Apache::lonnet::ssi_body($bottomurl).
64: &Apache::loncommon::end_page();
65: }
66:
67:
68: my %layout = ('border' => 0);
69: if ($env{'environment.remote'} eq 'off') {
70: $layout{'rows'} = "180,*";
71: } else {
72: $layout{'rows'} = "1,*";
73: $topurl = "/adm/rat/empty.html";
74: }
75:
76: my $start_page =
77: &Apache::loncommon::start_page(undef,undef,
78: {'force_register' => 1,
79: 'frameset' => 1,
80: 'add_entries' => \%layout, });
81:
82: my $end_page =
83: &Apache::loncommon::end_page({'frameset' => 1});
84:
85:
86: #
87: # frame-based rendering for graphical interface
88: #
89: my $result =<<ENDDOCUMENT;
90: $start_page
91: test
92: <frame src="$topurl" />
93: <frame src="$bottomurl" />
94: $end_page
95: ENDDOCUMENT
96:
97: return $result;
98: }
99:
100: sub handler {
101: my $r=shift;
102: &Apache::loncommon::content_type($r,'text/html');
103: $r->send_http_header;
104:
105: return OK if $r->header_only;
106:
107: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
108: ['wrapperdisplay']);
109: if ($env{'form.wrapperdisplay'} eq 'menu') {
110: $r->print(&simple_menu());
111: return OK;
112: }
113:
114: my $orgurl=$r->uri;
115: my $url=$orgurl;
116: $orgurl.=(($orgurl=~/\?/)?'&':'?').$ENV{'QUERY_STRING'};
117: $orgurl.=(($orgurl=~/\?/)?'&':'?').'wrapperdisplay=menu';
118: $url=~s/^\/adm\/wrapper//;
119: my $is_ext = $url =~ m|^/ext/|;
120: $url=~s/^\/ext\//http\:\/\//;
121: $url=~s|:|:|g;
122: #
123: # Actual URL
124: #
125: if ($url=~/\.(problem|exam|quiz|assess|survey|form|library)$/) {
126: #
127: # This is uploaded homework
128: #
129: $env{'request.state'}='uploaded';
130: &Apache::lonhomework::renderpage($r,$url);
131: } else {
132: #
133: # This is not homework
134: #
135: if ($is_ext) {
136: $ENV{'QUERY_STRING'}=~s/(^|\&)symb=[^\&]*/$1/;
137: }
138: $url.=(($url=~/\?/)?'&':'?').$ENV{'QUERY_STRING'};
139: # reappend the query arguments
140: $r->print(&wrapper($orgurl,$url));
141: } # not just the menu
142: return OK;
143: } # handler
144:
145: 1;
146: __END__
147:
148:
149:
150:
151:
152:
153:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>