From eed11761c772ed3ce133c624a7d3f246a506b8e0 Mon Sep 17 00:00:00 2001 From: Repellent Date: Thu, 5 Mar 2026 23:02:54 +0500 Subject: [PATCH] update ver 3.31 --- README.md | 9 +++-- class/search.php | 56 ++++++++++++++++---------- css/mod_search_styles.css | 9 +++++ info.php | 2 +- lang/ru.txt | 1 + module.php | 16 ++++++-- sql.php | 26 ++++++------- templates/form.tpl | 21 ++++++++-- templates/form_big.tpl | 63 +++++++++++++++++++++++------- templates/results.tpl | 63 +++++++++++++++++++++++++----- templates/words.tpl | 82 +++++++++++++++++++-------------------- 11 files changed, 237 insertions(+), 111 deletions(-) create mode 100644 css/mod_search_styles.css diff --git a/README.md b/README.md index 0a0cb0d..5734aad 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,17 @@ ### search -## Модуль Поиск v2.26.0 +## Модуль Поиск 3.31.1 -### Данный модуль позволяет организвать поиск необходимой информации на вашем сайте. +### Данный модуль позволяет организовать поиск необходимой информации на вашем сайте. - * Поиск информации осуществляется как по заголовкам документов, так и по содержимому. Для того, чтобы вывести форму для поиска на вашем сайте, разместите системный тег [mod_search] в нужном месте вашего шаблона сайта. + * Поиск информации осуществляется как по заголовкам документов, так и по содержимому. Для того, чтобы вывести форму для поиска на вашем сайте, разместите системный тег [mod_search] в нужном месте вашего шаблона сайта или шаблона рубрики. + * Не забудьте в разделе "Редактировать поля и права рубрики" активировать чекбоксы напротив полей, по которым вы хотите осуществлять поиск. ### Changelog: +05.03.2026 - версия 3.31.1 - Адаптация для версии AVE.CMS v3.31.1 ALT. Рефакторинг кода для работы в среде PHP-8.4, верстка публичной части модуля Bootstrap v5. Вы можете использовать файл mod_search_styles.css - подключается в основной шаблон при использовании модуля программно. + 02.09.2019 - версия 2.26.0 - Адаптация для версии AVE.CMS v3.26 16.07.2016 - версия 2.1.1 - обновления от @MadDen diff --git a/class/search.php b/class/search.php index ec15254..a0d8479 100644 --- a/class/search.php +++ b/class/search.php @@ -86,26 +86,36 @@ class Search * ВНЕШНИЕ МЕТОДЫ */ - function searchResultGet($tpl_dir, $lang_file) +function searchResultGet($tpl_dir, $lang_file) { global $AVE_DB, $AVE_Template; $AVE_Template->config_load($lang_file); - define('MODULE_TITLE', $AVE_Template->get_config_vars('SEARCH_RESULTS')); + // Подключаем CSS + $GLOBALS['user_header']['search_css'] = ''; + + if (!defined('MODULE_TITLE')) { + define('MODULE_TITLE', $AVE_Template->get_config_vars('SEARCH_RESULTS')); + } $stem_words = array(); - $tmp = preg_replace('/[^\x20-\xFF]|[>_search_string = trim(preg_replace('/ +/', ' ', stripslashes($tmp))); + $this->_search_string = trim(preg_replace('/\s+/', ' ', stripslashes($tmp))); + + // Определяем тип поиска (в заголовках или везде) + $type_search = (isset($_REQUEST['ts']) && $_REQUEST['ts'] == 1) ? 1 : 0; if (mb_strlen($this->_search_string) > 2) { // экранирование для LIKE $tmp = str_replace('\\', '\\\\', $this->_search_string); $tmp = addcslashes(addslashes($tmp), '%_'); - $tmp = preg_replace('/ +/', ' ', $tmp); + $tmp = preg_replace('/\s+/', ' ', $tmp); $tmp = preg_split('/\s+/', $tmp); $where = ''; @@ -171,12 +181,10 @@ class Search $query_feld = $AVE_DB->Query($sql); - //Debug::_echo($sql); - $num = $AVE_DB->NumAllRows($sql); - $pages = @ceil($num / $limit); + $pages = (int)@ceil($num / $limit); - $sw = addslashes(mb_strtolower($this->_search_string)); + $sw = addslashes(mb_strtolower($this->_search_string)); $exist = $AVE_DB->Query(" SELECT 1 @@ -207,23 +215,29 @@ class Search search_count = 1 "); } + + $page_nav = ''; + if ($num > $limit) { $page_nav = '{t}'; $page_nav = get_pagination($pages, 'page', $page_nav); } $AVE_Template->assign('q_navi', $page_nav); } - if ($num > 0) + if ($num > 0 && isset($query_feld)) { $modul_search_results = array(); - array_walk($this->_stem_words, create_function('&$val','$val=preg_quote(stripslashes(stripslashes(str_replace("\"",""",$val))),"/");')); + array_walk($this->_stem_words, function(&$val) { + $val = preg_quote(stripslashes(stripslashes(str_replace('"', """, $val))), "/"); + }); + $regex_snapshot = '/.{0,100}[^\s]*' . implode('[^\s]*.{0,100}|.{0,100}[^\s]*', $this->_stem_words) . '[^\s]*.{0,100}/iu'; $regex_highlight = '/[^\s]*' . implode('[^\s]*|[^\s]*', $this->_stem_words) . '[^\s]*/iu'; @@ -251,19 +265,21 @@ class Search $row->Text = strip_tags($row->Text, $this->_allowed_tags); $fo = array(); - - preg_match($regex_snapshot, $row->Text, $fo); - - $row->Text = $type_search ? '' : ''; - - while (list($key, $val) = @each($fo)) + preg_match_all($regex_snapshot, $row->Text, $fo); + + $row->Text = ''; + + if (!empty($fo[0]) && !$type_search) { - $row->Text .= $val . ($type_search ? '' : ''); + foreach ($fo[0] as $val) + { + $row->Text .= $val . ' ... '; + } } if (1 == $this->_highlight && !empty($this->_stem_words)) { - $row->Text = @preg_replace($regex_highlight, "$0", $row->Text); + $row->Text = preg_replace($regex_highlight, "$0", $row->Text); } $row->document_alias = rewrite_link('index.php?id=' . $row->Id . '&doc=' . (empty($row->document_alias) ? prepare_url($row->document_title) : $row->document_alias)); diff --git a/css/mod_search_styles.css b/css/mod_search_styles.css new file mode 100644 index 0000000..f039021 --- /dev/null +++ b/css/mod_search_styles.css @@ -0,0 +1,9 @@ +.mod_search_highlight { + background-color: #fff3cd; /* Светло-желтый фон (Bootstrap warning light) */ + color: #664d03; /* Темно-коричневый текст для контраста */ + padding: 0 2px; /* Небольшие отступы по бокам */ + border-radius: 3px; /* Скругление углов */ + font-weight: 600; /* Делаем текст чуть жирнее */ + border-bottom: 1px solid #ffe69c; /* Тонкая полоска снизу для акцента */ +} +.bi .bi-sort-alpha-down {color: #F70101 !important} \ No newline at end of file diff --git a/info.php b/info.php index 52ba89f..384ff68 100644 --- a/info.php +++ b/info.php @@ -4,7 +4,7 @@ $module = array( 'ModuleSysName' => 'search', - 'ModuleVersion' => '1.26.0', + 'ModuleVersion' => '3.31.1', 'ModuleAutor' => 'AVE.cms Team', 'ModuleCopyright' => '© 2007-' . date('Y') . ' AVE.cms', 'ModuleIsFunction' => 1, diff --git a/lang/ru.txt b/lang/ru.txt index 0820de8..8572b6f 100644 --- a/lang/ru.txt +++ b/lang/ru.txt @@ -4,6 +4,7 @@ MODULE_DESCRIPTION = "Данный модуль позволяет орган [module] SEARCH_BUTTON = "Поиск" +SEARCH_PLACEHOLDER = "Поиск по сайту..." SEARCH_IN_DESCRIPTION = "В тексте" SEARCH_IN_TITLE = "В заголовках" SEARCH_HELP = "Использование поиска

