From e7238e5dba73184ea08362170d79fc66be3da9d4 Mon Sep 17 00:00:00 2001 From: Brian Wolff Date: Sun, 26 Jun 2011 03:00:37 +0000 Subject: [PATCH] (sort of bug 29586) Make the (next 200) links on categories link directly to the relevant section of the category. The bug in question actually want to remove all the other sections of the category when you hit (next 200), I personally think that'd be confusing, but would be good to have other people's thoughts. --- RELEASE-NOTES-1.19 | 2 ++ includes/CategoryPage.php | 30 ++++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES-1.19 b/RELEASE-NOTES-1.19 index f7cd61bffd..206bf8674a 100644 --- a/RELEASE-NOTES-1.19 +++ b/RELEASE-NOTES-1.19 @@ -60,6 +60,8 @@ production. SHOW SLAVE STATUS instead of SHOW PROCESSLIST. * Language codes in $wgDummyLanguageCodes are now excluded on localization statistics (maintenance/language/transstat.php) +* (bug 29586) Make the (next 200) links on categories link directly to + the relevant section of the category. === Bug fixes in 1.19 === * (bug 28868) Show total pages in the subtitle of an image on the diff --git a/includes/CategoryPage.php b/includes/CategoryPage.php index 6843b82c4d..d84aeb79c8 100644 --- a/includes/CategoryPage.php +++ b/includes/CategoryPage.php @@ -629,7 +629,7 @@ class CategoryViewer { $prevQuery["{$type}until"] = $first; unset( $prevQuery["{$type}from"] ); $prevLink = $sk->linkKnown( - $this->title, + $this->addFragmentToTitle( $this->title, $type ), $prevLink, array(), $prevQuery @@ -643,7 +643,7 @@ class CategoryViewer { $lastQuery["{$type}from"] = $last; unset( $lastQuery["{$type}until"] ); $nextLink = $sk->linkKnown( - $this->title, + $this->addFragmentToTitle( $this->title, $type ), $nextLink, array(), $lastQuery @@ -653,6 +653,32 @@ class CategoryViewer { return "($prevLink) ($nextLink)"; } + /** + * Takes a title, and adds the fragment identifier that + * corresponds to the correct segment of the category. + * + * @param Title $title: The title (usually $this->title) + * @param String $section: Which section + */ + private function addFragmentToTitle( $title, $section ) { + switch ( $section ) { + case 'page': + $fragment = 'mw-pages'; + break; + case 'subcat': + $fragment = 'mw-subcategories'; + break; + case 'file': + $fragment = 'mw-category-media'; + break; + default: + throw new MWException( __METHOD__ . + " Invalid section $section." ); + } + + return Title::makeTitle( $title->getNamespace(), + $title->getDBkey(), $fragment ); + } /** * What to do if the category table conflicts with the number of results * returned? This function says what. Each type is considered independently -- 2.20.1