54 public function render( $term, $resultSets ) {
55 if ( !is_array( $resultSets ) ) {
56 $resultSets = [ $resultSets ];
61 if ( $this->showMultimedia ) {
62 $this->output->addModules(
'mediawiki.special.search.commonsInterwikiWidget' );
64 $this->output->addModuleStyles(
'mediawiki.special.search.interwikiwidget.styles' );
65 $this->output->addModuleStyles(
'oojs-ui.styles.icons-wikimedia' );
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 $headerHtml = $this->
headerHtml( $term, $iwPrefix );
89 $footerHtml = $this->
footerHtml( $term, $iwPrefix );
90 $iwResultListOutput .= Html::rawElement(
'li',
92 'class' =>
'iw-resultset',
93 'data-iw-resultset-pos' => $iwResultSetPos,
94 'data-iw-resultset-source' => $iwPrefix
104 return Html::rawElement(
106 [
'id' =>
'mw-interwiki-results' ],
108 'ul', [
'class' =>
'iw-results', ], $iwResultListOutput
121 $href = Title::makeTitle(
NS_SPECIAL,
'Search',
'', $iwPrefix )->getLocalURL(
122 [
'search' => $term,
'fulltext' => 1 ]
125 $interwiki = $this->iwLookup->fetch( $iwPrefix );
128 $iwHost = $interwiki ? parse_url( $interwiki->getURL(), PHP_URL_HOST ) :
false;
130 $captionText = $this->customCaptions[$iwPrefix] ?? $iwHost ?: $iwPrefix;
131 $searchLink =
Html::element(
'a', [
'href' => $href,
'target' =>
'_blank' ], $captionText );
133 return Html::rawElement(
'div',
134 [
'class' =>
'iw-result__header' ],
135 $this->
iwIcon( $iwPrefix ) . $searchLink );
146 $href = Title::makeTitle(
NS_SPECIAL,
'Search',
'', $iwPrefix )->getLocalURL(
147 [
'search' => $term,
'fulltext' => 1 ]
150 $captionText = $this->specialSearch->msg(
'search-interwiki-resultset-link' )->text();
151 $searchLink =
Html::element(
'a', [
'href' => $href,
'target' =>
'_blank' ], $captionText );
153 return Html::rawElement(
'div',
154 [
'class' =>
'iw-result__footer' ],
159 if ( $this->customCaptions !==
null ) {
163 $this->customCaptions = [];
164 $customLines = explode(
"\n", $this->specialSearch->msg(
'search-interwiki-custom' )->text() );
165 foreach ( $customLines as $line ) {
166 $parts = explode(
':', $line, 2 );
167 if ( count( $parts ) === 2 ) {
168 $this->customCaptions[$parts[0]] = $parts[1];
184 if ( filter_var( $logoName, FILTER_VALIDATE_URL ) || $logoName ===
"/" ) {
188 $iwIcon =
new OOUI\IconWidget( [
206 if ( isset( $this->iwLogoOverrides[ $prefix ] ) ) {
207 return $this->iwLogoOverrides[ $prefix ];
210 $interwiki = $this->iwLookup->fetch( $prefix );
211 return $interwiki ? $interwiki->getURL() :
'/';
222 '@phan-var array $parsed';
223 $iwIconUrl = $parsed[
'scheme'] .
224 $parsed[
'delimiter'] .
226 ( isset( $parsed[
'port'] ) ?
':' . $parsed[
'port'] :
'' ) .
229 $iwIcon =
new OOUI\IconWidget( [
233 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.