Smalyshev has uploaded a new change for review.
https://gerrit.wikimedia.org/r/239445
Change subject: [WIP] Displaying search results for multiple wikis
......................................................................
[WIP] Displaying search results for multiple wikis
Bug: T112349
Change-Id: Ia852e5097bc7a1e155e2bcc64acbfe09923fb5c6
---
M includes/search/SearchResultSet.php
M includes/specials/SpecialSearch.php
M languages/i18n/en.json
3 files changed, 46 insertions(+), 7 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/45/239445/1
diff --git a/includes/search/SearchResultSet.php
b/includes/search/SearchResultSet.php
index 8d18b0e..97513bc 100644
--- a/includes/search/SearchResultSet.php
+++ b/includes/search/SearchResultSet.php
@@ -25,6 +25,13 @@
* @ingroup Search
*/
class SearchResultSet {
+
+ /**
+ * Types of interwiki results
+ */
+ const SIDEBAR_RESULTS = 0;
+ const INLINE_RESULTS = 1;
+
protected $containedSyntax = false;
public function __construct( $containedSyntax = false ) {
@@ -116,7 +123,7 @@
*
* @return SearchResultSet
*/
- function getInterwikiResults() {
+ function getInterwikiResults( $type = self::SIDEBAR_RESULTS ) {
return null;
}
@@ -125,8 +132,8 @@
*
* @return bool
*/
- function hasInterwikiResults() {
- return $this->getInterwikiResults() != null;
+ function hasInterwikiResults( $type = self::SIDEBAR_RESULTS ) {
+ return false;
}
/**
diff --git a/includes/specials/SpecialSearch.php
b/includes/specials/SpecialSearch.php
index 6606c7f..03e7687 100644
--- a/includes/specials/SpecialSearch.php
+++ b/includes/specials/SpecialSearch.php
@@ -367,8 +367,8 @@
}
// show interwiki results if any
- if ( $textMatches->hasInterwikiResults() ) {
- $out->addHTML( $this->showInterwiki(
$textMatches->getInterwikiResults(), $term ) );
+ if ( $textMatches->hasInterwikiResults(
SearchResultSet::SIDEBAR_RESULTS ) ) {
+ $out->addHTML( $this->showInterwiki(
$textMatches->getInterwikiResults( SearchResultSet::SIDEBAR_RESULTS ), $term )
);
}
// show results
if ( $numTextMatches > 0 ) {
@@ -377,16 +377,38 @@
$textMatches->free();
}
+
+ $hasOtherResults = $textMatches->hasInterwikiResults(
SearchResultSet::INLINE_RESULTS );
+
if ( $num === 0 ) {
if ( $textStatus ) {
$out->addHTML( '<div class="error">' .
$textStatus->getMessage( 'search-error'
) . '</div>' );
} else {
- $out->wrapWikiMsg( "<p
class=\"mw-search-nonefound\">\n$1</p>",
- array( 'search-nonefound',
wfEscapeWikiText( $term ) ) );
$this->showCreateLink( $title, $num,
$titleMatches, $textMatches );
+ if( $hasOtherResults ) {
+ $out->wrapWikiMsg( "<p
class=\"mw-search-nonefound\">\n$1</p>",
+ array( $hasOtherResults ?
'search-nonefound-otherwiki' : 'search-nonefound', wfEscapeWikiText( $term ) )
);
+ } else {
+ $out->wrapWikiMsg( "<p
class=\"mw-search-nonefound\">\n$1</p>",
+ array(
'search-nonefound', wfEscapeWikiText( $term ) ) );
+ }
}
}
+
+ if( $hasOtherResults ) {
+ foreach( $textMatches->getInterwikiResults(
SearchResultSet::INLINE_RESULTS ) as $interwiki => $interwikiResult ) {
+ if( $interwikiResult instanceof Status ||
$interwikiResult->numRows() == 0 ) {
+ // ignore bad interwikis for now
+ continue;
+ }
+ // TODO: wiki header
+ $out->addHTML( $this->wikiHeader( $interwiki )
);
+ $out->addHTML( $this->showMatches(
$interwikiResult ) );
+ }
+ }
+
+ $out->addHtml( "</div>" );
if ( $prevnext ) {
$out->addHTML( "<p
class='mw-search-pager-bottom'>{$prevnext}</p>\n" );
@@ -399,6 +421,15 @@
}
/**
+ * Produce wiki header for interwiki results
+ * @param string $interwiki
+ */
+ protected function wikiHeader ( $interwiki ) {
+ // TODO: this needs to have something sane
+ return "<b>Another wiki: $interwiki</b><br>";
+ }
+
+ /**
* Decide if the suggested query should be run, and it's results
returned
* instead of the provided $textMatches
*
diff --git a/languages/i18n/en.json b/languages/i18n/en.json
index 12bd910..536d362 100644
--- a/languages/i18n/en.json
+++ b/languages/i18n/en.json
@@ -928,6 +928,7 @@
"showingresultsinrange": "Showing below up to
{{PLURAL:$1|<strong>1</strong> result|<strong>$1</strong> results}} in range
#<strong>$2</strong> to #<strong>$3</strong>.",
"search-showingresults": "{{PLURAL:$4|Result <strong>$1</strong> of
<strong>$3</strong>|Results <strong>$1 - $2</strong> of <strong>$3</strong>}}",
"search-nonefound": "There were no results matching the query.",
+ "search-nonefound-otherwiki": "There were no results matching the query
in this wiki. Below are the results from other wikis.",
"powersearch-legend": "Advanced search",
"powersearch-ns": "Search in namespaces:",
"powersearch-togglelabel": "Check:",
--
To view, visit https://gerrit.wikimedia.org/r/239445
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia852e5097bc7a1e155e2bcc64acbfe09923fb5c6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Smalyshev <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits