Annotation of rat/lonwrapper.pm, revision 1.31

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

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