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' );
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
122 [
'search' => $term,
'fulltext' => 1 ]
125 $interwiki = $this->iwLookup->fetch( $iwPrefix );
128 $caption = $this->customCaptions[$iwPrefix] ?? $parsed[
'host'];
130 $searchLink = Html::rawElement(
'a', [
'href' => $href,
'target' =>
'_blank' ], $caption );
132 return Html::rawElement(
'div',
133 [
'class' =>
'iw-result__header' ],
134 $this->
iwIcon( $iwPrefix ) . $searchLink );
146 [
'search' => $term,
'fulltext' => 1 ]
149 $interwiki = $this->iwLookup->fetch( $iwPrefix );
152 $caption = $this->specialSearch->msg(
'search-interwiki-resultset-link', $parsed[
'host'] )->escaped();
154 $searchLink = Html::rawElement(
'a', [
'href' => $href,
'target' =>
'_blank' ], $caption );
156 return Html::rawElement(
'div',
157 [
'class' =>
'iw-result__footer' ],
162 if ( $this->customCaptions !==
null ) {
166 $this->customCaptions = [];
167 $customLines = explode(
"\n", $this->specialSearch->msg(
'search-interwiki-custom' )->escaped() );
168 foreach ( $customLines as $line ) {
169 $parts = explode(
':', $line, 2 );
170 if ( count( $parts ) === 2 ) {
171 $this->customCaptions[$parts[0]] = $parts[1];
186 $interwiki = $this->iwLookup->fetch( $iwPrefix );
189 $iwIconUrl = $parsed[
'scheme'] .
190 $parsed[
'delimiter'] .
192 ( isset( $parsed[
'port'] ) ?
':' . $parsed[
'port'] :
'' ) .
195 $iwIcon =
new OOUI\IconWidget( [
199 $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 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.
implements Special:Search - Run text & title search and display the output
A set of SearchEngine results.