Annotation of rat/lonwrapper.pm, revision 1.38

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

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