1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
spellchecker.php
См. документацию.
1<?
3
5{
6 private
7 $lang,
8 $skip_len,
9 $pspell,
10 $pspell_mode,
11 $custom_spell,
12 $wrongWords,
13 $dics_path,
14 $custom_dics_path,
15 $dic;
16
17 public function __construct($params)
18 {
19 $this->lang = (isset($params["lang"]) && $params["lang"] != '') ? $params["lang"] : 'en';
20 $this->skip_len = $params["skip_length"];
21
22 $this->pspell = (function_exists('pspell_config_create') && ($params["use_pspell"] == "Y"));
23 //$this->custom_spell = $params["use_custom_spell"] == "Y";
24 $this->custom_spell = false;
25 $this->pspell_mode = $params["mode"];
26
27 $this->dics_path = $this->checkDicPath();
28 $this->user_dics_path = $this->dics_path."/custom.pws";
29 $this->custom_dics_path = $this->dics_path.'/custom_dics/'.$this->lang.'_';
30
31 if($this->custom_spell)
32 {
33 $this->dic = array();
34 }
35
36 if ($this->pspell)
37 {
38 $pspell_config = pspell_config_create ($this->lang, null, null, 'utf-8');
39 pspell_config_ignore($pspell_config, $this->skip_len);
40 pspell_config_mode($pspell_config, $params["mode"]);
41 pspell_config_personal($pspell_config, $this->user_dics_path);
42 $this->pspell_link = pspell_new_config($pspell_config);
43 }
44 }
45
46 private function checkDicPath()
47 {
48 global $USER;
49 $dics_path = $_SERVER["DOCUMENT_ROOT"].COption::GetOptionString('fileman', "user_dics_path", "/bitrix/modules/fileman/u_dics");
50
51 $custom_path = $dics_path.'/'.$this->lang;
52
53 if (COption::GetOptionString('fileman', "use_separeted_dics", "Y") == "Y")
54 {
55 $custom_path = $custom_path.'/'.$USER->GetID();
56 }
57
59 if(!$io->DirectoryExists($custom_path))
60 {
61 $io->CreateDirectory($custom_path);
62 }
63
64 return $custom_path;
65 }
66
67 function codeLetter($letter)
68 {
69 return (in_array($letter, $this->letters) && $letter != 'ы' && $letter != 'ь' && $letter != 'ъ') ? ord($letter) : 'def';
70 }
71
72 function loadDic($letter)
73 {
74 $path = $this->custom_dics_path.$letter.'.dic';
75 if (is_readable($path))
76 {
77 $dic = file($path);
78 foreach ($dic as $dict_word)
79 {
80 $this->dic[$letter][mb_strtolower(trim($dict_word))] = $dict_word;
81 }
82 }
83 else
84 $this->dic[$letter] = array();
85 }
86
87 function checkWord($word)
88 {
89 //pspell
90 if ($this->pspell)
91 {
92 return pspell_check($this->pspell_link, $word);
93 }
94 }
95
96
97 function checkWords($words)
98 {
99 $this->wrongWords = array();
100
101 for ($i = 0; $i < count($words); $i++)
102 {
103 if (!$this->checkWord($words[$i]))
104 {
105 $this->wrongWords[] = array(
106 0 => $i,
107 1 => $this->suggest($words[$i])
108 );
109 }
110 }
111
112 return $this->wrongWords;
113 }
114
115 function suggest($word)
116 {
117 $suggestions = array();
118 //pspell
119 if ($this->pspell)
120 {
121 $suggestions = pspell_suggest($this->pspell_link, $word);
122 }
123 return array_unique($suggestions);
124 }
125
126 function addWord($word = '')
127 {
128 //pspell
129 if ($this->pspell)
130 {
131 if (!pspell_add_to_personal($this->pspell_link, $word) || !pspell_save_wordlist($this->pspell_link))
132 {
133 return false;
134 }
135 }
136 }
137}
$path
Определения access_edit.php:21
static GetInstance()
Определения virtual_io.php:60
Определения spellchecker.php:5
suggest($word)
Определения spellchecker.php:115
codeLetter($letter)
Определения spellchecker.php:67
checkWord($word)
Определения spellchecker.php:87
addWord($word='')
Определения spellchecker.php:126
__construct($params)
Определения spellchecker.php:17
checkWords($words)
Определения spellchecker.php:97
loadDic($letter)
Определения spellchecker.php:72
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
global $USER
Определения csv_new_run.php:40
$io
Определения csv_new_run.php:98
if(!defined('SITE_ID')) $lang
Определения include.php:91
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
lang
Определения options.php:182
$i
Определения factura.php:643
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799