<?xml version="1.0"?>
<ZopeData>
  <record id="1" aka="AAAAAAAAAAE=">
    <pickle>
      <tuple>
        <global name="File" module="OFS.Image"/>
        <tuple/>
      </tuple>
    </pickle>
    <pickle>
      <dictionary>
        <item>
            <key> <string>_Cacheable__manager_id</string> </key>
            <value> <string>http_cache</string> </value>
        </item>
        <item>
            <key> <string>_EtagSupport__etag</string> </key>
            <value> <string>ts49309716.79</string> </value>
        </item>
        <item>
            <key> <string>__name__</string> </key>
            <value> <string>spellchecker.pl</string> </value>
        </item>
        <item>
            <key> <string>content_type</string> </key>
            <value> <string>text/plain</string> </value>
        </item>
        <item>
            <key> <string>data</string> </key>
            <value> <string encoding="cdata"><![CDATA[

#!/usr/bin/perl\n
\n
use CGI qw/ :standard /;\n
use File::Temp qw/ tempfile tempdir /;\n
\n
# my $spellercss = \'/speller/spellerStyle.css\';\t\t\t\t\t# by FredCK\n
my $spellercss = \'../spellerStyle.css\';\t\t\t\t\t\t\t# by FredCK\n
# my $wordWindowSrc = \'/speller/wordWindow.js\';\t\t\t\t\t# by FredCK\n
my $wordWindowSrc = \'../wordWindow.js\';\t\t\t\t\t\t\t# by FredCK\n
my @textinputs = param( \'textinputs[]\' ); # array\n
# my $aspell_cmd = \'aspell\';\t\t\t\t\t\t\t\t\t# by FredCK (for Linux)\n
my $aspell_cmd = \'"C:\\Program Files\\Aspell\\bin\\aspell.exe"\';\t# by FredCK (for Windows)\n
my $lang = \'en_US\';\n
# my $aspell_opts = "-a --lang=$lang --encoding=utf-8";\t\t\t# by FredCK\n
my $aspell_opts = "-a --lang=$lang --encoding=utf-8 -H --rem-sgml-check=alt";\t\t# by FredCK\n
my $input_separator = "A";\n
\n
# set the \'wordtext\' JavaScript variable to the submitted text.\n
sub printTextVar {\n
\tfor( my $i = 0; $i <= $#textinputs; $i++ ) {\n
\t        print "textinputs[$i] = decodeURIComponent(\'" . escapeQuote( $textinputs[$i] ) . "\')\\n";\n
\t}\n
}\n
\n
sub printTextIdxDecl {\n
\tmy $idx = shift;\n
\tprint "words[$idx] = [];\\n";\n
\tprint "suggs[$idx] = [];\\n";\n
}\n
\n
sub printWordsElem {\n
\tmy( $textIdx, $wordIdx, $word ) = @_;\n
\tprint "words[$textIdx][$wordIdx] = \'" . escapeQuote( $word ) . "\';\\n";\n
}\n
\n
sub printSuggsElem {\n
\tmy( $textIdx, $wordIdx, @suggs ) = @_;\n
\tprint "suggs[$textIdx][$wordIdx] = [";\n
\tfor my $i ( 0..$#suggs ) {\n
\t\tprint "\'" . escapeQuote( $suggs[$i] ) . "\'";\n
\t\tif( $i < $#suggs ) {\n
\t\t\tprint ", ";\n
\t\t}\n
\t}\n
\tprint "];\\n";\n
}\n
\n
sub printCheckerResults {\n
\tmy $textInputIdx = -1;\n
\tmy $wordIdx = 0;\n
\tmy $unhandledText;\n
\t# create temp file\n
\tmy $dir = tempdir( CLEANUP => 1 );\n
\tmy( $fh, $tmpfilename ) = tempfile( DIR => $dir );\n
\n
\t# temp file was created properly?\n
\n
\t# open temp file, add the submitted text.\n
\tfor( my $i = 0; $i <= $#textinputs; $i++ ) {\n
\t\t$text = url_decode( $textinputs[$i] );\n
\t\t# Strip all tags for the text. (by FredCK - #339 / #681)\n
\t\t$text =~ s/<[^>]+>/ /g;\n
\t\t@lines = split( /\\n/, $text );\n
\t\tprint $fh "\\%\\n"; # exit terse mode\n
\t\tprint $fh "^$input_separator\\n";\n
\t\tprint $fh "!\\n";  # enter terse mode\n
\t\tfor my $line ( @lines ) {\n
\t\t\t# use carat on each line to escape possible aspell commands\n
\t\t\tprint $fh "^$line\\n";\n
\t\t}\n
\n
\t}\n
\t# exec aspell command\n
\tmy $cmd = "$aspell_cmd $aspell_opts < $tmpfilename 2>&1";\n
\topen ASPELL, "$cmd |" or handleError( "Could not execute `$cmd`\\\\n$!" ) and return;\n
\t# parse each line of aspell return\n
\tfor my $ret ( <ASPELL> ) {\n
\t\tchomp( $ret );\n
\t\t# if \'&\', then not in dictionary but has suggestions\n
\t\t# if \'#\', then not in dictionary and no suggestions\n
\t\t# if \'*\', then it is a delimiter between text inputs\n
\t\tif( $ret =~ /^\\*/ ) {\n
\t\t\t$textInputIdx++;\n
\t\t\tprintTextIdxDecl( $textInputIdx );\n
\t\t\t$wordIdx = 0;\n
\n
\t\t} elsif( $ret =~ /^(&|#)/ ) {\n
\t\t\tmy @tokens = split( " ", $ret, 5 );\n
\t\t\tprintWordsElem( $textInputIdx, $wordIdx, $tokens[1] );\n
\t\t\tmy @suggs = ();\n
\t\t\tif( $tokens[4] ) {\n
\t\t\t\t@suggs = split( ", ", $tokens[4] );\n
\t\t\t}\n
\t\t\tprintSuggsElem( $textInputIdx, $wordIdx, @suggs );\n
\t\t\t$wordIdx++;\n
\t\t} else {\n
\t\t\t$unhandledText .= $ret;\n
\t\t}\n
\t}\n
\tclose ASPELL or handleError( "Error executing `$cmd`\\\\n$unhandledText" ) and return;\n
}\n
\n
sub escapeQuote {\n
\tmy $str = shift;\n
\t$str =~ s/\'/\\\\\'/g;\n
\treturn $str;\n
}\n
\n
sub handleError {\n
\tmy $err = shift;\n
\tprint "error = \'" . escapeQuote( $err ) . "\';\\n";\n
}\n
\n
sub url_decode {\n
\tlocal $_ = @_ ? shift : $_;\n
\tdefined or return;\n
\t# change + signs to spaces\n
\ttr/+/ /;\n
\t# change hex escapes to the proper characters\n
\ts/%([a-fA-F0-9]{2})/pack "H2", $1/eg;\n
\treturn $_;\n
}\n
\n
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #\n
# Display HTML\n
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #\n
\n
print <<EOF;\n
Content-type: text/html; charset=utf-8\n
\n
<html>\n
<head>\n
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">\n
<link rel="stylesheet" type="text/css" href="$spellercss"/>\n
<script src="$wordWindowSrc"></script>\n
<script type="text/javascript">\n
var suggs = new Array();\n
var words = new Array();\n
var textinputs = new Array();\n
var error;\n
EOF\n
\n
printTextVar();\n
\n
printCheckerResults();\n
\n
print <<EOF;\n
var wordWindowObj = new wordWindow();\n
wordWindowObj.originalSpellings = words;\n
wordWindowObj.suggestions = suggs;\n
wordWindowObj.textInputs = textinputs;\n
\n
\n
function init_spell() {\n
\t// check if any error occured during server-side processing\n
\tif( error ) {\n
\t\talert( error );\n
\t} else {\n
\t\t// call the init_spell() function in the parent frameset\n
\t\tif (parent.frames.length) {\n
\t\t\tparent.init_spell( wordWindowObj );\n
\t\t} else {\n
\t\t\terror = "This page was loaded outside of a frameset. ";\n
\t\t\terror += "It might not display properly";\n
\t\t\talert( error );\n
\t\t}\n
\t}\n
}\n
\n
</script>\n
\n
</head>\n
<body onLoad="init_spell();">\n
\n
<script type="text/javascript">\n
wordWindowObj.writeBody();\n
</script>\n
\n
</body>\n
</html>\n
EOF\n


]]></string> </value>
        </item>
        <item>
            <key> <string>precondition</string> </key>
            <value> <string></string> </value>
        </item>
        <item>
            <key> <string>size</string> </key>
            <value> <int>4746</int> </value>
        </item>
        <item>
            <key> <string>title</string> </key>
            <value> <string></string> </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
