r99525 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99524‎ | r99525 | r99526 >
Date:18:34, 11 October 2011
Author:demon
Status:deferred (Comments)
Tags:
Comment:
Various work in progress on WM ext
Modified paths:
  • /trunk/extensions/Wikimania/Wikimania.php (modified) (history)
  • /trunk/extensions/Wikimania/backend/WikimaniaRegistration.php (modified) (history)
  • /trunk/extensions/Wikimania/lang/Wikimania.i18n.php (modified) (history)
  • /trunk/extensions/Wikimania/resources (added) (history)
  • /trunk/extensions/Wikimania/resources/ext.wikimania.css (added) (history)
  • /trunk/extensions/Wikimania/specials/SpecialRegisterForWikimania.php (modified) (history)
  • /trunk/extensions/Wikimania/sql/tables.sql (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikimania/Wikimania.php
@@ -64,6 +64,15 @@
6565 $wgGroupPermissions['sysop']['wikimania-admin'] = true;
6666
6767 /**
 68+ * RL
 69+ */
 70+$wgResourceModules['ext.wikimania'] = array(
 71+ 'localBasePath' => dirname( __FILE__ ) . '/resources',
 72+ 'remoteExtPath' => 'Wikimania/resources',
 73+ 'styles' => 'ext.wikimania.css',
 74+);
 75+
 76+/**
6877 * Configuration array for Wikimania. It is a complex array, with many sub-options.
6978 * Dates, unless otherwise specified, should be in MediaWiki timestamp format,
7079 * that is: YYYYMMDDHHMMSS
Index: trunk/extensions/Wikimania/sql/tables.sql
@@ -21,8 +21,8 @@
2222 -- Last name
2323 reg_lname varchar(255) not null,
2424
25 - -- Gender
26 - reg_sex varchar(1) not null,
 25+ -- Gender (male, female, decline)
 26+ reg_sex varchar(8) not null,
2727
2828 -- Country of residence
2929 reg_country varchar(4) not null,
Index: trunk/extensions/Wikimania/lang/Wikimania.i18n.php
@@ -18,6 +18,17 @@
1919 'right-wikimania-admin' => 'Manage Wikimania registrations',
2020 'right-wikimania-register' => 'Register for Wikimania',
2121 'right-wikimania-checkstatus' => 'Check status of a Wikimania registration',
 22+ 'wikimania-personal-info' => 'Personal identification data',
 23+ 'wikimania-reg-fname' => 'First name',
 24+ 'wikimania-reg-lname' => 'Last name',
 25+ 'wikimania-reg-gender' => 'Gender',
 26+ 'wikimania-reg-gender-decline' => 'Decline to answer',
 27+ 'wikimania-reg-country' => 'Country of residence',
 28+ 'wikimania-linguistic-abilities' => 'Linguistic abilities',
 29+ 'wikimania-reg-langn' => 'Native language',
 30+ 'wikimania-reg-lang1' => 'Second language',
 31+ 'wikimania-reg-lang2' => 'Third language',
 32+ 'wikimania-reg-lang3' => 'Fourth language',
2233 );
2334
2435 /**
@@ -33,4 +44,11 @@
3445 'right-wikimania-admin' => 'User right for managing Wikimania registerations',
3546 'right-wikimania-register' => 'User right for registering for Wikimania',
3647 'right-wikimania-checkstatus' => 'User right for checking Wikimania registration status',
 48+ 'wikimania-personal-info' => 'Section header for personal ID fields',
 49+ 'wikimania-reg-fname' => "User's given name for registration form",
 50+ 'wikimania-reg-lname' => "User's surname for registration form",
 51+ 'wikimania-reg-gender' => "User's gender for registration form",
 52+ 'wikimania-reg-gender-decline' => 'Option to decline answering "gender" question',
 53+ 'wikimania-reg-country' => 'Country the user lives in',
 54+ 'wikimania-linguistic-abilities' => "Form section for user's language abilities",
3755 );
Index: trunk/extensions/Wikimania/specials/SpecialRegisterForWikimania.php
@@ -9,6 +9,8 @@
1010
1111 public function execute( $par = '' ) {
1212 $this->setHeaders();
13 - $this->getOutput()->addHTML( '<p>Todo</p>' );
 13+ $this->getOutput()->addModules( 'ext.wikimania' );
 14+ $form = new WikimaniaRegistration( Wikimania::getWikimania(), $this->getContext() );
 15+ $form->show();
1416 }
1517 }
Index: trunk/extensions/Wikimania/backend/WikimaniaRegistration.php
@@ -2,18 +2,85 @@
33 /**
44 * Class referring to a specific registration
55 */
6 -class WikimaniaRegistration {
 6+class WikimaniaRegistration extends HTMLForm {
 7+ public function __construct( Wikimania $wm, $context = null ) {
 8+ parent::__construct( $this->getFields( $wm, $context->getUser() ), $context, 'wikimania' );
 9+ }
710
8 - private static function fieldList() {
9 - return array(
10 - );
 11+ public static function generateRegistrationID( User $u ) {
 12+ $str = $u->getName() . ":" . microtime() . ":" . wfGetIP();
 13+ return substr( sha1( $str ), 0, 5 );
1114 }
1215
13 - public static function getFields() {
14 - return array_keys( self::fieldList() );
 16+ private function getFields( Wikimania $wm, User $u ) {
 17+ static $fields;
 18+ if( !$fields ) {
 19+ $langList = array_flip( LanguageNames::getNames( $u->getOption( 'lang') ) );
 20+ $langListWithEmpty = $langList;
 21+ $langListWithEmpty[''] = '';
 22+ $fields = array(
 23+ /** PERSONAL INFORMATION **/
 24+ 'reg_fname' => array(
 25+ 'type' => 'text',
 26+ 'label-message' => 'wikimania-reg-fname',
 27+ 'section' => 'personal-info',
 28+ 'required' => true,
 29+ ),
 30+ 'reg_lname' => array(
 31+ 'type' => 'text',
 32+ 'label-message' => 'wikimania-reg-lname',
 33+ 'section' => 'personal-info',
 34+ 'required' => true,
 35+ ),
 36+ 'reg_gender' => array(
 37+ 'type' => 'radio',
 38+ 'label-message' => 'wikimania-reg-gender',
 39+ 'options' => self::getGenderPossibilities(),
 40+ 'section' => 'personal-info',
 41+ 'required' => true,
 42+ ),
 43+ 'reg_country' => array(
 44+ 'type' => 'select',
 45+ 'options' => array(),
 46+ 'section' => 'personal-info',
 47+ 'required' => true,
 48+ ),
 49+ /** LINGUISTIC ABILItIES **/
 50+ 'langn' => array(
 51+ 'type' => 'select',
 52+ 'label-message' => 'wikimania-reg-langn',
 53+ 'options' => $langList,
 54+ 'section' => 'linguistic-abilities',
 55+ 'required' => true,
 56+ ),
 57+ 'lang1' => array(
 58+ 'type' => 'select',
 59+ 'label-message' => 'wikimania-reg-lang1',
 60+ 'options' => $langListWithEmpty,
 61+ 'section' => 'linguistic-abilities',
 62+ ),
 63+ 'lang2' => array(
 64+ 'type' => 'select',
 65+ 'label-message' => 'wikimania-reg-lang2',
 66+ 'options' => $langListWithEmpty,
 67+ 'section' => 'linguistic-abilities',
 68+ ),
 69+ 'lang3' => array(
 70+ 'type' => 'select',
 71+ 'label-message' => 'wikimania-reg-lang3',
 72+ 'options' => $langListWithEmpty,
 73+ 'section' => 'linguistic-abilities',
 74+ ),
 75+ );
 76+ }
 77+ return $fields;
1578 }
1679
17 - public static function buildSchema() {
18 -
 80+ private static function getGenderPossibilities() {
 81+ return array(
 82+ wfMsg( 'gender-male') => 'male',
 83+ wfMsg( 'gender-female') => 'female',
 84+ wfMsg( 'wikimania-reg-gender-decline') => 'decline'
 85+ );
1986 }
2087 }
Index: trunk/extensions/Wikimania/resources/ext.wikimania.css
@@ -0,0 +1,3 @@
 2+/**
 3+ * CSS for Wikimania
 4+ */

Comments

#Comment by Nikerabbit (talk | contribs)   19:59, 11 October 2011

l33t ABILItIES? :)

#Comment by 😂 (talk | contribs)   20:20, 11 October 2011

ya rly!

Status & tagging log