r97436 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97435‎ | r97436 | r97437 >
Date:19:47, 18 September 2011
Author:demon
Status:deferred
Tags:
Comment:
Some work-in-progress for Wikimania ext (so people can get an idea of how I envisioned it)
* Move lang files to /lang/ subdir. Also create a lazy-loaded per-year language file so we can do per-year customizations (for things like hotel names, etc)
* Some basic docs and initial config for $wgWikimaniaConf
* I was thinking of making the schema be designed based on what fields are configured/required. Haven't quite figured out the best way yet. If that's too difficult I'll just do it the crappy normal way we usually do.
* Fix totally bogus $wgSpecialPageGroups config
* Add a bunch of qqq messages like Nikerabbit asked for in r97396.
Modified paths:
  • /trunk/extensions/Wikimania/README (modified) (history)
  • /trunk/extensions/Wikimania/Wikimania.alias.php (deleted) (history)
  • /trunk/extensions/Wikimania/Wikimania.i18n.php (deleted) (history)
  • /trunk/extensions/Wikimania/Wikimania.php (modified) (history)
  • /trunk/extensions/Wikimania/backend/Payment.php (added) (history)
  • /trunk/extensions/Wikimania/backend/PaymentGoogleCheckout.php (added) (history)
  • /trunk/extensions/Wikimania/backend/PaymentPaypal.php (added) (history)
  • /trunk/extensions/Wikimania/backend/Wikimania.php (added) (history)
  • /trunk/extensions/Wikimania/backend/WikimaniaHooks.php (deleted) (history)
  • /trunk/extensions/Wikimania/backend/WikimaniaRegistration.php (added) (history)
  • /trunk/extensions/Wikimania/backend/WikimaniaSchema.php (added) (history)
  • /trunk/extensions/Wikimania/lang (added) (history)
  • /trunk/extensions/Wikimania/lang/Wikimania.alias.php (added) (history)
  • /trunk/extensions/Wikimania/lang/Wikimania.i18n.php (added) (history)
  • /trunk/extensions/Wikimania/lang/Wikimania2012.i18n.php (added) (history)

Diff [purge]

Index: trunk/extensions/Wikimania/Wikimania.alias.php
@@ -1,16 +0,0 @@
2 -<?php
3 -/**
4 - * Aliases for extension Wikimania
5 - *
6 - * @file
7 - * @ingroup Extensions
8 - */
9 -
10 -$specialPageAliases = array();
11 -
12 -/** English (English) */
13 -$specialPageAliases['en'] = array(
14 - 'AdministerWikimania' => array( 'AdministerWikimania' ),
15 - 'CheckWikimaniaStatus' => array( 'CheckWikimaniaStatus' ),
16 - 'RegisterForWikimania' => array( 'RegisterForWikimania' ),
17 -);
Index: trunk/extensions/Wikimania/Wikimania.i18n.php
@@ -1,27 +0,0 @@
2 -<?php
3 -/*
4 - * i18n for Wikimania extension
5 - */
6 -
7 -$messages = array();
8 -
9 -/**
10 - * English
11 - */
12 -$messages['en'] = array(
13 - 'wikimania' => 'Wikimania',
14 - 'wikimania-desc' => 'Extension designed to manage the annual Wikimania conference',
15 - 'administerwikimania' => 'Administer Wikimania registrations',
16 - 'checkwikimaniastatus' => 'Check Wikimania registration status',
17 - 'registerforwikimania' => 'Register for Wikimania',
18 - 'right-wikimania-admin' => 'Manage Wikimania registrations',
19 - 'right-wikimania-register' => 'Register for Wikimania',
20 - 'right-wikimania-checkstatus' => 'Check status of a Wikimania registration',
21 -);
22 -
23 -/**
24 - * Message docs (qqq)
25 - */
26 -$messages['qqq'] = array(
27 - 'wikimania-desc' => '{{desc}}',
28 -);
Index: trunk/extensions/Wikimania/Wikimania.php
@@ -22,7 +22,12 @@
2323 /**
2424 * Classes
2525 */
26 -$wgAutoloadClasses['WikimaniaHooks'] = "$d/backend/WikimaniaHooks.php";
 26+$wgAutoloadClasses['Payment'] = "$d/backend/Payment.php";
 27+$wgAutoloadClasses['PaymentGoogleCheckout'] = "$d/backend/PaymentGoogleCheckout.php";
 28+$wgAutoloadClasses['PaymentPaypal'] = "$d/backend/PaymentPaypal.php";
 29+$wgAutoloadClasses['Wikimania'] = "$d/backend/Wikimania.php";
 30+$wgAutoloadClasses['WikimaniaRegistration'] = "$d/backend/WikimaniaRegistration.php";
 31+$wgAutoloadClasses['WikimaniaSchema'] = "$d/backend/WikimaniaSchema.php";
