use Hooks;
use HtmlArmor;
use MediaWiki\Linker\LinkRenderer;
+use MediaWiki\MediaWikiServices;
use SearchResult;
use SpecialSearch;
use Title;
/**
* @param SearchResult $result The result to render
- * @param string $terms Terms to be highlighted (@see SearchResult::getTextSnippet)
+ * @param string[] $terms Terms to be highlighted (@see SearchResult::getTextSnippet)
* @param int $position The result position, including offset
* @return string HTML
*/
// This is not quite safe, but better than showing excerpts from
// non-readable pages. Note that hiding the entry entirely would
// screw up paging (really?).
- if ( !$result->getTitle()->userCan( 'read', $this->specialPage->getUser() ) ) {
+ $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
+ if ( !$permissionManager->userCan(
+ 'read', $this->specialPage->getUser(), $result->getTitle()
+ ) ) {
return "<li>{$link}</li>";
}
"</table>";
}
- return "<li>{$html}</li>";
+ return "<li class='mw-search-result'>{$html}</li>";
}
/**
* title with highlighted words).
*
* @param SearchResult $result
- * @param string $terms
+ * @param string[] $terms
* @param int $position
* @return string HTML
*/
$descHtml = null;
$thumbHtml = null;
- $img = $result->getFile() ?: wfFindFile( $title );
+ $img = $result->getFile() ?: MediaWikiServices::getInstance()->getRepoGroup()
+ ->findFile( $title );
if ( $img ) {
$thumb = $img->transform( [ 'width' => 120, 'height' => 120 ] );
if ( $thumb ) {