Autocorrect layout

Опциональная корректировка раскладки клаваатуры в поиске. По умолчанию включено.
This commit is contained in:
Exile 2014-08-31 22:14:41 +04:00
commit 16de03b214
3 changed files with 24 additions and 9 deletions

View file

@ -485,6 +485,7 @@ $bb_cfg['search_min_word_len'] = 3;
$bb_cfg['search_max_word_len'] = 35; $bb_cfg['search_max_word_len'] = 35;
$bb_cfg['limit_max_search_results'] = false; $bb_cfg['limit_max_search_results'] = false;
$bb_cfg['spam_filter_file_path'] = ''; // BB_PATH .'/misc/spam_filter_words.txt'; $bb_cfg['spam_filter_file_path'] = ''; // BB_PATH .'/misc/spam_filter_words.txt';
$bb_cfg['autocorrect_wkl'] = true; // autocorrect wrong keyboard layout
// Posting // Posting
$bb_cfg['prevent_multiposting'] = true; // replace "reply" with "edit last msg" if user (not admin or mod) is last topic poster $bb_cfg['prevent_multiposting'] = true; // replace "reply" with "edit last msg" if user (not admin or mod) is last topic poster

View file

@ -430,11 +430,18 @@ if (!$items_found)
// Search words // Search words
if ($var =& $_REQUEST[$text_match_key]) if ($var =& $_REQUEST[$text_match_key])
{ {
if ($tmp = substr(trim($var), 0, $text_match_max_len)) if ($tmp = mb_substr(trim($var), 0, $text_match_max_len))
{
if ($bb_cfg['autocorrect_wkl'])
{ {
// Autocorrect wrong keyboard layout // Autocorrect wrong keyboard layout
$tlc = new Text_LangCorrect(); $tlc = new Text_LangCorrect();
$title_match_val = $tlc->parse($tlc->parse($tmp, 1), 2); $title_match_val = $tlc->parse($tlc->parse($tmp, 1), 2);
}
else
{
$title_match_val = $tmp;
}
$text_match_sql = clean_text_match($title_match_val, $all_words_val, false, true); $text_match_sql = clean_text_match($title_match_val, $all_words_val, false, true);
} }
} }

View file

@ -460,10 +460,17 @@ if (!$set_default)
if ($tm =& $_REQUEST[$title_match_key] AND is_string($tm)) if ($tm =& $_REQUEST[$title_match_key] AND is_string($tm))
{ {
if ($tmp = mb_substr(trim($tm), 0, $title_match_max_len)) if ($tmp = mb_substr(trim($tm), 0, $title_match_max_len))
{
if ($bb_cfg['autocorrect_wkl'])
{ {
// Autocorrect wrong keyboard layout // Autocorrect wrong keyboard layout
$tlc = new Text_LangCorrect(); $tlc = new Text_LangCorrect();
$title_match_val = $tlc->parse($tlc->parse($tmp, 1), 2); $title_match_val = $tlc->parse($tlc->parse($tmp, 1), 2);
}
else
{
$title_match_val = $tmp;
}
$title_match_sql = clean_text_match($title_match_val, true, false, false); $title_match_sql = clean_text_match($title_match_val, true, false, false);
} }
} }