Permalink
Browse files

Add Ignore List

Allow users/applications to define a custom dictionary of ignored word by adding a space-delimited list to `$config['general.ignored_words']` in `config.php`.
  • Loading branch information...
1 parent 1a147c5 commit ebe8e602dcc91048d09a8e4be3facbee97ee4053 @ericmann committed Nov 7, 2012
Showing with 21 additions and 0 deletions.
  1. +5 −0 classes/EnchantSpell.php
  2. +5 −0 classes/GoogleSpell.php
  3. +5 −0 classes/PSpell.php
  4. +5 −0 classes/PSpellShell.php
  5. +1 −0 config.php
View
@@ -18,6 +18,11 @@ class EnchantSpell extends SpellChecker {
* @return Array of misspelled words.
*/
function &checkWords($lang, $words) {
+ foreach ( explode( ' ', $this->config['general.ignored_words'] ) as $ignore ) {
+ if ( $index = array_search( $ignore, $words ) ) {
+ array_splice( $words, $index, 1 );
+ }
+ }
$r = enchant_broker_init();
if (enchant_broker_dict_exists($r,$lang)) {
View
@@ -16,6 +16,11 @@ class GoogleSpell extends SpellChecker {
* @return {Array} Array of misspelled words.
*/
function &checkWords($lang, $words) {
+ foreach ( explode( ' ', $this->config['general.ignored_words'] ) as $ignore ) {
+ if ( $index = array_search( $ignore, $words ) ) {
+ array_splice( $words, $index, 1 );
+ }
+ }
$wordstr = implode(' ', $words);
$matches = $this->_getMatches($lang, $wordstr);
$words = array();
View
@@ -16,6 +16,11 @@ class PSpell extends SpellChecker {
* @return {Array} Array of misspelled words.
*/
function &checkWords($lang, $words) {
+ foreach ( explode( ' ', $this->config['general.ignored_words'] ) as $ignore ) {
+ if ( $index = array_search( $ignore, $words ) ) {
+ array_splice( $words, $index, 1 );
+ }
+ }
$plink = $this->_getPLink($lang);
$outWords = array();
View
@@ -16,6 +16,11 @@ class PSpellShell extends SpellChecker {
* @return {Array} Array of misspelled words.
*/
function &checkWords($lang, $words) {
+ foreach ( explode( ' ', $this->config['general.ignored_words'] ) as $ignore ) {
+ if ( $index = array_search( $ignore, $words ) ) {
+ array_splice( $words, $index, 1 );
+ }
+ }
$cmd = $this->_getCMD($lang);
if ($fh = fopen($this->_tmpfile, "w")) {
View
@@ -9,6 +9,7 @@
//$config['general.engine'] = 'PSpell';
//$config['general.engine'] = 'PSpellShell';
//$config['general.remote_rpc_url'] = 'http://some.other.site/some/url/rpc.php';
+ $config['general.ignored_words'] = 'TinyMCE WordPress';
// PSpell settings
$config['PSpell.mode'] = PSPELL_FAST;

1 comment on commit ebe8e60

nacin commented on ebe8e60 Nov 7, 2012

Rather than array_splice(), use unset( $words[ $index ] ); This ensures the right index is always removed, regardless of how $words is indexed.

Please sign in to comment.