X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecialpage%2FSpecialPage.php;h=d7e39d5129aeb61e0b7ef33f796f39f38376ac04;hb=2e0cf0891444367942677692cf8efde87f19c3ef;hp=bd0e24f2e15524556fe86671900a41ccc4e9b213;hpb=3353ced6cd3148de1549568ee9633a913fd5faab;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specialpage/SpecialPage.php b/includes/specialpage/SpecialPage.php index bd0e24f2e1..d7e39d5129 100644 --- a/includes/specialpage/SpecialPage.php +++ b/includes/specialpage/SpecialPage.php @@ -24,6 +24,7 @@ use MediaWiki\Auth\AuthManager; use MediaWiki\Linker\LinkRenderer; use MediaWiki\MediaWikiServices; +use MediaWiki\Navigation\PrevNextNavigationRenderer; /** * Parent class for all special pages. @@ -162,6 +163,7 @@ class SpecialPage implements MessageLocalizer { } // @todo FIXME: Decide which syntax to use for this, and stick to it + /** * Whether this special page is listed in Special:SpecialPages * @since 1.3 (r3583) @@ -454,10 +456,10 @@ class SpecialPage implements MessageLocalizer { * For example, if a page supports subpages "foo", "bar" and "baz" (as in Special:PageName/foo, * etc.): * - * - `prefixSearchSubpages( "ba" )` should return `array( "bar", "baz" )` - * - `prefixSearchSubpages( "f" )` should return `array( "foo" )` - * - `prefixSearchSubpages( "z" )` should return `array()` - * - `prefixSearchSubpages( "" )` should return `array( foo", "bar", "baz" )` + * - `prefixSearchSubpages( "ba" )` should return `[ "bar", "baz" ]` + * - `prefixSearchSubpages( "f" )` should return `[ "foo" ]` + * - `prefixSearchSubpages( "z" )` should return `[]` + * - `prefixSearchSubpages( "" )` should return `[ foo", "bar", "baz" ]` * * @param string $search Prefix to search for * @param int $limit Maximum number of results to return (usually 10) @@ -656,18 +658,6 @@ class SpecialPage implements MessageLocalizer { return $this->msg( strtolower( $this->mName ) )->text(); } - /** - * Get a self-referential title object - * - * @param string|bool $subpage - * @return Title - * @deprecated since 1.23, use SpecialPage::getPageTitle - */ - function getTitle( $subpage = false ) { - wfDeprecated( __METHOD__, '1.23' ); - return $this->getPageTitle( $subpage ); - } - /** * Get a self-referential title object * @@ -932,58 +922,11 @@ class SpecialPage implements MessageLocalizer { * @return string */ protected function buildPrevNextNavigation( $offset, $limit, - array $query = [], $atend = false, $subpage = false + array $query = [], $atend = false, $subpage = false ) { - $lang = $this->getLanguage(); - - # Make 'previous' link - $prev = $this->msg( 'prevn' )->numParams( $limit )->text(); - if ( $offset > 0 ) { - $plink = $this->numLink( max( $offset - $limit, 0 ), $limit, $query, - $prev, 'prevn-title', 'mw-prevlink', $subpage ); - } else { - $plink = htmlspecialchars( $prev ); - } - - # Make 'next' link - $next = $this->msg( 'nextn' )->numParams( $limit )->text(); - if ( $atend ) { - $nlink = htmlspecialchars( $next ); - } else { - $nlink = $this->numLink( $offset + $limit, $limit, - $query, $next, 'nextn-title', 'mw-nextlink', $subpage ); - } - - # Make links to set number of items per page - $numLinks = []; - foreach ( [ 20, 50, 100, 250, 500 ] as $num ) { - $numLinks[] = $this->numLink( $offset, $num, $query, - $lang->formatNum( $num ), 'shown-title', 'mw-numlink', $subpage ); - } + $title = $this->getPageTitle( $subpage ); + $prevNext = new PrevNextNavigationRenderer( $this ); - return $this->msg( 'viewprevnext' )->rawParams( $plink, $nlink, $lang->pipeList( $numLinks ) )-> - escaped(); - } - - /** - * Helper function for buildPrevNextNavigation() that generates links - * - * @param int $offset - * @param int $limit - * @param array $query Extra query parameters - * @param string $link Text to use for the link; will be escaped - * @param string $tooltipMsg Name of the message to use as tooltip - * @param string $class Value of the "class" attribute of the link - * @param string|bool $subpage Optional param for specifying subpage - * @return string HTML fragment - */ - private function numLink( $offset, $limit, array $query, $link, - $tooltipMsg, $class, $subpage = false - ) { - $query = [ 'limit' => $limit, 'offset' => $offset ] + $query; - $tooltip = $this->msg( $tooltipMsg )->numParams( $limit )->text(); - $href = $this->getPageTitle( $subpage )->getLocalURL( $query ); - return Html::element( 'a', [ 'href' => $href, - 'title' => $tooltip, 'class' => $class ], $link ); + return $prevNext->buildPrevNextNavigation( $title, $offset, $limit, $query, $atend ); } }