From 98b27813e8e1b4fe4b9a03e831f4511efd43d53b Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Wed, 5 Nov 2008 19:28:55 +0000 Subject: [PATCH] * Made SpecialVersion directly extends SpecialPage * entries in $wgExtensionFunctions registred as "array( 'class', 'function' )" are now displayed correctly in Special:Version, e.g. for SkinPerPage extension. --- includes/SpecialPage.php | 2 +- includes/specials/SpecialVersion.php | 56 ++++++++++++---------------- 2 files changed, 24 insertions(+), 34 deletions(-) diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index 5e1e1bd59a..a6afba45c0 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -139,7 +139,7 @@ class SpecialPage 'Booksources' => 'SpecialBookSources', 'Categories' => array( 'SpecialPage', 'Categories' ), 'Export' => array( 'SpecialPage', 'Export' ), - 'Version' => array( 'SpecialPage', 'Version' ), + 'Version' => 'SpecialVersion', 'Blankpage' => array( 'UnlistedSpecialPage', 'Blankpage' ), 'Allmessages' => array( 'SpecialPage', 'Allmessages' ), 'Log' => array( 'SpecialPage', 'Log' ), diff --git a/includes/specials/SpecialVersion.php b/includes/specials/SpecialVersion.php index 8c8e386d11..bd7ccab580 100644 --- a/includes/specials/SpecialVersion.php +++ b/includes/specials/SpecialVersion.php @@ -1,42 +1,37 @@ * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later */ - -/** - * constructor - */ -function wfSpecialVersion() { - $version = new SpecialVersion; - $version->execute(); -} - -/** - * @ingroup SpecialPage - */ -class SpecialVersion { +class SpecialVersion extends SpecialPage { private $firstExtOpened = true; + function __construct(){ + parent::__construct( 'Version' ); + } + /** * main() */ - function execute() { + function execute( $par ) { global $wgOut, $wgMessageCache, $wgSpecialVersionShowHooks; $wgMessageCache->loadAllMessages(); + $this->setHeaders(); + $this->outputHeader(); + $wgOut->addHTML( '
' ); $text = $this->MediaWikiCredits() . $this->softwareInformation() . $this->extensionCredits(); - if ( $wgSpecialVersionShowHooks ) { + if ( $wgSpecialVersionShowHooks ) { $text .= $this->wgHooks(); } $wgOut->addWikiText( $text ); @@ -287,8 +282,6 @@ class SpecialVersion { } /** - * @static - * * @return string */ function IPInfo() { @@ -306,35 +299,34 @@ class SpecialVersion { if ( $cnt == 1 ) { // Enforce always returning a string - return (string)$this->arrayToString( $list[0] ); + return (string)self::arrayToString( $list[0] ); } elseif ( $cnt == 0 ) { return ''; } else { + global $wgLang; sort( $list ); - $t = array_slice( $list, 0, $cnt - 1 ); - $one = array_map( array( &$this, 'arrayToString' ), $t ); - $two = $this->arrayToString( $list[$cnt - 1] ); - $and = wfMsg( 'and' ); - - return implode( ', ', $one ) . " $and $two"; + return $wgLang->listToText( array_map( array( __CLASS__, 'arrayToString' ), $list ) ); } } /** - * @static - * * @param mixed $list Will convert an array to string if given and return * the paramater unaltered otherwise * @return mixed */ - function arrayToString( $list ) { + static function arrayToString( $list ) { + if( is_array( $list ) && count( $list ) == 1 ) + $list = $list[0]; if( is_object( $list ) ) { $class = get_class( $list ); return "($class)"; - } elseif ( ! is_array( $list ) ) { + } elseif ( !is_array( $list ) ) { return $list; } else { - $class = get_class( $list[0] ); + if( is_object( $list[0] ) ) + $class = get_class( $list[0] ); + else + $class = $list[0]; return "($class, {$list[1]})"; } } @@ -387,5 +379,3 @@ class SpecialVersion { /**#@-*/ } - -/**#@-*/ -- 2.20.1