r111783 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111782‎ | r111783 | r111784 >
Date:20:32, 17 February 2012
Author:kaldari
Status:ok (Comments)
Tags:
Comment:
new HelloWorld extension for teaching purposes
Modified paths:
  • /trunk/extensions/HelloWorld (added) (history)
  • /trunk/extensions/HelloWorld/HelloWorld.alias.php (added) (history)
  • /trunk/extensions/HelloWorld/HelloWorld.i18n.php (added) (history)
  • /trunk/extensions/HelloWorld/HelloWorld.php (added) (history)
  • /trunk/extensions/HelloWorld/SpecialHelloWorld.php (added) (history)

Diff [purge]

Index: trunk/extensions/HelloWorld/HelloWorld.i18n.php
@@ -0,0 +1,28 @@
 2+<?php
 3+/**
 4+ * Internationalisation for HelloWorld extension
 5+ *
 6+ * @file
 7+ * @ingroup Extensions
 8+ */
 9+
 10+$messages = array();
 11+
 12+/** English
 13+ * @author Ryan Kaldari
 14+ */
 15+$messages['en'] = array(
 16+ 'helloworld-desc' => 'This is an example of a basic MediaWiki extension',
 17+ 'helloworld' => 'HelloWorld',
 18+ 'helloworld-hello' => 'Hello World!',
 19+);
 20+
 21+/** Message documentation (Message documentation)
 22+ * @author Ryan Kaldari
 23+ */
 24+$messages['qqq'] = array(
 25+ 'helloworld-desc' => '{{desc}}
 26+See http://www.mediawiki.org/wiki/Extension:HelloWorld',
 27+ 'helloworld' => 'The name of the extension HelloWorld',
 28+ 'helloworld-hello' => 'A short message of greetings',
 29+);
Property changes on: trunk/extensions/HelloWorld/HelloWorld.i18n.php
___________________________________________________________________
Added: svn:eol-style
130 + native
Index: trunk/extensions/HelloWorld/HelloWorld.php
@@ -0,0 +1,57 @@
 2+<?php
 3+/**
 4+ * MediaWiki HelloWorld extension
 5+ * http://www.mediawiki.org/wiki/Extension:HelloWorld
 6+ *
 7+ * Permission is hereby granted, free of charge, to any person obtaining a copy
 8+ * of this software and associated documentation files (the "Software"), to deal
 9+ * in the Software without restriction, including without limitation the rights
 10+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 11+ * copies of the Software, and to permit persons to whom the Software is
 12+ * furnished to do so, subject to the following conditions:
 13+ *
 14+ * The above copyright notice and this permission notice shall be included in
 15+ * all copies or substantial portions of the Software.
 16+ *
 17+ * This program is distributed WITHOUT ANY WARRANTY.
 18+ */
 19+
 20+/**
 21+ * This file loads everything needed for the HelloWorld extension to function.
 22+ *
 23+ * @file
 24+ * @ingroup Extensions
 25+ * @author Ryan Kaldari
 26+ */
 27+
 28+// Tell the user how to install the extension if they try to access the page directly.
 29+if ( !defined( 'MEDIAWIKI' ) ) {
 30+ echo <<<EOT
 31+To install this extension, put the following line in LocalSettings.php:
 32+require_once( "\$IP/extensions/HelloWorld/HelloWorld.php" );\n
 33+EOT;
 34+ exit( 1 );
 35+}
 36+
 37+// Extension credits that will show up on Special:Version
 38+$wgExtensionCredits['specialpage'][] = array(
 39+ 'path' => __FILE__,
 40+ 'name' => 'HelloWorld',
 41+ 'version' => '1.0',
 42+ 'url' => 'https://www.mediawiki.org/wiki/Extension:HelloWorld',
 43+ 'author' => array( 'Ryan Kaldari' ),
 44+ 'descriptionmsg' => 'helloworld-desc',
 45+);
 46+
 47+$dir = dirname( __FILE__ ) . '/';
 48+
 49+// Load the HelloWorld special page class
 50+$wgAutoloadClasses['SpecialHelloWorld'] = $dir . 'SpecialHelloWorld.php';
 51+// Load the i18n file that provides translated messages
 52+$wgExtensionMessagesFiles['HelloWorld'] = $dir . 'HelloWorld.i18n.php';
 53+// Load the alias file that provides localized aliases for the special page
 54+$wgExtensionMessagesFiles['HelloWorldAlias'] = $dir . 'HelloWorld.alias.php';
 55+// Register the HelloWorld special page (Special:HelloWorld)
 56+$wgSpecialPages['HelloWorld'] = 'SpecialHelloWorld';
 57+// Assign the HelloWorld special page to the special page group 'other'
 58+$wgSpecialPageGroups['HelloWorld'] = 'other';
