Ignore:
Timestamp:
Dec 18, 2005 12:16:03 AM (18 years ago)
Author:
scdev
Message:

detabbed all files ;P

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/SpellCheck.inc.php

    r41 r42  
    99 * @version 1.1
    1010 */
    11  
     11
    1212/* Implementation example:
    1313--------------------------------------------------------------------------------
     
    1717// Instantiate with parameters. In this example we'll set the language and the path to the personal wordlist file.
    1818$spell = new SpellCheck(array(
    19     'language' => 'en', 
     19    'language' => 'en',
    2020    'personal_wordlist' => '/tmp/my_custom_dict'
    2121));
     
    4949        'highlight_end' => '</strong>',
    5050    );
    51    
     51
    5252    var $_pspell_cfg_handle;
    5353    var $_pspell_handle;
    5454    var $_use_personal_wordlist = false;
    5555    var $_errors = array();
    56    
     56
    5757    /**
    5858     * Constructor.
    59     *
     59    *
    6060     * @param  array    $params     Array of parameters (key => val pairs).
    6161     */
    6262    function SpellCheck($params)
    6363    {
    64         if (!is_array($params) || empty($params)) {
    65             trigger_error('SpellCheck parameters not set properly', E_USER_ERROR);
    66         }
    67 
    68         $this->setParam($params);
     64        if (!is_array($params) || empty($params)) {
     65            trigger_error('SpellCheck parameters not set properly', E_USER_ERROR);
     66        }
     67
     68        $this->setParam($params);
    6969
    7070        $this->_pspell_cfg_handle = pspell_config_create($this->getParam('language'));
     
    7575        if ('' != $this->getParam('personal_wordlist')) {
    7676            if (!is_writable(dirname($this->getParam('personal_wordlist'))) || !is_writable($this->getParam('personal_wordlist'))) {
    77                 App::logMsg(sprintf('Personal wordlist file not writable: %s', $this->getParam('personal_wordlist')), LOG_WARNING, __FILE__, __LINE__);
     77                App::logMsg(sprintf('Personal wordlist file not writable: %s', $this->getParam('personal_wordlist')), LOG_WARNING, __FILE__, __LINE__);
    7878            } else {
    7979                pspell_config_personal($this->_pspell_cfg_handle, $this->getParam('personal_wordlist'));
     
    118118        }
    119119    }
    120    
     120
    121121    /**
    122122     * Check whether any errors have been triggered.
     
    136136        $this->_errors = array();
    137137    }
    138    
     138
    139139    /**
    140140     * Check one word.
     
    156156        }
    157157    }
    158    
     158
    159159    /**
    160160     * Suggest the correct spelling for one misspelled word.
     
    171171        return pspell_suggest($this->_pspell_handle, $word);
    172172    }
    173    
     173
    174174    /**
    175175     * Add a word to a personal list.
     
    186186        if ($this->_use_personal_wordlist) {
    187187            if (pspell_add_to_personal($this->_pspell_handle, $word)) {
    188                 App::logMsg(sprintf('Added "%s" to personal wordlist: %s', $word, $this->getParam('personal_wordlist')), LOG_DEBUG, __FILE__, __LINE__);
    189                 return true;           
    190             } else {
    191                 App::logMsg(sprintf('Failed adding "%s" to personal wordlist: %s', $word, $this->getParam('personal_wordlist')), LOG_WARNING, __FILE__, __LINE__);
    192                 return false;
    193             }
    194         }
    195     }
    196    
     188                App::logMsg(sprintf('Added "%s" to personal wordlist: %s', $word, $this->getParam('personal_wordlist')), LOG_DEBUG, __FILE__, __LINE__);
     189                return true;
     190            } else {
     191                App::logMsg(sprintf('Failed adding "%s" to personal wordlist: %s', $word, $this->getParam('personal_wordlist')), LOG_WARNING, __FILE__, __LINE__);
     192                return false;
     193            }
     194        }
     195    }
     196
    197197    /**
    198198     * Save personal list to file.
     
    217217        }
    218218    }
    219    
     219
    220220    /**
    221221     * Returns an array of suggested words for each mispelled word in the given text.
     
    252252        }
    253253    }
    254    
     254
    255255    /**
    256256     * Checks all words in a given string.
     
    284284        }
    285285    }
    286    
     286
    287287    /**
    288288     * Returns a given string with misspelled words highlighted.
     
    310310        return join('', $words);
    311311    }
    312    
     312
    313313    /**
    314314     * Prints the HTML for correcting all mispellings found in the text of one $_FORM element.
     
    326326        <input name="<?php echo $form_name ?>" type="hidden" value="<?php echo getFormData($form_name) ?>" />
    327327        <?php
    328        
     328
    329329        $form_words = $this->getStringSuggestions(getFormData($form_name));
    330330        if (is_array($form_words) && !empty($form_words)) {
     
    337337                <option value="<?php echo $original_word ?>">(<?php echo $original_word ?>)</option>
    338338                <?php
    339                
     339
    340340                foreach ($words as $suggestion) {
    341341                    ?>
     
    343343                    <?php
    344344                }
    345                
     345
    346346                ?>
    347347                </select>
     
    356356        }
    357357    }
    358    
     358
    359359    /**
    360360     * Tests if any form spelling corrections have been submitted.
     
    370370        return (false !== getFormData('spelling_suggestions', false)) || (false !== getFormData('spelling_corrections', false));
    371371    }
    372    
     372
    373373    /**
    374374     * Replace the misspelled words in the text of a specified form with the corrections.
Note: See TracChangeset for help on using the changeset viewer.