diff --git a/cgi/spellcheck_test.pl b/cgi/spellcheck_test.pl index bcc5584e5e0a6..78a05cfc67a81 100644 --- a/cgi/spellcheck_test.pl +++ b/cgi/spellcheck_test.pl @@ -41,6 +41,10 @@ ProductOpener::Display::init(); +# Passing values to the template +my $template_data_ref = { + lang => \&lang, +}; # MIDDLE DOT with common substitutes (BULLET variants, BULLET OPERATOR and DOT OPERATOR (multiplication)) my $middle_dot = qr/(?:\N{U+00B7}|\N{U+2022}|\N{U+2023}|\N{U+25E6}|\N{U+2043}|\N{U+204C}|\N{U+204D}|\N{U+2219}|\N{U+22C5})/i; @@ -68,16 +72,14 @@ my $text = remove_tags_and_quote(decode utf8=>param('text')); -my $html = '

The spellcheck results are based on matches in a given taxonomy.

-

For words with at least 5 characters, we consider an edit distance of 1 (insert, replace or delete).

-'; +my $html; +$template_data_ref->{action_process} = $action; +$template_data_ref->{tagtype} = $tagtype; +$template_data_ref->{lc} = $lc; if ($action eq 'process') { - - $html .= "

Spellcheck result for taxonomy $tagtype and language $lc:

"; - $html .= ""; foreach my $token2 (split(/$separators/, $text)) { my $token = $token2; @@ -89,7 +91,7 @@ $token =~ s/\s+$//; $token =~ s/^\s+//; - + next if get_fileid($token) eq ''; my ($canon_tagid, $tagid, $tag) = spellcheck_taxonomy_tag($lc, $tagtype, $token); @@ -98,49 +100,29 @@ $tag = ""; } - $html .= "\n"; - - } - - $html .= "
InputCorrection$lc tagCanonical tag
$token$tag$tagid$canon_tagid
"; - - $action = 'display'; -} - - -if ($action eq 'display') { - - $html .= start_form(-method => "GET"); - - - - $html .= <

-Text (language code: $lc):
- - -HTML -; - - $html .= '' - . hidden(-name=>'type', -value=>$type, -override=>1) - . hidden(-name=>'action', -value=>'process', -override=>1); - - $html .= submit() - . end_form(); - -} -elsif ($action eq 'process') { + push @{$template_data_ref->{tokens}}, { + token => $token, + tag => $tag, + tagid => $tagid, + canon_tagid => $canon_tagid, + }; + } + $action = 'display'; } +$template_data_ref->{action_display} = $action; +$template_data_ref->{text} = $text; my $full_width = 1; if ($action ne 'display') { $full_width = 0; } +$tt->process('spellcheck_test.tt.html', $template_data_ref, \$html); +$html .= "

" . $tt->error() . "

"; + display_new( { title=>"Spellcheck Test", content_ref=>\$html, diff --git a/templates/spellcheck_test.tt.html b/templates/spellcheck_test.tt.html new file mode 100755 index 0000000000000..731da585474d9 --- /dev/null +++ b/templates/spellcheck_test.tt.html @@ -0,0 +1,41 @@ +

The spellcheck results are based on matches in a given taxonomy.

+

For words with at least 5 characters, we consider an edit distance of 1 (insert, replace or delete).

+ +[% IF action_process == 'process' %] +

+ Spellcheck result for taxonomy [% tagtype %] and language [% lc %]: +

+ + + + + + + + + [% FOREACH token IN tokens %] + + + + + + + [% END %] +
Spellcheck Results
InputCorrection[% lc %] tagCanonical tag
[% token.token %][% token.tag %][% token.tagid %][% token.canon_tagid %]
+[% END %] + +[% IF action_display == 'display' %] +
+ +
+
+ + + + +
+[% END %]