diff --git a/RELEASE-NOTES-1.41 b/RELEASE-NOTES-1.41 index b6e32359ff6..08dd47241c2 100644 --- a/RELEASE-NOTES-1.41 +++ b/RELEASE-NOTES-1.41 @@ -157,6 +157,8 @@ because of Phabricator reports. Query object as argument instead of a raw SQL string. * Database::unionConditionPermutations(), unused, has been removed without deprecation. +* SimpleSearchResultSetWidget and SimpleSearchResultWidget classes, deprecated + in 1.31, have been removed. * Database::factory(), deprecated in 1.39, has been removed. * Calling IDatabase::delete() or IDatabase::update() with empty conditions has been deprecated since 1.35. This now throws an error. diff --git a/autoload.php b/autoload.php index 2c5d5be3050..4a464809043 100644 --- a/autoload.php +++ b/autoload.php @@ -1868,8 +1868,6 @@ $wgAutoloadLocalClasses = [ 'MediaWiki\\Search\\SearchWidgets\\SearchFormWidget' => __DIR__ . '/includes/search/searchwidgets/SearchFormWidget.php', 'MediaWiki\\Search\\SearchWidgets\\SearchResultSetWidget' => __DIR__ . '/includes/search/searchwidgets/SearchResultSetWidget.php', 'MediaWiki\\Search\\SearchWidgets\\SearchResultWidget' => __DIR__ . '/includes/search/searchwidgets/SearchResultWidget.php', - 'MediaWiki\\Search\\SearchWidgets\\SimpleSearchResultSetWidget' => __DIR__ . '/includes/search/searchwidgets/SimpleSearchResultSetWidget.php', - 'MediaWiki\\Search\\SearchWidgets\\SimpleSearchResultWidget' => __DIR__ . '/includes/search/searchwidgets/SimpleSearchResultWidget.php', 'MediaWiki\\Search\\TitleMatcher' => __DIR__ . '/includes/search/TitleMatcher.php', 'MediaWiki\\Session\\BotPasswordSessionProvider' => __DIR__ . '/includes/session/BotPasswordSessionProvider.php', 'MediaWiki\\Session\\CookieSessionProvider' => __DIR__ . '/includes/session/CookieSessionProvider.php', diff --git a/includes/search/searchwidgets/SimpleSearchResultSetWidget.php b/includes/search/searchwidgets/SimpleSearchResultSetWidget.php deleted file mode 100644 index 060e7f30dbb..00000000000 --- a/includes/search/searchwidgets/SimpleSearchResultSetWidget.php +++ /dev/null @@ -1,139 +0,0 @@ -specialSearch = $specialSearch; - $this->resultWidget = $resultWidget; - $this->linkRenderer = $linkRenderer; - $this->iwLookup = $iwLookup; - } - - /** - * @param string $term User provided search term - * @param ISearchResultSet|ISearchResultSet[] $resultSets List of interwiki - * results to render. - * @return string HTML - */ - public function render( $term, $resultSets ) { - if ( !is_array( $resultSets ) ) { - $resultSets = [ $resultSets ]; - } - - $this->loadCustomCaptions(); - - $iwResults = []; - foreach ( $resultSets as $resultSet ) { - foreach ( $resultSet as $result ) { - if ( !$result->isBrokenTitle() ) { - $iwResults[$result->getTitle()->getInterwiki()][] = $result; - } - } - } - - $out = ''; - foreach ( $iwResults as $iwPrefix => $results ) { - $out .= $this->headerHtml( $iwPrefix, $term ); - $out .= Html::openElement( 'ul', [ 'class' => 'mw-search-iwresults' ] ); - // TODO: Assumes interwiki results are never paginated - $position = 0; - foreach ( $results as $result ) { - $out .= $this->resultWidget->render( $result, $position++ ); - } - $out .= Html::closeElement( 'ul' ); - } - - return Html::rawElement( - 'div', - [ 'id' => 'mw-search-interwiki' ], - Html::rawElement( - 'div', - [ 'id' => 'mw-search-interwiki-caption' ], - $this->specialSearch->msg( 'search-interwiki-caption' )->parse() - ) . $out - ); - } - - /** - * Generates an appropriate HTML header for the given interwiki prefix - * - * @param string $iwPrefix Interwiki prefix of wiki to show header for - * @param string $term User provided search term - * @return string HTML - */ - protected function headerHtml( $iwPrefix, $term ) { - if ( isset( $this->customCaptions[$iwPrefix] ) ) { - $caption = $this->customCaptions[$iwPrefix]; - } else { - $interwiki = $this->iwLookup->fetch( $iwPrefix ); - $parsed = wfParseUrl( wfExpandUrl( $interwiki ? $interwiki->getURL() : '/' ) ); - $caption = $this->specialSearch->msg( 'search-interwiki-default', $parsed['host'] )->escaped(); - } - - $href = Title::makeTitle( NS_SPECIAL, 'Search', '', $iwPrefix )->getLocalURL( - [ 'search' => $term, 'fulltext' => 1 ] - ); - $searchLink = Html::rawElement( - 'a', - [ 'href' => $href ], - $this->specialSearch->msg( 'search-interwiki-more' )->escaped() - ); - - return Html::rawElement( - 'div', - [ 'class' => 'mw-search-interwiki-project' ], - Html::rawElement( - 'span', - [ 'class' => 'mw-search-interwiki-more' ], - $searchLink - ) . $caption - ); - } - - protected function loadCustomCaptions() { - if ( $this->customCaptions !== null ) { - return; - } - - $this->customCaptions = []; - $customLines = explode( "\n", $this->specialSearch->msg( 'search-interwiki-custom' )->escaped() ); - foreach ( $customLines as $line ) { - $parts = explode( ':', $line, 2 ); - if ( count( $parts ) === 2 ) { - $this->customCaptions[$parts[0]] = $parts[1]; - } - } - } -} diff --git a/includes/search/searchwidgets/SimpleSearchResultWidget.php b/includes/search/searchwidgets/SimpleSearchResultWidget.php deleted file mode 100644 index 19554ca0c56..00000000000 --- a/includes/search/searchwidgets/SimpleSearchResultWidget.php +++ /dev/null @@ -1,62 +0,0 @@ -specialSearch = $specialSearch; - $this->linkRenderer = $linkRenderer; - } - - /** - * @param SearchResult $result The result to render - * @param int $position The result position, including offset - * @return string HTML - */ - public function render( SearchResult $result, $position ) { - $title = $result->getTitle(); - $titleSnippet = $result->getTitleSnippet(); - if ( $titleSnippet ) { - $titleSnippet = new HtmlArmor( $titleSnippet ); - } else { - $titleSnippet = null; - } - - $link = $this->linkRenderer->makeLink( $title, $titleSnippet ); - - $redirectTitle = $result->getRedirectTitle(); - $redirect = ''; - if ( $redirectTitle !== null ) { - $redirectText = $result->getRedirectSnippet(); - if ( $redirectText ) { - $redirectText = new HtmlArmor( $redirectText ); - } else { - $redirectText = null; - } - $redirect = - "" . - $this->specialSearch->msg( 'search-redirect' )->rawParams( - $this->linkRenderer->makeLink( $redirectTitle, $redirectText ) - )->parse() . - ""; - } - - return "