--- loncom/interface/lonspeller.pm 2004/07/29 13:38:31 1.7 +++ loncom/interface/lonspeller.pm 2006/07/03 13:40:42 1.17 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Interface routines for Aspell # -# $Id: lonspeller.pm,v 1.7 2004/07/29 13:38:31 www Exp $ +# $Id: lonspeller.pm,v 1.17 2006/07/03 13:40:42 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -33,6 +33,7 @@ package Apache::lonspeller; use Apache::Constants qw(:common); use Text::Aspell; use Apache::lonlocal; +use Apache::lonnet; use Apache::lontexconvert(); use HTML::LCParser; use strict; @@ -41,7 +42,7 @@ my $speller; my $insidelink; sub spellcheck_language { - if ($ENV{'form.lang'}) { return $ENV{'form.lang'}; } + if ($env{'form.lang'}) { return $env{'form.lang'}; } if (&mt('spellcheck_lang') ne 'spellcheck_lang') { return &mt('spellcheck_lang'); } @@ -53,6 +54,13 @@ sub set_language { $speller->set_option('lang',$lang); } +{ + my $uniq; + sub get_uniq { + return ++$uniq; + } +} + sub textsection { my $input=shift; my $output=''; @@ -63,11 +71,28 @@ sub textsection { $output.=$word; } else { my $suggestions=join(' ',$speller->suggest($word)); - $suggestions=~s/\'/\\\'/gs; + $suggestions = &Apache::loncommon::js_ready($suggestions); if (($suggestions) && (!$insidelink)) { - $output.=''; + my $start_page= + &Apache::loncommon::start_page('Speller Suggestions',undef, + {'only_body' => 1, + 'js_ready' => 1, + 'bgcolor' => '#FFFFFF'}); + my $end_page= + &Apache::loncommon::end_page({'js_ready' => 1,}); + my $num = &get_uniq(); + my $info ='

'.$word.'

'.$suggestions; + $output .= "
"; } $output.=''.$word.''; if (($suggestions) && (!$insidelink)) { $output.=''; } @@ -124,12 +149,14 @@ sub handler { &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}); &initspeller(); - $r->print(''. - &mt('Spell Checker'). - ''. + my $start_page = + &Apache::loncommon::start_page('Spell Checker',undef, + {'only_body' => 1, + 'bgcolor' => '#DDDDDD'}); + $r->print($start_page. &Apache::lontexconvert::msgtexconverted( - &markeduptext($ENV{'form.text'})). - ''); + &markeduptext($env{'form.text'})). + &Apache::loncommon::end_page()); return OK; }