r11987 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r11986‎ | r11987 | r11988 >
Date:05:28, 6 December 2005
Author:avar
Status:old
Tags:
Comment:
+ 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
Modified paths:
  • /trunk/phase3/includes/SpecialVersion.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialVersion.php
@@ -1,5 +1,5 @@
22 <?php
3 -/**
 3+/**#@+
44 * Give information about the version of MediaWiki, PHP, the DB and extensions
55 *
66 * @package MediaWiki
@@ -21,6 +21,7 @@
2222 class SpecialVersion {
2323 /**
2424 * @var object
 25+ * @access private
2526 */
2627 var $langObj;
2728
@@ -32,14 +33,28 @@
3334 $this->langObj = setupLangObj( 'LanguageEn' );
3435 $this->langObj->initEncoding();
3536 }
36 -
 37+
 38+ /**
 39+ * main()
 40+ */
3741 function execute() {
3842 global $wgOut;
3943
40 - $wgOut->addWikiText( $this->MediaWikiCredits() . $this->extensionCredits() . $this->wgHooks() );
 44+ $wgOut->addWikiText(
 45+ $this->MediaWikiCredits() .
 46+ $this->extensionCredits() .
 47+ $this->wgHooks()
 48+ );
4149 $wgOut->addHTML( $this->IPInfo() );
4250 }
4351
 52+ /**#@+
 53+ * @access private
 54+ */
 55+
 56+ /**
 57+ * @static
 58+ */
4459 function MediaWikiCredits() {
4560 global $wgVersion;
4661
@@ -87,12 +102,15 @@
88103 'variable' => 'Variables',
89104 'other' => 'Other',
90105 );
91 - wfRunHooks( 'SpecialVersionExtensionTypes', array( &$extensionTypes ) );
 106+ wfRunHooks( 'SpecialVersionExtensionTypes', array( &$this, &$extensionTypes ) );
92107
93108 $out = "\n* Extensions:\n";
94109 foreach ( $extensionTypes as $type => $text ) {
95110 if ( count( @$wgExtensionCredits[$type] ) ) {
96111 $out .= "** $text:\n";
 112+
 113+ usort( $wgExtensionCredits[$type], array( $this, 'compare' ) );
 114+
97115 foreach ( $wgExtensionCredits[$type] as $extension ) {
98116 wfSuppressWarnings();
99117 $out .= $this->formatCredits(
@@ -120,6 +138,13 @@
121139 return $out;
122140 }
123141
 142+ function compare( $a, $b ) {
 143+ if ( $a['name'] === $b['name'] )
 144+ return 0;
 145+ else
 146+ return $this->langObj->lc( $a['name'] ) > $this->langObj->lc( $b['name'] ) ? 1 : -1;
 147+ }
 148+
124149 function formatCredits( $name, $version = null, $author = null, $url = null, $description = null) {
125150 $ret = '*** ';
126151 if ( isset( $url ) )
@@ -143,16 +168,26 @@
144169 function wgHooks() {
145170 global $wgHooks;
146171
 172+ $myWgHooks = $wgHooks;
 173+ ksort( $myWgHooks );
 174+
147175 $ret = "* Hooks:\n";
148 - foreach ($wgHooks as $hook => $hooks)
149 - $ret .= "** $hook: " . $this->langObj->listToText( $hooks ) . "\n";
150 -
 176+ foreach ($myWgHooks as $hook => $hooks)
 177+ $ret .= "** $hook:" . $this->langObj->listToText( $hooks ) . "\n";
 178+
151179 return $ret;
152180 }
153181
 182+ /**
 183+ * @static
 184+ */
154185 function IPInfo() {
155 - $ip = str_replace( '--', ' - - ', htmlspecialchars( wfGetIP() ) );
 186+ $ip = str_replace( '--', '-', htmlspecialchars( wfGetIP() ) );
156187 return "<!-- visited from $ip -->\n";
157188 }
 189+
 190+ /**#@-*/
158191 }
 192+
 193+/**#@-*/
159194 ?>

Status & tagging log