Annotation of rat/lonwrapper.pm, revision 1.21

1.1       www         1: # The LearningOnline Network with CAPA
                      2: # Wrapper for external and binary files as standalone resources
                      3: #
1.21    ! albertel    4: # $Id: lonwrapper.pm,v 1.20 2006/03/19 23:06:00 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.21    ! albertel   43:     return '<html><body bgcolor="#FFFFFF">'.
        !            44: 	&Apache::lonmenu::menubuttons(1,'web',1).'</body></html>';
        !            45: 
        !            46: }
        !            47: 
        !            48: 
        !            49: sub wrapper {
        !            50:     my ($topurl,$bottomurl) = @_;
1.12      www        51: 
1.21    ! albertel   52:     if ($env{'browser.interface'} eq 'textual') {
1.12      www        53: #
                     54: # ssi-based rendering for text-based interface
                     55: #
1.21    ! albertel   56: 	return '<html><head>'.
        !            57: 	    &Apache::lonmenu::registerurl(1).
        !            58: 	    '</head><body bgcolor="#FFFFFF">'.
        !            59: 	    &Apache::lonmenu::menubuttons(1).
        !            60: 	    &Apache::lonnet::ssi_body($bottomurl).'</body></html>';
        !            61:     }
        !            62: 
        !            63:     my $events='onLoad="'.&Apache::lonmenu::loadevents.
        !            64: 	'" onUnload="'.&Apache::lonmenu::unloadevents.'"';
        !            65:     my $script=&Apache::lonmenu::registerurl(1,undef);
        !            66:     
        !            67:     my $result = <<ENDDOCUMENTINL;
1.12      www        68: <html>
                     69: <head>
                     70: $script
                     71: </head>
1.21    ! albertel   72: ENDDOCUMENTINL
        !            73: 
        !            74:     if ($env{'environment.remote'} eq 'off') {
        !            75: #
        !            76: # This is inline remote
        !            77: # 
        !            78: 	$result .= <<ENDDOCUMENTINL;
1.20      albertel   79: <frameset rows="180,*" border="0" $events>
1.21    ! albertel   80: <frame src="$topurl">
        !            81: <frame src="$bottomurl">
1.12      www        82: </frameset>
                     83: ENDDOCUMENTINL
1.21    ! albertel   84:     } else {
1.9       www        85: #
                     86: # frame-based rendering for graphical interface
                     87: #
1.21    ! albertel   88: 	$result .=<<ENDDOCUMENT;
1.20      albertel   89: <frameset rows="1,*" border="0" $events>
1.2       www        90: <frame src="/adm/rat/empty.html">
1.21    ! albertel   91: <frame src="$bottomurl">
1.1       www        92: </frameset>
                     93: ENDDOCUMENT
1.21    ! albertel   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;
1.13      www       142: } # handler
1.1       www       143: 
                    144: 1;
                    145: __END__
                    146: 
                    147: 
                    148: 
                    149: 
                    150: 
                    151: 
                    152: 

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