Annotation of rat/lonwrapper.pm, revision 1.40

1.1       www         1: # The LearningOnline Network with CAPA
                      2: # Wrapper for external and binary files as standalone resources
                      3: #
1.40    ! raeburn     4: # $Id: lonwrapper.pm,v 1.39 2010/03/04 19:35:53 droeschl 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.1       www        36: 
                     37: # ================================================================ Main Handler
1.21      albertel   38: sub wrapper {
1.38      droeschl   39:     my $url = shift;
1.23      albertel   40: 
1.38      droeschl   41:     my $startpage =  Apache::loncommon::start_page('Menu',undef,
                     42: 					  { 'force_register' =>1, 'bgcolor'   => '#FFFFFF',}) ;
                     43:     my $endpage =  Apache::loncommon::end_page();
                     44: 
1.39      droeschl   45:     my $script = Apache::lonhtmlcommon::scripttag(<<SCRIPT );
1.38      droeschl   46:     \$(document).ready( function() {
                     47:         \$(window).unbind('resize').resize(function(){
1.40    ! raeburn    48:             var header = \$('.LC_head_subbox')[0] ?  \$('.LC_head_subbox') 
1.39      droeschl   49:                                                   :  \$('#LC_breadcrumbs');
1.38      droeschl   50:             var pos = header.height() + header.position().top + 5;
1.39      droeschl   51:             \$('.LC_iframecontainer').css('top', pos);
1.38      droeschl   52:         });
                     53:     });
1.39      droeschl   54:     window.onload = function(){  \$(window).trigger('resize') }; 
                     55: SCRIPT
1.38      droeschl   56: 
1.39      droeschl   57:     # javascript will position the iframe if window was resized (or zoomed)
                     58:     return <<ENDFRAME;
                     59:     $startpage
                     60:     $script
1.38      droeschl   61:     <div class="LC_iframecontainer">
                     62:         <iframe src="$url">No iframe support!</iframe>
                     63:     </div>
                     64:     $endpage
                     65: ENDFRAME
1.21      albertel   66: }
                     67: 
                     68: sub handler {
                     69:     my $r=shift;
                     70:     &Apache::loncommon::content_type($r,'text/html');
                     71:     $r->send_http_header;
                     72: 
                     73:     return OK if $r->header_only;
                     74: 
1.38      droeschl   75:     my $url = $r->uri;
                     76:     my $is_ext;
                     77: 
                     78:     for ($url){
                     79:         s|^/adm/wrapper||;
                     80:         $is_ext = $_ =~ s|^/ext/|http://|;         
                     81:         s|http://https://|https://|;
                     82:         s|&colon;|:|g;              
1.21      albertel   83:     }
                     84: 
                     85: #
                     86: # Actual URL
                     87: #
                     88:     if ($url=~/\.(problem|exam|quiz|assess|survey|form|library)$/) {
                     89: #
                     90: # This is uploaded homework
                     91: #
1.38      droeschl   92:         $env{'request.state'}='uploaded';
                     93:         &Apache::lonhomework::renderpage($r,$url);
1.21      albertel   94:     } else {
                     95: #
                     96: # This is not homework
                     97: #
1.38      droeschl   98:         if ($is_ext) {
                     99:             $ENV{'QUERY_STRING'} =~ s/(^|\&)symb=[^\&]*/$1/;
1.34      raeburn   100:             $ENV{'QUERY_STRING'} =~ s/\&$//;  
1.38      droeschl  101:         }
                    102: 
1.35      raeburn   103:         unless ($ENV{'QUERY_STRING'} eq '') {
1.38      droeschl  104:             $url.=(($url=~/\?/)?'&':'?').$ENV{'QUERY_STRING'};
1.35      raeburn   105:         }
1.38      droeschl  106: 
                    107:         # encrypt url if not external
                    108:         &Apache::lonenc::check_encrypt(\$url) if $url !~ /^https?\:/ ;
                    109: 
                    110:         $r->print( wrapper($url) );
                    111: 
1.21      albertel  112:     } # not just the menu
1.38      droeschl  113:     
1.21      albertel  114:     return OK;
1.13      www       115: } # handler
1.1       www       116: 
                    117: 1;
                    118: __END__
                    119: 
1.30      jms       120: =pod
1.1       www       121: 
1.30      jms       122: =head1 NAME
                    123: 
                    124: Apache::lonwrapper - External and binary file management.
                    125: 
                    126: =head1 SYNOPSIS
                    127: 
                    128: Wrapper for external and binary files as standalone resources. Edit handler for rat maps; TeX content handler.
                    129: 
                    130: This is part of the LearningOnline Network with CAPA project
                    131: described at http://www.lon-capa.org.
                    132: 
                    133: =head1 Subroutines
                    134: 
                    135: =over
                    136: 
1.38      droeschl  137: =item wrapper($url)
1.30      jms       138: 
1.38      droeschl  139: Wraps $url in an iframe and generates a page for it.
                    140: Returns markup for the entire page.
1.30      jms       141: 
                    142: =item handler()
                    143: 
                    144: =back
                    145: 
                    146: =cut
1.1       www       147: 
                    148: 
                    149: 
                    150: 
                    151: 
1.29      jms       152: 
                    153: 

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