File:  [LON-CAPA] / rat / lonwrapper.pm
Revision 1.26: download - view: text, annotated - select for diffs
Wed Dec 20 22:42:48 2006 UTC (17 years, 4 months ago) by albertel
Branches: MAIN
CVS tags: version_2_6_0, version_2_5_X, version_2_5_99_1, version_2_5_99_0, version_2_5_2, version_2_5_1, version_2_5_0, version_2_4_X, version_2_4_99_0, version_2_4_2, version_2_4_1, version_2_4_0, version_2_3_X, version_2_3_99_0, version_2_3_2, version_2_3_1, version_2_3_0, version_2_2_99_1, HEAD
- bunch of \w replacements

    1: # The LearningOnline Network with CAPA
    2: # Wrapper for external and binary files as standalone resources
    3: #
    4: # $Id: lonwrapper.pm,v 1.26 2006/12/20 22:42:48 albertel 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: package Apache::lonwrapper;
   30: 
   31: use strict;
   32: use Apache::Constants qw(:common);
   33: use Apache::lonnet;
   34: use Apache::lonxml();
   35: use Apache::lonenc();
   36: use Apache::lonmenu();
   37: 
   38: # ================================================================ Main Handler
   39: 
   40: sub simple_menu {
   41: #
   42: # Producing the menu buttons
   43: #
   44:     return &Apache::loncommon::start_page('Menu',undef,
   45: 					  {'only_body' => 1,
   46: 					   'bgcolor'   => '#FFFFFF',}).
   47: 	&Apache::lonmenu::menubuttons(1,'web',1).
   48: 	&Apache::loncommon::end_page();
   49: }
   50: 
   51: 
   52: sub wrapper {
   53:     my ($topurl,$bottomurl) = @_;
   54: 
   55:     if ($env{'browser.interface'} eq 'textual') {
   56: #
   57: # ssi-based rendering for text-based interface
   58: #
   59: 	return 
   60: 	    &Apache::loncommon::start_page('Menu',undef,
   61: 					  {'bgcolor'        => '#FFFFFF',
   62: 					   'force_register' => 1,
   63: 				       }).
   64: 	    &Apache::lonnet::ssi_body($bottomurl).
   65: 	    &Apache::loncommon::end_page();
   66:     }
   67: 
   68: 
   69:     my %layout = ('border' => 0);
   70:     if ($env{'environment.remote'} eq 'off') {
   71: 	$layout{'rows'} = "180,*";
   72:     } else {
   73: 	$layout{'rows'} = "1,*";
   74: 	$topurl = "/adm/rat/empty.html";
   75:     }
   76: 
   77:     my $start_page = 
   78: 	&Apache::loncommon::start_page(undef,undef,
   79: 				       {'force_register' => 1,
   80: 					'frameset'       => 1,
   81: 					'add_entries'    => \%layout, });
   82: 
   83:     my $end_page = 
   84: 	&Apache::loncommon::end_page({'frameset' => 1});
   85:     
   86:     foreach my $url ($topurl,$bottomurl) {
   87: 	if ($url !~ /^http:/) {
   88: 	    $url = &Apache::lonenc::check_encrypt($url);
   89: 	}
   90:     }
   91: #
   92: # frame-based rendering for graphical interface
   93: #
   94:     my $result =<<ENDDOCUMENT;
   95: $start_page
   96: test
   97: <frame src="$topurl" />
   98: <frame src="$bottomurl" />
   99: $end_page
  100: ENDDOCUMENT
  101: 
  102:     return $result;
  103: }
  104: 
  105: sub handler {
  106:     my $r=shift;
  107:     &Apache::loncommon::content_type($r,'text/html');
  108:     $r->send_http_header;
  109: 
  110:     return OK if $r->header_only;
  111: 
  112:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
  113: 					    ['wrapperdisplay']);
  114:     if ($env{'form.wrapperdisplay'} eq 'menu') {
  115: 	$r->print(&simple_menu());
  116: 	return OK;
  117:     }
  118: 
  119:     my $orgurl=$r->uri;
  120:     my $url=$orgurl;
  121:     $orgurl.=(($orgurl=~/\?/)?'&':'?').$ENV{'QUERY_STRING'};
  122:     $orgurl.=(($orgurl=~/\?/)?'&':'?').'wrapperdisplay=menu';
  123:     $url=~s/^\/adm\/wrapper//;
  124:     my $is_ext = $url =~ m|^/ext/|;
  125:     $url=~s{^/ext/}{http://};
  126:     $url=~s|http://https://|https://|;
  127:     $url=~s|&colon;|:|g;
  128: #
  129: # Actual URL
  130: #
  131:     if ($url=~/\.(problem|exam|quiz|assess|survey|form|library)$/) {
  132: #
  133: # This is uploaded homework
  134: #
  135: 	$env{'request.state'}='uploaded';
  136: 	&Apache::lonhomework::renderpage($r,$url);
  137:     } else {
  138: #
  139: # This is not homework
  140: #
  141: 	if ($is_ext) {
  142: 	    $ENV{'QUERY_STRING'}=~s/(^|\&)symb=[^\&]*/$1/;
  143: 	}
  144: 	$url.=(($url=~/\?/)?'&':'?').$ENV{'QUERY_STRING'}; 
  145: 	# reappend the query arguments
  146: 	$r->print(&wrapper($orgurl,$url));
  147:     } # not just the menu
  148:     return OK;
  149: } # handler
  150: 
  151: 1;
  152: __END__
  153: 
  154: 
  155: 
  156: 
  157: 
  158: 
  159: 

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