MediaWiki r75805 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r75804‎ | r75805 (on ViewVC)‎ | r75806 >
Date:17:47, 1 November 2010
Author:demon
Status:ok
Tags:
Comment:
Kill off ancient ExtensionFunctions.php compat stuff. Nothing in trunk or REL1_16 still uses it (ED checks for needing it, but older branches will still contain it)
Modified paths:

Diff [purge]

Index: trunk/extensions/ExtensionFunctions.php
@@ -1,82 +0,0 @@
2 -<?php
3 -/**
4 - * Functions useful to extensions, which work regardless of the version of the MediaWiki core
5 - */
6 -
7 -if ( !defined( 'MEDIAWIKI' ) ) {
8 - echo "This file is part of MediaWiki, it is not a valid entry point.\n";
9 - exit( 1 );
10 -}
11 -
12 -if ( !defined( 'MW_SPECIALPAGE_VERSION' ) ) {
13 - /**
14 - * Equivalent of wfCreateObject
15 - */
16 - function extCreateObject( $name, $p ) {
17 - $p = array_values( $p );
18 - switch ( count( $p ) ) {
19 - case 0:
20 - return new $name;
21 - case 1:
22 - return new $name( $p[0] );
23 - case 2:
24 - return new $name( $p[0], $p[1] );
25 - case 3:
26 - return new $name( $p[0], $p[1], $p[2] );
27 - case 4:
28 - return new $name( $p[0], $p[1], $p[2], $p[3] );
29 - case 5:
30 - return new $name( $p[0], $p[1], $p[2], $p[3], $p[4] );
31 - case 6:
32 - return new $name( $p[0], $p[1], $p[2], $p[3], $p[4], $p[5] );
33 - default:
34 - wfDebugDieBacktrace( "Too many arguments to constructor in extCreateObject" );
35 - }
36 - }
37 -
38 - class SetupSpecialPage {
39 - function __construct( $file, $name, $params ) {
40 - $this->file = $file;
41 - $this->name = $name;
42 - $this->params = $params;
43 - }
44 -
45 - function setup() {
46 - global $IP;
47 - require_once( "$IP/includes/SpecialPage.php" );
48 - require_once( $this->file );
49 - if ( !is_array( $this->params ) ) {
50 - $this->params = array( $this->params );
51 - }
52 - $className = array_shift( $this->params );
53 - $obj = extCreateObject( $className, $this->params );
54 - SpecialPage::addPage( $obj );
55 - }
56 - }
57 -
58 - function extAddSpecialPage( $file, $name, $params ) {
59 - global $wgExtensionFunctions;
60 - $setup = new SetupSpecialPage( $file, $name, $params );
61 - $wgExtensionFunctions[] = array( &$setup, 'setup' );
62 - }
63 -} else {
64 - /**
65 - * Add a special page
66 - *
67 - * @param string $file Filename containing the derived class
68 - * @param string $name Name of the special page
69 - * @param mixed $params Name of the class, or array containing class name and constructor params
70 - * @deprecated Use $wgSpecialPages and $wgAutoloadClasses
71 - */
72 - function extAddSpecialPage( $file, $name, $params ) {
73 - global $wgSpecialPages, $wgAutoloadClasses;
74 - if ( !is_array( $params ) ) {
75 - $className = $params;
76 - } else {
77 - $className = $params[0];
78 - }
79 - $wgSpecialPages[$name] = $params;
80 - $wgAutoloadClasses[$className] = $file;
81 - }
82 -}
83 -
Index: trunk/extensions/MetavidWiki/ExtensionFunctions.php
@@ -1,80 +0,0 @@
2 -<?php
3 -/**
4 - * Functions useful to extensions, which work regardless of the version of the MediaWiki core
5 - */
6 -
7 -if ( !defined( 'MEDIAWIKI' ) ) {
8 - echo "This file is part of MediaWiki, it is not a valid entry point.\n";
9 - exit( 1 );
10 -}
11 -
12 -if ( !defined( 'MW_SPECIALPAGE_VERSION' ) ) {
13 - /**
14 - * Equivalent of wfCreateObject
15 - */
16 - function extCreateObject( $name, $p ) {
17 - $p = array_values( $p );
18 - switch ( count( $p ) ) {
19 - case 0:
20 - return new $name;
21 - case 1:
22 - return new $name( $p[0] );
23 - case 2:
24 - return new $name( $p[0], $p[1] );
25 - case 3:
26 - return new $name( $p[0], $p[1], $p[2] );
27 - case 4:
28 - return new $name( $p[0], $p[1], $p[2], $p[3] );
29 - case 5:
30 - return new $name( $p[0], $p[1], $p[2], $p[3], $p[4] );
31 - case 6:
32 - return new $name( $p[0], $p[1], $p[2], $p[3], $p[4], $p[5] );
33 - default:
34 - wfDebugDieBacktrace( "Too many arguments to constructor in extCreateObject" );
35 - }
36 - }
37 -
38 - class SetupSpecialPage {
39 - function __construct( $file, $name, $params ) {
40 - $this->file = $file;
41 - $this->name = $name;
42 - $this->params = $params;
43 - }
44 -
45 - function setup() {
46 - global $IP;
47 - require_once( "$IP/includes/SpecialPage.php" );
48 - require_once( $this->file );
49 - if ( !is_array( $this->params ) ) {
50 - $this->params = array( $this->params );
51 - }
52 - $className = array_shift( $this->params );
53 - $obj = extCreateObject( $className, $this->params );
54 - SpecialPage::addPage( $obj );
55 - }
56 - }
57 -
58 - function extAddSpecialPage( $file, $name, $params ) {
59 - global $wgExtensionFunctions;
60 - $setup = new SetupSpecialPage( $file, $name, $params );
61 - $wgExtensionFunctions[] = array( &$setup, 'setup' );
62 - }
63 -} else {
64 - /**
65 - * Add a special page
66 - *
67 - * @param string $file Filename containing the derived class
68 - * @param string $name Name of the special page
69 - * @param mixed $params Name of the class, or array containing class name and constructor params
70 - */
71 - function extAddSpecialPage( $file, $name, $params ) {
72 - global $wgSpecialPages, $wgAutoloadClasses;
73 - if ( !is_array( $params ) ) {
74 - $className = $params;
75 - } else {
76 - $className = $params[0];
77 - }
78 - $wgSpecialPages[$name] = $params;
79 - $wgAutoloadClasses[$className] = $file;
80 - }
81 -}
\ No newline at end of file

Status & tagging log

  • 16:35, 12 December 2010 Catrope (Talk | contribs) changed the status of r75805 [removed: new added: ok]
Personal tools
Namespaces

Variants
Views
Actions
Navigation
Support
Download
Development
Communication
Toolbox