Index: trunk/extensions/Wikimania/Wikimania.php |
— | — | @@ -64,6 +64,15 @@ |
65 | 65 | $wgGroupPermissions['sysop']['wikimania-admin'] = true; |
66 | 66 | |
67 | 67 | /** |
| 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 | +/** |
68 | 77 | * Configuration array for Wikimania. It is a complex array, with many sub-options. |
69 | 78 | * Dates, unless otherwise specified, should be in MediaWiki timestamp format, |
70 | 79 | * that is: YYYYMMDDHHMMSS |
Index: trunk/extensions/Wikimania/sql/tables.sql |
— | — | @@ -21,8 +21,8 @@ |
22 | 22 | -- Last name |
23 | 23 | reg_lname varchar(255) not null, |
24 | 24 | |
25 | | - -- Gender |
26 | | - reg_sex varchar(1) not null, |
| 25 | + -- Gender (male, female, decline) |
| 26 | + reg_sex varchar(8) not null, |
27 | 27 | |
28 | 28 | -- Country of residence |
29 | 29 | reg_country varchar(4) not null, |
Index: trunk/extensions/Wikimania/lang/Wikimania.i18n.php |
— | — | @@ -18,6 +18,17 @@ |
19 | 19 | 'right-wikimania-admin' => 'Manage Wikimania registrations', |
20 | 20 | 'right-wikimania-register' => 'Register for Wikimania', |
21 | 21 | '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', |
22 | 33 | ); |
23 | 34 | |
24 | 35 | /** |
— | — | @@ -33,4 +44,11 @@ |
34 | 45 | 'right-wikimania-admin' => 'User right for managing Wikimania registerations', |
35 | 46 | 'right-wikimania-register' => 'User right for registering for Wikimania', |
36 | 47 | '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", |
37 | 55 | ); |
Index: trunk/extensions/Wikimania/specials/SpecialRegisterForWikimania.php |
— | — | @@ -9,6 +9,8 @@ |
10 | 10 | |
11 | 11 | public function execute( $par = '' ) { |
12 | 12 | $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(); |
14 | 16 | } |
15 | 17 | } |
Index: trunk/extensions/Wikimania/backend/WikimaniaRegistration.php |
— | — | @@ -2,18 +2,85 @@ |
3 | 3 | /** |
4 | 4 | * Class referring to a specific registration |
5 | 5 | */ |
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 | + } |
7 | 10 | |
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 ); |
11 | 14 | } |
12 | 15 | |
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; |
15 | 78 | } |
16 | 79 | |
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 | + ); |
19 | 86 | } |
20 | 87 | } |
Index: trunk/extensions/Wikimania/resources/ext.wikimania.css |
— | — | @@ -0,0 +1,3 @@ |
| 2 | +/** |
| 3 | + * CSS for Wikimania |
| 4 | + */ |