2732 $wgAutoloadClasses['SpecialAdministerWikimania'] = "$d/specials/SpecialAdministerWikimania.php";
2833 $wgAutoloadClasses['SpecialCheckWikimaniaStatus'] = "$d/specials/SpecialCheckWikimaniaStatus.php";
2934 $wgAutoloadClasses['SpecialRegisterForWikimania'] = "$d/specials/SpecialRegisterForWikimania.php";
@@ -30,8 +35,8 @@
3136 /**
3237 * i18n
3338 */
34 -$wgExtensionMessageFiles['wikimania'] = "$d/Wikimania.i18n.php";
35 -$wgExtensionAliasesFiles['wikimania'] = "$d/Wikimania.alias.php";
 39+$wgExtensionMessageFiles['wikimania'] = "$d/lang/Wikimania.i18n.php";
 40+$wgExtensionAliasesFiles['wikimania'] = "$d/lang/Wikimania.alias.php";
3641
3742 /**
3843 * Special pages
@@ -39,14 +44,14 @@
4045 $wgSpecialPages['AdministerWikimania'] = 'SpecialAdministerWikimania';
4146 $wgSpecialPages['CheckWikimaniaStatus'] = 'SpecialCheckWikimaniaStatus';
4247 $wgSpecialPages['RegisterForWikimania'] = 'SpecialRegisterForWikimania';
43 -$wgSpecialPageGroups['wikimania'] = array(
44 - 'AdministerWikimania', 'CheckWikimaniaStatus', 'RegisterForWikimania'
45 -);
 48+$wgSpecialPageGroups['AdministerWikimania'] = 'wikimania';
 49+$wgSpecialPageGroups['CheckWikimaniaStatus'] = 'wikimania';
 50+$wgSpecialPageGroups['RegisterForWikimania'] = 'wikimania';
4651
4752 /**
4853 * Hooks
4954 */
50 -$wgHooks['LoadExtensionSchemaUpdates'][] = 'WikimaniaHooks::loadExtensionSchemaUpdates';
 55+$wgHooks['LoadExtensionSchemaUpdates'][] = 'WikimaniaSchema::hook';
5156
5257 /**
5358 * Rights
@@ -59,8 +64,47 @@
6065 $wgGroupPermissions['sysop']['wikimania-admin'] = true;
6166
6267 /**
63 - * Configuration array for Wikimania
 68+ * Configuration array for Wikimania. It is a complex array, with many sub-options.
 69+ * Dates, unless otherwise specified, should be in MediaWiki timestamp format,
 70+ * that is: YYYYMMDDHHMMSS
 71+ *
 72+ * year => The year of the conference, 2011, 2012, etc.
 73+ * openDate => Date to begin accepting registrations
 74+ * closeDate => Date to end accepting registrations
 75+ * baseCurrency => All prices are in this currency
 76+ * country => Country hosting this year's Wikimania
 77+ * paymentClass => Which payment handler to use for checkout. Right now
 78+ * takes one of PaymentGoogleCheckout|PaymentPaypal
 79+ * (pre|main|post)Days => Arrays configuring the days available for registration
 80+ * for the conference, including pre-events (eg: Developer
 81+ * Days) and post-event days (unconference or tours). They
 82+ * should each be given a unique key, a date, price and url
 83+ * to describe the event.
6484 */
6585 $wgWikimaniaConf = array(
66 -
 86+ 'year' => 2012,
 87+ 'openDate' => '',
 88+ 'closeDate' => '',
 89+ 'baseCurrency' => 'USD',
 90+ 'country' => 'us',
 91+ 'paymentClass' => 'PaymentGoogleCheckout',
 92+ 'preDays' => array(
 93+ 'devday1' => array(
 94+ 'date' => '',
 95+ 'price' => '',
 96+ 'url' => '',
 97+ ),
 98+ 'devday2' => array(
 99+ 'date' => '',
 100+ 'price' => '',
 101+ ),
 102+ ),
 103+ 'mainDays' => array(
 104+
 105+ ),
 106+ 'postDays' => array(
 107+ 'unconf1' => array(
 108+
 109+ ),
 110+ ),
67111 );
Index: trunk/extensions/Wikimania/lang/Wikimania2012.i18n.php
@@ -0,0 +1,13 @@
 2+<?php
 3+/*
 4+ * Year-specific localization for 2012
 5+ */
 6+
 7+$messages = array();
 8+
 9+/**
 10+ * English
 11+ */
 12+$messages['en'] = array(
 13+
 14+);
