Annotation of rat/lonwrapper.pm, revision 1.49.2.11.2.2
1.1 www 1: # The LearningOnline Network with CAPA
2: # Wrapper for external and binary files as standalone resources
3: #
1.49.2.11.2.2! (raeburn 4:: # $Id: lonwrapper.pm,v 1.49.2.11.2.1 2022/01/02 15:37:30 raeburn Exp $
1.4 www 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: #
1.1 www 28:
1.29 jms 29:
1.1 www 30: package Apache::lonwrapper;
31:
32: use strict;
33: use Apache::Constants qw(:common);
1.38 droeschl 34: use Apache::lonenc();
1.18 albertel 35: use Apache::lonnet;
1.42 raeburn 36: use Apache::lonlocal;
37: use Apache::loncommon();
38: use Apache::lonhtmlcommon();
39: use Apache::lonextresedit();
1.49.2.11.2.1 (raeburn 40:: use Apache::lonexttool();
1.49.2.11.2.2! (raeburn 41:: use Apache::lonnavmaps();
1.49.2.11.2.1 (raeburn 42:: use LONCAPA qw(:DEFAULT :match);
43:: use HTML::Entities();
1.49.2.11.2.2! (raeburn 44:: use Digest::MD5();
1.1 www 45:
46: # ================================================================ Main Handler
1.21 albertel 47: sub wrapper {
1.49.2.11.2.1 (raeburn 48:: my ($r,$url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,$linktext,$explanation,
1.49.2.11.2.2! (raeburn 49:: $title,$width,$height,$reuse) = @_;
1.23 albertel 50:
1.42 raeburn 51: my $forcereg;
52: unless ($env{'form.folderpath'}) {
53: $forcereg = 1;
54: }
55:
1.46 raeburn 56: my %lt = &Apache::lonlocal::texthash(
57: 'noif' => 'No iframe support.',
58: 'show' => 'Show content in pop-up window',
59: );
60:
1.49.2.11 raeburn 61: (undef,undef,undef,undef,undef,undef,my $clientmobile) =
62: &Apache::loncommon::decode_user_agent($r);
63:
1.49.2.11.2.1 (raeburn 64:: my ($anchor,$uselink);
1.49.2.2 raeburn 65: if ($is_ext) {
66: if ($env{'form.symb'}) {
67: (undef,undef,my $res) = &Apache::lonnet::decode_symb($env{'form.symb'});
1.49.2.3 raeburn 68: if ($res =~ /(#[^#]+)$/) {
1.49.2.2 raeburn 69: $anchor = $1;
70: }
71: } elsif ($env{'form.anchor'} ne '') {
72: $anchor = '#'.$env{'form.anchor'};
1.49.2.1 raeburn 73: }
1.49.2.11.2.2! (raeburn 74:: if (($is_ext eq 'tab') || ($is_ext eq 'window')) {
! 75:: $uselink = 1;
! 76:: }
! 77:: unless (($is_pdf && $clientmobile) || $uselink) {
1.49.2.6 raeburn 78: my $hostname = $r->hostname();
79: my $lonhost = $r->dir_config('lonHostID');
80: my $ip = &Apache::lonnet::get_host_ip($lonhost);
81: $uselink = &Apache::loncommon::is_nonframeable($url,$absolute,$hostname,$ip);
82: }
1.49.2.1 raeburn 83: }
84:
85: my $noiframe = &Apache::loncommon::modal_link($url.$anchor,$lt{'show'},500,400);
1.42 raeburn 86: my $args = {'bgcolor' => '#FFFFFF'};
87: if ($forcereg) {
88: $args->{'force_register'} = $forcereg;
89: }
90: if (ref($brcrum) eq 'ARRAY') {
1.45 raeburn 91: $args->{'bread_crumbs'} = $brcrum;
1.42 raeburn 92: }
1.44 raeburn 93: if ($absolute) {
1.49.2.4 raeburn 94: $args->{'use_absolute'} = $absolute;
95: }
96: if ($env{'form.only_body'}) {
97: $args->{'only_body'} = $env{'form.only_body'};
1.44 raeburn 98: }
1.42 raeburn 99:
1.49.2.8 raeburn 100: my $headjs;
101:
102: #
103: # Where iframe is in use, if window.onload() executes before the custom resize function
104: # has been defined (jQuery), two global javascript vars (LCnotready and LCresizedef)
105: # are used to ensure document.ready() triggers a call to resize, so the iframe contents
106: # do not obscure the Functions menu.
107: #
108:
1.49.2.11.2.1 (raeburn 109:: unless ($clientmobile || ($exttool eq 'window') || ($exttool eq 'tab') || $uselink) {
1.49.2.8 raeburn 110: $headjs = '
111: <script type="text/javascript">
112: // <![CDATA[
113: var LCnotready = 0;
114: var LCresizedef = 0;
115: // ]]>
116: </script>'."\n";
1.49.2.9 raeburn 117: }
1.49.2.8 raeburn 118:
119: my $startpage = &Apache::loncommon::start_page('Menu',$headjs,$args);
1.46 raeburn 120: my $endpage = &Apache::loncommon::end_page();
1.38 droeschl 121:
1.49.2.6 raeburn 122: if (($uselink) && ($title eq '')) {
123: if ($env{'form.symb'}) {
124: $title=&Apache::lonnet::gettitle($env{'form.symb'});
125: } else {
126: my $symb=&Apache::lonnet::symbread($r->uri);
127: if ($symb) {
128: $title=&Apache::lonnet::gettitle($symb);
129: }
130: }
131: }
1.49.2.11.2.2! (raeburn 132:: if ($clientmobile || ($exttool eq 'window') || ($exttool eq 'tab') ||
! 133:: ($is_ext eq 'tab') || ($is_ext eq 'window')) {
1.47 raeburn 134: my $output = $startpage;
135: if ($is_pdf) {
1.49.2.6 raeburn 136: $linktext = &mt('Link to PDF (for mobile devices)');
137: $output .= &create_link($url,$anchor,$title,$linktext);
1.49.2.11.2.2! (raeburn 138:: } elsif (($exttool eq 'window') || ($exttool eq 'tab') ||
! 139:: ($is_ext eq 'tab') || ($is_ext eq 'window')) {
! 140:: my $preamble;
1.49.2.11.2.1 (raeburn 141:: if ($linktext eq '') {
1.49.2.11.2.2! (raeburn 142:: if ($exttool) {
! 143:: $linktext = &mt('Launch External Tool');
! 144:: } else {
! 145:: $linktext = &mt('Link to External Resource');
! 146:: }
! 147:: }
! 148:: if ($exttool) {
! 149:: $url = &HTML::Entities::encode($url,'"<>&');
! 150:: } else {
! 151:: $url = &HTML::Entities::encode($url.$anchor,'&<>"');
1.49.2.11.2.1 (raeburn 152:: }
1.49.2.11.2.2! (raeburn 153:: if (($exttool eq 'tab') || ($is_ext eq 'tab')) {
! 154:: my $target;
! 155:: if ($exttool) {
! 156:: $target = 'LCExternalToolTab';
! 157:: } else {
! 158:: if ($reuse) {
! 159:: $target = 'LCExternalResTab';
! 160:: } else {
! 161:: $target = '_blank';
! 162:: }
! 163:: if ($title ne '') {
! 164:: $preamble = '<span style="font-weight:bold;">'.$title.'</span><br />';
! 165:: }
! 166:: }
! 167:: $output .= '<div>'.$preamble.
! 168:: '<a href="'.$url.'" target="'.$target.'" style="padding:0;clear:both;margin:0;border:0">'.
1.49.2.11.2.1 (raeburn 169:: $linktext.'</a>'.
170:: '</div>';
171:: } else {
1.49.2.11.2.2! (raeburn 172:: my ($target,$extlinkimg);
! 173:: if ($exttool) {
! 174:: $target = 'LCExternalToolPopUp';
! 175:: } else {
! 176:: $target = 'LCExternalResPopUp';
! 177:: if ($title ne '') {
! 178:: $preamble = '<span style="font-weight:bold;">'.$title.'</span><br />';
! 179:: }
! 180:: $extlinkimg = '<img src="'.&Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL').'/externallink.gif').'" width="19" height="18" border="0" />';
! 181:: unless ($reuse) {
! 182:: my $resid;
! 183:: if ($env{'request.course.id'}) {
! 184:: unless ($env{'form.folderpath'} =~ /^supplemental/) {
! 185:: my $symb=&Apache::lonnet::symbread($r->uri);
! 186:: if ($symb) {
! 187:: my $navmap = Apache::lonnavmaps::navmap->new();
! 188:: if (ref($navmap)) {
! 189:: my $res = $navmap->getBySymb($symb);
! 190:: if (ref($res)) {
! 191:: $resid = $res->id;
! 192:: $resid =~ s/\./_/g;
! 193:: }
! 194:: }
! 195:: }
! 196:: }
! 197:: }
! 198:: if ($resid eq '') {
! 199:: $resid = substr(Digest::MD5::md5_hex(Digest::MD5::md5_hex(time(). {}. rand(). $$)), 0, 8);
! 200:: }
! 201:: &js_escape(\$resid);
! 202:: $target .= $resid;
! 203:: }
! 204:: }
1.49.2.11.2.1 (raeburn 205:: $output .= <<"ENDLINK";
206:: <script type="text/javascript">
207:: // <![CDATA[
208:: var windowObjectReference = null;
209:: var PreviousUrl;
210::
211:: function openSinglePopup(strUrl) {
212:: if (windowObjectReference == null || windowObjectReference.closed) {
1.49.2.11.2.2! (raeburn 213:: windowObjectReference = window.open(strUrl, "$target",
1.49.2.11.2.1 (raeburn 214:: "height=$height,width=$width,scrollbars=yes,resizable=yes,status=yes,menubar=no,location=no'");
215:: } else if(PreviousUrl != strUrl) {
1.49.2.11.2.2! (raeburn 216:: windowObjectReference = window.open(strUrl, "$target",
1.49.2.11.2.1 (raeburn 217:: "height=$height,width=$width,scrollbars=yes,resizable=yes,status=yes,menubar=no,location=no'");
218:: windowObjectReference.focus();
219:: } else {
220:: windowObjectReference.focus();
221:: };
222:: PreviousUrl = strUrl;
223:: }
224:: // ]]>
225:: </script>
1.49.2.11.2.2! (raeburn 226:: <div>$preamble
! 227:: <a href="$url" target="$target" onclick="openSinglePopup(this.href); return false;">
! 228:: $linktext$extlinkimg</a>
1.49.2.11.2.1 (raeburn 229:: </div>
230:: ENDLINK
231:: }
1.49.2.11.2.2! (raeburn 232:: if ($exttool) {
! 233:: if ($explanation ne '') {
! 234:: $output .= '<div>'.$explanation.'</div>';
! 235:: }
1.49.2.11.2.1 (raeburn 236:: }
1.47 raeburn 237: } else {
1.49.2.6 raeburn 238: if ($uselink) {
239: $linktext = &mt('Link to resource');
240: $output .= &create_link($url,$anchor,$title,$linktext);
241: } else {
242: my $dest = &HTML::Entities::encode($url.$anchor,'&<>"');
243: $output .= '<div style="overflow:scroll; -webkit-overflow-scrolling:touch;">'."\n".
244: '<iframe src="'.$dest.'" height="100%" width="100%" frameborder="0">'."\n".
245: "$lt{'noif'} $noiframe\n".
246: "</iframe>\n".
247: "</div>\n";
248: }
1.47 raeburn 249: }
250: $output .= $endpage;
251: return $output;
1.49.2.6 raeburn 252: } elsif ($uselink) {
253: $linktext = &mt('Link to resource');
254: return $startpage.&create_link($url,$anchor,$title,$linktext).$endpage;
1.46 raeburn 255: } else {
1.49.2.3 raeburn 256: my $offset = 5;
257: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['inhibitmenu']);
258: if ($env{'form.inhibitmenu'} eq 'yes') {
259: $offset = 0;
260: }
1.46 raeburn 261: my $script = &Apache::lonhtmlcommon::scripttag(<<SCRIPT);
262: \$(document).ready( function() {
263: \$(window).unbind('resize').resize(function(){
1.49.2.3 raeburn 264: var header = null;
265: var offset = $offset;
1.46 raeburn 266: var height = 0;
267: var hdrtop = 0;
268: if (\$('div.LC_head_subbox:first').length) {
269: header = \$('div.LC_head_subbox:first');
270: offset = 9;
271: } else {
272: if (\$('#LC_breadcrumbs').length) {
273: header = \$('#LC_breadcrumbs');
274: }
275: }
1.49.2.3 raeburn 276: if (header != null && header.length) {
1.46 raeburn 277: height = header.height();
278: hdrtop = header.position().top;
1.42 raeburn 279: }
1.46 raeburn 280: var pos = height + hdrtop + offset;
281: \$('.LC_iframecontainer').css('top', pos);
282: });
1.49.2.8 raeburn 283: LCresizedef = 1;
284: if (LCnotready == 1) {
285: LCnotready = 0;
286: \$(window).trigger('resize');
287: }
1.38 droeschl 288: });
1.49.2.8 raeburn 289: window.onload = function(){
290: if (LCresizedef) {
291: LCnotready = 0;
1.49.2.9 raeburn 292: \$(window).trigger('resize');
1.49.2.8 raeburn 293: } else {
294: LCnotready = 1;
295: }
296: };
1.39 droeschl 297: SCRIPT
1.46 raeburn 298: # javascript will position the iframe if window was resized (or zoomed)
1.49.2.11.2.1 (raeburn 299:: my $dest = &HTML::Entities::encode($url.$anchor,'&<>"');
1.46 raeburn 300: return <<ENDFRAME;
301: $startpage
302: $script
303: <div class="LC_iframecontainer">
1.49.2.11.2.1 (raeburn 304:: <iframe src="$dest">$lt{'noif'} $noiframe</iframe>
1.46 raeburn 305: </div>
306: $endpage
1.38 droeschl 307: ENDFRAME
1.46 raeburn 308: }
1.21 albertel 309: }
310:
1.49.2.6 raeburn 311: sub create_link {
312: my ($url,$anchor,$title,$linktext) = @_;
313: my $shownlink;
314: if ($title eq '') {
315: $title = $env{'form.title'};
316: if ($title eq '') {
317: unless ($env{'request.enc'}) {
318: ($title) = ($url =~ m{/([^/]+)$});
319: $title =~ s/(\?[^\?]+)$//;
320: }
321: }
322: }
323: unless ($title eq '') {
324: $shownlink = '<span style="font-weight:bold;">'.$title.'</span><br />';
325: }
326: my $dest = &HTML::Entities::encode($url.$anchor,'&<>"');
327: $shownlink .= '<a href="'.$dest.'">'.$linktext.'</a>';
328: return $shownlink;
329: }
330:
1.21 albertel 331: sub handler {
332: my $r=shift;
333: &Apache::loncommon::content_type($r,'text/html');
334: $r->send_http_header;
335:
336: return OK if $r->header_only;
337:
1.38 droeschl 338: my $url = $r->uri;
1.49.2.11.2.1 (raeburn 339:: my ($is_ext,$brcrum,$absolute,$is_pdf,$exttool,$cdom,$cnum,$hostname,
1.49.2.11.2.2! (raeburn 340:: $linktext,$explanation,$width,$height,$reuse);
1.38 droeschl 341:
342: for ($url){
343: s|^/adm/wrapper||;
1.49.2.8 raeburn 344: $is_ext = $_ =~ s|^/ext/|http://|;
1.49.2.10 raeburn 345: s|http://https://|https://| if ($is_ext);
1.49.2.8 raeburn 346: s|:|:|g;
1.21 albertel 347: }
348:
1.47 raeburn 349: if ($url =~ /\.pdf$/i) {
350: $is_pdf = 1;
1.49.2.11.2.2! (raeburn 351:: } elsif (($is_ext) && ($env{'request.course.id'})) {
! 352:: if ($env{'course.'.$env{'request.course.id'}.'.extresource'}) {
! 353:: (my $selected,$reuse,$width,$height) = split(/:/,$env{'course.'.$env{'request.course.id'}.'.extresource'});
! 354:: if ($selected eq 'tab') {
! 355:: $is_ext = 'tab';
! 356:: $width = '';
! 357:: $height = '';
! 358:: } elsif ($selected eq 'window') {
! 359:: $is_ext = 'window';
! 360:: unless ($width =~ /^\d+$/) {
! 361:: $width = '';
! 362:: }
! 363:: unless ($height =~ /^\d+$/) {
! 364:: $height = '';
! 365:: }
! 366:: } else {
! 367:: $width = '';
! 368:: $height = '';
! 369:: $reuse = '';
! 370:: }
! 371:: }
1.49.2.11.2.1 (raeburn 372:: } elsif ($url =~ m{^/adm/($match_domain)/($match_courseid)/(\d+)/ext\.tool$}) {
373:: $cdom = $1;
374:: $cnum = $2;
375:: my $marker = $3;
376:: $exttool = 'iframe';
377:: my $exttoolremote;
378:: my %toolhash = &Apache::lonnet::get('exttool_'.$marker,['target','linktext','explanation','id','width','height'],
379:: $cdom,$cnum);
380:: if ($toolhash{'id'}) {
381:: my %ltitools = &Apache::lonnet::get_domain_lti($cdom,'consumer');
382:: if (ref($ltitools{$toolhash{'id'}}) eq 'HASH') {
383:: $exttoolremote = $ltitools{$toolhash{'id'}}{'url'};
384:: }
385:: }
386:: if ($toolhash{'target'} eq 'window') {
387:: $exttool = 'window';
388:: $width = $toolhash{'width'};
389:: $height = $toolhash{'height'};
390:: } elsif ($toolhash{'target'} eq 'tab') {
391:: $exttool = 'tab';
392:: }
393:: if (($exttool eq 'window') || ($exttool eq 'tab')) {
394:: $linktext = $toolhash{'linktext'};
395:: $explanation = $toolhash{'explanation'};
396:: } elsif (($exttoolremote =~ /^http:/) && ($ENV{'SERVER_PORT'} == 443)) {
397:: $exttool = 'tab';
398:: }
1.47 raeburn 399: }
1.49.2.11.2.1 (raeburn 400:: if (($is_ext) || ($exttool)) {
1.42 raeburn 401: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.49.2.2 raeburn 402: ['forceedit','register','folderpath','symb','idx','title','anchor']);
1.42 raeburn 403: if (($env{'form.forceedit'}) &&
404: (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) &&
405: (($env{'form.folderpath'} =~ /^supplemental/) ||
406: ($env{'form.symb'} =~ /^uploaded/))) {
1.49.2.2 raeburn 407: if ($env{'form.symb'}) {
408: (undef,undef,my $res) = &Apache::lonnet::decode_symb($env{'form.symb'});
409: if ($res =~ /(#[^#]+)$/) {
410: $url .= $1;
411: }
412: } elsif ($env{'form.folderpath'} =~ /^supplemental/) {
413: if ($env{'form.anchor'} ne '') {
414: $url .= '#'.$env{'form.anchor'};
415: }
416: }
1.49.2.11.2.1 (raeburn 417:: my $type = 'ext';
418:: if ($exttool) {
419:: $type = 'tool';
420:: } elsif (($url =~ /^http:/) && ($ENV{'SERVER_PORT'} == 443)) {
1.49.2.5 raeburn 421: $hostname = $r->hostname();
422: }
1.42 raeburn 423: $r->print(
424: &Apache::lonextresedit::display_editor($url,$env{'form.folderpath'},
425: $env{'form.symb'},
1.49.2.5 raeburn 426: $env{'form.idx'},$type,$cdom,
427: $cnum,$hostname));
1.42 raeburn 428: return OK;
429: } elsif ($env{'form.folderpath'} =~ /^supplemental/) {
430: my $crstype = &Apache::loncommon::course_type();
1.43 raeburn 431: my $title = $env{'form.title'};
432: if ($title eq '') {
1.49.2.11.2.1 (raeburn 433:: if ($is_ext) {
434:: $title = &mt('External Resource');
435:: } else {
436:: $title = &mt('External Tool');
437:: }
1.43 raeburn 438: }
1.42 raeburn 439: $brcrum =
1.43 raeburn 440: &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
1.42 raeburn 441: }
442: }
443:
1.21 albertel 444: #
445: # Actual URL
446: #
1.49.2.11.2.1 (raeburn 447:: if (($url=~/$LONCAPA::assess_re/) && (!$exttool)) {
1.21 albertel 448: #
449: # This is uploaded homework
450: #
1.38 droeschl 451: $env{'request.state'}='uploaded';
452: &Apache::lonhomework::renderpage($r,$url);
1.21 albertel 453: } else {
454: #
455: # This is not homework
456: #
1.49.2.11.2.1 (raeburn 457:: if (($is_ext) || ($exttool)) {
1.49 raeburn 458: $absolute = $env{'request.use_absolute'};
1.38 droeschl 459: $ENV{'QUERY_STRING'} =~ s/(^|\&)symb=[^\&]*/$1/;
1.42 raeburn 460: $ENV{'QUERY_STRING'} =~ s/\&$//;
1.38 droeschl 461: }
462:
1.35 raeburn 463: unless ($ENV{'QUERY_STRING'} eq '') {
1.38 droeschl 464: $url.=(($url=~/\?/)?'&':'?').$ENV{'QUERY_STRING'};
1.35 raeburn 465: }
1.38 droeschl 466:
467: # encrypt url if not external
1.49.2.11.2.1 (raeburn 468:: unless ($is_ext) {
469:: &Apache::lonenc::check_encrypt(\$url);
470:: }
1.38 droeschl 471:
1.49.2.11.2.1 (raeburn 472:: $r->print( wrapper($r,$url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,
1.49.2.11.2.2! (raeburn 473:: $linktext,$explanation,undef,$width,$height,$reuse) );
1.38 droeschl 474:
1.21 albertel 475: } # not just the menu
1.38 droeschl 476:
1.21 albertel 477: return OK;
1.13 www 478: } # handler
1.1 www 479:
480: 1;
481: __END__
482:
1.30 jms 483: =pod
1.1 www 484:
1.30 jms 485: =head1 NAME
486:
487: Apache::lonwrapper - External and binary file management.
488:
489: =head1 SYNOPSIS
490:
491: Wrapper for external and binary files as standalone resources. Edit handler for rat maps; TeX content handler.
492:
493: This is part of the LearningOnline Network with CAPA project
494: described at http://www.lon-capa.org.
495:
496: =head1 Subroutines
497:
498: =over
499:
1.49.2.11.2.2! (raeburn 500:: =item wrapper($r,$url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,$linktext,$explanation,$title,$width,$height,$reuse)
1.30 jms 501:
1.45 raeburn 502: =over
503:
1.49.2.6 raeburn 504: =item $r
505:
506: request object
507:
1.46 raeburn 508: =item $url
509:
1.49.2.11.2.2! (raeburn 510:: url to display either by including in an iframe within a
! 511:: LON-CAPA page which has a standard LON-CAPA inline menu,
! 512:: or in some cases launched in a separate tab or window,
! 513:: launched via a link in a LON-CAPA page with standard inline
! 514:: menu.
1.45 raeburn 515:
516: =item $brcrum
517:
518: breadcrumbs for unregistered urls
1.42 raeburn 519: (i.e., external resources in Supplemental Content).
1.45 raeburn 520:
1.46 raeburn 521: =item $absolute
1.45 raeburn 522:
523: contains protocol (http or https) followed by
524: the hostname, if menu items in the standard LON-CAPA
525: interface created by the call to loncommon::start_page()
526: within &wrapper() need to use absolute URLs rather than
527: relative URLs.
528:
529: That will be the case where an external resource has been
530: served from port 80, when the server customarily serves
531: requests using Apache/SSL (i.e., port 443). mod_rewrite
1.49 raeburn 532: is used to switch requests for external resources and
533: the syllabus: /public/<domain>/<courseid>/syllabus
534: (which might also point at an external resource)
1.45 raeburn 535: from https:// to http:// where the the URL of the remote site
536: specified in the resource itself is http://.
537:
538: This is done to avoid default mixed content blocking
539: in Firefox 23 and later, when serving from Apache/SSL.
540:
541: =item $is_ext
542:
1.49.2.11.2.2! (raeburn 543:: true if URL is for an external resource. Default true value
! 544:: is 1 (display in iframe, unless $uselink is true).
! 545:: If external resource is to be displayed in a tab,
! 546:: value of $is_ext will be tab, if to be displayed in a pop-up window,
! 547:: value of $is_ext will be window.
1.45 raeburn 548:
1.47 raeburn 549: =item $is_pdf
550:
551: true if URL is for a PDF (based on file extension).
552:
1.49.2.11.2.2! (raeburn 553:: =item $exttool
! 554::
! 555:: If URL is for an External Tool, will contain the target type: iframe, window or tab.
! 556::
! 557:: =item $linktext
! 558::
! 559:: optional. If URL is for an External Tool, and target type is window or tab,
! 560:: then the link text may be an option set in the course for each tool instance,
! 561:: or may be a default defined in the domain for all instances of the tool.
! 562::
! 563:: =item $explanation
! 564::
! 565:: optional. If URL is for an External Tool, and target type is window or tab,
! 566:: then the explanation is an option set in the course for each tool instance,
! 567:: or may be a default defined in the domain for all instances of the tool.
! 568::
1.49 raeburn 569: =item $title
570:
1.49.2.11 raeburn 571: optional. If wrapped item is a PDF, and $clientmobile is true,
572: a link to a PDF is shown. The "title" will be displayed
1.49 raeburn 573: above the link, but if not provided as an arg, $env{'form.title'}
574: will be used, otherwise, the filename will be displayed (unless
575: hidden URL set for the resource).
576:
1.49.2.11.2.2! (raeburn 577:: =item $width
! 578::
! 579:: optional. If URL is for an External Tool, and target type is window,
! 580:: then a default width may have been defined in the domain for all instances of
! 581:: the tool. If so, that width will be used for the window opened (via a link)
! 582:: to launch the external tool. If the URL is for an External Resource, and
! 583:: $is_ext is window, then a default width (px) may have been defined in the current
! 584:: course for all external resource instances.
! 585::
! 586:: =item $height
! 587::
! 588:: optional. If URL is for an External Tool, and target type is window,
! 589:: then a default height may have been defined in the domain for all instances of
! 590:: the tool. If so, that height will be used for the window opened (via a link)
! 591:: to launch the external tool. If the URL is for an External Resource, and
! 592:: $is_ext is window, then a default height (px) may have been defined in the current
! 593:: course for all external resource instances.
! 594::
! 595:: =item $reuse
! 596::
! 597:: optional. If the URL is for an External Resource, and $is_ext is tab or window,
! 598:: then $reuse will be true if the same tab or window is to be reused for display
! 599:: of all external resource instances in a a course.
! 600::
1.45 raeburn 601: =back
602:
1.38 droeschl 603: Returns markup for the entire page.
1.30 jms 604:
605: =item handler()
606:
1.49.2.11.2.2! (raeburn 607:: Content handler for requests for: /adm/wrapper/...
! 608:: used for content to be displayed in an iframe, or launched in a separate tab
! 609:: or window via a link. The target URL is extracted from the requested URL, by
! 610:: removing the /adm/wrapper prefix.
! 611::
! 612:: The target URL will typically be a PDF served from the current server, an
! 613:: external resource URL served from a different server, or an external tool
! 614:: (from an LTI Provider) launched from LON-CAPA (as LTI Consumer) and launched
! 615:: via a link.
! 616::
! 617:: If the request included forceedit in the query string, and the requester has
! 618:: rights to modify course content, then the editor will be displayed to allow
! 619:: changes to be made to the resource (e.g., change the URL of the external resource,
! 620:: or change the setting for the external tool instance).
! 621::
! 622:: If not in edit mode, then the wrapper() subroutine will be called to generate the
! 623:: standard LON-CAPA inline menu, and then either a link to launch a separate tab or
! 624:: window, or an iframe to display the content inline.
! 625::
1.30 jms 626: =back
627:
628: =cut
1.1 www 629:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>