[ Index ]

WordPress Cross Reference

title

Body

[close]

/wp-includes/js/tinymce/plugins/spellchecker/classes/ -> PSpell.php (source)

   1  <?php
   2  /**
   3   * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
   4   *
   5   * @package MCManager.includes
   6   * @author Moxiecode
   7   * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
   8   */
   9  
  10  class PSpell extends SpellChecker {
  11      /**
  12       * Spellchecks an array of words.
  13       *
  14       * @param {String} $lang Language code like sv or en.
  15       * @param {Array} $words Array of words to spellcheck.
  16       * @return {Array} Array of misspelled words.
  17       */
  18      function &checkWords($lang, $words) {
  19          $plink = $this->_getPLink($lang);
  20  
  21          $outWords = array();
  22          foreach ($words as $word) {
  23              if (!pspell_check($plink, trim($word)))
  24                  $outWords[] = utf8_encode($word);
  25          }
  26  
  27          return $outWords;
  28      }
  29  
  30      /**
  31       * Returns suggestions of for a specific word.
  32       *
  33       * @param {String} $lang Language code like sv or en.
  34       * @param {String} $word Specific word to get suggestions for.
  35       * @return {Array} Array of suggestions for the specified word.
  36       */
  37      function &getSuggestions($lang, $word) {
  38          $words = pspell_suggest($this->_getPLink($lang), $word);
  39  
  40          for ($i=0; $i<count($words); $i++)
  41              $words[$i] = utf8_encode($words[$i]);
  42  
  43          return $words;
  44      }
  45  
  46      /**
  47       * Opens a link for pspell.
  48       */
  49      function &_getPLink($lang) {
  50          // Check for native PSpell support
  51          if (!function_exists("pspell_new"))
  52              $this->throwError("PSpell support not found in PHP installation.");
  53  
  54          // Setup PSpell link
  55          $plink = pspell_new(
  56              $lang,
  57              $this->_config['PSpell.spelling'],
  58              $this->_config['PSpell.jargon'],
  59              $this->_config['PSpell.encoding'],
  60              $this->_config['PSpell.mode']
  61          );
  62  
  63          // Setup PSpell link
  64  /*        if (!$plink) {
  65              $pspellConfig = pspell_config_create(
  66                  $lang,
  67                  $this->_config['PSpell.spelling'],
  68                  $this->_config['PSpell.jargon'],
  69                  $this->_config['PSpell.encoding']
  70              );
  71  
  72              $plink = pspell_new_config($pspell_config);
  73          }*/
  74  
  75          if (!$plink)
  76              $this->throwError("No PSpell link found opened.");
  77  
  78          return $plink;
  79      }
  80  }
  81  
  82  ?>


Generated: Tue Mar 25 01:41:18 2014 WordPress honlapkészítés: online1.hu