Property changes on: trunk/extensions/HelloWorld/HelloWorld.php
___________________________________________________________________
Added: svn:eol-style
159 + native
Index: trunk/extensions/HelloWorld/SpecialHelloWorld.php
@@ -0,0 +1,34 @@
 2+<?php
 3+/**
 4+ * This file defines the SpecialHelloWorld class which handles the functionality for the
 5+ * HelloWorld special page (Special:HelloWorld).
 6+ *
 7+ * @file
 8+ * @ingroup Extensions
 9+ * @author Ryan Kaldari
 10+ */
 11+class SpecialHelloWorld extends SpecialPage {
 12+
 13+ /**
 14+ * Initialize the special page.
 15+ * In this case, we're just calling the parent class's constructor with the name of the special
 16+ * page and no extra parameters.
 17+ */
 18+ public function __construct() {
 19+ parent::__construct( 'HelloWorld' );
 20+ }
 21+
 22+ /**
 23+ * Define what happens when the special page is loaded by the user.
 24+ * @param $sub string The subpage, if any
 25+ */
 26+ public function execute( $sub ) {
 27+ global $wgOut;
 28+
 29+ // Output the title of the page
 30+ $wgOut->setPageTitle( wfMsg( 'helloworld' ) );
 31+ // Output a hello world message as the content of the page
 32+ $wgOut->addWikiMsg( 'helloworld-hello' );
 33+ }
 34+
 35+}
Property changes on: trunk/extensions/HelloWorld/SpecialHelloWorld.php
___________________________________________________________________
Added: svn:eol-style
136 + native
Index: trunk/extensions/HelloWorld/HelloWorld.alias.php
@@ -0,0 +1,14 @@
 2+<?php
 3+/**
 4+ * Aliases for Special:HelloWorld
 5+ *
 6+ * @file
 7+ * @ingroup Extensions
 8+ */
 9+
 10+$specialPageAliases = array();
 11+
 12+/** English */
 13+$specialPageAliases['en'] = array(
 14+ 'HelloWorld' => array( 'HelloWorld' ),
 15+);
Property changes on: trunk/extensions/HelloWorld/HelloWorld.alias.php
___________________________________________________________________
Added: svn:eol-style
116 + native

Follow-up revisions

RevisionCommit summaryAuthorDate
r111784r111783: Register extension for translatewiki.net....raymond20:38, 17 February 2012

Comments

#Comment by Awjrichards (talk | contribs)   20:35, 17 February 2012

Have you seen the 'Example' extension? I checked it in about a week ago for the Pune hackathon - it is fairly similar, at least in essence.

#Comment by Siebrand (talk | contribs)   20:36, 17 February 2012

Actually, can we move these into "examples/"?

#Comment by Awjrichards (talk | contribs)   20:41, 17 February 2012

Ah yes, I remember you mentioning that when I showed you the 'Example' extension. I still haven't been able to find this 'examples/' dir though... where exactly is it?

#Comment by Kaldari (talk | contribs)   22:11, 17 February 2012

Unfortunately, it looks like putting extensions in /examples breaks the use of Special:ExtensionDistributor for those extensions :(

#Comment by Reedy (talk | contribs)   22:15, 17 February 2012

It doesn't work with GIT yet...

But you can get it by selecting examples.

r111794.tar.gz https://upload.wikimedia.org/ext-dist/examples-trunk-r111794.tar.gz

Hmm

#Comment by Kaldari (talk | contribs)   21:03, 17 February 2012

crap :)

Status & tagging log