60 public function render( $term, $resultSets ) {
61 if ( !is_array( $resultSets ) ) {
62 $resultSets = [ $resultSets ];
67 if ( $this->showMultimedia ) {
68 $this->output->addModules(
'mediawiki.special.search.commonsInterwikiWidget' );
70 $this->output->addModuleStyles(
'mediawiki.special.search.interwikiwidget.styles' );
71 $this->output->addModuleStyles(
'oojs-ui.styles.icons-wikimedia' );
74 foreach ( $resultSets as $resultSet ) {
75 foreach ( $resultSet as $result ) {
76 if ( !$result->isBrokenTitle() ) {
77 $iwResults[$result->getTitle()->getInterwiki()][] = $result;
83 $iwResultListOutput =
'';
85 foreach ( $iwResults as $iwPrefix => $results ) {
88 $iwResultItemOutput =
'';
90 foreach ( $results as $result ) {
91 $iwResultItemOutput .= $this->resultWidget->render( $result, $position++ );
94 $headerHtml = $this->
headerHtml( $term, $iwPrefix );
95 $footerHtml = $this->
footerHtml( $term, $iwPrefix );
96 $iwResultListOutput .= Html::rawElement(
'li',
98 'class' =>
'iw-resultset',
99 'data-iw-resultset-pos' => $iwResultSetPos,
100 'data-iw-resultset-source' => $iwPrefix
104 $iwResultItemOutput .
110 return Html::rawElement(
112 [
'id' =>
'mw-interwiki-results' ],
114 'ul', [
'class' =>
'iw-results', ], $iwResultListOutput
127 $href = Title::makeTitle(
NS_SPECIAL,
'Search',
'', $iwPrefix )->getLocalURL(
128 [
'search' => $term,
'fulltext' => 1 ]
131 $interwiki = $this->iwLookup->fetch( $iwPrefix );
134 $iwHost = $interwiki ? parse_url( $interwiki->getURL(), PHP_URL_HOST ) :
false;
136 $captionText = $this->customCaptions[$iwPrefix] ?? $iwHost ?: $iwPrefix;
137 $searchLink =
Html::element(
'a', [
'href' => $href,
'target' =>
'_blank' ], $captionText );
139 return Html::rawElement(
'div',
140 [
'class' =>
'iw-result__header' ],
141 $this->
iwIcon( $iwPrefix ) . $searchLink );
152 $href = Title::makeTitle(
NS_SPECIAL,
'Search',
'', $iwPrefix )->getLocalURL(
153 [
'search' => $term,
'fulltext' => 1 ]
156 $captionText = $this->specialSearch->msg(
'search-interwiki-resultset-link' )->text();
157 $searchLink =
Html::element(
'a', [
'href' => $href,
'target' =>
'_blank' ], $captionText );
159 return Html::rawElement(
'div',
160 [
'class' =>
'iw-result__footer' ],
165 if ( $this->customCaptions !==
null ) {
169 $this->customCaptions = [];
170 $customLines = explode(
"\n", $this->specialSearch->msg(
'search-interwiki-custom' )->text() );
171 foreach ( $customLines as $line ) {
172 $parts = explode(
':', $line, 2 );
173 if ( count( $parts ) === 2 ) {
174 $this->customCaptions[$parts[0]] = $parts[1];
190 if ( filter_var( $logoName, FILTER_VALIDATE_URL ) || $logoName ===
"/" ) {
194 $iwIcon =
new OOUI\IconWidget( [
212 $logoOverridesKeys = array_keys( $this->iwLogoOverrides );
213 if ( in_array( $prefix, $logoOverridesKeys ) ) {
214 return $this->iwLogoOverrides[ $prefix ];
217 $interwiki = $this->iwLookup->fetch( $prefix );
218 return $interwiki ? $interwiki->getURL() :
'/';
229 '@phan-var array $parsed';
230 $iwIconUrl = $parsed[
'scheme'] .
231 $parsed[
'delimiter'] .
233 ( isset( $parsed[
'port'] ) ?
':' . $parsed[
'port'] :
'' ) .
236 $iwIcon =
new OOUI\IconWidget( [
240 return $iwIcon->setAttributes( [
'style' =>
"background-image:url($iwIconUrl);" ] );
A class containing constants representing the names of configuration variables.
const InterwikiLogoOverride
Name constant for the InterwikiLogoOverride setting, for use with Config::get()
This is one of the Core classes and should be read at least once by any new developers.
getOutput()
Get the OutputPage being used for this instance.
A set of SearchEngine results.