Diff for /rat/lonwrapper.pm between versions 1.10 and 1.43

version 1.10, 2003/02/20 22:04:18 version 1.43, 2012/11/29 20:13:49
Line 25 Line 25
 #  #
 # http://www.lon-capa.org/  # http://www.lon-capa.org/
 #  #
 # (Edit Handler for RAT Maps  
 # (TeX Content Handler  
 #  
 # 05/29/00,05/30 Gerd Kortemeyer)  
 # 7/1,6/30 Gerd Kortemeyer)  
 #  
 # 7/5 Gerd Kortemeyer  
   
 package Apache::lonwrapper;  package Apache::lonwrapper;
   
 use strict;  use strict;
 use Apache::Constants qw(:common);  use Apache::Constants qw(:common);
 use Apache::lonnet();  use Apache::lonenc();
 use Apache::lonxml();  use Apache::lonnet;
 use Apache::lonmenu;  use Apache::lonlocal;
   use Apache::loncommon();
   use Apache::lonhtmlcommon();
   use Apache::lonextresedit();
   
 # ================================================================ Main Handler  # ================================================================ Main Handler
   sub wrapper {
       my ($url,$brcrum) = @_;
   
 sub handler {      my $forcereg;
   my $r=shift;      unless ($env{'form.folderpath'}) {
   $r->content_type('text/html');          $forcereg = 1;
   $r->send_http_header;      }
   
   return OK if $r->header_only;      my $args = {'bgcolor' => '#FFFFFF'};
       if ($forcereg) {
   my $url=$r->uri;          $args->{'force_register'} = $forcereg;
   $url=~s/^\/adm\/wrapper//;      }
   $url=~s/^\/ext\//http\:\/\//;      if (ref($brcrum) eq 'ARRAY') {
   if ($url=~/^\/uploaded\//) {           $args->{'bread_crumbs'} = $brcrum;
       $url=&Apache::lonnet::tokenwrapper($url);      }
   }  
   $url.='?'.$ENV{'QUERY_STRING'}; #reappend the query arguments      my $startpage =  Apache::loncommon::start_page('Menu',undef,$args);
   my $events='onLoad="'.&Apache::lonmenu::loadevents.      my $endpage =  Apache::loncommon::end_page();
            '" onUnload="'.&Apache::lonmenu::unloadevents.'"';  
   my $script=&Apache::lonmenu::registerurl(1,undef);      my $script = Apache::lonhtmlcommon::scripttag(<<SCRIPT );
   unless ($ENV{'browser.interface'} eq 'textual') {      \$(document).ready( function() {
 #          \$(window).unbind('resize').resize(function(){
 # frame-based rendering for graphical interface              var header;
 #              var offset = 5;
      $r->print(<<ENDDOCUMENT);              var height = 0;
 <html>              var hdrtop = 0;
 <head>              if (\$('div.LC_head_subbox:first').length) {
 $script                  header = \$('div.LC_head_subbox:first');
 </head>                  offset = 9;
 <frameset rows="1,*" border=0 $events>              } else {
 <frame src="/adm/rat/empty.html">                  if (\$('#LC_breadcrumbs').length) {
 <frame src="$url">                      header = \$('#LC_breadcrumbs');
 </frameset>                  }
 </html>              }
 ENDDOCUMENT              if (header.length) {
   } else {                  height = header.height();
 #                  hdrtop = header.position().top;
 # ssi-based rendering for text-based interface              }
 #              var pos = height + hdrtop + offset;
       $r->print('<html><head>'.              \$('.LC_iframecontainer').css('top', pos);
                 &Apache::lonmenu::registerurl(1).          });
                 '</head><body bgcolor="#FFFFFF">'.      });
                 &Apache::lonmenu::menubuttons(1).      window.onload = function(){  \$(window).trigger('resize') }; 
                 &Apache::lonnet::ssi_body($url).'</body></html>');  SCRIPT
   }  
   return OK;      # javascript will position the iframe if window was resized (or zoomed)
       return <<ENDFRAME;
       $startpage
       $script
       <div class="LC_iframecontainer">
           <iframe src="$url">No iframe support!</iframe>
       </div>
       $endpage
   ENDFRAME
 }  }
   
   sub handler {
       my $r=shift;
       &Apache::loncommon::content_type($r,'text/html');
       $r->send_http_header;
   
       return OK if $r->header_only;
   
       my $url = $r->uri;
       my ($is_ext,$brcrum);
   
       for ($url){
           s|^/adm/wrapper||;
           $is_ext = $_ =~ s|^/ext/|http://|;         
           s|http://https://|https://|;
           s|&colon;|:|g;              
       }
   
       if ($is_ext) {
           &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
               ['forceedit','register','folderpath','symb','idx','title']);
           if (($env{'form.forceedit'}) &&
               (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) &&
               (($env{'form.folderpath'} =~ /^supplemental/) ||
                ($env{'form.symb'} =~ /^uploaded/))) {
               $r->print(
                   &Apache::lonextresedit::display_editor($url,$env{'form.folderpath'},
                                                          $env{'form.symb'},
                                                          $env{'form.idx'}));
               return OK;
           } elsif ($env{'form.folderpath'} =~ /^supplemental/) {
               my $crstype = &Apache::loncommon::course_type();
               my $title = $env{'form.title'};
               if ($title eq '') {
                   $title = &mt('External Resource');
               }
               $brcrum =
                   &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
           }
       }
   
   #
   # Actual URL
   #
       if ($url=~/$LONCAPA::assess_re/) {
   #
   # This is uploaded homework
   #
           $env{'request.state'}='uploaded';
           &Apache::lonhomework::renderpage($r,$url);
       } else {
   #
   # This is not homework
   #
           if ($is_ext) {
               $ENV{'QUERY_STRING'} =~ s/(^|\&)symb=[^\&]*/$1/;
               $ENV{'QUERY_STRING'} =~ s/\&$//;
           }
   
           unless ($ENV{'QUERY_STRING'} eq '') {
               $url.=(($url=~/\?/)?'&':'?').$ENV{'QUERY_STRING'};
           }
   
           # encrypt url if not external
           &Apache::lonenc::check_encrypt(\$url) if $url !~ /^https?\:/ ;
   
           $r->print( wrapper($url,$brcrum) );
   
       } # not just the menu
       
       return OK;
   } # handler
   
 1;  1;
 __END__  __END__
   
   =pod
   
   =head1 NAME
   
   Apache::lonwrapper - External and binary file management.
   
   =head1 SYNOPSIS
   
   Wrapper for external and binary files as standalone resources. Edit handler for rat maps; TeX content handler.
   
   This is part of the LearningOnline Network with CAPA project
   described at http://www.lon-capa.org.
   
   =head1 Subroutines
   
   =over
   
   =item wrapper($url,$brcrum)
   
   Wraps $url in an iframe and generates a page for it.
   $brcrum contains breadcrumbs for unregistered urls
   (i.e., external resources in Supplemental Content).
   Returns markup for the entire page.
   
   =item handler()
   
   =back
   
   =cut
   
   
   
   

Removed from v.1.10  
changed lines
  Added in v.1.43


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>
500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.