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 $caption = $this->customCaptions[$iwPrefix] ?? $parsed[
'host'];
136 $searchLink = Html::rawElement(
'a', [
'href' => $href,
'target' =>
'_blank' ], $caption );
138 return Html::rawElement(
'div',
139 [
'class' =>
'iw-result__header' ],
140 $this->
iwIcon( $iwPrefix ) . $searchLink );
151 $href = Title::makeTitle(
NS_SPECIAL,
'Search',
'', $iwPrefix )->getLocalURL(
152 [
'search' => $term,
'fulltext' => 1 ]
155 $interwiki = $this->iwLookup->fetch( $iwPrefix );
158 $caption = $this->specialSearch->msg(
'search-interwiki-resultset-link', $parsed[
'host'] )->escaped();
160 $searchLink = Html::rawElement(
'a', [
'href' => $href,
'target' =>
'_blank' ], $caption );
162 return Html::rawElement(
'div',
163 [
'class' =>
'iw-result__footer' ],
168 if ( $this->customCaptions !==
null ) {
172 $this->customCaptions = [];
173 $customLines = explode(
"\n", $this->specialSearch->msg(
'search-interwiki-custom' )->escaped() );
174 foreach ( $customLines as $line ) {
175 $parts = explode(
':', $line, 2 );
176 if ( count( $parts ) === 2 ) {
177 $this->customCaptions[$parts[0]] = $parts[1];
193 if ( filter_var( $logoName, FILTER_VALIDATE_URL ) || $logoName ===
"/" ) {
197 $iwIcon =
new OOUI\IconWidget( [
215 $logoOverridesKeys = array_keys( $this->iwLogoOverrides );
216 if ( in_array( $prefix, $logoOverridesKeys ) ) {
217 return $this->iwLogoOverrides[ $prefix ];
220 $interwiki = $this->iwLookup->fetch( $prefix );
221 return $interwiki ? $interwiki->getURL() :
'/';
232 $iwIconUrl = $parsed[
'scheme'] .
233 $parsed[
'delimiter'] .
235 ( isset( $parsed[
'port'] ) ?
':' . $parsed[
'port'] :
'' ) .
238 $iwIcon =
new OOUI\IconWidget( [
242 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).
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.