55 public function render( $term, $resultSets ) {
56 if ( !is_array( $resultSets ) ) {
57 $resultSets = [ $resultSets ];
62 if ( $this->showMultimedia ) {
63 $this->output->addModules(
'mediawiki.special.search.commonsInterwikiWidget' );
65 $this->output->addModuleStyles(
'mediawiki.special.search.interwikiwidget.styles' );
68 foreach ( $resultSets as $resultSet ) {
69 foreach ( $resultSet as $result ) {
70 if ( !$result->isBrokenTitle() ) {
71 $iwResults[$result->getTitle()->getInterwiki()][] = $result;
77 $iwResultListOutput =
'';
79 foreach ( $iwResults as $iwPrefix => $results ) {
82 $iwResultItemOutput =
'';
84 foreach ( $results as $result ) {
85 $iwResultItemOutput .= $this->resultWidget->render( $result, $position++ );
88 $footerHtml = $this->
footerHtml( $term, $iwPrefix );
89 $iwResultListOutput .= Html::rawElement(
'li',
91 'class' =>
'iw-resultset',
92 'data-iw-resultset-pos' => $iwResultSetPos,
93 'data-iw-resultset-source' => $iwPrefix
103 return Html::rawElement(
105 [
'id' =>
'mw-interwiki-results' ],
108 [
'class' =>
'iw-headline' ],
109 $this->specialSearch->msg(
'search-interwiki-caption' )->parse()
112 'ul', [
'class' =>
'iw-results', ], $iwResultListOutput
125 $href = Title::makeTitle(
NS_SPECIAL,
'Search',
null, $iwPrefix )->getLocalURL(
126 [
'search' => $term,
'fulltext' => 1 ]
129 $interwiki = $this->iwLookup->fetch( $iwPrefix );
132 $caption = $this->customCaptions[$iwPrefix] ??
133 $this->specialSearch->msg(
'search-interwiki-default', $parsed[
'host'] )->escaped();
135 $searchLink = Html::rawElement(
'em',
null,
136 Html::rawElement(
'a', [
'href' => $href,
'target' =>
'_blank' ], $caption )
139 return Html::rawElement(
'div',
140 [
'class' =>
'iw-result__footer' ],
141 $this->
iwIcon( $iwPrefix ) . $searchLink );
145 if ( $this->customCaptions !==
null ) {
149 $this->customCaptions = [];
150 $customLines = explode(
"\n", $this->specialSearch->msg(
'search-interwiki-custom' )->escaped() );
151 foreach ( $customLines as
$line ) {
152 $parts = explode(
':',
$line, 2 );
153 if ( count( $parts ) === 2 ) {
154 $this->customCaptions[$parts[0]] = $parts[1];