42 function openHandler(&$parser, $elem, $attribs)
45 foreach ($attribs as $key => $val) {
46 echo $key.
'="'.str_replace(
'"',
'\\"', $val).
'" ';
63 function closeHandler(&$parser, $elem)
79 function spellCallback($match)
81 $check_spelling =
true;
85 if ($check_spelling) {
86 $converted_word = (int)$word;
87 if ((
string)$converted_word == $word) $check_spelling =
false;
91 if ($check_spelling) {
92 $converted_word = strtoupper($word);
93 if ($converted_word == $word) $check_spelling =
false;
96 if (!$check_spelling || pspell_check($GLOBALS[
'spellerid'], $word)) {
97 return htmlspecialchars($match[1]).$match[2];
99 $retv =
'<span class="HA-spellcheck-error">'.$word.
'</span>';
100 $suggestions = pspell_suggest($GLOBALS[
'spellerid'], $word);
101 $retv.=
'<span class="HA-spellcheck-suggestions">';
103 for ($i = 0; $i < count($suggestions); $i++) {
105 $retv .= htmlspecialchars($suggestions[$i]);
106 if ($i != count($suggestions)) {
111 $retv .=
'</span>'.$match[2];
127 function dataHandler(&$parser, $data)
129 $matches = preg_match(
'|[^\w]|', $data);
135 echo preg_replace_callback(
'|(\w+)([^;\w])|', Array($this,
'spellCallback'), $data);
136 $contents = ob_get_contents();
138 echo substr($contents, 0, -1);
140 echo $this->spellCallback(Array($data, $data,
''));
155 function setLanguage($dict=
'en')
157 $pspell_config = pspell_config_create($dict);
158 pspell_config_mode($pspell_config, PSPELL_FAST);
159 $GLOBALS[
'spellerid'] = pspell_new_config($pspell_config);