Added ability to filter search by topic.
This commit is contained in:
parent
e1cb500f99
commit
6b2bfb726f
3 changed files with 15 additions and 4 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
20250210
|
20250210.1
|
||||||
|
|
|
@ -33,6 +33,11 @@ Template::addFunction('search_merge_query', function($attrs) use (&$searchQueryE
|
||||||
elseif(!empty($searchQueryEvaluated['after']))
|
elseif(!empty($searchQueryEvaluated['after']))
|
||||||
$existing[] = 'after:' . $searchQueryEvaluated['after'];
|
$existing[] = 'after:' . $searchQueryEvaluated['after'];
|
||||||
|
|
||||||
|
if(!empty($attrs['topic']))
|
||||||
|
$existing[] = 'topic:' . $attrs['topic'];
|
||||||
|
elseif(!empty($searchQueryEvaluated['topic']))
|
||||||
|
$existing[] = 'topic:' . $searchQueryEvaluated['topic'];
|
||||||
|
|
||||||
$existing = array_merge($existing, array_unique(array_merge(
|
$existing = array_merge($existing, array_unique(array_merge(
|
||||||
$searchQueryEvaluated['query'],
|
$searchQueryEvaluated['query'],
|
||||||
empty($attrs['query']) ? [] : explode(' ', $attrs['query'])
|
empty($attrs['query']) ? [] : explode(' ', $attrs['query'])
|
||||||
|
@ -41,7 +46,7 @@ Template::addFunction('search_merge_query', function($attrs) use (&$searchQueryE
|
||||||
return implode(' ', $existing);
|
return implode(' ', $existing);
|
||||||
});
|
});
|
||||||
if(!empty($searchQuery)) {
|
if(!empty($searchQuery)) {
|
||||||
$searchQueryAttributes = ['type', 'author', 'after'];
|
$searchQueryAttributes = ['type', 'author', 'after', 'topic'];
|
||||||
$searchQueryParts = explode(' ', $searchQuery);
|
$searchQueryParts = explode(' ', $searchQuery);
|
||||||
foreach($searchQueryParts as $queryPart) {
|
foreach($searchQueryParts as $queryPart) {
|
||||||
$queryPart = trim($queryPart);
|
$queryPart = trim($queryPart);
|
||||||
|
@ -141,8 +146,10 @@ if(!empty($searchQuery)) {
|
||||||
else
|
else
|
||||||
$newsCategoryInfos[$categoryId] = $categoryInfo = $msz->news->getCategory(postInfo: $postInfo);
|
$newsCategoryInfos[$categoryId] = $categoryInfo = $msz->news->getCategory(postInfo: $postInfo);
|
||||||
|
|
||||||
$commentsCount = $postInfo->commentsSectionId !== null
|
$commentsCount = $msz->commentsCtx->posts->countPosts(
|
||||||
? $msz->comments->countPosts(categoryInfo: $postInfo->commentsSectionId, deleted: false) : 0;
|
categoryName: $postInfo->commentsCategoryName,
|
||||||
|
deleted: false,
|
||||||
|
);
|
||||||
|
|
||||||
$newsPosts[] = [
|
$newsPosts[] = [
|
||||||
'post' => $postInfo,
|
'post' => $postInfo,
|
||||||
|
|
|
@ -94,6 +94,7 @@ class ForumPostsData {
|
||||||
&& $searchQuery['type'] !== 'forum:post')
|
&& $searchQuery['type'] !== 'forum:post')
|
||||||
return [];
|
return [];
|
||||||
|
|
||||||
|
$topicInfo = null;
|
||||||
$userInfo = null;
|
$userInfo = null;
|
||||||
$deleted = false;
|
$deleted = false;
|
||||||
$pagination = null;
|
$pagination = null;
|
||||||
|
@ -101,6 +102,9 @@ class ForumPostsData {
|
||||||
$afterPostInfo = null;
|
$afterPostInfo = null;
|
||||||
$newerThanDays = null;
|
$newerThanDays = null;
|
||||||
|
|
||||||
|
if(!empty($searchQuery['topic']))
|
||||||
|
$topicInfo = $searchQuery['topic'];
|
||||||
|
|
||||||
if(!empty($searchQuery['author']))
|
if(!empty($searchQuery['author']))
|
||||||
$userInfo = $searchQuery['author'];
|
$userInfo = $searchQuery['author'];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue