r99382 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99381‎ | r99382 | r99383 >
Date:22:55, 9 October 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
added submission url 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
@@ -124,7 +124,8 @@
125125 'contest-signup-invalid-name' => 'The name you provided is to short.',
126126 'contest-signup-require-challenge' => 'You must select a challenge.',
127127 'contest-signup-invalid-cv' => 'You entered an invalid URL.',
128 -
 128+
 129+ 'contest-submission-submission' => 'Url to your submission',
129130 'contest-submission-invalid-url' => 'This URL does not match one of the allowed formats.',
130131
131132 // Special:ContestSubmission
Index: trunk/extensions/Contest/specials/SpecialContestSubmission.php
@@ -116,7 +116,7 @@
117117
118118 $form = new HTMLForm( $this->getFormFields( $contestant ), $this->getContext() );
119119
120 - $form->setSubmitCallback( array( __CLASS__, 'handleSubmission' ) );
 120+ $form->setSubmitCallback( array( $this, 'handleSubmission' ) );
121121 $form->setSubmitText( wfMsg( 'contest-submission-submit' ) );
122122
123123 if( $form->show() ){
@@ -134,8 +134,8 @@
135135 *
136136 * @return true|array
137137 */
138 - public static function handleSubmission( array $data ) {
139 - $user = $GLOBALS['wgUser']; //$this->getUser();
 138+ public function handleSubmission( array $data ) {
 139+ $user = $this->getUser();
140140
141141 $user->setEmail( $data['contestant-email'] );
142142 $user->setRealName( $data['contestant-realname'] );
@@ -149,6 +149,8 @@
150150 'volunteer' => $data['contestant-volunteer'],
151151 'wmf' => $data['contestant-wmf'],
152152 'cv' => $data['contestant-cv'],
 153+
 154+ 'submission' => $data['contestant-submission'],
153155 ) );
154156
155157 return $contestant->writeToDB();
@@ -217,6 +219,16 @@
218220 'validation-callback' => array( __CLASS__, 'validateCVField' )
219221 );
220222
 223+ // TODO: this needs UI work to explain to the user what they can enter here,
 224+ // and possibly some pop-up thing where they can just enter their
 225+ // user and project, after which we just find the latest rev and store that url.
 226+ $fields['contestant-submission'] = array(
 227+ 'type' => 'text',
 228+ 'default' => $contestant->getField( 'submission' ),
 229+ 'label-message' => 'contest-submission-submission',
 230+ 'validation-callback' => array( __CLASS__, 'validateSubmissionField' )
 231+ );
 232+
221233 return $fields;
222234 }
223235
@@ -278,6 +290,8 @@
279291 * HTMLForm field validation-callback for the submissiom field.
280292 * Warning: regexes used! o_O
281293 *
 294+ * TODO: add support for other services such as Gitorious?
 295+ *
282296 * @since 0.1
283297 *
284298 * @param $value String

Status & tagging log