50 $this->iwLogoOverrides = $this->specialSearch->getConfig()->get(
'InterwikiLogoOverride' );
59 public function render( $term, $resultSets ) {
60 if ( !is_array( $resultSets ) ) {
61 $resultSets = [ $resultSets ];
66 if ( $this->showMultimedia ) {
67 $this->output->addModules(
'mediawiki.special.search.commonsInterwikiWidget' );
69 $this->output->addModuleStyles(
'mediawiki.special.search.interwikiwidget.styles' );
70 $this->output->addModuleStyles(
'oojs-ui.styles.icons-wikimedia' );
73 foreach ( $resultSets as $resultSet ) {
74 foreach ( $resultSet as $result ) {
75 if ( !$result->isBrokenTitle() ) {
76 $iwResults[$result->getTitle()->getInterwiki()][] = $result;
82 $iwResultListOutput =
'';
84 foreach ( $iwResults as $iwPrefix => $results ) {
87 $iwResultItemOutput =
'';
89 foreach ( $results as $result ) {
90 $iwResultItemOutput .= $this->resultWidget->render( $result, $position++ );
93 $headerHtml = $this->
headerHtml( $term, $iwPrefix );
94 $footerHtml = $this->
footerHtml( $term, $iwPrefix );
95 $iwResultListOutput .= Html::rawElement(
'li',
97 'class' =>
'iw-resultset',
98 'data-iw-resultset-pos' => $iwResultSetPos,
99 'data-iw-resultset-source' => $iwPrefix
103 $iwResultItemOutput .
109 return Html::rawElement(
111 [
'id' =>
'mw-interwiki-results' ],
113 'ul', [
'class' =>
'iw-results', ], $iwResultListOutput
126 $href = Title::makeTitle(
NS_SPECIAL,
'Search',
'', $iwPrefix )->getLocalURL(
127 [
'search' => $term,
'fulltext' => 1 ]
130 $interwiki = $this->iwLookup->fetch( $iwPrefix );
133 $caption = $this->customCaptions[$iwPrefix] ?? $parsed[
'host'];
135 $searchLink = Html::rawElement(
'a', [
'href' => $href,
'target' =>
'_blank' ], $caption );
137 return Html::rawElement(
'div',
138 [
'class' =>
'iw-result__header' ],
139 $this->
iwIcon( $iwPrefix ) . $searchLink );
150 $href = Title::makeTitle(
NS_SPECIAL,
'Search',
'', $iwPrefix )->getLocalURL(
151 [
'search' => $term,
'fulltext' => 1 ]
154 $interwiki = $this->iwLookup->fetch( $iwPrefix );
157 $caption = $this->specialSearch->msg(
'search-interwiki-resultset-link', $parsed[
'host'] )->escaped();
159 $searchLink = Html::rawElement(
'a', [
'href' => $href,
'target' =>
'_blank' ], $caption );
161 return Html::rawElement(
'div',
162 [
'class' =>
'iw-result__footer' ],
167 if ( $this->customCaptions !==
null ) {
171 $this->customCaptions = [];
172 $customLines = explode(
"\n", $this->specialSearch->msg(
'search-interwiki-custom' )->escaped() );
173 foreach ( $customLines as $line ) {
174 $parts = explode(
':', $line, 2 );
175 if ( count( $parts ) === 2 ) {
176 $this->customCaptions[$parts[0]] = $parts[1];
192 if ( filter_var( $logoName, FILTER_VALIDATE_URL ) || $logoName ===
"/" ) {
196 $iwIcon =
new OOUI\IconWidget( [
214 $logoOverridesKeys = array_keys( $this->iwLogoOverrides );
215 if ( in_array( $prefix, $logoOverridesKeys ) ) {
216 return $this->iwLogoOverrides[ $prefix ];
219 $interwiki = $this->iwLookup->fetch( $prefix );
220 return $interwiki ? $interwiki->getURL() :
'/';
231 $iwIconUrl = $parsed[
'scheme'] .
232 $parsed[
'delimiter'] .
234 ( isset( $parsed[
'port'] ) ?
':' . $parsed[
'port'] :
'' ) .
237 $iwIcon =
new OOUI\IconWidget( [
241 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).
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.