version 1.49.2.2, 2016/10/31 21:31:42
|
version 1.51, 2016/02/22 03:36:52
|
Line 37 use Apache::lonlocal;
|
Line 37 use Apache::lonlocal;
|
use Apache::loncommon(); |
use Apache::loncommon(); |
use Apache::lonhtmlcommon(); |
use Apache::lonhtmlcommon(); |
use Apache::lonextresedit(); |
use Apache::lonextresedit(); |
|
use Apache::lonexttool(); |
|
use LONCAPA qw(:DEFAULT :match);; |
|
|
# ================================================================ Main Handler |
# ================================================================ Main Handler |
sub wrapper { |
sub wrapper { |
my ($url,$brcrum,$absolute,$is_ext,$is_pdf,$title) = @_; |
my ($url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,$title) = @_; |
|
|
my $forcereg; |
my $forcereg; |
unless ($env{'form.folderpath'}) { |
unless ($env{'form.folderpath'}) { |
$forcereg = 1; |
$forcereg = 1; |
} |
} |
|
|
my %lt = &Apache::lonlocal::texthash( |
my %lt = &Apache::lonlocal::texthash( |
'noif' => 'No iframe support.', |
'noif' => 'No iframe support.', |
'show' => 'Show content in pop-up window', |
'show' => 'Show content in pop-up window', |
); |
); |
|
|
my $anchor; |
my $anchor; |
if ($is_ext) { |
if (($is_ext) && ($env{'form.symb'})) { |
if ($env{'form.symb'}) { |
(undef,undef,my $res) = &Apache::lonnet::decode_symb($env{'form.symb'}); |
(undef,undef,my $res) = &Apache::lonnet::decode_symb($env{'form.symb'}); |
if ($res =~ /(\#.+)$/) { |
if ($res =~ /(\#.+)$/) { |
$anchor = $1; |
$anchor = $1; |
|
} |
|
} elsif ($env{'form.anchor'} ne '') { |
|
$anchor = '#'.$env{'form.anchor'}; |
|
} |
} |
} |
} |
|
|
Line 78 sub wrapper {
|
Line 75 sub wrapper {
|
|
|
my $startpage = &Apache::loncommon::start_page('Menu',undef,$args); |
my $startpage = &Apache::loncommon::start_page('Menu',undef,$args); |
my $endpage = &Apache::loncommon::end_page(); |
my $endpage = &Apache::loncommon::end_page(); |
|
|
if ($env{'browser.mobile'}) { |
if (($env{'browser.mobile'}) || ($exttool eq 'window')) { |
my $output = $startpage; |
my $output = $startpage; |
if ($is_pdf) { |
if ($is_pdf) { |
if ($title eq '') { |
if ($title eq '') { |
Line 95 sub wrapper {
|
Line 92 sub wrapper {
|
$output .= $title.'<br />'; |
$output .= $title.'<br />'; |
} |
} |
$output .= '<a href="'.$url.'">'.&mt('Link to PDF (for mobile devices)').'</a>'; |
$output .= '<a href="'.$url.'">'.&mt('Link to PDF (for mobile devices)').'</a>'; |
|
} elsif ($exttool eq 'window') { |
|
$output .= '<div>'. |
|
'<a href="'.$url.'" target="LC_LTI" style="padding:0;clear:both;margin:0;border:0">'. |
|
&mt('Launch External Tool').'</a>'. |
|
'</div>'; |
} else { |
} else { |
$output .= '<div style="overflow:scroll; -webkit-overflow-scrolling:touch;">'."\n". |
$output .= '<div style="overflow:scroll; -webkit-overflow-scrolling:touch;">'."\n". |
'<iframe src="'.$url.$anchor.'" height="100%" width="100%" frameborder="0">'."\n". |
'<iframe src="'.$url.$anchor.'" height="100%" width="100%" frameborder="0">'."\n". |
Line 150 sub handler {
|
Line 152 sub handler {
|
return OK if $r->header_only; |
return OK if $r->header_only; |
|
|
my $url = $r->uri; |
my $url = $r->uri; |
my ($is_ext,$brcrum,$absolute,$is_pdf); |
my ($is_ext,$brcrum,$absolute,$is_pdf,$exttool,$cdom,$cnum); |
|
|
for ($url){ |
for ($url){ |
s|^/adm/wrapper||; |
s|^/adm/wrapper||; |
Line 159 sub handler {
|
Line 161 sub handler {
|
s|:|:|g; |
s|:|:|g; |
} |
} |
|
|
|
|
if ($url =~ /\.pdf$/i) { |
if ($url =~ /\.pdf$/i) { |
$is_pdf = 1; |
$is_pdf = 1; |
|
} elsif ($url =~ m{^/adm/($match_domain)/($match_courseid)/(\d+)/exttools?$}) { |
|
$cdom = $1; |
|
$cnum = $2; |
|
my $marker = $3; |
|
$exttool = 'iframe'; |
|
my %toolhash = &Apache::lonnet::get('exttool_'.$marker,['target'],$cdom,$cnum); |
|
if ($toolhash{'target'} eq 'window') { |
|
$exttool = 'window'; |
|
} |
} |
} |
|
if (($is_ext) || ($exttool)) { |
if ($is_ext) { |
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
['forceedit','register','folderpath','symb','idx','title','anchor']); |
['forceedit','register','folderpath','symb','idx','title']); |
if (($env{'form.forceedit'}) && |
if (($env{'form.forceedit'}) && |
(&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) && |
(&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) && |
(($env{'form.folderpath'} =~ /^supplemental/) || |
(($env{'form.folderpath'} =~ /^supplemental/) || |
($env{'form.symb'} =~ /^uploaded/))) { |
($env{'form.symb'} =~ /^uploaded/))) { |
if ($env{'form.symb'}) { |
my $type = 'ext'; |
(undef,undef,my $res) = &Apache::lonnet::decode_symb($env{'form.symb'}); |
my %ltitools; |
if ($res =~ /(#[^#]+)$/) { |
if ($exttool) { |
$url .= $1; |
$type = 'tool'; |
} |
%ltitools = &Apache::lonnet::get_domain_ltitools($cdom); |
} elsif ($env{'form.folderpath'} =~ /^supplemental/) { |
|
if ($env{'form.anchor'} ne '') { |
|
$url .= '#'.$env{'form.anchor'}; |
|
} |
|
} |
} |
$r->print( |
$r->print( |
&Apache::lonextresedit::display_editor($url,$env{'form.folderpath'}, |
&Apache::lonextresedit::display_editor($url,$env{'form.folderpath'}, |
$env{'form.symb'}, |
$env{'form.symb'}, |
$env{'form.idx'})); |
$env{'form.idx'},$type,$cdom, |
|
$cnum,\%ltitools)); |
return OK; |
return OK; |
} elsif ($env{'form.folderpath'} =~ /^supplemental/) { |
} elsif ($env{'form.folderpath'} =~ /^supplemental/) { |
my $crstype = &Apache::loncommon::course_type(); |
my $crstype = &Apache::loncommon::course_type(); |
my $title = $env{'form.title'}; |
my $title = $env{'form.title'}; |
if ($title eq '') { |
if ($title eq '') { |
$title = &mt('External Resource'); |
if ($is_ext) { |
|
$title = &mt('External Resource'); |
|
} else { |
|
$title = &mt('External Tool'); |
|
} |
} |
} |
$brcrum = |
$brcrum = |
&Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1); |
&Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1); |
Line 209 sub handler {
|
Line 221 sub handler {
|
# |
# |
# This is not homework |
# This is not homework |
# |
# |
if ($is_ext) { |
if (($is_ext) || ($exttool)) { |
$absolute = $env{'request.use_absolute'}; |
$absolute = $env{'request.use_absolute'}; |
$ENV{'QUERY_STRING'} =~ s/(^|\&)symb=[^\&]*/$1/; |
$ENV{'QUERY_STRING'} =~ s/(^|\&)symb=[^\&]*/$1/; |
$ENV{'QUERY_STRING'} =~ s/\&$//; |
$ENV{'QUERY_STRING'} =~ s/\&$//; |
Line 220 sub handler {
|
Line 232 sub handler {
|
} |
} |
|
|
# encrypt url if not external |
# encrypt url if not external |
&Apache::lonenc::check_encrypt(\$url) if $url !~ /^https?\:/ ; |
unless ($is_ext || $exttool) { |
|
&Apache::lonenc::check_encrypt(\$url); |
|
} |
|
|
$r->print( wrapper($url,$brcrum,$absolute,$is_ext,$is_pdf) ); |
$r->print( wrapper($url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool) ); |
|
|
} # not just the menu |
} # not just the menu |
|
|