Annotation of loncom/publisher/lonconstruct.pm, revision 1.33

1.1       www         1: # The LearningOnline Network with CAPA
1.6       albertel    2: # Construction Space Page Wrapper for Construction
                      3: #
1.33    ! albertel    4: # $Id: lonconstruct.pm,v 1.32 2006/04/06 22:15:18 albertel Exp $
1.6       albertel    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/
1.1       www        27: #
                     28: #
1.30      albertel   29: 
1.7       foxr       30: package Apache::lonconstruct;
1.1       www        31: 
                     32: 
                     33: use strict;
1.24      raeburn    34: use Apache::Constants qw(:common :http :methods);
1.7       foxr       35: use Apache::lonnet;
1.8       foxr       36: use HTML::Entities();
1.7       foxr       37: 
1.17      taceyjo1   38: my $DEBUG = 0;
1.7       foxr       39: =pod
                     40: 
                     41: =item Debug($request, $message)
                     42: 
                     43:   If debugging is enabled puts out a debuggin message determined by the
                     44:   caller.  The debug message goes to the Apache error log file. Debugging
                     45:   is enabled by ssetting the module global DEBUG variable to nonzero (TRUE).
                     46: 
                     47:  Parameters:
                     48: 
                     49: =over 4
                     50:  
                     51: =item $request - The curretn request operation.
                     52: 
                     53: =item $message - The message to put inthe log file.
                     54: 
                     55: =back
                     56:   
                     57:  Returns:
                     58:    nothing.
                     59: 
                     60: =cut
                     61: 
                     62: sub Debug {
1.31      albertel   63:     # Put out the indicated message but only if DEBUG is true.
                     64:     if ($DEBUG) {
                     65: 	my ($r,$message) = @_;
                     66: 	$r->log_reason($message);
                     67:     }
                     68: } 
1.7       foxr       69: 
1.1       www        70: # ================================================================ Main Handler
                     71: 
                     72: sub handler {
                     73:    my $r=shift;
                     74: 
                     75: # -------------------------------------------------------------- Build frameset
                     76: 
1.28      albertel   77:    &Apache::loncommon::content_type($r,'text/html');
1.1       www        78:    $r->send_http_header;
                     79:    return OK if $r->header_only;
                     80: 
                     81:    my $lowerframe=$r->path_info;
1.7       foxr       82:    &Debug($r, "Initial URL for lower frame: ".$lowerframe);
1.1       www        83:    $lowerframe=~s/^\//\/\~/;
1.7       foxr       84:    &Debug($r, "Lower frame URL afer ~ subst: ".$lowerframe);
1.22      albertel   85:    $lowerframe= &HTML::Entities::encode($lowerframe,'<>&"');
1.15      taceyjo1   86:    &Debug($r, "Lower frame URL after quote subst: ".$lowerframe);
1.13      www        87: 
                     88: #
                     89: # Are we forcing edit mode?
                     90: #
                     91: 
                     92:    &Apache::loncommon::get_unprocessed_cgi
                     93:         ($ENV{'QUERY_STRING'},['forceedit']);
1.30      albertel   94:    if ($env{'form.forceedit'}) {
1.13      www        95:        $lowerframe.='?editmode=Edit&problemmode=EditXML';
1.14      taceyjo1   96:    }	
                     97:    &Apache::loncommon::get_unprocessed_cgi
                     98:         ($ENV{'QUERY_STRING'},['forceColoredit']);
1.30      albertel   99:    if ($env{'form.forceColoredit'}) {
1.14      taceyjo1  100:        $lowerframe.='?editmode=Edit&problemmode=Edit';
1.13      www       101:    }
1.23      raeburn   102: 
                    103: #
                    104: # Checking to see if we should display the topframe
                    105: #
                    106:    my $toprows = 0;
                    107:    my $topsrc = '';
1.30      albertel  108:    if ($env{'environment.remote'} ne 'off') {
1.23      raeburn   109:        $toprows = '110';
1.27      raeburn   110:        $topsrc = '/adm/localize/adm/publisher.html';
1.23      raeburn   111:    }
1.33    ! albertel  112: 
        !           113:    my $js=qq|
1.29      albertel  114: <script type="text/javascript">
1.12      www       115: var lastknownpriv="$lowerframe";
                    116: </script>
1.33    ! albertel  117:     |;
        !           118: 
        !           119:    my $start_page=
        !           120:        &Apache::loncommon::start_page('Construction Space',$js,
        !           121: 				      {'frameset'    => 1,
        !           122: 				       'add_entries' => {
        !           123: 					   'rows'   => "$toprows,*",
        !           124: 					   'border' => "0",}});
        !           125:    my $end_page=
        !           126:        &Apache::loncommon::end_page({'frameset' => 1});
        !           127: 
        !           128:    $r->print(<<ENDPAGE);
        !           129: $start_page
1.29      albertel  130: <frame src='$topsrc' />
                    131: <frame src="$lowerframe" name="LONCAPAToBePublished" />
1.33    ! albertel  132: $end_page
1.1       www       133: ENDPAGE
                    134:    return OK;
                    135: }
                    136: 1;
                    137: __END__
                    138: 

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