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' );
67 foreach ( $resultSets as $resultSet ) {
68 foreach ( $resultSet as $result ) {
69 if ( !$result->isBrokenTitle() ) {
70 $iwResults[$result->getTitle()->getInterwiki()][] =
$result;
76 $iwResultListOutput =
'';
78 foreach ( $iwResults as $iwPrefix => $results ) {
81 $iwResultItemOutput =
'';
83 foreach ( $results as $result ) {
84 $iwResultItemOutput .= $this->resultWidget->render( $result,
$term, $position++ );
88 $iwResultListOutput .= Html::rawElement(
'li',
90 'class' =>
'iw-resultset',
91 'data-iw-resultset-pos' => $iwResultSetPos,
92 'data-iw-resultset-source' => $iwPrefix
102 return Html::rawElement(
104 [
'id' =>
'mw-interwiki-results' ],
107 [
'class' =>
'iw-headline' ],
108 $this->specialSearch->msg(
'search-interwiki-caption' )->parse()
111 'ul', [
'class' =>
'iw-results', ], $iwResultListOutput
124 $href = Title::makeTitle(
NS_SPECIAL,
'Search',
null, $iwPrefix )->getLocalURL(
125 [
'search' =>
$term,
'fulltext' => 1 ]
128 $interwiki = $this->iwLookup->fetch( $iwPrefix );
131 if ( isset( $this->customCaptions[$iwPrefix] ) ) {
132 $caption = $this->customCaptions[$iwPrefix];
134 $caption = $this->specialSearch->msg(
'search-interwiki-default', $parsed[
'host'] )->escaped();
137 $searchLink = Html::rawElement(
'em',
null,
138 Html::rawElement(
'a', [
'href' => $href,
'target' =>
'_blank' ], $caption )
141 return Html::rawElement(
'div',
142 [
'class' =>
'iw-result__footer' ],
143 $this->
iwIcon( $iwPrefix ) . $searchLink );
147 if ( $this->customCaptions !==
null ) {
151 $this->customCaptions = [];
152 $customLines = explode(
"\n", $this->specialSearch->msg(
'search-interwiki-custom' )->escaped() );
153 foreach ( $customLines as
$line ) {
154 $parts = explode(
':',
$line, 2 );
155 if ( count( $parts ) === 2 ) {
156 $this->customCaptions[$parts[0]] = $parts[1];
171 $interwiki = $this->iwLookup->fetch( $iwPrefix );
174 $iwIconUrl = $parsed[
'scheme'] .
175 $parsed[
'delimiter'] .
177 ( isset( $parsed[
'port'] ) ?
':' . $parsed[
'port'] :
'' ) .
180 $iwIcon =
new OOUI\IconWidget( [
184 $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.
This class is a collection of static functions that serve two purposes:
getOutput()
Get the OutputPage being used for this instance.
implements Special:Search - Run text & title search and display the output
Represents a title within MediaWiki.
namespace being checked & $result
For QUnit the mediawiki tests qunit testrunner dependency will be added to any module whereas SearchGetNearMatch runs after $term