From e2db2d4de0f7c5585764df3346c32cba87c640cb Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Tue, 6 Dec 2005 05:28:20 +0000 Subject: [PATCH] + Using usort() on the extensnion list with a callback function that sorts by byte order * Using ksort() on the $wgHooks list * Changed the SpecialVersionExtensionTypes hook to pass &$this as well as &$extensionTypes * Changing "--" to "-" rather than " - - " in IP addresses (like that'll ever happen at all) * Code formatting * PHPDoc improvements --- includes/SpecialVersion.php | 51 +++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/includes/SpecialVersion.php b/includes/SpecialVersion.php index c1cb8bc825..5f5873bf3d 100644 --- a/includes/SpecialVersion.php +++ b/includes/SpecialVersion.php @@ -1,5 +1,5 @@ langObj = setupLangObj( 'LanguageEn' ); $this->langObj->initEncoding(); } - + + /** + * main() + */ function execute() { global $wgOut; - $wgOut->addWikiText( $this->MediaWikiCredits() . $this->extensionCredits() . $this->wgHooks() ); + $wgOut->addWikiText( + $this->MediaWikiCredits() . + $this->extensionCredits() . + $this->wgHooks() + ); $wgOut->addHTML( $this->IPInfo() ); } + /**#@+ + * @access private + */ + + /** + * @static + */ function MediaWikiCredits() { global $wgVersion; @@ -87,12 +102,15 @@ class SpecialVersion { 'variable' => 'Variables', 'other' => 'Other', ); - wfRunHooks( 'SpecialVersionExtensionTypes', array( &$extensionTypes ) ); + wfRunHooks( 'SpecialVersionExtensionTypes', array( &$this, &$extensionTypes ) ); $out = "\n* Extensions:\n"; foreach ( $extensionTypes as $type => $text ) { if ( count( @$wgExtensionCredits[$type] ) ) { $out .= "** $text:\n"; + + usort( $wgExtensionCredits[$type], array( $this, 'compare' ) ); + foreach ( $wgExtensionCredits[$type] as $extension ) { wfSuppressWarnings(); $out .= $this->formatCredits( @@ -120,6 +138,13 @@ class SpecialVersion { return $out; } + function compare( $a, $b ) { + if ( $a['name'] === $b['name'] ) + return 0; + else + return $this->langObj->lc( $a['name'] ) > $this->langObj->lc( $b['name'] ) ? 1 : -1; + } + function formatCredits( $name, $version = null, $author = null, $url = null, $description = null) { $ret = '*** '; if ( isset( $url ) ) @@ -143,16 +168,26 @@ class SpecialVersion { function wgHooks() { global $wgHooks; - $ret = "* Hooks:\n"; - foreach ($wgHooks as $hook => $hooks) - $ret .= "** $hook: " . $this->langObj->listToText( $hooks ) . "\n"; + $myWgHooks = $wgHooks; + ksort( $myWgHooks ); + $ret = "* Hooks:\n"; + foreach ($myWgHooks as $hook => $hooks) + $ret .= "** $hook:" . $this->langObj->listToText( $hooks ) . "\n"; + return $ret; } + /** + * @static + */ function IPInfo() { - $ip = str_replace( '--', ' - - ', htmlspecialchars( wfGetIP() ) ); + $ip = str_replace( '--', '-', htmlspecialchars( wfGetIP() ) ); return "\n"; } + + /**#@-*/ } + +/**#@-*/ ?> -- 2.20.1