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' );
66 $this->output->addModuleStyles(
'oojs-ui.styles.icons-wikimedia' );
69 foreach ( $resultSets as $resultSet ) {
70 foreach ( $resultSet as $result ) {
71 if ( !$result->isBrokenTitle() ) {
72 $iwResults[$result->getTitle()->getInterwiki()][] = $result;
78 $iwResultListOutput =
'';
80 foreach ( $iwResults as $iwPrefix => $results ) {
83 $iwResultItemOutput =
'';
85 foreach ( $results as $result ) {
86 $iwResultItemOutput .= $this->resultWidget->render( $result, $position++ );
89 $headerHtml = $this->
headerHtml( $term, $iwPrefix );
90 $footerHtml = $this->
footerHtml( $term, $iwPrefix );
91 $iwResultListOutput .= Html::rawElement(
'li',
93 'class' =>
'iw-resultset',
94 'data-iw-resultset-pos' => $iwResultSetPos,
95 'data-iw-resultset-source' => $iwPrefix
105 return Html::rawElement(
107 [
'id' =>
'mw-interwiki-results' ],
109 'ul', [
'class' =>
'iw-results', ], $iwResultListOutput
123 [
'search' => $term,
'fulltext' => 1 ]
126 $interwiki = $this->iwLookup->fetch( $iwPrefix );
129 $iwHost = $interwiki ? parse_url( $interwiki->getURL(), PHP_URL_HOST ) :
false;
131 $captionText = $this->customCaptions[$iwPrefix] ?? $iwHost ?: $iwPrefix;
132 $searchLink =
Html::element(
'a', [
'href' => $href,
'target' =>
'_blank' ], $captionText );
134 return Html::rawElement(
'div',
135 [
'class' =>
'iw-result__header' ],
136 $this->
iwIcon( $iwPrefix ) . $searchLink );
148 [
'search' => $term,
'fulltext' => 1 ]
151 $captionText = $this->specialSearch->msg(
'search-interwiki-resultset-link' )->text();
152 $searchLink =
Html::element(
'a', [
'href' => $href,
'target' =>
'_blank' ], $captionText );
154 return Html::rawElement(
'div',
155 [
'class' =>
'iw-result__footer' ],
160 if ( $this->customCaptions !==
null ) {
164 $this->customCaptions = [];
165 $customLines = explode(
"\n", $this->specialSearch->msg(
'search-interwiki-custom' )->text() );
166 foreach ( $customLines as $line ) {
167 $parts = explode(
':', $line, 2 );
168 if ( count( $parts ) === 2 ) {
169 $this->customCaptions[$parts[0]] = $parts[1];
185 if ( filter_var( $logoName, FILTER_VALIDATE_URL ) || $logoName ===
"/" ) {
189 $iwIcon =
new OOUI\IconWidget( [
207 if ( isset( $this->iwLogoOverrides[ $prefix ] ) ) {
208 return $this->iwLogoOverrides[ $prefix ];
211 $interwiki = $this->iwLookup->fetch( $prefix );
212 return $interwiki ? $interwiki->getURL() :
'/';
223 $parsed = $urlUtils->parse( (
string)$urlUtils->expand( $logoUrl,
PROTO_CURRENT ) );
224 '@phan-var array $parsed';
225 $iwIconUrl = $parsed[
'scheme'] .
226 $parsed[
'delimiter'] .
228 ( isset( $parsed[
'port'] ) ?
':' . $parsed[
'port'] :
'' ) .
231 $iwIcon =
new OOUI\IconWidget( [
235 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.