Index: trunk/extensions/Contest/Contest.i18n.php |
— | — | @@ -94,7 +94,7 @@ |
95 | 95 | // Special:ContestWelcome |
96 | 96 | 'contest-welcome-unknown' => 'There is no contest with the provided name.', |
97 | 97 | |
98 | | - // Special:ContestSignup |
| 98 | + // Special:ContestSignup & Special:ContestSubmission |
99 | 99 | 'contest-signup-unknown' => 'There is no contest with the provided name.', |
100 | 100 | 'contest-signup-submit' => 'Signup', |
101 | 101 | 'contest-signup-header' => 'Please fill out the form to complete your registration for $1.', |
— | — | @@ -105,11 +105,12 @@ |
106 | 106 | 'contest-signup-readrules' => 'I confirm that I have read, and agree to, [[$1|the contest rules]]', |
107 | 107 | 'contest-signup-challange' => 'What challange do you want to take on?', |
108 | 108 | 'contest-signup-finished' => 'This contest has ended.', |
| 109 | + 'contest-signup-country' => 'Your country', |
109 | 110 | |
110 | 111 | // Special:ContestSubmission |
111 | 112 | 'contest-submission-submit' => 'Submit', |
112 | 113 | 'contest-submission-unknown' => 'There is no contest with the provided name.', |
113 | | - 'contest-submission-header' => 'On this page you can modify your submission untill the deadline.', |
| 114 | + 'contest-submission-header' => 'On this page you can modify your submission until the deadline.', |
114 | 115 | 'contest-submission-finished' => 'This contest has ended.', |
115 | 116 | |
116 | 117 | // Special:Contest |
Index: trunk/extensions/Contest/specials/SpecialContestSubmission.php |
— | — | @@ -46,8 +46,8 @@ |
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
| 50 | + * Handle view requests for the page. |
50 | 51 | * |
51 | | - * |
52 | 52 | * @since 0.1 |
53 | 53 | * |
54 | 54 | * @param string $contestName |
— | — | @@ -79,6 +79,13 @@ |
80 | 80 | } |
81 | 81 | } |
82 | 82 | |
| 83 | + /** |
| 84 | + * Handle page request when the contest is enabled. |
| 85 | + * |
| 86 | + * @since 0.1 |
| 87 | + * |
| 88 | + * @param Contest $contest |
| 89 | + */ |
83 | 90 | protected function handleEnabledPage( Contest $contest ) { |
84 | 91 | // Check if the user is already a contestant in this contest. |
85 | 92 | // If he is, reirect to submission page, else show signup form. |
— | — | @@ -99,6 +106,13 @@ |
100 | 107 | } |
101 | 108 | } |
102 | 109 | |
| 110 | + /** |
| 111 | + * Show the page content. |
| 112 | + * |
| 113 | + * @since 0.1 |
| 114 | + * |
| 115 | + * @param ContestContestant $contestant |
| 116 | + */ |
103 | 117 | protected function showPage( ContestContestant $contestant ) { |
104 | 118 | $this->getOutput()->setPageTitle( $contestant->getContest()->getField( 'name' ) ); |
105 | 119 | $this->getOutput()->addWikiMsg( 'contest-submission-header', $contestant->getContest()->getField( 'name' ) ); |
— | — | @@ -126,6 +140,7 @@ |
127 | 141 | |
128 | 142 | $user->setEmail( $data['contestant-email'] ); |
129 | 143 | $user->setRealName( $data['contestant-realname'] ); |
| 144 | + $user->saveSettings(); |
130 | 145 | |
131 | 146 | $contestant = new ContestContestant( array( |
132 | 147 | 'id' => $data['contestant-id'], |
— | — | @@ -171,6 +186,13 @@ |
172 | 187 | 'validation-callback' => array( __CLASS__, 'validateEmailField' ) |
173 | 188 | ); |
174 | 189 | |
| 190 | + $fields['contestant-country'] = array( |
| 191 | + 'type' => 'select', |
| 192 | + 'label-message' => 'contest-signup-country', |
| 193 | + 'required' => true, |
| 194 | + 'options' => ContestContestant::getCountriesForInput() |
| 195 | + ); |
| 196 | + |
175 | 197 | $fields['contestant-volunteer'] = array( |
176 | 198 | 'type' => 'check', |
177 | 199 | 'default' => '0', |
Index: trunk/extensions/Contest/specials/SpecialContestSignup.php |
— | — | @@ -56,6 +56,7 @@ |
57 | 57 | |
58 | 58 | $user->setEmail( $data['contestant-email'] ); |
59 | 59 | $user->setRealName( $data['contestant-realname'] ); |
| 60 | + $user->saveSettings(); |
60 | 61 | |
61 | 62 | $contestant = new ContestContestant( array( |
62 | 63 | 'contest_id' => $data['contest-id'], |
— | — | @@ -103,6 +104,13 @@ |
104 | 105 | } |
105 | 106 | } |
106 | 107 | |
| 108 | + /** |
| 109 | + * Handle page request when the contest is enabled. |
| 110 | + * |
| 111 | + * @since 0.1 |
| 112 | + * |
| 113 | + * @param Contest $contest |
| 114 | + */ |
107 | 115 | protected function showEnabledPage( Contest $contest ) { |
108 | 116 | $out = $this->getOutput(); |
109 | 117 | |
— | — | @@ -193,6 +201,13 @@ |
194 | 202 | 'validation-callback' => array( __CLASS__, 'validateEmailField' ) |
195 | 203 | ); |
196 | 204 | |
| 205 | + $fields['contestant-country'] = array( |
| 206 | + 'type' => 'select', |
| 207 | + 'label-message' => 'contest-signup-country', |
| 208 | + 'required' => true, |
| 209 | + 'options' => ContestContestant::getCountriesForInput() |
| 210 | + ); |
| 211 | + |
197 | 212 | $fields['contestant-challangeid'] = array( |
198 | 213 | 'type' => 'radio', |
199 | 214 | 'label-message' => 'contest-signup-challange', |
Index: trunk/extensions/Contest/includes/ContestContestant.php |
— | — | @@ -143,6 +143,276 @@ |
144 | 144 | */ |
145 | 145 | public function setContest( Contest $contest ) { |
146 | 146 | $this->contest = $contest; |
147 | | - } |
| 147 | + } |
148 | 148 | |
| 149 | + /** |
| 150 | + * Returns a list of countries and their corresponding country |
| 151 | + * codes that can be fed directly into an HTML input. |
| 152 | + * |
| 153 | + * @since 0.1 |
| 154 | + * |
| 155 | + * @return array |
| 156 | + */ |
| 157 | + public static function getCountriesForInput() { |
| 158 | + $countries = array(); |
| 159 | + |
| 160 | + foreach ( self::getCountries() as $code => $name ) { |
| 161 | + $countries["$code - $name"] = $code; |
| 162 | + } |
| 163 | + |
| 164 | + return $countries; |
| 165 | + } |
| 166 | + |
| 167 | + /** |
| 168 | + * Returns a list of ISO 3166-1-alpha-2 country codes (keys) and their corresponding country (values). |
| 169 | + * |
| 170 | + * @since 0.1 |
| 171 | + * |
| 172 | + * @return array |
| 173 | + */ |
| 174 | + public static function getCountries() { |
| 175 | + return array( |
| 176 | + 'AF' => 'Afghanistan', |
| 177 | + 'AL' => 'Albania', |
| 178 | + 'DZ' => 'Algeria', |
| 179 | + 'AS' => 'American Samoa', |
| 180 | + 'AD' => 'Andorra', |
| 181 | + 'AO' => 'Angola', |
| 182 | + 'AI' => 'Anguilla', |
| 183 | + 'AQ' => 'Antarctica', |
| 184 | + 'AG' => 'Antigua and Barbuda', |
| 185 | + 'AR' => 'Argentina', |
| 186 | + 'AM' => 'Armenia', |
| 187 | + 'AW' => 'Aruba', |
| 188 | + 'AU' => 'Australia', |
| 189 | + 'AT' => 'Austria', |
| 190 | + 'AZ' => 'Azerbaijan', |
| 191 | + 'BS' => 'Bahamas', |
| 192 | + 'BH' => 'Bahrain', |
| 193 | + 'BD' => 'Bangladesh', |
| 194 | + 'BB' => 'Barbados', |
| 195 | + 'BY' => 'Belarus', |
| 196 | + 'BE' => 'Belgium', |
| 197 | + 'BZ' => 'Belize', |
| 198 | + 'BJ' => 'Benin', |
| 199 | + 'BM' => 'Bermuda', |
| 200 | + 'BT' => 'Bhutan', |
| 201 | + 'BO' => 'Bolivia', |
| 202 | + 'BA' => 'Bosnia and Herzegovina', |
| 203 | + 'BW' => 'Botswana', |
| 204 | + 'BV' => 'Bouvet Island', |
| 205 | + 'BR' => 'Brazil', |
| 206 | + 'IO' => 'British Indian Ocean Territory', |
| 207 | + 'BN' => 'Brunei Darussalam', |
| 208 | + 'BG' => 'Bulgaria', |
| 209 | + 'BF' => 'Burkina Faso', |
| 210 | + 'BI' => 'Burundi', |
| 211 | + 'KH' => 'Cambodia', |
| 212 | + 'CM' => 'Cameroon', |
| 213 | + 'CA' => 'Canada', |
| 214 | + 'CV' => 'Cape Verde', |
| 215 | + 'KY' => 'Cayman Islands', |
| 216 | + 'CF' => 'Central African Republic', |
| 217 | + 'TD' => 'Chad', |
| 218 | + 'CL' => 'Chile', |
| 219 | + 'CN' => 'China', |
| 220 | + 'CX' => 'Christmas Island', |
| 221 | + 'CC' => 'Cocos (Keeling) Islands', |
| 222 | + 'CO' => 'Colombia', |
| 223 | + 'KM' => 'Comoros', |
| 224 | + 'CG' => 'Congo', |
| 225 | + 'CD' => 'Congo, the Democratic Republic of the', |
| 226 | + 'CK' => 'Cook Islands', |
| 227 | + 'CR' => 'Costa Rica', |
| 228 | + 'CI' => "Cote D'Ivoire", |
| 229 | + 'HR' => 'Croatia', |
| 230 | + 'CU' => 'Cuba', |
| 231 | + 'CY' => 'Cyprus', |
| 232 | + 'CZ' => 'Czech Republic', |
| 233 | + 'DK' => 'Denmark', |
| 234 | + 'DJ' => 'Djibouti', |
| 235 | + 'DM' => 'Dominica', |
| 236 | + 'DO' => 'Dominican Republic', |
| 237 | + 'EC' => 'Ecuador', |
| 238 | + 'EG' => 'Egypt', |
| 239 | + 'SV' => 'El Salvador', |
| 240 | + 'GQ' => 'Equatorial Guinea', |
| 241 | + 'ER' => 'Eritrea', |
| 242 | + 'EE' => 'Estonia', |
| 243 | + 'ET' => 'Ethiopia', |
| 244 | + 'FK' => 'Falkland Islands (Malvinas)', |
| 245 | + 'FO' => 'Faroe Islands', |
| 246 | + 'FJ' => 'Fiji', |
| 247 | + 'FI' => 'Finland', |
| 248 | + 'FR' => 'France', |
| 249 | + 'GF' => 'French Guiana', |
| 250 | + 'PF' => 'French Polynesia', |
| 251 | + 'TF' => 'French Southern Territories', |
| 252 | + 'GA' => 'Gabon', |
| 253 | + 'GM' => 'Gambia', |
| 254 | + 'GE' => 'Georgia', |
| 255 | + 'DE' => 'Germany', |
| 256 | + 'GH' => 'Ghana', |
| 257 | + 'GI' => 'Gibraltar', |
| 258 | + 'GR' => 'Greece', |
| 259 | + 'GL' => 'Greenland', |
| 260 | + 'GD' => 'Grenada', |
| 261 | + 'GP' => 'Guadeloupe', |
| 262 | + 'GU' => 'Guam', |
| 263 | + 'GT' => 'Guatemala', |
| 264 | + 'GN' => 'Guinea', |
| 265 | + 'GW' => 'Guinea-Bissau', |
| 266 | + 'GY' => 'Guyana', |
| 267 | + 'HT' => 'Haiti', |
| 268 | + 'HM' => 'Heard Island and Mcdonald Islands', |
| 269 | + 'VA' => 'Holy See (Vatican City State)', |
| 270 | + 'HN' => 'Honduras', |
| 271 | + 'HK' => 'Hong Kong', |
| 272 | + 'HU' => 'Hungary', |
| 273 | + 'IS' => 'Iceland', |
| 274 | + 'IN' => 'India', |
| 275 | + 'ID' => 'Indonesia', |
| 276 | + 'IR' => 'Iran, Islamic Republic of', |
| 277 | + 'IQ' => 'Iraq', |
| 278 | + 'IE' => 'Ireland', |
| 279 | + 'IL' => 'Israel', |
| 280 | + 'IT' => 'Italy', |
| 281 | + 'JM' => 'Jamaica', |
| 282 | + 'JP' => 'Japan', |
| 283 | + 'JO' => 'Jordan', |
| 284 | + 'KZ' => 'Kazakhstan', |
| 285 | + 'KE' => 'Kenya', |
| 286 | + 'KI' => 'Kiribati', |
| 287 | + 'KP' => "Korea, Democratic People's Republic of", |
| 288 | + 'KR' => 'Korea, Republic of', |
| 289 | + 'KW' => 'Kuwait', |
| 290 | + 'KG' => 'Kyrgyzstan', |
| 291 | + 'LA' => "Lao People's Democratic Republic", |
| 292 | + 'LV' => 'Latvia', |
| 293 | + 'LB' => 'Lebanon', |
| 294 | + 'LS' => 'Lesotho', |
| 295 | + 'LR' => 'Liberia', |
| 296 | + 'LY' => 'Libyan Arab Jamahiriya', |
| 297 | + 'LI' => 'Liechtenstein', |
| 298 | + 'LT' => 'Lithuania', |
| 299 | + 'LU' => 'Luxembourg', |
| 300 | + 'MO' => 'Macao', |
| 301 | + 'MK' => 'Macedonia, the Former Yugoslav Republic of', |
| 302 | + 'MG' => 'Madagascar', |
| 303 | + 'MW' => 'Malawi', |
| 304 | + 'MY' => 'Malaysia', |
| 305 | + 'MV' => 'Maldives', |
| 306 | + 'ML' => 'Mali', |
| 307 | + 'MT' => 'Malta', |
| 308 | + 'MH' => 'Marshall Islands', |
| 309 | + 'MQ' => 'Martinique', |
| 310 | + 'MR' => 'Mauritania', |
| 311 | + 'MU' => 'Mauritius', |
| 312 | + 'YT' => 'Mayotte', |
| 313 | + 'MX' => 'Mexico', |
| 314 | + 'FM' => 'Micronesia, Federated States of', |
| 315 | + 'MD' => 'Moldova, Republic of', |
| 316 | + 'MC' => 'Monaco', |
| 317 | + 'MN' => 'Mongolia', |
| 318 | + 'MS' => 'Montserrat', |
| 319 | + 'MA' => 'Morocco', |
| 320 | + 'MZ' => 'Mozambique', |
| 321 | + 'MM' => 'Myanmar', |
| 322 | + 'NA' => 'Namibia', |
| 323 | + 'NR' => 'Nauru', |
| 324 | + 'NP' => 'Nepal', |
| 325 | + 'NL' => 'Netherlands', |
| 326 | + 'AN' => 'Netherlands Antilles', |
| 327 | + 'NC' => 'New Caledonia', |
| 328 | + 'NZ' => 'New Zealand', |
| 329 | + 'NI' => 'Nicaragua', |
| 330 | + 'NE' => 'Niger', |
| 331 | + 'NG' => 'Nigeria', |
| 332 | + 'NU' => 'Niue', |
| 333 | + 'NF' => 'Norfolk Island', |
| 334 | + 'MP' => 'Northern Mariana Islands', |
| 335 | + 'NO' => 'Norway', |
| 336 | + 'OM' => 'Oman', |
| 337 | + 'PK' => 'Pakistan', |
| 338 | + 'PW' => 'Palau', |
| 339 | + 'PS' => 'Palestinian Territory, Occupied', |
| 340 | + 'PA' => 'Panama', |
| 341 | + 'PG' => 'Papua New Guinea', |
| 342 | + 'PY' => 'Paraguay', |
| 343 | + 'PE' => 'Peru', |
| 344 | + 'PH' => 'Philippines', |
| 345 | + 'PN' => 'Pitcairn', |
| 346 | + 'PL' => 'Poland', |
| 347 | + 'PT' => 'Portugal', |
| 348 | + 'PR' => 'Puerto Rico', |
| 349 | + 'QA' => 'Qatar', |
| 350 | + 'RE' => 'Reunion', |
| 351 | + 'RO' => 'Romania', |
| 352 | + 'RU' => 'Russian Federation', |
| 353 | + 'RW' => 'Rwanda', |
| 354 | + 'SH' => 'Saint Helena', |
| 355 | + 'KN' => 'Saint Kitts and Nevis', |
| 356 | + 'LC' => 'Saint Lucia', |
| 357 | + 'PM' => 'Saint Pierre and Miquelon', |
| 358 | + 'VC' => 'Saint Vincent and the Grenadines', |
| 359 | + 'WS' => 'Samoa', |
| 360 | + 'SM' => 'San Marino', |
| 361 | + 'ST' => 'Sao Tome and Principe', |
| 362 | + 'SA' => 'Saudi Arabia', |
| 363 | + 'SN' => 'Senegal', |
| 364 | + 'CS' => 'Serbia and Montenegro', |
| 365 | + 'SC' => 'Seychelles', |
| 366 | + 'SL' => 'Sierra Leone', |
| 367 | + 'SG' => 'Singapore', |
| 368 | + 'SK' => 'Slovakia', |
| 369 | + 'SI' => 'Slovenia', |
| 370 | + 'SB' => 'Solomon Islands', |
| 371 | + 'SO' => 'Somalia', |
| 372 | + 'ZA' => 'South Africa', |
| 373 | + //'GS' => 'South Georgia and the South Sandwich Islands', |
| 374 | + 'ES' => 'Spain', |
| 375 | + 'LK' => 'Sri Lanka', |
| 376 | + 'SD' => 'Sudan', |
| 377 | + 'SR' => 'Suriname', |
| 378 | + 'SJ' => 'Svalbard and Jan Mayen', |
| 379 | + 'SZ' => 'Swaziland', |
| 380 | + 'SE' => 'Sweden', |
| 381 | + 'CH' => 'Switzerland', |
| 382 | + 'SY' => 'Syrian Arab Republic', |
| 383 | + 'TW' => 'Taiwan, Province of China', |
| 384 | + 'TJ' => 'Tajikistan', |
| 385 | + 'TZ' => 'Tanzania, United Republic of', |
| 386 | + 'TH' => 'Thailand', |
| 387 | + 'TL' => 'Timor-Leste', |
| 388 | + 'TG' => 'Togo', |
| 389 | + 'TK' => 'Tokelau', |
| 390 | + 'TO' => 'Tonga', |
| 391 | + 'TT' => 'Trinidad and Tobago', |
| 392 | + 'TN' => 'Tunisia', |
| 393 | + 'TR' => 'Turkey', |
| 394 | + 'TM' => 'Turkmenistan', |
| 395 | + 'TC' => 'Turks and Caicos Islands', |
| 396 | + 'TV' => 'Tuvalu', |
| 397 | + 'UG' => 'Uganda', |
| 398 | + 'UA' => 'Ukraine', |
| 399 | + 'AE' => 'United Arab Emirates', |
| 400 | + 'GB' => 'United Kingdom', |
| 401 | + 'US' => 'United States', |
| 402 | + 'UM' => 'United States Minor Outlying Islands', |
| 403 | + 'UY' => 'Uruguay', |
| 404 | + 'UZ' => 'Uzbekistan', |
| 405 | + 'VU' => 'Vanuatu', |
| 406 | + 'VE' => 'Venezuela', |
| 407 | + 'VN' => 'Viet Nam', |
| 408 | + 'VG' => 'Virgin Islands, British', |
| 409 | + 'VI' => 'Virgin Islands, U.s.', |
| 410 | + 'WF' => 'Wallis and Futuna', |
| 411 | + 'EH' => 'Western Sahara', |
| 412 | + 'YE' => 'Yemen', |
| 413 | + 'ZM' => 'Zambia', |
| 414 | + 'ZW' => 'Zimbabwe' |
| 415 | + ); |
| 416 | + } |
| 417 | + |
| 418 | + |
149 | 419 | } |
Index: trunk/extensions/Contest/Contest.sql |
— | — | @@ -24,7 +24,7 @@ |
25 | 25 | contestant_email TINYBLOB NOT NULL, -- Email of the contestant |
26 | 26 | |
27 | 27 | -- Extra contestant info |
28 | | - contestant_country VARCHAR(255) NOT NULL, -- Country of the contestant |
| 28 | + contestant_country VARCHAR(255) NOT NULL, -- Country code of the contestant |
29 | 29 | contestant_volunteer TINYINT unsigned NOT NULL, -- If the user is interested in voluneer oportunities |
30 | 30 | contestant_wmf TINYINT unsigned NOT NULL, -- If the user is interested in a WMF job |
31 | 31 | |