mirror of
https://github.com/humhub/humhub.git
synced 2025-01-16 21:58:17 +01:00
Improve rendering of meta search content (#7193)
Co-authored-by: Lucas Bartholemy <luke-@users.noreply.github.com>
This commit is contained in:
parent
5752d62c72
commit
960a58e50e
@ -25,6 +25,7 @@ HumHub Changelog
|
||||
- Fix #7182: Fix initialization of several select2 inputs on the same page
|
||||
- Fix #7187: Fix search reindexing after content deletion
|
||||
- Fix #7152: Fix search starting with special characters
|
||||
- Enh #7148: Improve rendering of meta search content
|
||||
- Fix #7192: Deny deleting user from single group
|
||||
|
||||
1.16.1 (July 1, 2024)
|
||||
|
@ -10,7 +10,7 @@ namespace humhub\modules\content\search;
|
||||
use humhub\interfaces\MetaSearchResultInterface;
|
||||
use humhub\modules\content\components\ContentContainerActiveRecord;
|
||||
use humhub\modules\content\models\Content;
|
||||
use humhub\modules\content\widgets\richtext\RichText;
|
||||
use humhub\modules\content\widgets\richtext\converter\RichTextToHtmlConverter;
|
||||
use humhub\modules\ui\icon\widgets\Icon;
|
||||
use humhub\modules\user\models\User;
|
||||
use Yii;
|
||||
@ -46,7 +46,20 @@ class SearchRecord implements MetaSearchResultInterface
|
||||
*/
|
||||
public function getTitle(): string
|
||||
{
|
||||
return RichText::output($this->content->getContentDescription(), ['record' => $this->content->getModel()]);
|
||||
$title = RichTextToHtmlConverter::process($this->content->getContentDescription());
|
||||
$title = str_replace(["\r", "\n"], ' ', strip_tags($title));
|
||||
|
||||
// Cut text to first word contained the searched keyword
|
||||
$keywordIndex = strpos($title, $this->keyword);
|
||||
if ($keywordIndex) {
|
||||
do {
|
||||
$keywordIndex--;
|
||||
$titlePart = substr($title, $keywordIndex);
|
||||
} while ($keywordIndex && $titlePart[0] !== ' ');
|
||||
$title = '...' . trim($titlePart);
|
||||
}
|
||||
|
||||
return $title;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user