r98434 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98433‎ | r98434 | r98435 >
Date:19:23, 29 September 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
work on signup form
Modified paths:
  • /trunk/extensions/Contest/Contest.i18n.php (modified) (history)
  • /trunk/extensions/Contest/Contest.sql (modified) (history)
  • /trunk/extensions/Contest/includes/Contest.class.php (modified) (history)
  • /trunk/extensions/Contest/specials/SpecialContestSignup.php (modified) (history)
  • /trunk/extensions/Contest/specials/SpecialEditContest.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Contest/Contest.i18n.php
@@ -79,6 +79,7 @@
8080 'editcontest-legend' => 'Contest',
8181 'contest-edit-name' => 'Contest name',
8282 'contest-edit-status' => 'Contest status',
 83+ 'contest-edit-rulespage' => 'Rules page',
8384 'contest-edit-exists-already' => 'Note: you are editing an already existing contest, not creating a new one.',
8485 'contest-edit-submit' => 'Submit',
8586
@@ -95,6 +96,13 @@
9697
9798 // Special:ContestSignup
9899 'contest-signup-unknown' => 'There is no contest with the provided name.',
 100+ 'contest-signup-submit' => 'Signup',
 101+ 'contest-signup-header' => 'Please fill out the form to complete your registration for $1.',
 102+ 'contest-signup-email' => 'Your email address',
 103+ 'contest-signup-realname' => 'Your real name',
 104+ 'contest-signup-volunteer' => 'I am interested in volunteer opportunities',
 105+ 'contest-signup-wmf' => 'I am interested in working for the Wikimedia Foundation',
 106+ 'contest-signup-readrules' => 'I confirm that I have read, and agree to, [[$1|the contest rules]]',
99107
100108 // Special:Contest
101109 'contest-contest-title' => 'Contest: $1',
Index: trunk/extensions/Contest/specials/SpecialContestSignup.php
@@ -36,9 +36,22 @@
3737 return;
3838 }
3939
 40+ if ( $this->getRequest()->wasPosted() && $this->getUser()->matchEditToken( $this->getRequest()->getVal( 'wpEditToken' ) ) ) {
 41+ $this->handleSubmission();
 42+ }
 43+ else {
 44+ $this->showPage( $subPage );
 45+ }
 46+ }
 47+
 48+ protected function handleSubmission() {
 49+
 50+ }
 51+
 52+ protected function showPage( $contestName ) {
4053 $out = $this->getOutput();
4154
42 - $contest = Contest::s()->selectRow( null, array( 'name' => $subPage ) );
 55+ $contest = Contest::s()->selectRow( null, array( 'name' => $contestName ) );
4356
4457 if ( $contest === false ) {
4558 $this->showError( 'contest-signup-unknown' );
@@ -48,6 +61,7 @@
4962 else {
5063 // TODO: we might want to have a title field here
5164 $out->setPageTitle( $contest->getField( 'name' ) );
 65+ $out->addWikiMsg( 'contest-signup-header', $contest->getField( 'name' ) );
5266
5367 $this->showSignupForm( $contest );
5468 }
@@ -62,8 +76,67 @@
6377 */
6478 protected function showSignupForm( Contest $contest ) {
6579 $out = $this->getOutput();
 80+ $form = new HTMLForm( $this->getFormFields( $contest ), $this->getContext() );
6681
 82+ $form->setSubmitText( wfMsg( 'contest-signup-submit' ) );
 83+ $form->show();
 84+ }
 85+
 86+ /**
 87+ * Gets the field definitions for the form.
 88+ *
 89+ * @since 0.1
 90+ *
 91+ * @param Contest $contest
 92+ */
 93+ protected function getFormFields( Contest $contest ) {
 94+ $fields = array();
6795
 96+ $user = $this->getUser();
 97+
 98+ $fields[] = array(
 99+ 'type' => 'hidden',
 100+ 'default' => $contest->getId(),
 101+ 'name' => 'contest-id',
 102+ 'id' => 'contest-id',
 103+ );
 104+
 105+ $fields[] = array(
 106+ 'type' => 'text',
 107+ 'default' => $user->getRealName(),
 108+ 'label-message' => 'contest-signup-realname',
 109+ 'name' => 'contestant-realname',
 110+ );
 111+
 112+ $fields[] = array(
 113+ 'type' => 'text',
 114+ 'default' => $user->getEmail(),
 115+ 'label-message' => 'contest-signup-email',
 116+ 'name' => 'contestant-email',
 117+ );
 118+
 119+ $fields[] = array(
 120+ 'type' => 'check',
 121+ 'default' => '0',
 122+ 'label-message' => 'contest-signup-volunteer',
 123+ 'name' => 'contestant-volunteer',
 124+ );
 125+
 126+ $fields[] = array(
 127+ 'type' => 'check',
 128+ 'default' => '0',
 129+ 'label-message' => 'contest-signup-wmf',
 130+ 'name' => 'contestant-wmf',
 131+ );
 132+
 133+ $fields[] = array(
 134+ 'type' => 'check',
 135+ 'default' => '0',
 136+ 'label-message' => array( 'contest-signup-readrules', $contest->getField( 'rules_page' ) ),
 137+ 'name' => 'contestant-readrules',
 138+ );
 139+
 140+ return $fields;
68141 }
69142
70143 }
Index: trunk/extensions/Contest/specials/SpecialEditContest.php
@@ -168,6 +168,11 @@
169169 'options' => Contest::getStatusMessages()
170170 );
171171
 172+ $fields['rules_page'] = array (
 173+ 'type' => 'text',
 174+ 'label-message' => 'contest-edit-rulespage',
 175+ );
 176+
172177 if ( $contest !== false ) {
173178 foreach ( $fields as $name => $data ) {
174179 $fields[$name]['default'] = $contest->getField( $name );
Index: trunk/extensions/Contest/includes/Contest.class.php
@@ -91,6 +91,7 @@
9292 'name' => 'str',
9393 'status' => 'int',
9494 'submission_count' => 'int',
 95+ 'rules_page' => 'str',
9596 );
9697 }
9798
@@ -106,6 +107,7 @@
107108 'name' => '',
108109 'status' => self::STATUS_DRAFT,
109110 'submission_count' => 0,
 111+ 'rules_page' => '',
110112 );
111113 }
112114
Index: trunk/extensions/Contest/Contest.sql
@@ -7,7 +7,8 @@
88 contest_id SMALLINT unsigned NOT NULL auto_increment PRIMARY KEY,
99 contest_name VARCHAR(255) NOT NULL, -- String indentifier for the contest
1010 contest_status TINYINT unsigned NOT NULL default '0', -- Status of the contest
11 - contest_submission_count SMALLINT unsigned NOT NULL --
 11+ contest_submission_count SMALLINT unsigned NOT NULL, --
 12+ contest_rules_page VARCHAR(255) NOT NULL
1213 ) /*$wgDBTableOptions*/;
1314
1415 -- Contestants

Status & tagging log