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

@ -484,7 +484,8 @@ $bb_cfg['max_search_words_per_post'] = 200;
$bb_cfg['search_min_word_len'] = 3; $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))
{ {
// Autocorrect wrong keyboard layout if ($bb_cfg['autocorrect_wkl'])
$tlc = new Text_LangCorrect(); {
$title_match_val = $tlc->parse($tlc->parse($tmp, 1), 2); // Autocorrect wrong keyboard layout
$tlc = new Text_LangCorrect();
$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);
} }
} }
@ -571,7 +578,7 @@ if ($post_mode)
{ {
if (empty($tmp[$post_id])) if (empty($tmp[$post_id]))
{ {
continue; // if post was deleted but still remain in search results continue; // if post was deleted but still remain in search results
} }
$topic_id = $tmp[$post_id]['topic_id']; $topic_id = $tmp[$post_id]['topic_id'];
$sorted_rows[$topic_id][] = $tmp[$post_id]; $sorted_rows[$topic_id][] = $tmp[$post_id];

View file

@ -461,9 +461,16 @@ if (!$set_default)
{ {
if ($tmp = mb_substr(trim($tm), 0, $title_match_max_len)) if ($tmp = mb_substr(trim($tm), 0, $title_match_max_len))
{ {
// Autocorrect wrong keyboard layout if ($bb_cfg['autocorrect_wkl'])
$tlc = new Text_LangCorrect(); {
$title_match_val = $tlc->parse($tlc->parse($tmp, 1), 2); // Autocorrect wrong keyboard layout
$tlc = new Text_LangCorrect();
$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);
} }
} }