Diff for /rat/lonwrapper.pm between versions 1.21 and 1.42

version 1.21, 2006/03/21 21:50:39 version 1.42, 2012/11/27 23:45:15
Line 26 Line 26
 # http://www.lon-capa.org/  # http://www.lon-capa.org/
 #  #
   
   
 package Apache::lonwrapper;  package Apache::lonwrapper;
   
 use strict;  use strict;
 use Apache::Constants qw(:common);  use Apache::Constants qw(:common);
   use Apache::lonenc();
 use Apache::lonnet;  use Apache::lonnet;
 use Apache::lonxml();  use Apache::lonlocal;
 use Apache::lonmenu;  use Apache::loncommon();
   use Apache::lonhtmlcommon();
   use Apache::lonextresedit();
   
 # ================================================================ Main Handler  # ================================================================ Main Handler
   
 sub simple_menu {  
 #  
 # Producing the menu buttons  
 #  
     return '<html><body bgcolor="#FFFFFF">'.  
  &Apache::lonmenu::menubuttons(1,'web',1).'</body></html>';  
   
 }  
   
   
 sub wrapper {  sub wrapper {
     my ($topurl,$bottomurl) = @_;      my ($url,$brcrum) = @_;
   
     if ($env{'browser.interface'} eq 'textual') {      my $forcereg;
 #      unless ($env{'form.folderpath'}) {
 # ssi-based rendering for text-based interface          $forcereg = 1;
 #  
  return '<html><head>'.  
     &Apache::lonmenu::registerurl(1).  
     '</head><body bgcolor="#FFFFFF">'.  
     &Apache::lonmenu::menubuttons(1).  
     &Apache::lonnet::ssi_body($bottomurl).'</body></html>';  
     }      }
   
     my $events='onLoad="'.&Apache::lonmenu::loadevents.      my $args = {'bgcolor' => '#FFFFFF'};
  '" onUnload="'.&Apache::lonmenu::unloadevents.'"';      if ($forcereg) {
     my $script=&Apache::lonmenu::registerurl(1,undef);          $args->{'force_register'} = $forcereg;
           }
     my $result = <<ENDDOCUMENTINL;      if (ref($brcrum) eq 'ARRAY') {
 <html>           $args->{'bread_crumbs'} = $brcrum;
 <head>  
 $script  
 </head>  
 ENDDOCUMENTINL  
   
     if ($env{'environment.remote'} eq 'off') {  
 #  
 # This is inline remote  
 #   
  $result .= <<ENDDOCUMENTINL;  
 <frameset rows="180,*" border="0" $events>  
 <frame src="$topurl">  
 <frame src="$bottomurl">  
 </frameset>  
 ENDDOCUMENTINL  
     } else {  
 #  
 # frame-based rendering for graphical interface  
 #  
  $result .=<<ENDDOCUMENT;  
 <frameset rows="1,*" border="0" $events>  
 <frame src="/adm/rat/empty.html">  
 <frame src="$bottomurl">  
 </frameset>  
 ENDDOCUMENT  
     }      }
   
     $result .= "\n</html>\n";      my $startpage =  Apache::loncommon::start_page('Menu',undef,$args);
       my $endpage =  Apache::loncommon::end_page();
   
       my $script = Apache::lonhtmlcommon::scripttag(<<SCRIPT );
       \$(document).ready( function() {
           \$(window).unbind('resize').resize(function(){
               var header;
               var offset = 5;
               var height = 0;
               var hdrtop = 0;
               if (\$('div.LC_head_subbox:first').length) {
                   header = \$('div.LC_head_subbox:first');
                   offset = 9;
               } else {
                   if (\$('#LC_breadcrumbs').length) {
                       header = \$('#LC_breadcrumbs');
                   }
               }
               if (header.length) {
                   height = header.height();
                   hdrtop = header.position().top;
               }
               var pos = height + hdrtop + offset;
               \$('.LC_iframecontainer').css('top', pos);
           });
       });
       window.onload = function(){  \$(window).trigger('resize') }; 
   SCRIPT
   
       # 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 {  sub handler {
Line 103  sub handler { Line 102  sub handler {
   
     return OK if $r->header_only;      return OK if $r->header_only;
   
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},      my $url = $r->uri;
     ['wrapperdisplay']);      my ($is_ext,$brcrum);
     if ($env{'form.wrapperdisplay'} eq 'menu') {  
  $r->print(&simple_menu());      for ($url){
  return OK;          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();
               $brcrum =
                   &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$env{'form.title'},1);
               if (ref($brcrum) eq 'ARRAY') {
                   my $last = $env{'form.title'};
                   if ($last eq '') {
                       $last = &mt('External Resource');
                   }
                   push(@{$brcrum},
                            {'title' => $last,
                             'text' => $last,
                             'no_mt' => 1,
                            });
   
               }
           }
     }      }
   
     my $orgurl=$r->uri;  
     my $url=$orgurl;  
     $orgurl.=(($orgurl=~/\?/)?'&':'?').$ENV{'QUERY_STRING'};  
     $orgurl.=(($orgurl=~/\?/)?'&':'?').'wrapperdisplay=menu';  
     $url=~s/^\/adm\/wrapper//;  
     my $is_ext = $url =~ m|^/ext/|;  
     $url=~s/^\/ext\//http\:\/\//;  
     $url=~s|&colon;|:|g;  
 #  #
 # Actual URL  # Actual URL
 #  #
     if ($url=~/\.(problem|exam|quiz|assess|survey|form|library)$/) {      if ($url=~/$LONCAPA::assess_re/) {
 #  #
 # This is uploaded homework  # This is uploaded homework
 #  #
  $env{'request.state'}='uploaded';          $env{'request.state'}='uploaded';
  &Apache::lonhomework::renderpage($r,$url);          &Apache::lonhomework::renderpage($r,$url);
     } else {      } else {
 #  #
 # This is not homework  # This is not homework
 #  #
  if ($is_ext) {          if ($is_ext) {
     $ENV{'QUERY_STRING'}=~s/(^|\&)symb=[^\&]*/$1/;              $ENV{'QUERY_STRING'} =~ s/(^|\&)symb=[^\&]*/$1/;
  }              $ENV{'QUERY_STRING'} =~ s/\&$//;
  $url.=(($url=~/\?/)?'&':'?').$ENV{'QUERY_STRING'};           }
  # reappend the query arguments  
  $r->print(&wrapper($orgurl,$url));          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      } # not just the menu
       
     return OK;      return OK;
 } # handler  } # 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.21  
changed lines
  Added in v.1.42


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.