http://www.mediawiki.org/wiki/Special:Code/MediaWiki/99382

Revision: 99382
Author:   jeroendedauw
Date:     2011-10-09 22:55:51 +0000 (Sun, 09 Oct 2011)
Log Message:
-----------
added submission url field

Modified Paths:
--------------
    trunk/extensions/Contest/Contest.i18n.php
    trunk/extensions/Contest/specials/SpecialContestSubmission.php

Modified: trunk/extensions/Contest/Contest.i18n.php
===================================================================
--- trunk/extensions/Contest/Contest.i18n.php   2011-10-09 22:50:36 UTC (rev 
99381)
+++ trunk/extensions/Contest/Contest.i18n.php   2011-10-09 22:55:51 UTC (rev 
99382)
@@ -124,7 +124,8 @@
        'contest-signup-invalid-name' => 'The name you provided is to short.',
        'contest-signup-require-challenge' => 'You must select a challenge.',
        'contest-signup-invalid-cv' => 'You entered an invalid URL.',
-
+       
+       'contest-submission-submission' => 'Url to your submission',
        'contest-submission-invalid-url' => 'This URL does not match one of the 
allowed formats.',
 
        // Special:ContestSubmission

Modified: trunk/extensions/Contest/specials/SpecialContestSubmission.php
===================================================================
--- trunk/extensions/Contest/specials/SpecialContestSubmission.php      
2011-10-09 22:50:36 UTC (rev 99381)
+++ trunk/extensions/Contest/specials/SpecialContestSubmission.php      
2011-10-09 22:55:51 UTC (rev 99382)
@@ -116,7 +116,7 @@
                
                $form = new HTMLForm( $this->getFormFields( $contestant ), 
$this->getContext() );
                
-               $form->setSubmitCallback( array( __CLASS__, 'handleSubmission' 
) );
+               $form->setSubmitCallback( array( $this, 'handleSubmission' ) );
                $form->setSubmitText( wfMsg( 'contest-submission-submit' ) );
                
                if( $form->show() ){
@@ -134,8 +134,8 @@
         * 
         * @return true|array
         */
-       public static function handleSubmission( array $data ) {
-               $user = $GLOBALS['wgUser']; //$this->getUser();
+       public function handleSubmission( array $data ) {
+               $user = $this->getUser();
                
                $user->setEmail( $data['contestant-email'] );
                $user->setRealName( $data['contestant-realname'] );
@@ -149,6 +149,8 @@
                        'volunteer' => $data['contestant-volunteer'],
                        'wmf' => $data['contestant-wmf'],
                        'cv' => $data['contestant-cv'],
+               
+                       'submission' => $data['contestant-submission'],
                ) );
                
                return $contestant->writeToDB();
@@ -217,6 +219,16 @@
                        'validation-callback' => array( __CLASS__, 
'validateCVField' )
                );
                
+               // TODO: this needs UI work to explain to the user what they 
can enter here,
+               // and possibly some pop-up thing where they can just enter 
their
+               // user and project, after which we just find the latest rev 
and store that url.
+               $fields['contestant-submission'] = array(
+                       'type' => 'text',
+                       'default' => $contestant->getField( 'submission' ),
+                       'label-message' => 'contest-submission-submission',
+                       'validation-callback' => array( __CLASS__, 
'validateSubmissionField' )
+               );
+               
                return $fields;
        }
        
@@ -278,6 +290,8 @@
         * HTMLForm field validation-callback for the submissiom field.
         * Warning: regexes used! o_O
         * 
+        * TODO: add support for other services such as Gitorious?
+        * 
         * @since 0.1
         * 
         * @param $value String


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to