Используйте знак "+" для строгого включения слова в поиск.
Используйте знак "-" для исключения слова из поиска.

Обязательно используйте пробел перед знаками "+" и "-". " diff --git a/module.php b/module.php index c29f434..0bc27e5 100644 --- a/module.php +++ b/module.php @@ -13,10 +13,20 @@ if (!defined('BASE_DIR')) exit; function mod_search() { - global $AVE_Template; + global $AVE_Template; - if (isset($_REQUEST['module']) && $_REQUEST['module'] == 'search') $AVE_Template->assign('hide', 1); - $AVE_Template->display(BASE_DIR . '/modules/search/templates/form.tpl'); + $lang = preg_replace('/[^a-zA-Z0-9_-]/', '', $_SESSION['user_language'] ?? 'ru'); + $lang_file = BASE_DIR . '/modules/search/lang/' . $lang . '.txt'; + + if (file_exists($lang_file)) { + $AVE_Template->config_load($lang_file, 'module'); + } + + if (isset($_REQUEST['module']) && $_REQUEST['module'] == 'search') { + $AVE_Template->assign('hide', 1); + } + + $AVE_Template->display(BASE_DIR . '/modules/search/templates/form.tpl'); } if (!defined('ACP') && (isset($_REQUEST['module']) && $_REQUEST['module'] == 'search')) diff --git a/sql.php b/sql.php index 425d739..923c65f 100644 --- a/sql.php +++ b/sql.php @@ -8,39 +8,35 @@ * @filesource */ +if (!defined('BASE_DIR')) exit; + $module_sql_install = array(); $module_sql_deinstall = array(); $module_sql_update = array(); -$module_sql_deinstall[] = "DROP TABLE IF EXISTS %%PRFX%%_module_search;"; +$module_sql_deinstall[] = "DROP TABLE IF EXISTS `%%PRFX%%_module_search`;"; -$module_sql_install[] = "CREATE TABLE %%PRFX%%_module_search ( +$module_sql_install[] = " +CREATE TABLE IF NOT EXISTS `%%PRFX%%_module_search` ( `Id` int(10) unsigned NOT NULL auto_increment, `search_query` char(255) NOT NULL, `search_count` mediumint(5) unsigned NOT NULL default '0', `search_found` mediumint(5) unsigned NOT NULL default '0', PRIMARY KEY (`Id`), UNIQUE KEY `search_query` (`search_query`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 PACK_KEYS=0;"; +) ENGINE=MyISAM DEFAULT CHARSET=utf8 PACK_KEYS=0; +"; -// Обновление модуля $module_sql_update[] = " UPDATE `%%PRFX%%_module` SET - ModuleAveTag = '" . $modul['ModuleAveTag'] . "', - ModulePHPTag = '" . $modul['ModulePHPTag'] . "', - ModuleVersion = '" . $modul['ModuleVersion'] . "' + ModuleAveTag = '" . $module['ModuleAveTag'] . "', + ModulePHPTag = '" . $module['ModulePHPTag'] . "', + ModuleVersion = '" . $module['ModuleVersion'] . "' WHERE - ModuleSysName = '" . $modul['ModuleSysName'] . "' + ModuleSysName = '" . $module['ModuleSysName'] . "' LIMIT 1; "; -$module_sql_update[] = " - RENAME TABLE - `%%PRFX%%_modul_search` - TO - `%%PRFX%%_module_search` -"; - ?> \ No newline at end of file diff --git a/templates/form.tpl b/templates/form.tpl index ee4ea20..156b66c 100644 --- a/templates/form.tpl +++ b/templates/form.tpl @@ -1,5 +1,18 @@ - \ No newline at end of file diff --git a/templates/form_big.tpl b/templates/form_big.tpl index 4d20bfa..49ce028 100644 --- a/templates/form_big.tpl +++ b/templates/form_big.tpl @@ -1,17 +1,52 @@ -
-
- - -   - -
+
+ + + +
+
+ + +
+
-
- {#SEARCH_IN_DESCRIPTION#} - {#SEARCH_IN_TITLE#} +
+
+ +
+
+ + +
+
+ + +
+
- {#SEARCH_USE_AND#} - {#SEARCH_USE_OR#} -
- +
+ +
+
+ + +
+
+ + +
+
+ +
+
+
diff --git a/templates/results.tpl b/templates/results.tpl index 25689e2..7a4069a 100644 --- a/templates/results.tpl +++ b/templates/results.tpl @@ -1,16 +1,59 @@ -

{#SEARCH_RESULTS#}

+

{#SEARCH_RESULTS#}

-{if $no_results==1} -

{#SEARCH_NO_RESULTS#}

+{if $no_results == 1} +
+ {#SEARCH_NO_RESULTS#} +
{else} - {if $q_navi}{/if} + {if $q_navi} +
+ {#SEARCH_PAGES#}: {$q_navi} +
+ {/if} - {foreach from=$searchresults item=result} -

{$result->document_title|escape} {$result->document_published|date_format:$DATE_FORMAT|pretty_date}

-
{$result->Text}
{#SEARCH_VIEW#} | {#SEARCH_VIEW_BLANK#} {$result->document_count_view}

- {/foreach} + + + {if $q_navi} +
+ {#SEARCH_PAGES#}: {$q_navi} +
+ {/if} {/if} -{include file="$inc_path/form_big.tpl"} \ No newline at end of file +
+
Новый поиск
+ {include file="$inc_path/form_big.tpl"} +
\ No newline at end of file diff --git a/templates/words.tpl b/templates/words.tpl index 8abbdca..a3a05be 100644 --- a/templates/words.tpl +++ b/templates/words.tpl @@ -1,22 +1,21 @@ @@ -40,32 +39,33 @@ $(document).ready(function(){ldelim}
-
{#SEARCH_MODULE_NAME#}
- - - - - - - - - +
{#SEARCH_MODULE_NAME#}
+
{#SEARCH_WORD#}{#SEARCH_QUERIES#}{#SEARCH_FOUND_DOCS#}
+ + + + + + + + {foreach from=$items item=item} - - - - - - {/foreach} - -
{#SEARCH_WORD#}{#SEARCH_QUERIES#}{#SEARCH_FOUND_DOCS#}
{$item->search_query|escape}{$item->search_count}{$item->search_found}
+ + {$item->search_query|escape} + {$item->search_count} + {$item->search_found} + + {/foreach} + +
+
-
-
- -
+
+
+ +
-
- - +
\ No newline at end of file