Annotation of rat/lonwrapper.pm, revision 1.77

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>