| Index: trunk/phase3/includes/specials/SpecialVersion.php |
| — | — | @@ -201,11 +201,15 @@ |
| 202 | 202 | * Returns an array with the base extension types. |
| 203 | 203 | * Type is stored as array key, the message as array value. |
| 204 | 204 | * |
| | 205 | + * TODO: ideally this would return all extension types, including |
| | 206 | + * those added by SpecialVersionExtensionTypes. This is not possible |
| | 207 | + * since this hook is passing along $this though. |
| | 208 | + * |
| 205 | 209 | * @since 1.17 |
| 206 | 210 | * |
| 207 | 211 | * @return array |
| 208 | 212 | */ |
| 209 | | - public static function getBaseExtensionTypes() { |
| | 213 | + public static function getExtensionTypes() { |
| 210 | 214 | return array( |
| 211 | 215 | 'specialpage' => wfMsg( 'version-specialpages' ), |
| 212 | 216 | 'parserhook' => wfMsg( 'version-parserhooks' ), |
| — | — | @@ -227,24 +231,34 @@ |
| 228 | 232 | return ''; |
| 229 | 233 | } |
| 230 | 234 | |
| 231 | | - $extensionTypes = self::getBaseExtensionTypes(); |
| | 235 | + $extensionTypes = self::getExtensionTypes(); |
| 232 | 236 | |
| 233 | 237 | wfRunHooks( 'SpecialVersionExtensionTypes', array( &$this, &$extensionTypes ) ); |
| 234 | 238 | |
| 235 | 239 | $out = Xml::element( 'h2', array( 'id' => 'mw-version-ext' ), wfMsg( 'version-extensions' ) ) . |
| 236 | 240 | Xml::openElement( 'table', array( 'class' => 'wikitable', 'id' => 'sv-ext' ) ); |
| 237 | 241 | |
| 238 | | - foreach ( $extensionTypes as $type => $text ) { |
| 239 | | - if ( isset ( $wgExtensionCredits[$type] ) && count ( $wgExtensionCredits[$type] ) ) { |
| 240 | | - $out .= $this->openExtType( $text, 'credits-' . $type ); |
| 241 | | - |
| 242 | | - usort( $wgExtensionCredits[$type], array( $this, 'compare' ) ); |
| 243 | | - |
| 244 | | - foreach ( $wgExtensionCredits[$type] as $extension ) { |
| 245 | | - $out .= $this->getCreditsForExtension( $extension ); |
| 246 | | - } |
| | 242 | + // Make sure the 'other' type is set to an array. |
| | 243 | + if ( !array_key_exists( 'other', $wgExtensionCredits ) ) { |
| | 244 | + $wgExtensionCredits['other'] = array(); |
| | 245 | + } |
| | 246 | + |
| | 247 | + // Find all extensions that do not have a valid type and give them the type 'other'. |
| | 248 | + foreach ( $wgExtensionCredits as $type => $extensions ) { |
| | 249 | + if ( !array_key_exists( $type, $extensionTypes ) ) { |
| | 250 | + $wgExtensionCredits['other'] = array_merge( $wgExtensionCredits['other'], $extensions ); |
| 247 | 251 | } |
| 248 | 252 | } |
| | 253 | + |
| | 254 | + // Loop through the extension categories to display their extensions in the list. |
| | 255 | + foreach ( $extensionTypes as $type => $message ) { |
| | 256 | + if ( $type != 'other' ) { |
| | 257 | + $out .= $this->getExtensionCategory( $type, $message ); |
| | 258 | + } |
| | 259 | + } |
| | 260 | + |
| | 261 | + // We want the 'other' type to be last in the list. |
| | 262 | + $out .= $this->getExtensionCategory( 'other', $extensionTypes['other'] ); |
| 249 | 263 | |
| 250 | 264 | if ( count( $wgExtensionFunctions ) ) { |
| 251 | 265 | $out .= $this->openExtType( wfMsg( 'version-extension-functions' ), 'extension-functions' ); |
| — | — | @@ -272,7 +286,35 @@ |
| 273 | 287 | |
| 274 | 288 | return $out; |
| 275 | 289 | } |
| | 290 | + |
| | 291 | + /** |
| | 292 | + * Creates and returns the HTML for a single extension category. |
| | 293 | + * |
| | 294 | + * @since 1.17 |
| | 295 | + * |
| | 296 | + * @param $type String |
| | 297 | + * @param $message String |
| | 298 | + * |
| | 299 | + * @return string |
| | 300 | + */ |
| | 301 | + protected function getExtensionCategory( $type, $message ) { |
| | 302 | + global $wgExtensionCredits; |
| | 303 | + |
| | 304 | + $out = ''; |
| | 305 | + |
| | 306 | + if ( array_key_exists( $type, $wgExtensionCredits ) && count( $wgExtensionCredits[$type] ) > 0 ) { |
| | 307 | + $out .= $this->openExtType( $message, 'credits-' . $type ); |
| 276 | 308 | |
| | 309 | + usort( $wgExtensionCredits[$type], array( $this, 'compare' ) ); |
| | 310 | + |
| | 311 | + foreach ( $wgExtensionCredits[$type] as $extension ) { |
| | 312 | + $out .= $this->getCreditsForExtension( $extension ); |
| | 313 | + } |
| | 314 | + } |
| | 315 | + |
| | 316 | + return $out; |
| | 317 | + } |
| | 318 | + |
| 277 | 319 | /** |
| 278 | 320 | * Callback to sort extensions by type. |
| 279 | 321 | */ |