File:  [LON-CAPA] / rat / lonwrapper.pm
Revision 1.38: download - view: text, annotated - select for diffs
Wed Mar 3 21:33:20 2010 UTC (14 years, 2 months ago) by droeschl
Branches: MAIN
CVS tags: HEAD
- replaced frameset by iframe in lonwrapper
    ! IE 7 doesn't scale iframe to 100% height, IE 6 and 8 do
    ! scrolling in Mobile Safari is limited
- added styles for iframe to loncommon
- replaced menubuttons call in lonwrapper by start_page call to make full use of the new header
- removed remote control specific code (RC will be removed shortly)
- replaced code in lonsyllabus with a call to new wrapper routine
- removed subs initlittle and menubutton from lonmenu since they aren't needed anymore

    1: # The LearningOnline Network with CAPA
    2: # Wrapper for external and binary files as standalone resources
    3: #
    4: # $Id: lonwrapper.pm,v 1.38 2010/03/03 21:33:20 droeschl Exp $
    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: #
   28: 
   29: 
   30: package Apache::lonwrapper;
   31: 
   32: use strict;
   33: use Apache::Constants qw(:common);
   34: use Apache::lonenc();
   35: use Apache::lonnet;
   36: 
   37: # ================================================================ Main Handler
   38: sub wrapper {
   39:     my $url = shift;
   40: 
   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
   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: 
   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;              
   81:     }
   82: 
   83: #
   84: # Actual URL
   85: #
   86:     if ($url=~/\.(problem|exam|quiz|assess|survey|form|library)$/) {
   87: #
   88: # This is uploaded homework
   89: #
   90:         $env{'request.state'}='uploaded';
   91:         &Apache::lonhomework::renderpage($r,$url);
   92:     } else {
   93: #
   94: # This is not homework
   95: #
   96:         if ($is_ext) {
   97:             $ENV{'QUERY_STRING'} =~ s/(^|\&)symb=[^\&]*/$1/;
   98:             $ENV{'QUERY_STRING'} =~ s/\&$//;  
   99:         }
  100: 
  101:         unless ($ENV{'QUERY_STRING'} eq '') {
  102:             $url.=(($url=~/\?/)?'&':'?').$ENV{'QUERY_STRING'};
  103:         }
  104: 
  105:         # encrypt url if not external
  106:         &Apache::lonenc::check_encrypt(\$url) if $url !~ /^https?\:/ ;
  107: 
  108:         $r->print( wrapper($url) );
  109: 
  110:     } # not just the menu
  111:     
  112:     return OK;
  113: } # handler
  114: 
  115: 1;
  116: __END__
  117: 
  118: =pod
  119: 
  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: 
  135: =item wrapper($url)
  136: 
  137: Wraps $url in an iframe and generates a page for it.
  138: Returns markup for the entire page.
  139: 
  140: =item handler()
  141: 
  142: =back
  143: 
  144: =cut
  145: 
  146: 
  147: 
  148: 
  149: 
  150: 
  151: 

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