File:  [LON-CAPA] / rat / lonwrapper.pm
Revision 1.37: download - view: text, annotated - select for diffs
Tue Nov 24 05:37:35 2009 UTC (14 years, 5 months ago) by raeburn
Branches: MAIN
CVS tags: version_2_9_99_0, bz6209-base, bz6209, HEAD, GCI_3
- Number of rows in upper frame reduced for new inline navigation.
  - Try to allow extra rows if user has a role where a "Functions" box is displayed by checking opa priv for course.

    1: # The LearningOnline Network with CAPA
    2: # Wrapper for external and binary files as standalone resources
    3: #
    4: # $Id: lonwrapper.pm,v 1.37 2009/11/24 05:37:35 raeburn 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::lonnet;
   35: use Apache::lonxml();
   36: use Apache::lonenc();
   37: use Apache::lonmenu();
   38: 
   39: # ================================================================ Main Handler
   40: 
   41: sub simple_menu {
   42: #
   43: # Producing the menu buttons
   44: #
   45:     return &Apache::loncommon::start_page('Menu',undef,
   46: 					  {'only_body' => 1,
   47: 					   'bgcolor'   => '#FFFFFF',}).
   48: 	&Apache::lonmenu::menubuttons(1,'web',1).
   49: 	&Apache::loncommon::end_page();
   50: }
   51: 
   52: 
   53: sub wrapper {
   54:     my ($topurl,$bottomurl) = @_;
   55: 
   56:     my %layout = ('border' => 0);
   57:     if ($env{'environment.remote'} eq 'off') {
   58:         if (($env{'request.course.id'}) &&
   59:             (&Apache::lonnet::allowed('opa',$env{'request.course.id'}.
   60:              ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')))) {
   61:             $layout{'rows'} = "135,*";
   62:         } else {
   63:             $layout{'rows'} = "100,*";
   64:         }
   65:     } else {
   66: 	$layout{'rows'} = "1,*";
   67: 	$topurl = "/adm/rat/empty.html";
   68:     }
   69: 
   70:     my $start_page = 
   71: 	&Apache::loncommon::start_page(undef,undef,
   72: 				       {'force_register' => 1,
   73: 					'frameset'       => 1,
   74: 					'add_entries'    => \%layout, });
   75: 
   76:     my $end_page = 
   77: 	&Apache::loncommon::end_page({'frameset' => 1});
   78:     
   79:     foreach my $url ($topurl,$bottomurl) {
   80: 	if ($url !~ /^https?\:/) {
   81: 	    $url = &Apache::lonenc::check_encrypt($url);
   82: 	}
   83:     }
   84: #
   85: # frame-based rendering for graphical interface
   86: #
   87:     my $result =<<ENDDOCUMENT;
   88: $start_page
   89: test
   90: <frame src="$topurl" />
   91: <frame src="$bottomurl" />
   92: $end_page
   93: ENDDOCUMENT
   94: 
   95:     return $result;
   96: }
   97: 
   98: sub handler {
   99:     my $r=shift;
  100:     &Apache::loncommon::content_type($r,'text/html');
  101:     $r->send_http_header;
  102: 
  103:     return OK if $r->header_only;
  104: 
  105:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
  106: 					    ['wrapperdisplay']);
  107:     if ($env{'form.wrapperdisplay'} eq 'menu') {
  108: 	$r->print(&simple_menu());
  109: 	return OK;
  110:     }
  111: 
  112:     my $orgurl=$r->uri;
  113:     my $url=$orgurl;
  114:     $orgurl.=(($orgurl=~/\?/)?'&':'?').$ENV{'QUERY_STRING'};
  115:     $orgurl.=(($orgurl=~/\?/)?'&':'?').'wrapperdisplay=menu';
  116:     $url=~s/^\/adm\/wrapper//;
  117:     my $is_ext = $url =~ m|^/ext/|;
  118:     $url=~s{^/ext/}{http://};
  119:     $url=~s|http://https://|https://|;
  120:     $url=~s|&colon;|:|g;
  121: #
  122: # Actual URL
  123: #
  124:     if ($url=~/\.(problem|exam|quiz|assess|survey|form|library)$/) {
  125: #
  126: # This is uploaded homework
  127: #
  128: 	$env{'request.state'}='uploaded';
  129: 	&Apache::lonhomework::renderpage($r,$url);
  130:     } else {
  131: #
  132: # This is not homework
  133: #
  134: 	if ($is_ext) {
  135: 	    $ENV{'QUERY_STRING'}=~s/(^|\&)symb=[^\&]*/$1/;
  136:             $ENV{'QUERY_STRING'} =~ s/\&$//;  
  137: 	}
  138:         unless ($ENV{'QUERY_STRING'} eq '') {
  139: 	    $url.=(($url=~/\?/)?'&':'?').$ENV{'QUERY_STRING'};
  140:         }
  141: 	# reappend the query arguments
  142: 	$r->print(&wrapper($orgurl,$url));
  143:     } # not just the menu
  144:     return OK;
  145: } # handler
  146: 
  147: 1;
  148: __END__
  149: 
  150: =pod
  151: 
  152: =head1 NAME
  153: 
  154: Apache::lonwrapper - External and binary file management.
  155: 
  156: =head1 SYNOPSIS
  157: 
  158: Wrapper for external and binary files as standalone resources. Edit handler for rat maps; TeX content handler.
  159: 
  160: This is part of the LearningOnline Network with CAPA project
  161: described at http://www.lon-capa.org.
  162: 
  163: =head1 Subroutines
  164: 
  165: =over
  166: 
  167: =item simple_menu()
  168: 
  169: =item wrapper()
  170: 
  171: =item handler()
  172: 
  173: =back
  174: 
  175: =cut
  176: 
  177: 
  178: 
  179: 
  180: 
  181: 
  182: 

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