Annotation of loncom/interface/lonsimplepage.pm, revision 1.10

1.1       www         1: # The LearningOnline Network
                      2: # Simple Page Editor
                      3: #
1.10    ! www         4: # $Id: lonsimplepage.pm,v 1.9 2003/03/10 14:20:07 www Exp $
1.1       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: #
                     28: 
                     29: package Apache::lonsimplepage;
                     30: 
                     31: use strict;
                     32: use Apache::Constants qw(:common);
                     33: use Apache::loncommon;
                     34: use Apache::lonnet;
                     35: use Apache::lontexconvert;
1.6       matthew    36: use Apache::lonfeedback;
1.1       www        37: 
                     38: sub handler {
                     39:     my $r = shift;
                     40:     $r->content_type('text/html');
                     41:     $r->send_http_header;
                     42:     return OK if $r->header_only;
                     43: 
                     44: # ------------------------------------------------------------ Print the screen
                     45:     $r->print(<<ENDDOCUMENT);
                     46: <html>
                     47: <head>
                     48: <title>The LearningOnline Network with CAPA</title>
                     49: ENDDOCUMENT
1.2       www        50:     my (undef,undef,undef,undef,$marker)=split(/\//,$r->uri);
1.1       www        51: # Is this even in a course?
                     52:     unless ($ENV{'request.course.id'}) {
1.8       www        53: 	$r->print('</head><body>Not in a course</body></html>');
1.1       www        54:         return OK;
                     55:     }
                     56: 
                     57:     $marker=~s/\D//g;
                     58: 
                     59:     unless ($marker) {
                     60: 	$r->print('<body>Invalid call</body>');
                     61:         return OK;
                     62:     }
                     63: 
                     64:     my $dom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
                     65:     my $crs = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
                     66: 
                     67: # --------------------------------------------------------- The syllabus fields
                     68:     my %syllabusfields=(
                     69:        'aaa_title'         => 'Page Title',
                     70:        'bbb_content'       => 'Content',
                     71:        'ccc_webreferences' => 'Web References');
                     72: 
1.7       www        73: 
                     74: # ------------------------------------------------------------ Get query string
                     75:     &Apache::loncommon::get_unprocessed_cgi
                     76:                         ($ENV{'QUERY_STRING'},['forcestudent','register']);
                     77: # ----------------------------------------------------- Force menu registration
                     78:     my $addentries='';
                     79:     if ($ENV{'form.register'}) {
                     80:        $addentries=' onLoad="'.&Apache::lonmenu::loadevents().
                     81: 	   '" onUnload="'.&Apache::lonmenu::unloadevents().'"';
                     82:        $r->print(&Apache::lonmenu::registerurl(1));
                     83:     }
1.1       www        84: # --------------------------------------------------------------- Force Student
                     85:     my $forcestudent='';
                     86:     if ($ENV{'form.forcestudent'}) { $forcestudent='student'; };
                     87: 
1.7       www        88: 
1.1       www        89:     my %syllabus=&Apache::lonnet::dump('smppage_'.$marker,$dom,$crs);
                     90:        
                     91: # --------------------------------------- There is such a user, get environment
                     92: 
1.7       www        93:     $r->print('</head>'.&Apache::loncommon::bodytag
1.8       www        94:       ("Course Page",$forcestudent,$addentries,'',$dom,$ENV{'form.register'}));
1.1       www        95: 
                     96:     my $allowed=&Apache::lonnet::allowed('srm',$ENV{'request.course.id'});
                     97: 
                     98:        if ($forcestudent) { $allowed=0; }
                     99:  
                    100:        if ($allowed) {
1.5       www       101:           $r->print('<p>'.
                    102: &Apache::loncommon::help_open_topic('Uploaded_Templates_TextBoxes','Help with filling in text boxes').'<br /><a href="'.$r->uri.'?forcestudent=1">Show Public View</a>'.
1.4       www       103:  &Apache::loncommon::help_open_topic('Uploaded_Templates_PublicView').'</p>');
1.1       www       104:       }
                    105:       if (($ENV{'form.uploaddoc.filename'}) &&
                    106:           ($ENV{'form.storeupl'}) && ($allowed)) {
1.9       www       107:  	  if ($ENV{'form.uploaddoc.filename'}=~/\.(gif|jpg|png|jpeg)$/i) {
1.1       www       108:              $syllabus{'uploaded.photourl'}=
                    109:                  &Apache::lonnet::userfileupload('uploaddoc',1);
                    110:  	  }
                    111:           $syllabus{'uploaded.lastmodified'}=time;
                    112:           &Apache::lonnet::put('smppage_'.$marker,\%syllabus,$dom,$crs);
                    113:        }
                    114:        if (($allowed) && ($ENV{'form.storesyl'})) {
                    115: 	   foreach (keys %syllabusfields) {
                    116:                my $field=$ENV{'form.'.$_};
                    117:                $field=~s/\s+$//s;
1.4       www       118:                $field=&Apache::lonfeedback::clear_out_html($field,1);
1.1       www       119: 	       $syllabus{$_}=$field;
                    120:            }
                    121:            $syllabus{'uploaded.lastmodified'}=time;
                    122:            &Apache::lonnet::put('smppage_'.$marker,\%syllabus,$dom,$crs);
                    123:        }
                    124: 
                    125: # ---------------------------------------------------------------- Get syllabus
                    126:     if (($syllabus{'uploaded.lastmodified'}) || ($allowed)) {
                    127:        if ($syllabus{'uploaded.photourl'}) {
                    128: 	   $r->print('<img src="'.
                    129:              &Apache::lonnet::tokenwrapper($syllabus{'uploaded.photourl'}).
                    130:              '" align="right" />');
                    131:        }
                    132:        if ($allowed) {
                    133:            $r->print(
                    134: 	 '<form method="post" enctype="multipart/form-data">'.
                    135:          '<h3>Upload a Photo</h3>'.
                    136:          '<input type="file" name="uploaddoc" size="50">'.
                    137:          '<input type="submit" name="storeupl" value="Upload">'.
                    138: 	 '</form><form method="post">');
                    139:        }
                    140:        foreach (sort keys %syllabusfields) {
                    141:           if (($syllabus{$_}) || ($allowed)) {
                    142:               my $message=$syllabus{$_};
                    143:               $message=~s/\n/\<br \/\>/g;
                    144:               $message
1.10    ! www       145:         =~s/(https*\:\/\/[^\s]+)/\<a href=\"$1\"\>\<tt\>$1\<\/tt\>\<\/a\>/g;
1.1       www       146: 	      $message=&Apache::lontexconvert::msgtexconverted($message);
1.2       www       147:             unless ($_ eq 'aaa_title') {
                    148: 		if (($_ ne 'bbb_content') || ($allowed)) {
                    149:                     $r->print('<h3>'.$syllabusfields{$_}.'</h3>');
                    150: 		}
                    151:                  $r->print('<blockquote>'.
1.1       www       152:                         $message.'</blockquote>');
1.2       www       153:                  if ($allowed) {
                    154:                 $r->print('<br /><textarea cols="80" rows="20" name="'.$_.'">'.
1.1       www       155: 			   $syllabus{$_}.
                    156:            '</textarea><input type="submit" name="storesyl" value="Store" />');
1.2       www       157: 	        }
                    158: 	    } else {
                    159: 		$r->print('<h1>'.$message.'</h1>');
                    160:                 if ($allowed) {
                    161:                  $r->print(
                    162:                 '<br />Title<br /><textarea cols="80" rows="2" name="'.$_.'">'.
                    163: 			   $syllabus{$_}.
                    164:            '</textarea><input type="submit" name="storesyl" value="Store" />');
                    165:                 }
                    166:             }
1.1       www       167: 	  }
                    168:        }
                    169:        if ($allowed) {
                    170: 	   $r->print('</form>');
                    171:        }
                    172:        $r->print('</p>');
                    173:     } else {
                    174:        $r->print('<p>No page information provided.</p>');
                    175:     }
                    176:     $r->print('</body></html>');
                    177:     return OK;
                    178: } 
                    179: 
                    180: 1;
                    181: __END__

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