From a2bd8ce7506a8286835dd5972a09fdf94c738046 Mon Sep 17 00:00:00 2001
From: Andreas Gohr <andi@splitbrain.org>
Date: Sun, 31 Jul 2005 19:26:12 +0200
Subject: [PATCH] Personal wordlist for spellchecker #488

This patch allows you to add a file named conf/words.aspell with your own
words you don't want the spellchecker to choke on.

Thanks to Steven Danz for code idea

darcs-hash:20050731172612-7ad00-60fb3f09589c4758f1093f532de9699beb048569.gz
---
 conf/words.aspell.dist       | 5 +++++
 data/pages/wiki/dokuwiki.txt | 2 +-
 inc/aspell.php               | 8 ++++++--
 lib/exe/spellcheck.php       | 5 +++++
 4 files changed, 17 insertions(+), 3 deletions(-)
 create mode 100644 conf/words.aspell.dist

diff --git a/conf/words.aspell.dist b/conf/words.aspell.dist
new file mode 100644
index 000000000..a49138fcb
--- /dev/null
+++ b/conf/words.aspell.dist
@@ -0,0 +1,5 @@
+personal_ws-1.1 en 4 utf-8
+DokuWiki
+Wiki
+WikiWiki
+Gohr
diff --git a/data/pages/wiki/dokuwiki.txt b/data/pages/wiki/dokuwiki.txt
index cc43d2ee3..d8b107310 100644
--- a/data/pages/wiki/dokuwiki.txt
+++ b/data/pages/wiki/dokuwiki.txt
@@ -41,7 +41,7 @@ All documentation and additional information besides the [[syntax|syntax descrip
 
 2004-2005 (c) Andreas Gohr <andi@splitbrain.org>
 
-The DokuWiki engine is licensend under [[http://www.gnu.org/licenses/gpl.html|GNU General Public License]] Version 2. If you use DokuWiki in your company, consider donating a few bucks to me via [[https://www.paypal.com/xclick/business=andi%40splitbrain.org&amp;item_name=DokuWiki+Donation&amp;no_shipping=1&amp;no_note=1&amp;tax=0&amp;currency_code=EUR&amp;lc=US|PayPal]] ;-).
+The DokuWiki engine is licensed under [[http://www.gnu.org/licenses/gpl.html|GNU General Public License]] Version 2. If you use DokuWiki in your company, consider donating a few bucks to me via [[https://www.paypal.com/xclick/business=andi%40splitbrain.org&amp;item_name=DokuWiki+Donation&amp;no_shipping=1&amp;no_note=1&amp;tax=0&amp;currency_code=EUR&amp;lc=US|PayPal]] ;-).
 
 The content published in the DokuWiki at http://www.splitbrain.org/dokuwiki/ is licensed under the [[http://creativecommons.org/licenses/by-nc-sa/2.0/|Creative Commons Attribution-NonCommercial-ShareAlike License]] Version 2.0. This is true for all content (files inside the ''data'' directory) distributed in the download tarball, too.
 
diff --git a/inc/aspell.php b/inc/aspell.php
index 72d2f8b86..570656795 100644
--- a/inc/aspell.php
+++ b/inc/aspell.php
@@ -70,6 +70,7 @@ if(defined('PSPELL_COMP')){
 class Aspell{
     var $language = null;
     var $jargon   = null;
+    var $personal = null;
     var $encoding = 'iso8859-1';
     var $mode     = PSPELL_NORMAL;
     var $version  = 0;
@@ -85,7 +86,6 @@ class Aspell{
         $this->language = $language;
         $this->jargon   = $jargon;
         $this->encoding = $encoding;
-        $this->_prepareArgs();
     } 
 
     /**
@@ -101,7 +101,6 @@ class Aspell{
         }
 
         $this->mode = $mode;
-        $this->_prepareArgs();
         return $mode;
     }
 
@@ -125,6 +124,10 @@ class Aspell{
             $this->args .= ' --jargon='.escapeshellarg($this->jargon);
         }
 
+        if($this->personal != null){
+            $this->args .= ' --personal='.escapeshellarg($this->personal);
+        }
+
         if($this->encoding != null){
             $this->args .= ' --encoding='.escapeshellarg($this->encoding);
         }
@@ -160,6 +163,7 @@ class Aspell{
      * @link     http://aspell.sf.net/man-html/Through-A-Pipe.html
      */
     function runAspell($text,&$out,&$err,$specials=null){
+        $this->_prepareArgs();
         if(empty($text)) return true;
         //prepare file descriptors
         $descspec = array(
diff --git a/lib/exe/spellcheck.php b/lib/exe/spellcheck.php
index 968e25395..4bb08fd88 100644
--- a/lib/exe/spellcheck.php
+++ b/lib/exe/spellcheck.php
@@ -58,6 +58,11 @@ header('Content-Type: text/plain; charset=utf-8');
 $spell = new Aspell($conf['lang'],null,'utf-8');
 $spell->setMode(PSPELL_FAST);
 
+//add personal dictionary
+if(@file_exists(DOKU_INC.'conf/words.aspell')){
+  $spell->personal = DOKU_INC.'conf/words.aspell';
+}
+
 //call the requested function
 $call = 'spell_'.$_POST['call'];
 if(function_exists($call)){
-- 
GitLab