--- loncom/interface/lonsimplepage.pm 2004/05/12 19:25:15 1.20 +++ loncom/interface/lonsimplepage.pm 2005/04/07 06:56:23 1.25 @@ -1,7 +1,7 @@ # The LearningOnline Network # Simple Page Editor # -# $Id: lonsimplepage.pm,v 1.20 2004/05/12 19:25:15 albertel Exp $ +# $Id: lonsimplepage.pm,v 1.25 2005/04/07 06:56:23 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -40,23 +40,24 @@ use Apache::lonxml; sub handler { my $r = shift; - $r->content_type('text/html'); + &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; return OK if $r->header_only; - my $target=$ENV{'form.grade_target'}; + my $target=$env{'form.grade_target'}; # ------------------------------------------------------------ Print the screen if ($target ne 'tex') { + my $html=&Apache::lonxml::xmlbegin(); $r->print(< +$html The LearningOnline Network with CAPA ENDDOCUMENT } else { - $r->print(&Apache::lonprintout::print_latex_header($ENV{'form.latex_type'})); + $r->print(&Apache::lonprintout::print_latex_header($env{'form.latex_type'})); } my (undef,undef,undef,undef,$marker)=split(/\//,$r->uri); # Is this even in a course? - unless ($ENV{'request.course.id'}) { + unless ($env{'request.course.id'}) { if ($target ne 'tex') { $r->print('Not in a course'); return OK; @@ -72,8 +73,8 @@ ENDDOCUMENT return OK; } - my $dom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}; - my $crs = $ENV{'course.'.$ENV{'request.course.id'}.'.num'}; + my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; # --------------------------------------------------------- The syllabus fields my %syllabusfields=&Apache::lonlocal::texthash( @@ -87,16 +88,16 @@ ENDDOCUMENT ($ENV{'QUERY_STRING'},['forcestudent','forceedit','register']); # ----------------------------------------------------- Force menu registration my $addentries=''; - if ($ENV{'form.register'}) { + if ($env{'form.register'}) { $addentries=' onLoad="'.&Apache::lonmenu::loadevents(). '" onUnload="'.&Apache::lonmenu::unloadevents().'"'; $r->print(&Apache::lonmenu::registerurl(1)); } # --------------------------------------------------------------- Force Student my $forcestudent=''; - if ($ENV{'form.forcestudent'} || $target eq 'tex' ) { $forcestudent='student'; }; + if ($env{'form.forcestudent'} || $target eq 'tex' ) { $forcestudent='student'; }; my $forceedit=''; - if ($ENV{'form.forceedit'}) { $forceedit='edit'; } + if ($env{'form.forceedit'}) { $forceedit='edit'; } my %syllabus=&Apache::lonnet::dump('smppage_'.$marker,$dom,$crs); @@ -104,11 +105,12 @@ ENDDOCUMENT # --------------------------------------- There is such a user, get environment if ($target ne 'tex') { - $r->print(''.&Apache::loncommon::bodytag - ("Course Page",$forcestudent,$addentries,'',$dom,$ENV{'form.register'})); + $r->print(&Apache::lonhtmlcommon::htmlareaheaders(). + ''.&Apache::loncommon::bodytag + ("Course Page",$forcestudent,$addentries,'',$dom,$env{'form.register'})); } - my $allowed=&Apache::lonnet::allowed('mdc',$ENV{'request.course.id'}); + my $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'}); my $privileged=$allowed; if (($syllabus{'uploaded.lastmodified'}) && (!$forceedit)) { $forcestudent='student'; @@ -123,9 +125,9 @@ ENDDOCUMENT } elsif ($privileged and $target ne 'tex') { $r->print(''.&mt('Edit').''); } - if (($ENV{'form.uploaddoc.filename'} and $target ne 'tex') && - ($ENV{'form.storeupl'}) && ($allowed)) { - if ($ENV{'form.uploaddoc.filename'}=~/\.(gif|jpg|png|jpeg)$/i) { + if (($env{'form.uploaddoc.filename'} and $target ne 'tex') && + ($env{'form.storeupl'}) && ($allowed)) { + if ($env{'form.uploaddoc.filename'}=~/\.(gif|jpg|png|jpeg)$/i) { if ($syllabus{'uploaded.photourl'}) { &Apache::lonnet::removeuploadedurl($syllabus{'uploaded.photourl'}); } @@ -135,10 +137,13 @@ ENDDOCUMENT $syllabus{'uploaded.lastmodified'}=time; &Apache::lonnet::put('smppage_'.$marker,\%syllabus,$dom,$crs); } - if (($allowed) && ($ENV{'form.storesyl'})) { + if (($allowed) && ($env{'form.storesyl'})) { foreach (keys %syllabusfields) { - my $field=$ENV{'form.'.$_}; + my $field=$env{'form.'.$_}; + chomp($field); $field=~s/\s+$//s; + $field=~s/^\s+//s; + $field=~s/\$//s; $field=&Apache::lonfeedback::clear_out_html($field,1); $syllabus{$_}=$field; } @@ -175,6 +180,9 @@ ENDDOCUMENT $message =~s/(https*\:\/\/[^\s]+)/\\$1\<\/tt\>\<\/a\>/g; $message=&Apache::lontexconvert::msgtexconverted($message); + if ($allowed) { + $message=&Apache::lonspeller::markeduptext($message); + } unless ($_ eq 'aaa_title') { if (($_ ne 'bbb_content') || ($allowed)) { if ($target ne 'tex') { @@ -193,7 +201,7 @@ ENDDOCUMENT } if ($allowed) { if ($target ne 'tex') { - $r->print('
'); } else { @@ -209,7 +217,7 @@ ENDDOCUMENT $r->print(&Apache::lonxml::xmlparse($r,'tex','

'.$message.'

')); } if ($allowed) { - if ($ENV{'form.grade_target'} ne 'tex') { + if ($env{'form.grade_target'} ne 'tex') { $r->print( '
Title