Changeset b214f8d in github
- Timestamp:
- Oct 14, 2008 9:32:48 AM (5 years ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
- Children:
- b92a674
- Parents:
- 32eb29f
- File:
-
- 1 edited
-
program/steps/mail/spell_pspell.inc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
program/steps/mail/spell_pspell.inc
r81308b3 rb214f8d 30 30 } 31 31 32 // read input 32 33 $data = file_get_contents('php://input'); 33 $xml = simplexml_load_string($data); 34 $text = (string)$xml->text; 34 35 // parse data (simplexml_load_string breaks CRLFs) 36 $left = strpos($data, '<text>'); 37 $right = strrpos($data, '</text>'); 38 $text = substr($data, $left+6, $right-($left+6)); 39 40 // tokenize 35 41 $words = preg_split('/[ !"#$%&()*+\\,-.\/\n:;<=>?@\[\]^_{|}]+/', $text, NULL, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_OFFSET_CAPTURE ); 36 $plink = pspell_new(get_input_value('lang', RCUBE_INPUT_GET), null, null, 'utf-8'); 42 43 // init spellchecker 44 $plink = pspell_new(get_input_value('lang', RCUBE_INPUT_GET), null, null, 'utf-8', PSPELL_FAST); 45 46 // send output 37 47 $out = '<?xml version="1.0" encoding="UTF-8"?><spellresult charschecked="'.rc_strlen($text).'">'; 38 48 39 49 $diff = 0; 40 50 foreach ($words as $w) { 41 $word = $w[0];51 $word = trim($w[0]); 42 52 $pos = $w[1] - $diff; 43 53 $len = rc_strlen($word); 44 if ($ plink && !pspell_check($plink, $word)) {54 if ($word && $plink && !pspell_check($plink, $word)) { 45 55 $suggestions = pspell_suggest($plink, $word); 46 56 $out .= '<c o="'.$pos.'" l="'.$len.'">'; … … 50 60 $diff += (strlen($word) - $len); 51 61 } 62 52 63 $out .= '</spellresult>'; 53 64
Note: See TracChangeset
for help on using the changeset viewer.
