Index: trunk/extensions/examples/FourFileTemplate/MyExtension_body.php |
— | — | @@ -1,12 +1,49 @@ |
2 | 2 | <?php |
| 3 | + |
3 | 4 | class MyExtension extends SpecialPage { |
4 | | - function __construct() { |
5 | | - parent::__construct( "MyExtension" ); |
| 5 | + |
| 6 | + /** |
| 7 | + * Constructor -- set up the new special page |
| 8 | + */ |
| 9 | + public function __construct() { |
| 10 | + parent::__construct( 'MyExtension' ); |
6 | 11 | } |
7 | 12 | |
8 | | - function execute( $par ) { |
| 13 | + /** |
| 14 | + * Show the special page |
| 15 | + * |
| 16 | + * @param $par Mixed: parameter passed to the special page or null |
| 17 | + */ |
| 18 | + public function execute( $par ) { |
9 | 19 | global $wgRequest, $wgOut; |
10 | 20 | |
| 21 | + /* If you want to make this special page a restricted special page, |
| 22 | + you can uncomment the following three checks and add 'permission-name' |
| 23 | + as the second parameter to parent::__construct in the __construct |
| 24 | + function. |
| 25 | + Note that you will not need the read-only check if your special page |
| 26 | + doesn't perform any write queries against the database. |
| 27 | + |
| 28 | + // If the user doesn't have the required permission, display an error |
| 29 | + if( !$wgUser->isAllowed( 'permission-name' ) ) { |
| 30 | + $wgOut->permissionRequired( 'permission-name' ); |
| 31 | + return; |
| 32 | + } |
| 33 | + |
| 34 | + // Show a message if the database is in read-only mode |
| 35 | + if ( wfReadOnly() ) { |
| 36 | + $wgOut->readOnlyPage(); |
| 37 | + return; |
| 38 | + } |
| 39 | + |
| 40 | + // If the user is blocked, they don't need to access this page |
| 41 | + if ( $wgUser->isBlocked() ) { |
| 42 | + $wgOut->blockedPage(); |
| 43 | + return; |
| 44 | + } |
| 45 | + */ |
| 46 | + |
| 47 | + // Set the page title and robot policies |
11 | 48 | $this->setHeaders(); |
12 | 49 | |
13 | 50 | # Get request data from, e.g. |
Index: trunk/extensions/examples/FourFileTemplate/MyExtension.i18n.php |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | | - * Internationalisation file for extension MyExtension. |
| 4 | + * Internationalisation file for MyExtension extension. |
5 | 5 | * |
6 | 6 | * @file |
7 | 7 | * @ingroup Extensions |
— | — | @@ -8,7 +8,8 @@ |
9 | 9 | |
10 | 10 | $messages = array(); |
11 | 11 | |
| 12 | +/** English */ |
12 | 13 | $messages['en'] = array( |
| 14 | + 'myextension' => 'My extension', |
13 | 15 | 'myextension-desc' => 'MyExtension description', |
14 | | - 'myextension' => 'My extension' |
15 | 16 | ); |
Index: trunk/extensions/examples/FourFileTemplate/MyExtension.php |
— | — | @@ -1,23 +1,35 @@ |
2 | 2 | <?php |
| 3 | +/** |
| 4 | + * MyExtensionName -- short description of MyExtensionName goes here |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + * @version 0.1 |
| 9 | + * @author MyExtensionName <foo.bar@example.com> |
| 10 | + * @license http://licenses.example.com/foo Foo License, version 2+ |
| 11 | + * @link http://www.mediawiki.org/wiki/Extension:MyExtension Documentation |
| 12 | + */ |
| 13 | + |
3 | 14 | # Not a valid entry point, skip unless MEDIAWIKI is defined |
4 | 15 | if ( !defined( 'MEDIAWIKI' ) ) { |
5 | | - echo <<<EOT |
| 16 | + echo <<<EOT |
6 | 17 | To install my extension, put the following line in LocalSettings.php: |
7 | 18 | require_once( "\$IP/extensions/MyExtension/MyExtension.php" ); |
8 | 19 | EOT; |
9 | | - exit( 1 ); |
| 20 | + exit( 1 ); |
10 | 21 | } |
11 | 22 | |
| 23 | +// Extension credits that will show up on Special:Version |
12 | 24 | $wgExtensionCredits['specialpage'][] = array( |
13 | 25 | 'path' => __FILE__, |
14 | 26 | 'name' => 'MyExtensionName', |
15 | 27 | 'version' => '0.1', |
16 | | - // You can use array for multiple authors |
17 | | - 'author' => 'MyExtensionAuthor', |
| 28 | + 'author' => 'MyExtensionAuthor', // You can use array for multiple authors |
| 29 | + 'descriptionmsg' => 'myextension-desc', |
18 | 30 | 'url' => 'http://www.mediawiki.org/wiki/Extension:MyExtension', |
19 | | - 'descriptionmsg' => 'myextension-desc', |
20 | 31 | ); |
21 | 32 | |
| 33 | +// Autoload classes, set up the special page and i18n |
22 | 34 | $dir = dirname( __FILE__ ) . '/'; |
23 | 35 | $wgAutoloadClasses['MyExtension'] = $dir . 'MyExtension_body.php'; |
24 | 36 | $wgSpecialPages['MyExtension'] = 'MyExtension'; |