Property changes on: trunk/extensions/Wikimania/lang/Wikimania2012.i18n.php
___________________________________________________________________
Added: svn:eol-style
115 + native
Index: trunk/extensions/Wikimania/lang/Wikimania.alias.php
@@ -0,0 +1,16 @@
 2+<?php
 3+/**
 4+ * Aliases for extension Wikimania
 5+ *
 6+ * @file
 7+ * @ingroup Extensions
 8+ */
 9+
 10+$specialPageAliases = array();
 11+
 12+/** English (English) */
 13+$specialPageAliases['en'] = array(
 14+ 'AdministerWikimania' => array( 'AdministerWikimania' ),
 15+ 'CheckWikimaniaStatus' => array( 'CheckWikimaniaStatus' ),
 16+ 'RegisterForWikimania' => array( 'RegisterForWikimania' ),
 17+);
Property changes on: trunk/extensions/Wikimania/lang/Wikimania.alias.php
___________________________________________________________________
Added: svn:eol-style
118 + native
Index: trunk/extensions/Wikimania/lang/Wikimania.i18n.php
@@ -0,0 +1,36 @@
 2+<?php
 3+/*
 4+ * i18n for Wikimania extension
 5+ */
 6+
 7+$messages = array();
 8+
 9+/**
 10+ * English
 11+ */
 12+$messages['en'] = array(
 13+ 'wikimania' => 'Wikimania',
 14+ 'wikimania-desc' => 'Extension designed to manage the annual Wikimania conference',
 15+ 'specialpages-group-wikimania' => 'Wikimania registration',
 16+ 'administerwikimania' => 'Administer Wikimania registrations',
 17+ 'checkwikimaniastatus' => 'Check Wikimania registration status',
 18+ 'registerforwikimania' => 'Register for Wikimania',
 19+ 'right-wikimania-admin' => 'Manage Wikimania registrations',
 20+ 'right-wikimania-register' => 'Register for Wikimania',
 21+ 'right-wikimania-checkstatus' => 'Check status of a Wikimania registration',
 22+);
 23+
 24+/**
 25+ * Message docs (qqq)
 26+ */
 27+$messages['qqq'] = array(
 28+ 'wikimania' => 'Name of the annual Wikimedia conference, called "Wikimania"',
 29+ 'wikimania-desc' => '{{desc}}',
 30+ 'specialpages-group-wikimania' => 'Group heading on Special:SpecialPages',
 31+ 'administerwikimania' => "Special page for administering people's Wikimania registrations",
 32+ 'checkwikimaniastatus' => 'Special page for a user to check their Wikimania registration status',
 33+ 'registerforwikimania' => 'Special page form for registering for Wikimania',
 34+ 'right-wikimania-admin' => 'User right for managing Wikimania registerations',
 35+ 'right-wikimania-register' => 'User right for registering for Wikimania',
 36+ 'right-wikimania-checkstatus' => 'User right for checking Wikimania registration status',
 37+);
