PageRenderTime 63ms CodeModel.GetById 32ms RepoModel.GetById 0ms app.codeStats 0ms

/public/frontend/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpell.php

https://bitbucket.org/floppyxyz/musical
PHP | 82 lines | 33 code | 12 blank | 37 comment | 4 complexity | a3a743460547b80fef653f43871684cc MD5 | raw file
Possible License(s): GPL-2.0, AGPL-1.0, LGPL-2.1
  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. class PSpell extends SpellChecker {
  10. /**
  11. * Spellchecks an array of words.
  12. *
  13. * @param {String} $lang Language code like sv or en.
  14. * @param {Array} $words Array of words to spellcheck.
  15. * @return {Array} Array of misspelled words.
  16. */
  17. function &checkWords($lang, $words) {
  18. $plink = $this->_getPLink($lang);
  19. $outWords = array();
  20. foreach ($words as $word) {
  21. if (!pspell_check($plink, trim($word)))
  22. $outWords[] = utf8_encode($word);
  23. }
  24. return $outWords;
  25. }
  26. /**
  27. * Returns suggestions of for a specific word.
  28. *
  29. * @param {String} $lang Language code like sv or en.
  30. * @param {String} $word Specific word to get suggestions for.
  31. * @return {Array} Array of suggestions for the specified word.
  32. */
  33. function &getSuggestions($lang, $word) {
  34. $words = pspell_suggest($this->_getPLink($lang), $word);
  35. for ($i=0; $i<count($words); $i++)
  36. $words[$i] = utf8_encode($words[$i]);
  37. return $words;
  38. }
  39. /**
  40. * Opens a link for pspell.
  41. */
  42. function &_getPLink($lang) {
  43. // Check for native PSpell support
  44. if (!function_exists("pspell_new"))
  45. $this->throwError("PSpell support not found in PHP installation.");
  46. // Setup PSpell link
  47. $plink = pspell_new(
  48. $lang,
  49. $this->_config['PSpell.spelling'],
  50. $this->_config['PSpell.jargon'],
  51. $this->_config['PSpell.encoding'],
  52. $this->_config['PSpell.mode']
  53. );
  54. // Setup PSpell link
  55. /* if (!$plink) {
  56. $pspellConfig = pspell_config_create(
  57. $lang,
  58. $this->_config['PSpell.spelling'],
  59. $this->_config['PSpell.jargon'],
  60. $this->_config['PSpell.encoding']
  61. );
  62. $plink = pspell_new_config($pspell_config);
  63. }*/
  64. if (!$plink)
  65. $this->throwError("No PSpell link found opened.");
  66. return $plink;
  67. }
  68. }
  69. ?>