Beispiel #1
0
        } else {
            enchant_broker_free($enchant);
            throw new Exception("Enchant spellchecker could not find dictionary for language: " . $lang);
        }
        return $suggestions;
    }
    /**
     * Return true/false if the engine is supported by the server.
     *
     * @return boolean True/false if the engine is supported.
     */
    public function isSupported()
    {
        return function_exists("enchant_broker_init");
    }
    private function normalizeLangCode($enchant, $lang)
    {
        $variants = array("en" => array("en_US", "en_GB"));
        if (isset($variants[$lang])) {
            array_unshift($variants, $lang);
            foreach ($variants[$lang] as $variant) {
                if (enchant_broker_dict_exists($enchant, $variant)) {
                    return $variant;
                }
            }
        }
        return $lang;
    }
}
TinyMCE_Spellchecker_Engine::add("enchant", "TinyMCE_SpellChecker_EnchantEngine");
Beispiel #2
0
<?php

/**
 * spellcheck.php
 *
 * Copyright, Moxiecode Systems AB
 * Released under LGPL License.
 *
 * License: http://www.tinymce.com/license
 * Contributing: http://www.tinymce.com/contributing
 */
require './includes/Engine.php';
require './includes/EnchantEngine.php';
require './includes/PSpellEngine.php';
$tinymceSpellCheckerConfig = array("engine" => "enchant", "enchant_dicts_path" => "./dicts", "pspell.mode" => "fast", "pspell.spelling" => "", "pspell.jargon" => "", "pspell.encoding" => "");
TinyMCE_Spellchecker_Engine::processRequest($tinymceSpellCheckerConfig);
Beispiel #3
0
            case "slow":
                $mode = PSPELL_SLOW;
                break;
            default:
                $mode = PSPELL_NORMAL;
        }
        // Setup PSpell link
        $plink = pspell_new($lang, $config['pspell.spelling'], $config['pspell.jargon'], $config['pspell.encoding'], $mode);
        if (!$plink) {
            throw new Exception("No PSpell link found opened.");
        }
        $outWords = array();
        foreach ($words as $word) {
            if (!pspell_check($plink, trim($word))) {
                $outWords[] = utf8_encode($word);
            }
        }
        return $outWords;
    }
    /**
     * Return true/false if the engine is supported by the server.
     *
     * @return boolean True/false if the engine is supported.
     */
    public function isSupported()
    {
        return function_exists("pspell_new");
    }
}
TinyMCE_Spellchecker_Engine::add("pspell", "TinyMCE_SpellChecker_PSpellEngine");