r85217 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85216‎ | r85217 | r85218 >
Date:22:48, 2 April 2011
Author:ashley
Status:deferred
Tags:
Comment:
make example special page suck less
Modified paths:
  • /trunk/extensions/examples/FourFileTemplate/MyExtension.i18n.php (modified) (history)
  • /trunk/extensions/examples/FourFileTemplate/MyExtension.php (modified) (history)
  • /trunk/extensions/examples/FourFileTemplate/MyExtension_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/examples/FourFileTemplate/MyExtension_body.php
@@ -1,12 +1,49 @@
22 <?php
 3+
34 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' );
611 }
712
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 ) {
919 global $wgRequest, $wgOut;
1020
 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
1148 $this->setHeaders();
1249
1350 # Get request data from, e.g.
Index: trunk/extensions/examples/FourFileTemplate/MyExtension.i18n.php
@@ -1,6 +1,6 @@
22 <?php
33 /**
4 - * Internationalisation file for extension MyExtension.
 4+ * Internationalisation file for MyExtension extension.
55 *
66 * @file
77 * @ingroup Extensions
@@ -8,7 +8,8 @@
99
1010 $messages = array();
1111
 12+/** English */
1213 $messages['en'] = array(
 14+ 'myextension' => 'My extension',
1315 'myextension-desc' => 'MyExtension description',
14 - 'myextension' => 'My extension'
1516 );
Index: trunk/extensions/examples/FourFileTemplate/MyExtension.php
@@ -1,23 +1,35 @@
22 <?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+
314 # Not a valid entry point, skip unless MEDIAWIKI is defined
415 if ( !defined( 'MEDIAWIKI' ) ) {
5 - echo <<<EOT
 16+ echo <<<EOT
617 To install my extension, put the following line in LocalSettings.php:
718 require_once( "\$IP/extensions/MyExtension/MyExtension.php" );
819 EOT;
9 - exit( 1 );
 20+ exit( 1 );
1021 }
1122
 23+// Extension credits that will show up on Special:Version
1224 $wgExtensionCredits['specialpage'][] = array(
1325 'path' => __FILE__,
1426 'name' => 'MyExtensionName',
1527 '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',
1830 'url' => 'http://www.mediawiki.org/wiki/Extension:MyExtension',
19 - 'descriptionmsg' => 'myextension-desc',
2031 );
2132
 33+// Autoload classes, set up the special page and i18n
2234 $dir = dirname( __FILE__ ) . '/';
2335 $wgAutoloadClasses['MyExtension'] = $dir . 'MyExtension_body.php';
2436 $wgSpecialPages['MyExtension'] = 'MyExtension';

Status & tagging log