49 $this->iwLogoOverrides = $this->specialSearch->getConfig()->get(
'InterwikiLogoOverride' );
58 public function render( $term, $resultSets ) {
59 if ( !is_array( $resultSets ) ) {
60 $resultSets = [ $resultSets ];
65 if ( $this->showMultimedia ) {
66 $this->output->addModules(
'mediawiki.special.search.commonsInterwikiWidget' );
68 $this->output->addModuleStyles(
'mediawiki.special.search.interwikiwidget.styles' );
69 $this->output->addModuleStyles(
'oojs-ui.styles.icons-wikimedia' );
72 foreach ( $resultSets as $resultSet ) {
73 foreach ( $resultSet as $result ) {
74 if ( !$result->isBrokenTitle() ) {
75 $iwResults[$result->getTitle()->getInterwiki()][] = $result;
81 $iwResultListOutput =
'';
83 foreach ( $iwResults as $iwPrefix => $results ) {
86 $iwResultItemOutput =
'';
88 foreach ( $results as $result ) {
89 $iwResultItemOutput .= $this->resultWidget->render( $result, $position++ );
92 $headerHtml = $this->
headerHtml( $term, $iwPrefix );
93 $footerHtml = $this->
footerHtml( $term, $iwPrefix );
96 'class' =>
'iw-resultset',
97 'data-iw-resultset-pos' => $iwResultSetPos,
98 'data-iw-resultset-source' => $iwPrefix
102 $iwResultItemOutput .
110 [
'id' =>
'mw-interwiki-results' ],
112 'ul', [
'class' =>
'iw-results', ], $iwResultListOutput
126 [
'search' => $term,
'fulltext' => 1 ]
129 $interwiki = $this->iwLookup->fetch( $iwPrefix );
132 $caption = $this->customCaptions[$iwPrefix] ?? $parsed[
'host'];
134 $searchLink =
Html::rawElement(
'a', [
'href' => $href,
'target' =>
'_blank' ], $caption );
137 [
'class' =>
'iw-result__header' ],
138 $this->
iwIcon( $iwPrefix ) . $searchLink );
150 [
'search' => $term,
'fulltext' => 1 ]
153 $interwiki = $this->iwLookup->fetch( $iwPrefix );
156 $caption = $this->specialSearch->msg(
'search-interwiki-resultset-link', $parsed[
'host'] )->escaped();
158 $searchLink =
Html::rawElement(
'a', [
'href' => $href,
'target' =>
'_blank' ], $caption );
161 [
'class' =>
'iw-result__footer' ],
166 if ( $this->customCaptions !==
null ) {
170 $this->customCaptions = [];
171 $customLines = explode(
"\n", $this->specialSearch->msg(
'search-interwiki-custom' )->escaped() );
172 foreach ( $customLines as $line ) {
173 $parts = explode(
':', $line, 2 );
174 if ( count( $parts ) === 2 ) {
175 $this->customCaptions[$parts[0]] = $parts[1];
191 if ( filter_var( $logoName, FILTER_VALIDATE_URL ) || $logoName ===
"/" ) {
195 $iwIcon =
new OOUI\IconWidget( [
213 $logoOverridesKeys = array_keys( $this->iwLogoOverrides );
214 if ( in_array( $prefix, $logoOverridesKeys ) ) {
215 return $this->iwLogoOverrides[ $prefix ];
218 $interwiki = $this->iwLookup->fetch( $prefix );
219 return $interwiki ? $interwiki->getURL() :
'/';
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);" ] );
wfParseUrl( $url)
parse_url() work-alike, but non-broken.
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL using $wgServer (or one of its alternatives).
getOutput()
Get the OutputPage being used for this instance.
A set of SearchEngine results.