summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandi <andi@splitbrain.org>2005-06-28 21:10:48 +0200
committerandi <andi@splitbrain.org>2005-06-28 21:10:48 +0200
commit1e5322079b34cf36f264c4a11e81d932fa6314a5 (patch)
tree0ec4141f41ba57415f5ecc7af1592b430852f95f
parent4029d111c92196cc819ef8b51942f08ede4157db (diff)
downloadrpg-1e5322079b34cf36f264c4a11e81d932fa6314a5.tar.gz
rpg-1e5322079b34cf36f264c4a11e81d932fa6314a5.tar.bz2
fix for UTF-8 problem in spaceslink (spellchecker)
darcs-hash:20050628191048-9977f-7fe308bc4f13f36af78cdd67bd31acff0a2ebc7f.gz
-rw-r--r--lib/exe/spellcheck.php18
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/exe/spellcheck.php b/lib/exe/spellcheck.php
index 5af5c43dd..0a3a8403b 100644
--- a/lib/exe/spellcheck.php
+++ b/lib/exe/spellcheck.php
@@ -75,12 +75,18 @@ if(function_exists($call)){
* spelling errors again.
*
* @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
+ * @author Andreas Gohr <andi@splitbrain.org>
*/
function spaceslink($string, $check=""){
$string = stripslashes($string);
$check = stripslashes($check);
- $result = str_pad($check,utf8_strlen($string)-2," ",STR_PAD_LEFT);
- return $result." ";
+
+ $result = ' '; //opening [[
+ $result .= str_pad('',utf8_strlen($string),' ');
+ $result .= $check;
+ $result .= ' '; //closing ]]
+
+ return $result;
}
/**
@@ -108,18 +114,20 @@ function spell_check() {
$data = explode("\n",$string);
// don't check links and medialinks for spelling errors
- $string = preg_replace('/\{\{(.*?)(\|(.*?))?(\}\})/e','spaceslink("\\0","\\3")',$string);
- $string = preg_replace('/\[\[(.*?)(\|(.*?))?(\]\])/e','spaceslink("\\0","\\3")',$string);
+ $string = preg_replace('/\{\{(.*?)(\|(.*?))?(\}\})/e','spaceslink("\\1","\\2")',$string);
+ $string = preg_replace('/\[\[(.*?)(\|(.*?))?(\]\])/e','spaceslink("\\1","\\2")',$string);
// run aspell in terse sgml mode
if(!$spell->runAspell($string,$out,$err,array('!','+html'))){
- //if(!$spell->runAspell($string,$out,$err)){
print '2'; //to indicate an error
print "An error occured while trying to run the spellchecker:\n";
print $err;
return;
}
+ #use this to debug raw aspell output
+ #print "1$out"; return;
+
// go through the result
$lines = split("\n",$out);
$rcnt = count($lines)-1; // aspell result count