Index: trunk/lib/SpellCheck.inc.php
===================================================================
--- trunk/lib/SpellCheck.inc.php	(revision 1)
+++ trunk/lib/SpellCheck.inc.php	(revision 15)
@@ -7,23 +7,26 @@
  *
  * @author  Quinn Comendant <quinn@strangecode.com>
- * @version 1.0
+ * @version 1.1
  */
  
 /* Implementation example:
 --------------------------------------------------------------------------------
-include '_config.inc.php';
+include_once dirname(__FILE__) . '/_config.inc.php';
 include 'codebase/lib/SpellCheck.inc.php';
 
-// Instantiate with language and optionally the path to the custom wordlist file.
-$spell = new SpellCheck('en', '/tmp/my_custom_dict');
+// Instantiate with parameters. In this example we'll set the language and the path to the personal wordlist file.
+$spell = new SpellCheck(array(
+    'language' => 'en', 
+    'personal_wordlist' => '/tmp/my_custom_dict'
+));
+
+// Just for the heck of it add a new word to persistent personal wordlist file.
+$spell->add('mealworm');
 
 $text_to_check = 'donky rinds taste like mealworm paste';
-
-// Add new word to persistent custom wordlist file.
-$spell->add('mealworm');
 
 if (!$spell->checkString($text_to_check)) {
     $suggestions = $spell->getStringSuggestions($text_to_check);
-    echo 'Spelling errors:';
+    echo 'Spelling errors! Here are suggested alternatives:';
     print_r($suggestions);
 } else {
@@ -39,6 +42,7 @@
 
     var $_params = array(
-        'personal_wordlist' => '',
-        'skip_len' => 3,
+        'language' => 'en',
+        'personal_wordlist' => '', // Text file to save custom words to.
+        'skip_length' => 3, // Words with this many chars or less will not be checked.
         'mode' => PSPELL_NORMAL, // PSPELL_FAST, PSPELL_NORMAL, or PSPELL_BAD_SPELLERS.
         'highlight_start' => '<strong style="color:red;">',
@@ -53,20 +57,27 @@
     /**
      * Constructor.
-     */
-    function SpellCheck($lang='en', $personal_wordlist=null)
-    {
-        $this->_pspell_cfg_handle = pspell_config_create($lang);
-
-        pspell_config_ignore($this->_pspell_cfg_handle, $skip_len);
-        pspell_config_mode($this->_pspell_cfg_handle, $mode);
-
-        if (isset($personal_wordlist)) {
-            if (!is_writable(dirname($personal_wordlist)) && !is_writable($personal_wordlist)) {
-                App::logMsg(sprintf('Personal wordlist file not writable: %s', $personal_wordlist), LOG_NOTICE, __FILE__, __LINE__);
+	 *
+     * @param  array    $params     Array of parameters (key => val pairs).
+     */
+    function SpellCheck($params)
+    {
+		if (!is_array($params) || empty($params)) {
+			trigger_error('SpellCheck parameters not set properly', E_USER_ERROR);
+		}
+
+		$this->setParam($params);
+
+        $this->_pspell_cfg_handle = pspell_config_create($this->getParam('language'));
+
+        pspell_config_ignore($this->_pspell_cfg_handle, $this->getParam('skip_length'));
+        pspell_config_mode($this->_pspell_cfg_handle, $this->getParam('mode'));
+
+        if ('' != $this->getParam('personal_wordlist')) {
+            if (!is_writable(dirname($this->getParam('personal_wordlist'))) || !is_writable($this->getParam('personal_wordlist'))) {
+            	App::logMsg(sprintf('Personal wordlist file not writable: %s', $this->getParam('personal_wordlist')), LOG_WARNING, __FILE__, __LINE__);
             } else {
-                $this->setParam(array('personal_wordlist' => $personal_wordlist));
-                pspell_config_personal($this->_pspell_cfg_handle, $personal_wordlist);
+                pspell_config_personal($this->_pspell_cfg_handle, $this->getParam('personal_wordlist'));
                 $this->_use_personal_wordlist = true;
-                App::logMsg(sprintf('Using personal wordlist: %s', $personal_wordlist), LOG_DEBUG, __FILE__, __LINE__);
+                App::logMsg(sprintf('Using personal wordlist: %s', $this->getParam('personal_wordlist')), LOG_DEBUG, __FILE__, __LINE__);
             }
         }
@@ -174,6 +185,11 @@
     {
         if ($this->_use_personal_wordlist) {
-            App::logMsg(sprintf('Added "%s" to personal wordlist: %s', $word, $this->getParam('personal_wordlist')), LOG_DEBUG, __FILE__, __LINE__);
-            return pspell_add_to_personal($this->_pspell_handle, $word);
+            if (pspell_add_to_personal($this->_pspell_handle, $word)) {
+				App::logMsg(sprintf('Added "%s" to personal wordlist: %s', $word, $this->getParam('personal_wordlist')), LOG_DEBUG, __FILE__, __LINE__);
+				return true;			
+			} else {
+				App::logMsg(sprintf('Failed adding "%s" to personal wordlist: %s', $word, $this->getParam('personal_wordlist')), LOG_ERR, __FILE__, __LINE__);
+				return false;
+			}
         }
     }
