57 public function render( $term, $resultSets ) {
58 if ( !is_array( $resultSets ) ) {
59 $resultSets = [ $resultSets ];
64 if ( $this->showMultimedia ) {
65 $this->output->addModules(
'mediawiki.special.search.commonsInterwikiWidget' );
67 $this->output->addModuleStyles(
'mediawiki.special.search.interwikiwidget.styles' );
68 $this->output->addModuleStyles(
'oojs-ui.styles.icons-wikimedia' );
71 foreach ( $resultSets as $resultSet ) {
72 foreach ( $resultSet as $result ) {
73 if ( !$result->isBrokenTitle() ) {
74 $iwResults[$result->getTitle()->getInterwiki()][] = $result;
80 $iwResultListOutput =
'';
82 foreach ( $iwResults as $iwPrefix => $results ) {
85 $iwResultItemOutput =
'';
87 foreach ( $results as $result ) {
88 $iwResultItemOutput .= $this->resultWidget->render( $result, $position++ );
91 $headerHtml = $this->
headerHtml( $term, $iwPrefix );
92 $footerHtml = $this->
footerHtml( $term, $iwPrefix );
93 $iwResultListOutput .= Html::rawElement(
'li',
95 'class' =>
'iw-resultset',
96 'data-iw-resultset-pos' => $iwResultSetPos,
97 'data-iw-resultset-source' => $iwPrefix
101 $iwResultItemOutput .
107 return Html::rawElement(
109 [
'id' =>
'mw-interwiki-results' ],
111 'ul', [
'class' =>
'iw-results', ], $iwResultListOutput
124 $href = Title::makeTitle(
NS_SPECIAL,
'Search',
'', $iwPrefix )->getLocalURL(
125 [
'search' => $term,
'fulltext' => 1 ]
128 $interwiki = $this->iwLookup->fetch( $iwPrefix );
131 $iwHost = $interwiki ? parse_url( $interwiki->getURL(), PHP_URL_HOST ) :
false;
133 $captionText = $this->customCaptions[$iwPrefix] ?? $iwHost ?: $iwPrefix;
134 $searchLink =
Html::element(
'a', [
'href' => $href,
'target' =>
'_blank' ], $captionText );
136 return Html::rawElement(
'div',
137 [
'class' =>
'iw-result__header' ],
138 $this->
iwIcon( $iwPrefix ) . $searchLink );
149 $href = Title::makeTitle(
NS_SPECIAL,
'Search',
'', $iwPrefix )->getLocalURL(
150 [
'search' => $term,
'fulltext' => 1 ]
153 $captionText = $this->specialSearch->msg(
'search-interwiki-resultset-link' )->text();
154 $searchLink =
Html::element(
'a', [
'href' => $href,
'target' =>
'_blank' ], $captionText );
156 return Html::rawElement(
'div',
157 [
'class' =>
'iw-result__footer' ],
162 if ( $this->customCaptions !==
null ) {
166 $this->customCaptions = [];
167 $customLines = explode(
"\n", $this->specialSearch->msg(
'search-interwiki-custom' )->text() );
168 foreach ( $customLines as $line ) {
169 $parts = explode(
':', $line, 2 );
170 if ( count( $parts ) === 2 ) {
171 $this->customCaptions[$parts[0]] = $parts[1];
187 if ( filter_var( $logoName, FILTER_VALIDATE_URL ) || $logoName ===
"/" ) {
191 $iwIcon =
new OOUI\IconWidget( [
209 $logoOverridesKeys = array_keys( $this->iwLogoOverrides );
210 if ( in_array( $prefix, $logoOverridesKeys ) ) {
211 return $this->iwLogoOverrides[ $prefix ];
214 $interwiki = $this->iwLookup->fetch( $prefix );
215 return $interwiki ? $interwiki->getURL() :
'/';
226 '@phan-var array $parsed';
227 $iwIconUrl = $parsed[
'scheme'] .
228 $parsed[
'delimiter'] .
230 ( isset( $parsed[
'port'] ) ?
':' . $parsed[
'port'] :
'' ) .
233 $iwIcon =
new OOUI\IconWidget( [
237 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.