r71051 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71050‎ | r71051 | r71052 >
Date:22:07, 13 August 2010
Author:simetrical
Status:ok
Tags:
Comment:
Fix extensions to work with category sort changes

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.
Modified paths:
  • /trunk/extensions/CategoryTree/CategoryPageSubclass.php (modified) (history)
  • /trunk/extensions/MetavidWiki/includes/articlepages/MV_CategoryPage.php (modified) (history)
  • /trunk/extensions/PeopleCategories/PeopleCategories.body.php (modified) (history)
  • /trunk/phase3/includes/CategoryPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/CategoryPage.php
@@ -11,6 +11,9 @@
1212 /**
1313 */
1414 class CategoryPage extends Article {
 15+ # Subclasses can change this to override the viewer class.
 16+ protected $mCategoryViewerClass = 'CategoryViewer';
 17+
1518 function view() {
1619 global $wgRequest, $wgUser;
1720
@@ -62,7 +65,7 @@
6366 $until[$type] = isset( $_GET["{$type}until"] ) ? $_GET["{$type}until"] : null;
6467 }
6568
66 - $viewer = new CategoryViewer( $this->mTitle, $from, $until, $_GET );
 69+ $viewer = new $this->mCategoryViewerClass( $this->mTitle, $from, $until, $_GET );
6770 $wgOut->addHTML( $viewer->getHTML() );
6871 }
6972 }
Index: trunk/extensions/PeopleCategories/PeopleCategories.body.php
@@ -8,6 +8,8 @@
99 */
1010
1111 class PeopleCategoriesPage extends CategoryPage {
 12+ protected $mCategoryViewerClass = 'PeopleCategoriesViewer';
 13+
1214 function view() {
1315 // From CategoryPage::view()
1416 if( NS_CATEGORY == $this->mTitle->getNamespace() ) {
@@ -21,19 +23,6 @@
2224 $this->closeShowCategory();
2325 }
2426 }
25 -
26 - function closeShowCategory() {
27 - // From CategoryPage::view();
28 - global $wgOut, $wgRequest;
29 - $from = $wgRequest->getVal( 'from' );
30 - $until = $wgRequest->getVal( 'until' );
31 -
32 - // Customization.
33 - $viewer = new PeopleCategoriesViewer( $this->mTitle, $from, $until );
34 -
35 - // From CategoryPage::view();
36 - $wgOut->addHTML( $viewer->getHTML() );
37 - }
3827 }
3928
4029 class PeopleCategoriesViewer extends CategoryViewer {
Index: trunk/extensions/CategoryTree/CategoryPageSubclass.php
@@ -1,15 +1,7 @@
22 <?php
33
44 class CategoryTreeCategoryPage extends CategoryPage {
5 - function closeShowCategory() {
6 - global $wgOut, $wgRequest;
7 -
8 - $from = $wgRequest->getVal( 'from' );
9 - $until = $wgRequest->getVal( 'until' );
10 -
11 - $viewer = new CategoryTreeCategoryViewer( $this->mTitle, $from, $until );
12 - $wgOut->addHTML( $viewer->getHTML() );
13 - }
 5+ protected $mCategoryViewerClass = 'CategoryTreeCategoryViewer';
146 }
157
168 class CategoryTreeCategoryViewer extends CategoryViewer {
Index: trunk/extensions/MetavidWiki/includes/articlepages/MV_CategoryPage.php
@@ -16,13 +16,7 @@
1717 if ( !defined( 'MEDIAWIKI' ) ) die( 1 );
1818
1919 class MV_CategoryPage extends CategoryPage {
20 - function closeShowCategory() {
21 - global $wgOut, $wgRequest;
22 - $from = $wgRequest->getVal( 'from' );
23 - $until = $wgRequest->getVal( 'until' );
24 - $viewer = new MvCategoryViewer( $this->mTitle, $from, $until );
25 - $wgOut->addHTML( $viewer->getHTML() );
26 - }
 20+ protected $mCategoryViewerClass = 'MvCategoryViewer';
2721 }
2822 class MvCategoryViewer extends CategoryViewer {
2923 var $show_mv_links = false;

Follow-up revisions

RevisionCommit summaryAuthorDate
r822431.17wmf1: Revert r71051 on CategoryTree per vvv's suggestioncatrope13:58, 16 February 2011

Status & tagging log