(sort of bug 29586) Make the (next 200) links on categories link directly to
authorBrian Wolff <bawolff@users.mediawiki.org>
Sun, 26 Jun 2011 03:00:37 +0000 (03:00 +0000)
committerBrian Wolff <bawolff@users.mediawiki.org>
Sun, 26 Jun 2011 03:00:37 +0000 (03:00 +0000)
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
includes/CategoryPage.php

index f7cd61b..206bf86 100644 (file)
@@ -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
index 6843b82..d84aeb7 100644 (file)
@@ -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