Property changes on: trunk/extensions/Wikimania/lang/Wikimania.i18n.php
___________________________________________________________________
Added: svn:eol-style
138 + native
Index: trunk/extensions/Wikimania/backend/WikimaniaHooks.php
@@ -1,15 +0,0 @@
2 -<?php
3 -/*
4 - * Hook registration
5 - */
6 -
7 -class WikimaniaHooks {
8 - public static function onLoadExtensionSchemaUpdates( $updater = null ) {
9 - if( !$updater ) {
10 - $updater->output( "Wikimania Extension requires MW 1.17+" );
11 - } else {
12 -
13 - }
14 - return true;
15 - }
16 -}
Index: trunk/extensions/Wikimania/backend/Wikimania.php
@@ -0,0 +1,141 @@
 2+<?php
 3+/*
 4+ * Manager class for this year's Wikimania
 5+ */
 6+class Wikimania {
 7+ /**
 8+ * Singleton
 9+ * @var Wikimania
 10+ */
 11+ private static $i = null;
 12+
 13+ /**
 14+ * Payment handler
 15+ * @var Payment
 16+ */
 17+ private $paymentClass;
 18+
 19+ /**
 20+ * Year of Wikimania
 21+ * @var String
 22+ */
 23+ private $year;
 24+
 25+ /**
 26+ * Beginning registration date
 27+ * @var String
 28+ */
 29+ private $openDate;
 30+
 31+ /**
 32+ * Ending registration date
 33+ * @var String
 34+ */
 35+ private $closeDate;
 36+
 37+ /**
 38+ * Base currency code
 39+ * @var String
 40+ */
 41+ private $baseCurrency;
 42+
 43+ /**
 44+ * Country hosting Wikimania
 45+ * @var String
 46+ */
 47+ private $country;
 48+
 49+
 50+ /**
 51+ * Do a bit of delayed setup, based on this year's config
 52+ * @param $year int Year to host Wikimania for
 53+ */
 54+ public static function hostWikimania( $year ) {
 55+ if( !self::$i ) {
 56+ global $wgWikimaniaConf, $wgExtensionMessagesFiles;
 57+ if( !isset( $wgWikimaniaConf['year'] ) || $wgWikimaniaConf['year'] !== $year ) {
 58+ throw new MWException( "Trying to host Wikimania for invalid $year\n" );
 59+ }
 60+ self::$i = new self( $wgWikimaniaConf );
 61+ $wgExtensionmessagesFiles["wikimania-$year"] = dirname( __FILE__ ) .
 62+ "/lang/Wikimania{$year}.i18n.php";
 63+ } elseif( self::$i && self::$i->getYear() !== $year ) {
 64+ throw new MWException( "Can only host one year at a time!\n" );
 65+ }
 66+ }
 67+
 68+ /**
 69+ * Accessor for singleton
 70+ * @return Wikimania
 71+ */
 72+ public static function getWikimania() {
 73+ if( !self::$i ) {
 74+ throw new MWException( "Tried to getWikimania() with no instance found. Did you forget hostWikimania()?\n" );
 75+ }
 76+ return self::$i;
 77+ }
 78+
 79+ /**
 80+ * Constructor. Use the singleton
 81+ * @param $conf Array A $wgWikimaniaConf array
 82+ */
 83+ private function __construct( array $conf ) {
 84+ $baseRequiredConf = array( 'year', 'openDate', 'closeDate', 'baseCurrency', 'country' );
 85+ foreach( $baseRequiredConf as $confItem ) {
 86+ if( !isset( $conf[$confItem] ) ) {
 87+ throw new MWException( "Missing config item '$confItem'\n" );
 88+ }
 89+ $this->$confItem = $conf[$confItem];
 90+ }
 91+ $paymentClass = isset( $conf['paymentClass'] ) ? $conf['paymentClass'] : 'PaymentBogus';
 92+ $this->paymentClass = new $paymentClass( $this );
 93+ }
 94+
 95+ /**
 96+ * Get the configured payment handler
 97+ * @return Payment
 98+ */
 99+ public function getPaymentClass() {
 100+ return $this->paymentClass;
 101+ }
 102+
 103+ /**
 104+ * Get the year hosting Wikimania
 105+ * @return int
 106+ */
 107+ public function getYear() {
 108+ return $this->year;
 109+ }
 110+
 111+ /**
 112+ * Get the date we're opening registration on
 113+ * @return String
 114+ */
 115+ public function getOpenDate() {
 116+ return $this->openDate;
 117+ }
 118+
 119+ /**
 120+ * Get the date we're closing registration on
 121+ * @return String
 122+ */
 123+ public function getCloseDate() {
 124+ return $this->closeDate;
 125+ }
 126+
 127+ /**
 128+ * Get the currency code that all prices are configured in
 129+ * @return String
 130+ */
 131+ public function getBaseCurrency() {
 132+ return $this->baseCurrency;
 133+ }
 134+
 135+ /**
 136+ * Get the country code of the country hosting Wikimania
 137+ * @return String
 138+ */
 139+ public function getCountry() {
 140+ return $this->country;
 141+ }
 142+}
