version 1.25, 2006/11/30 23:35:38
|
version 1.44, 2013/09/07 19:58:08
|
Line 26
|
Line 26
|
# http://www.lon-capa.org/ |
# http://www.lon-capa.org/ |
# |
# |
|
|
|
|
package Apache::lonwrapper; |
package Apache::lonwrapper; |
|
|
use strict; |
use strict; |
use Apache::Constants qw(:common); |
use Apache::Constants qw(:common); |
use Apache::lonnet; |
|
use Apache::lonxml(); |
|
use Apache::lonenc(); |
use Apache::lonenc(); |
use Apache::lonmenu(); |
use Apache::lonnet; |
|
use Apache::lonlocal; |
|
use Apache::loncommon(); |
|
use Apache::lonhtmlcommon(); |
|
use Apache::lonextresedit(); |
|
|
# ================================================================ Main Handler |
# ================================================================ Main Handler |
|
|
sub simple_menu { |
|
# |
|
# Producing the menu buttons |
|
# |
|
return &Apache::loncommon::start_page('Menu',undef, |
|
{'only_body' => 1, |
|
'bgcolor' => '#FFFFFF',}). |
|
&Apache::lonmenu::menubuttons(1,'web',1). |
|
&Apache::loncommon::end_page(); |
|
} |
|
|
|
|
|
sub wrapper { |
sub wrapper { |
my ($topurl,$bottomurl) = @_; |
my ($url,$brcrum,$absolute) = @_; |
|
|
if ($env{'browser.interface'} eq 'textual') { |
my $forcereg; |
# |
unless ($env{'form.folderpath'}) { |
# ssi-based rendering for text-based interface |
$forcereg = 1; |
# |
|
return |
|
&Apache::loncommon::start_page('Menu',undef, |
|
{'bgcolor' => '#FFFFFF', |
|
'force_register' => 1, |
|
}). |
|
&Apache::lonnet::ssi_body($bottomurl). |
|
&Apache::loncommon::end_page(); |
|
} |
} |
|
|
|
my $args = {'bgcolor' => '#FFFFFF'}; |
my %layout = ('border' => 0); |
if ($forcereg) { |
if ($env{'environment.remote'} eq 'off') { |
$args->{'force_register'} = $forcereg; |
$layout{'rows'} = "180,*"; |
} |
} else { |
if (ref($brcrum) eq 'ARRAY') { |
$layout{'rows'} = "1,*"; |
$args->{'bread_crumbs'} = $brcrum; |
$topurl = "/adm/rat/empty.html"; |
} |
|
if ($absolute) { |
|
$args->{'use_absolute'} = $absolute; |
} |
} |
|
|
my $start_page = |
my $startpage = Apache::loncommon::start_page('Menu',undef,$args); |
&Apache::loncommon::start_page(undef,undef, |
my $endpage = Apache::loncommon::end_page(); |
{'force_register' => 1, |
|
'frameset' => 1, |
|
'add_entries' => \%layout, }); |
|
|
|
my $end_page = |
|
&Apache::loncommon::end_page({'frameset' => 1}); |
|
|
|
foreach my $url ($topurl,$bottomurl) { |
|
if ($url !~ /^http:/) { |
|
$url = &Apache::lonenc::check_encrypt($url); |
|
} |
|
} |
|
# |
|
# frame-based rendering for graphical interface |
|
# |
|
my $result =<<ENDDOCUMENT; |
|
$start_page |
|
test |
|
<frame src="$topurl" /> |
|
<frame src="$bottomurl" /> |
|
$end_page |
|
ENDDOCUMENT |
|
|
|
return $result; |
my $script = Apache::lonhtmlcommon::scripttag(<<SCRIPT ); |
|
\$(document).ready( function() { |
|
\$(window).unbind('resize').resize(function(){ |
|
var header; |
|
var offset = 5; |
|
var height = 0; |
|
var hdrtop = 0; |
|
if (\$('div.LC_head_subbox:first').length) { |
|
header = \$('div.LC_head_subbox:first'); |
|
offset = 9; |
|
} else { |
|
if (\$('#LC_breadcrumbs').length) { |
|
header = \$('#LC_breadcrumbs'); |
|
} |
|
} |
|
if (header.length) { |
|
height = header.height(); |
|
hdrtop = header.position().top; |
|
} |
|
var pos = height + hdrtop + offset; |
|
\$('.LC_iframecontainer').css('top', pos); |
|
}); |
|
}); |
|
window.onload = function(){ \$(window).trigger('resize') }; |
|
SCRIPT |
|
|
|
# javascript will position the iframe if window was resized (or zoomed) |
|
return <<ENDFRAME; |
|
$startpage |
|
$script |
|
<div class="LC_iframecontainer"> |
|
<iframe src="$url">No iframe support!</iframe> |
|
</div> |
|
$endpage |
|
ENDFRAME |
} |
} |
|
|
sub handler { |
sub handler { |
Line 109 sub handler {
|
Line 105 sub handler {
|
|
|
return OK if $r->header_only; |
return OK if $r->header_only; |
|
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
my $url = $r->uri; |
['wrapperdisplay']); |
my ($is_ext,$brcrum,$absolute); |
if ($env{'form.wrapperdisplay'} eq 'menu') { |
|
$r->print(&simple_menu()); |
for ($url){ |
return OK; |
s|^/adm/wrapper||; |
} |
$is_ext = $_ =~ s|^/ext/|http://|; |
|
s|http://https://|https://|; |
my $orgurl=$r->uri; |
s|:|:|g; |
my $url=$orgurl; |
} |
$orgurl.=(($orgurl=~/\?/)?'&':'?').$ENV{'QUERY_STRING'}; |
|
$orgurl.=(($orgurl=~/\?/)?'&':'?').'wrapperdisplay=menu'; |
if ($is_ext) { |
$url=~s/^\/adm\/wrapper//; |
my $hostname = $r->hostname(); |
my $is_ext = $url =~ m|^/ext/|; |
my $lonhost = &Apache::lonnet::host_from_dns($hostname); |
$url=~s/^\/ext\//http\:\/\//; |
if ($lonhost) { |
$url=~s|http://https://|https://|; |
my $actual = &Apache::lonnet::absolute_url($hostname); |
$url=~s|:|:|g; |
my $expected = $Apache::lonnet::protocol{$lonhost}.'://'.$hostname; |
|
unless ($actual eq $expected) { |
|
$absolute = $expected; |
|
} |
|
} |
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
|
['forceedit','register','folderpath','symb','idx','title']); |
|
if (($env{'form.forceedit'}) && |
|
(&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) && |
|
(($env{'form.folderpath'} =~ /^supplemental/) || |
|
($env{'form.symb'} =~ /^uploaded/))) { |
|
$r->print( |
|
&Apache::lonextresedit::display_editor($url,$env{'form.folderpath'}, |
|
$env{'form.symb'}, |
|
$env{'form.idx'})); |
|
return OK; |
|
} elsif ($env{'form.folderpath'} =~ /^supplemental/) { |
|
my $crstype = &Apache::loncommon::course_type(); |
|
my $title = $env{'form.title'}; |
|
if ($title eq '') { |
|
$title = &mt('External Resource'); |
|
} |
|
$brcrum = |
|
&Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1); |
|
} |
|
} |
|
|
# |
# |
# Actual URL |
# Actual URL |
# |
# |
if ($url=~/\.(problem|exam|quiz|assess|survey|form|library)$/) { |
if ($url=~/$LONCAPA::assess_re/) { |
# |
# |
# This is uploaded homework |
# This is uploaded homework |
# |
# |
$env{'request.state'}='uploaded'; |
$env{'request.state'}='uploaded'; |
&Apache::lonhomework::renderpage($r,$url); |
&Apache::lonhomework::renderpage($r,$url); |
} else { |
} else { |
# |
# |
# This is not homework |
# This is not homework |
# |
# |
if ($is_ext) { |
if ($is_ext) { |
$ENV{'QUERY_STRING'}=~s/(^|\&)symb=[^\&]*/$1/; |
$ENV{'QUERY_STRING'} =~ s/(^|\&)symb=[^\&]*/$1/; |
} |
$ENV{'QUERY_STRING'} =~ s/\&$//; |
$url.=(($url=~/\?/)?'&':'?').$ENV{'QUERY_STRING'}; |
} |
# reappend the query arguments |
|
$r->print(&wrapper($orgurl,$url)); |
unless ($ENV{'QUERY_STRING'} eq '') { |
|
$url.=(($url=~/\?/)?'&':'?').$ENV{'QUERY_STRING'}; |
|
} |
|
|
|
# encrypt url if not external |
|
&Apache::lonenc::check_encrypt(\$url) if $url !~ /^https?\:/ ; |
|
|
|
$r->print( wrapper($url,$brcrum,$absolute) ); |
|
|
} # not just the menu |
} # not just the menu |
|
|
return OK; |
return OK; |
} # handler |
} # handler |
|
|
1; |
1; |
__END__ |
__END__ |
|
|
|
=pod |
|
|
|
=head1 NAME |
|
|
|
Apache::lonwrapper - External and binary file management. |
|
|
|
=head1 SYNOPSIS |
|
|
|
Wrapper for external and binary files as standalone resources. Edit handler for rat maps; TeX content handler. |
|
|
|
This is part of the LearningOnline Network with CAPA project |
|
described at http://www.lon-capa.org. |
|
|
|
=head1 Subroutines |
|
|
|
=over |
|
|
|
=item wrapper($url,$brcrum) |
|
|
|
Wraps $url in an iframe and generates a page for it. |
|
$brcrum contains breadcrumbs for unregistered urls |
|
(i.e., external resources in Supplemental Content). |
|
Returns markup for the entire page. |
|
|
|
=item handler() |
|
|
|
=back |
|
|
|
=cut |
|
|
|
|
|
|
|
|