r98700 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98699‎ | r98700 | r98701 >
Date:18:37, 2 October 2011
Author:dantman
Status:deferred
Tags:
Comment:
Implement SpecialPage name autodetection based on class name.
Modified paths:
  • /branches/pageoutput/includes/SpecialPage.php (modified) (history)
  • /branches/pageoutput/includes/specials/SpecialHistory.php (modified) (history)

Diff [purge]

Index: branches/pageoutput/includes/specials/SpecialHistory.php
@@ -28,10 +28,6 @@
2929 */
3030 class SpecialHistory extends UnlistedSpecialPage implements SpecialTitleTarget { // XXX: Should this be listed or unlisted?
3131
32 - function __construct() {
33 - parent::__construct( 'History' );
34 - }
35 -
3632 function executeWithTarget() {
3733 $context = new DerivativeContext( $this->getContext() );
3834 $context->setTitle( $this->target() );
Index: branches/pageoutput/includes/SpecialPage.php
@@ -344,6 +344,9 @@
345345 * @param $includable Bool: whether the page can be included in normal pages
346346 */
347347 private function init( $name, $restriction, $listed, $function, $file, $includable ) {
 348+ if ( $name == '' && preg_match( '/^Special[_A-Za-z0-9]+$/', get_class( $this ) ) ) {
 349+ $name = preg_replace( '/^Special/', '', get_class( $this ) );
 350+ }
348351 $this->mName = $name;
349352 $this->mRestriction = $restriction;
350353 $this->mListed = $listed;
@@ -921,7 +924,7 @@
922925 * @ingroup SpecialPage
923926 */
924927 class UnlistedSpecialPage extends SpecialPage {
925 - function __construct( $name, $restriction = '', $function = false, $file = 'default' ) {
 928+ function __construct( $name = '', $restriction = '', $function = false, $file = 'default' ) {
926929 parent::__construct( $name, $restriction, false, $function, $file );
927930 }
928931
@@ -936,7 +939,7 @@
937940 */
938941 class IncludableSpecialPage extends SpecialPage {
939942 function __construct(
940 - $name, $restriction = '', $listed = true, $function = false, $file = 'default'
 943+ $name = '', $restriction = '', $listed = true, $function = false, $file = 'default'
941944 ) {
942945 parent::__construct( $name, $restriction, $listed, $function, $file, true );
943946 }

Status & tagging log