File:  [LON-CAPA] / rat / lonwrapper.pm
Revision 1.22: download - view: text, annotated - select for diffs
Tue Apr 4 15:11:48 2006 UTC (18 years ago) by albertel
Branches: MAIN
CVS tags: HEAD
- start_page work
- pass throught the args var to startheadtag

    1: # The LearningOnline Network with CAPA
    2: # Wrapper for external and binary files as standalone resources
    3: #
    4: # $Id: lonwrapper.pm,v 1.22 2006/04/04 15:11: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::lonmenu;
   36: 
   37: # ================================================================ Main Handler
   38: 
   39: sub simple_menu {
   40: #
   41: # Producing the menu buttons
   42: #
   43:     return &Apache::loncommon::start_page('Menu',undef,
   44: 					  {'only_body' => 1,
   45: 					   'bgcolor'   => '#FFFFFF',}).
   46: 	&Apache::lonmenu::menubuttons(1,'web',1).
   47: 	&Apache::loncommon::end_page();
   48: }
   49: 
   50: 
   51: sub wrapper {
   52:     my ($topurl,$bottomurl) = @_;
   53: 
   54:     if ($env{'browser.interface'} eq 'textual') {
   55: #
   56: # ssi-based rendering for text-based interface
   57: #
   58: 	return 
   59: 	    &Apache::loncommon::start_page('Menu',undef,
   60: 					  {'bgcolor'        => '#FFFFFF',
   61: 					   'force_register' => 1,
   62: 				       }).
   63: 	    &Apache::lonnet::ssi_body($bottomurl).
   64: 	    &Apache::loncommon::end_page();
   65:     }
   66: 
   67:     my $events='onLoad="'.&Apache::lonmenu::loadevents.
   68: 	'" onUnload="'.&Apache::lonmenu::unloadevents.'"';
   69:     
   70:     my $result = &Apache::lonxml::xmlbegin().
   71: 	&Apache::loncommon::head(undef,undef,
   72: 				 {'force_register' => 1});
   73:   
   74:     if ($env{'environment.remote'} eq 'off') {
   75: #
   76: # This is inline remote
   77: # 
   78: 	$result .= <<ENDDOCUMENTINL;
   79: <frameset rows="180,*" border="0" $events>
   80: <frame src="$topurl">
   81: <frame src="$bottomurl">
   82: </frameset>
   83: ENDDOCUMENTINL
   84:     } else {
   85: #
   86: # frame-based rendering for graphical interface
   87: #
   88: 	$result .=<<ENDDOCUMENT;
   89: <frameset rows="1,*" border="0" $events>
   90: <frame src="/adm/rat/empty.html">
   91: <frame src="$bottomurl">
   92: </frameset>
   93: ENDDOCUMENT
   94:     }
   95: 
   96:     $result .= "\n</html>\n";
   97: }
   98: 
   99: sub handler {
  100:     my $r=shift;
  101:     &Apache::loncommon::content_type($r,'text/html');
  102:     $r->send_http_header;
  103: 
  104:     return OK if $r->header_only;
  105: 
  106:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
  107: 					    ['wrapperdisplay']);
  108:     if ($env{'form.wrapperdisplay'} eq 'menu') {
  109: 	$r->print(&simple_menu());
  110: 	return OK;
  111:     }
  112: 
  113:     my $orgurl=$r->uri;
  114:     my $url=$orgurl;
  115:     $orgurl.=(($orgurl=~/\?/)?'&':'?').$ENV{'QUERY_STRING'};
  116:     $orgurl.=(($orgurl=~/\?/)?'&':'?').'wrapperdisplay=menu';
  117:     $url=~s/^\/adm\/wrapper//;
  118:     my $is_ext = $url =~ m|^/ext/|;
  119:     $url=~s/^\/ext\//http\:\/\//;
  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: 	}
  137: 	$url.=(($url=~/\?/)?'&':'?').$ENV{'QUERY_STRING'}; 
  138: 	# reappend the query arguments
  139: 	$r->print(&wrapper($orgurl,$url));
  140:     } # not just the menu
  141:     return OK;
  142: } # handler
  143: 
  144: 1;
  145: __END__
  146: 
  147: 
  148: 
  149: 
  150: 
  151: 
  152: 

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