r98949 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98948‎ | r98949 | r98950 >
Date:23:28, 4 October 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
added cv field
Modified paths:
  • /trunk/extensions/Contest/Contest.i18n.php (modified) (history)
  • /trunk/extensions/Contest/specials/SpecialContestSubmission.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Contest/Contest.i18n.php
@@ -107,6 +107,7 @@
108108 'contest-signup-realname' => 'Your real name',
109109 'contest-signup-volunteer' => 'I am interested in volunteer opportunities',
110110 'contest-signup-wmf' => 'I am interested in working for the Wikimedia Foundation',
 111+ 'contest-signup-cv' => 'Link to your CV',
111112 'contest-signup-readrules' => 'I confirm that I have read, and agree to, [[$1|the contest rules]]',
112113 'contest-signup-challenge' => 'What challenge do you want to take on?',
113114 'contest-signup-finished' => 'This contest has ended.',
@@ -118,6 +119,7 @@
119120 'contest-signup-invalid-email' => 'The email address you provided is not valid.',
120121 'contest-signup-invalid-name' => 'The name you provided is to short.',
121122 'contest-signup-require-challenge' => 'You must select a challenge.',
 123+ 'contest-signup-invalid-cv' => 'You entered an invalid URL.',
122124
123125 // Special:ContestSubmission
124126 'contest-submission-submit' => 'Submit',
Index: trunk/extensions/Contest/specials/SpecialContestSubmission.php
@@ -148,6 +148,7 @@
149149
150150 'volunteer' => $data['contestant-volunteer'],
151151 'wmf' => $data['contestant-wmf'],
 152+ 'cv' => $data['contestant-cv'],
152153 ) );
153154
154155 return $contestant->writeToDB();
@@ -207,6 +208,15 @@
208209 'label-message' => 'contest-signup-wmf',
209210 );
210211
 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+
211221 return $fields;
212222 }
213223
@@ -246,4 +256,22 @@
247257 return true;
248258 }
249259
 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+
250278 }

Status & tagging log