Property changes on: trunk/extensions/Wikimania/backend/Wikimania.php
___________________________________________________________________
Added: svn:eol-style
1143 + native
Index: trunk/extensions/Wikimania/backend/WikimaniaSchema.php
@@ -0,0 +1,20 @@
 2+<?php
 3+/*
 4+ * Schema generation and such
 5+ */
 6+
 7+class WikimaniaSchema {
 8+ /**
 9+ * Hook for LoadExtensionSchemaUpdates
 10+ * @param $updater DatabaseUpdater object
 11+ * @return bool
 12+ */
 13+ public static function hook( $updater = null ) {
 14+ if( !$updater ) {
 15+ $updater->output( "Wikimania Extension requires MW 1.17+" );
 16+ } else {
 17+
 18+ }
 19+ return true;
 20+ }
 21+}
Property changes on: trunk/extensions/Wikimania/backend/WikimaniaSchema.php
___________________________________________________________________
Added: svn:eol-style
122 + native
Index: trunk/extensions/Wikimania/backend/Payment.php
@@ -0,0 +1,25 @@
 2+<?php
 3+/*
 4+ * To change this template, choose Tools | Templates
 5+ * and open the template in the editor.
 6+ */
 7+
 8+abstract class Payment {
 9+ /**
 10+ * Return the form for this payment provider, in HTML
 11+ * @return String
 12+ */
 13+ abstract function getForm();
 14+}
 15+
 16+/**
 17+ * Bogus class designed to throw an exception when it's used
 18+ */
 19+class PaymentBogus extends Payment {
 20+ public function __construct() {
 21+ throw new MWException( "Bogus payment handler defined" );
 22+ }
 23+
 24+ /** no-op */
 25+ public function getForm() {}
 26+}
Property changes on: trunk/extensions/Wikimania/backend/Payment.php
___________________________________________________________________
Added: svn:eol-style
127 + native
Index: trunk/extensions/Wikimania/backend/PaymentGoogleCheckout.php
@@ -0,0 +1,10 @@
 2+<?php
 3+/*
 4+ * GoogleCheckout payment implementation
 5+ */
 6+
 7+class PaymentGoogleCheckout extends Payment {
 8+ public function getForm() {
 9+ return '';
 10+ }
 11+}
Property changes on: trunk/extensions/Wikimania/backend/PaymentGoogleCheckout.php
___________________________________________________________________
Added: svn:eol-style
112 + native
Index: trunk/extensions/Wikimania/backend/PaymentPaypal.php
@@ -0,0 +1,10 @@
 2+<?php
 3+/*
 4+ * Paypal payment implementation
 5+ */
 6+
 7+class PaymentPaypal extends Payment {
 8+ public function getForm() {
 9+ return '';
 10+ }
 11+}
Property changes on: trunk/extensions/Wikimania/backend/PaymentPaypal.php
___________________________________________________________________
Added: svn:eol-style
112 + native
Index: trunk/extensions/Wikimania/backend/WikimaniaRegistration.php
@@ -0,0 +1,20 @@
 2+<?php
 3+/*
 4+ * Class referring to a specific registration
 5+ */
 6+
 7+class WikimaniaRegistration {
 8+
 9+ private static function fieldList() {
 10+ return array(
 11+ );
 12+ }
 13+
 14+ public static function getFields() {
 15+ return array_keys( self::fieldList() );
 16+ }
 17+
 18+ public static function buildSchema() {
 19+
 20+ }
 21+}
Property changes on: trunk/extensions/Wikimania/backend/WikimaniaRegistration.php
___________________________________________________________________
Added: svn:eol-style
122 + native
Index: trunk/extensions/Wikimania/README
@@ -1,5 +1,7 @@
22 This extension is designed for managing the annual Wikimania conference.
33
4 -Install like a normal extension, run update.php to create tables.
5 -
6 -Configure $wgWikimaniaConf (see docs in Wikimania.php)
 4+* Install like a normal extension in LocalSettings.php
 5+* Configure $wgWikimaniaConf (see docs in Wikimania.php)
 6+* Add a line after your configuration called "Wikimania::host( 2012 );" where
 7+ '2012' is the year in question
 8+* Run update.php to create the schema

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r97396Initial framework for Extension:Wikimania so we can port the old thing over t...demon22:28, 17 September 2011

Status & tagging log