Update functions.php

This commit is contained in:
Roman Kelesidis 2025-08-21 11:08:11 +03:00
commit b063c13d74
No known key found for this signature in database
GPG key ID: D8157C4D4C4C6DB4

View file

@ -1768,13 +1768,23 @@ function clean_text_match($text, $ltrim_star = true, $die_if_empty = false)
$text = ' ' . str_compact(ltrim($text, $ltrim_chars)) . ' ';
if ($bb_cfg['search_engine_type'] == 'sphinx') {
if ($bb_cfg['search_engine_type'] == 'manticore') {
$text = preg_replace('#(?<=\S)\-#u', ' ', $text); // "1-2-3" -> "1 2 3"
$text = preg_replace('#[^0-9a-zA-Zа-яА-ЯёЁ\-_*|]#u', ' ', $text); // valid characters (except '"' which are separate)
$text = str_replace(['-', '*'], [' -', '* '], $text); // only at the beginning/end of a word
$text = preg_replace('#[^0-9a-zA-Zа-яА-ЯёЁ\-_*|@]#u', ' ', $text); // валидные символы + @ для email поиска
$text = str_replace(['-', '*'], [' -', '* '], $text);
$text = preg_replace('#\s*\|\s*#u', '|', $text); // "| " -> "|"
$text = preg_replace('#\|+#u', ' | ', $text); // "||" -> "|"
$text = preg_replace('#(?<=\s)[\-*]+\s#u', ' ', $text); // single " - ", " * "
$text = preg_replace('#(?<=\s)[\-*]+\s#u', ' ', $text); // удаление одиночных " - ", " * "
$text = trim($text, ' -|');
$text = str_compact($text);
$text_match_sql = ($wrap_with_quotes && $text != '') ? '"' . $text . '"' : $text;
} elseif ($bb_cfg['search_engine_type'] == 'sphinx') {
$text = preg_replace('#(?<=\S)\-#u', ' ', $text);
$text = preg_replace('#[^0-9a-zA-Zа-яА-ЯёЁ\-_*|]#u', ' ', $text);
$text = str_replace(['-', '*'], [' -', '* '], $text);
$text = preg_replace('#\s*\|\s*#u', '|', $text);
$text = preg_replace('#\|+#u', ' | ', $text);
$text = preg_replace('#(?<=\s)[\-*]+\s#u', ' ', $text);
$text = trim($text, ' -|');
$text = str_compact($text);
$text_match_sql = ($wrap_with_quotes && $text != '') ? '"' . $text . '"' : $text;