Index: trunk/extensions/Contest/Contest.i18n.php |
— | — | @@ -107,6 +107,7 @@ |
108 | 108 | 'contest-signup-realname' => 'Your real name', |
109 | 109 | 'contest-signup-volunteer' => 'I am interested in volunteer opportunities', |
110 | 110 | 'contest-signup-wmf' => 'I am interested in working for the Wikimedia Foundation', |
| 111 | + 'contest-signup-cv' => 'Link to your CV', |
111 | 112 | 'contest-signup-readrules' => 'I confirm that I have read, and agree to, [[$1|the contest rules]]', |
112 | 113 | 'contest-signup-challenge' => 'What challenge do you want to take on?', |
113 | 114 | 'contest-signup-finished' => 'This contest has ended.', |
— | — | @@ -118,6 +119,7 @@ |
119 | 120 | 'contest-signup-invalid-email' => 'The email address you provided is not valid.', |
120 | 121 | 'contest-signup-invalid-name' => 'The name you provided is to short.', |
121 | 122 | 'contest-signup-require-challenge' => 'You must select a challenge.', |
| 123 | + 'contest-signup-invalid-cv' => 'You entered an invalid URL.', |
122 | 124 | |
123 | 125 | // Special:ContestSubmission |
124 | 126 | 'contest-submission-submit' => 'Submit', |
Index: trunk/extensions/Contest/specials/SpecialContestSubmission.php |
— | — | @@ -148,6 +148,7 @@ |
149 | 149 | |
150 | 150 | 'volunteer' => $data['contestant-volunteer'], |
151 | 151 | 'wmf' => $data['contestant-wmf'], |
| 152 | + 'cv' => $data['contestant-cv'], |
152 | 153 | ) ); |
153 | 154 | |
154 | 155 | return $contestant->writeToDB(); |
— | — | @@ -207,6 +208,15 @@ |
208 | 209 | 'label-message' => 'contest-signup-wmf', |
209 | 210 | ); |
210 | 211 | |
| 212 | + $hasWMF = $contestant->hasField( 'wmf' ); |
| 213 | + |
| 214 | + $fields['contestant-cv'] = array( |
| 215 | + 'type' => $hasWMF && $contestant->getField( 'wmf' ) ? 'text' : 'hidden', |
| 216 | + 'default' => $hasWMF ? $contestant->getField( 'cv' ) : '', |
| 217 | + 'label-message' => 'contest-signup-cv', |
| 218 | + 'validation-callback' => array( __CLASS__, 'validateCVField' ) |
| 219 | + ); |
| 220 | + |
211 | 221 | return $fields; |
212 | 222 | } |
213 | 223 | |
— | — | @@ -246,4 +256,22 @@ |
247 | 257 | return true; |
248 | 258 | } |
249 | 259 | |
| 260 | + /** |
| 261 | + * HTMLForm field validation-callback for cv field. |
| 262 | + * |
| 263 | + * @since 0.1 |
| 264 | + * |
| 265 | + * @param $value String |
| 266 | + * @param $alldata Array |
| 267 | + * |
| 268 | + * @return true|string |
| 269 | + */ |
| 270 | + public static function validateCVField( $value, $alldata = null ) { |
| 271 | + if ( trim( $value ) !== '' && filter_var( $value, FILTER_VALIDATE_URL ) === false ) { |
| 272 | + return wfMsg( 'contest-signup-invalid-cv' ); |
| 273 | + } |
| 274 | + |
| 275 | + return true; |
| 276 | + } |
| 277 | + |
250 | 278 | } |