{foreach from=$objects item=message}
<li class="gridListItem gridListItemMessage">
<div class="gridListItemImage">
- {if $message->getUserProfile()}
+ {if $customIcons[$message->getObjectTypeName()]|isset}
+ {icon size=48 name=$customIcons[$message->getObjectTypeName()]}
+ {elseif $message->getUserProfile()}
{user object=$message->getUserProfile() type='avatar48' ariaHidden='true' tabindex='-1'}
{else}
{icon size=48 name='file'}
WCF::getTPL()->assign([
'objects' => $resultHandler->getSearchResults(),
'query' => $resultHandler->getQuery(),
+ 'customIcons' => $resultHandler->getCustomIcons(),
]);
return [
WCF::getTPL()->assign([
'objects' => $resultHandler->getSearchResults(),
'query' => $resultHandler->getQuery(),
+ 'customIcons' => $resultHandler->getCustomIcons(),
]);
return [
return '';
}
+ /**
+ * @inheritDoc
+ */
+ public function getCustomIconName(): ?string
+ {
+ return null;
+ }
+
/**
* @deprecated 5.5
*/
* placeholder {WCF_SEARCH_INNER_JOIN} within an empty INNER JOIN() statement.
*/
public function getFetchObjectsQuery(?PreparedStatementConditionBuilder $additionalConditions = null): string;
+
+ /**
+ * Provides the ability to show a custom icon in the list of search results.
+ * Returns either a FontAwesome icon name or null. The latter will trigger the default behavior.
+ * @since 6.0
+ */
+ public function getCustomIconName(): ?string;
}
return $this->getLegacyTemplateName();
}
+ /**
+ * @return array<string, string|null>
+ */
+ public function getCustomIcons(): array
+ {
+ $customIcons = [];
+ foreach (SearchEngine::getInstance()->getAvailableObjectTypes() as $name => $type) {
+ if ($type instanceof ISearchProvider) {
+ $customIcons[$name] = $type->getCustomIconName();
+ }
+ }
+
+ return $customIcons;
+ }
+
/**
* Will be removed with 6.0 once all search providers have switched to ISearchProvider.
* @deprecated 5.5