Annotation of rat/lonwrapper.pm, revision 1.23

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

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