r111786 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111785‎ | r111786 | r111787 >
Date:21:13, 17 February 2012
Author:kaldari
Status:ok
Tags:
Comment:
moving HelloWorld into examples
Modified paths:
  • /trunk/extensions/HelloWorld (deleted) (history)
  • /trunk/extensions/examples/HelloWorld (added) (history)
  • /trunk/extensions/examples/HelloWorld/INSTALL (added) (history)

Diff [purge]

Index: trunk/extensions/examples/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/examples/HelloWorld/HelloWorld.i18n.php
___________________________________________________________________
Added: svn:eol-style
130 + native
Index: trunk/extensions/examples/HelloWorld/HelloWorld.php
@@ -0,0 +1,58 @@
 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+// The full directory path for this extension
 48+$dir = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
 49+
 50+// Load the HelloWorld special page class
 51+$wgAutoloadClasses['SpecialHelloWorld'] = $dir . 'SpecialHelloWorld.php';
 52+// Load the i18n file that provides translated messages
 53+$wgExtensionMessagesFiles['HelloWorld'] = $dir . 'HelloWorld.i18n.php';
 54+// Load the alias file that provides localized aliases for the special page
 55+$wgExtensionMessagesFiles['HelloWorldAlias'] = $dir . 'HelloWorld.alias.php';
 56+// Register the HelloWorld special page (Special:HelloWorld)
 57+$wgSpecialPages['HelloWorld'] = 'SpecialHelloWorld';
 58+// Assign the HelloWorld special page to the special page group 'other'
 59+$wgSpecialPageGroups['HelloWorld'] = 'other';
Property changes on: trunk/extensions/examples/HelloWorld/HelloWorld.php
___________________________________________________________________
Added: svn:eol-style
160 + native
Index: trunk/extensions/examples/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/examples/HelloWorld/SpecialHelloWorld.php
___________________________________________________________________
Added: svn:eol-style
136 + native
Index: trunk/extensions/examples/HelloWorld/INSTALL
@@ -0,0 +1,10 @@
 2+HelloWorld Extension
 3+
 4+* Download the latest available version and extract it to your wiki extension directory.
 5+* Add the following line to LocalSettings.php:
 6+
 7+ require_once( "$IP/extensions/HelloWorld/HelloWorld.php" );
 8+
 9+* Check out the Special:HelloWorld page to verify the installation.
 10+
 11+See http://www.mediawiki.org/wiki/Extension:HelloWorld for further details.
Index: trunk/extensions/examples/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/examples/HelloWorld/HelloWorld.alias.php
___________________________________________________________________
Added: svn:eol-style
116 + native

Follow-up revisions

RevisionCommit summaryAuthorDate
r111787follow-up to r111786, updating paths for new directory locationkaldari21:16, 17 February 2012
r111791r111786: extension movedraymond21:23, 17 February 2012

Status & tagging log