Index: trunk/extensions/Contest/Contest.i18n.php |
— | — | @@ -79,6 +79,7 @@ |
80 | 80 | 'editcontest-legend' => 'Contest', |
81 | 81 | 'contest-edit-name' => 'Contest name', |
82 | 82 | 'contest-edit-status' => 'Contest status', |
| 83 | + 'contest-edit-rulespage' => 'Rules page', |
83 | 84 | 'contest-edit-exists-already' => 'Note: you are editing an already existing contest, not creating a new one.', |
84 | 85 | 'contest-edit-submit' => 'Submit', |
85 | 86 | |
— | — | @@ -95,6 +96,13 @@ |
96 | 97 | |
97 | 98 | // Special:ContestSignup |
98 | 99 | '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]]', |
99 | 107 | |
100 | 108 | // Special:Contest |
101 | 109 | 'contest-contest-title' => 'Contest: $1', |
Index: trunk/extensions/Contest/specials/SpecialContestSignup.php |
— | — | @@ -36,9 +36,22 @@ |
37 | 37 | return; |
38 | 38 | } |
39 | 39 | |
| 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 ) { |
40 | 53 | $out = $this->getOutput(); |
41 | 54 | |
42 | | - $contest = Contest::s()->selectRow( null, array( 'name' => $subPage ) ); |
| 55 | + $contest = Contest::s()->selectRow( null, array( 'name' => $contestName ) ); |
43 | 56 | |
44 | 57 | if ( $contest === false ) { |
45 | 58 | $this->showError( 'contest-signup-unknown' ); |
— | — | @@ -48,6 +61,7 @@ |
49 | 62 | else { |
50 | 63 | // TODO: we might want to have a title field here |
51 | 64 | $out->setPageTitle( $contest->getField( 'name' ) ); |
| 65 | + $out->addWikiMsg( 'contest-signup-header', $contest->getField( 'name' ) ); |
52 | 66 | |
53 | 67 | $this->showSignupForm( $contest ); |
54 | 68 | } |
— | — | @@ -62,8 +76,67 @@ |
63 | 77 | */ |
64 | 78 | protected function showSignupForm( Contest $contest ) { |
65 | 79 | $out = $this->getOutput(); |
| 80 | + $form = new HTMLForm( $this->getFormFields( $contest ), $this->getContext() ); |
66 | 81 | |
| 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(); |
67 | 95 | |
| 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; |
68 | 141 | } |
69 | 142 | |
70 | 143 | } |
Index: trunk/extensions/Contest/specials/SpecialEditContest.php |
— | — | @@ -168,6 +168,11 @@ |
169 | 169 | 'options' => Contest::getStatusMessages() |
170 | 170 | ); |
171 | 171 | |
| 172 | + $fields['rules_page'] = array ( |
| 173 | + 'type' => 'text', |
| 174 | + 'label-message' => 'contest-edit-rulespage', |
| 175 | + ); |
| 176 | + |
172 | 177 | if ( $contest !== false ) { |
173 | 178 | foreach ( $fields as $name => $data ) { |
174 | 179 | $fields[$name]['default'] = $contest->getField( $name ); |
Index: trunk/extensions/Contest/includes/Contest.class.php |
— | — | @@ -91,6 +91,7 @@ |
92 | 92 | 'name' => 'str', |
93 | 93 | 'status' => 'int', |
94 | 94 | 'submission_count' => 'int', |
| 95 | + 'rules_page' => 'str', |
95 | 96 | ); |
96 | 97 | } |
97 | 98 | |
— | — | @@ -106,6 +107,7 @@ |
107 | 108 | 'name' => '', |
108 | 109 | 'status' => self::STATUS_DRAFT, |
109 | 110 | 'submission_count' => 0, |
| 111 | + 'rules_page' => '', |
110 | 112 | ); |
111 | 113 | } |
112 | 114 | |
Index: trunk/extensions/Contest/Contest.sql |
— | — | @@ -7,7 +7,8 @@ |
8 | 8 | contest_id SMALLINT unsigned NOT NULL auto_increment PRIMARY KEY, |
9 | 9 | contest_name VARCHAR(255) NOT NULL, -- String indentifier for the contest |
10 | 10 | 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 |
12 | 13 | ) /*$wgDBTableOptions*/; |
13 | 14 | |
14 | 15 | -- Contestants |