Fix extensions to work with category sort changes
authorAryeh Gregor <simetrical@users.mediawiki.org>
Fri, 13 Aug 2010 22:07:48 +0000 (22:07 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Fri, 13 Aug 2010 22:07:48 +0000 (22:07 +0000)
Three different extensions were copy-pasting all of
CategoryPage::closeShowCategory() just to change which CategoryViewer
descendant was used.  I changed the base class to use a member variable
for the CategoryViewer class, so this reduces code duplication too.  I
only tested this on CategoryTree; MetavidWiki is certainly still broken,
from the looks of it (assumes $this->from is a string), but
PeopleCategories might be okay.  Hard to avoid breaking extensions with
this sort of schema/index change.

includes/CategoryPage.php

index dc90b04..287efcf 100644 (file)
@@ -11,6 +11,9 @@ if ( !defined( 'MEDIAWIKI' ) )
 /**
  */
 class CategoryPage extends Article {
+       # Subclasses can change this to override the viewer class.
+       protected $mCategoryViewerClass = 'CategoryViewer';
+
        function view() {
                global $wgRequest, $wgUser;
 
@@ -62,7 +65,7 @@ class CategoryPage extends Article {
                        $until[$type] = isset( $_GET["{$type}until"] ) ? $_GET["{$type}until"] : null;
                }
 
-               $viewer = new CategoryViewer( $this->mTitle, $from, $until, $_GET );
+               $viewer = new $this->mCategoryViewerClass( $this->mTitle, $from, $until, $_GET );
                $wgOut->addHTML( $viewer->getHTML() );
        }
 }