/**
  * Gets the field definitions for the form.
  *
  * @since 0.1
  *
  * @param ContestContestant $contest
  *
  * @return array
  */
 protected function getFormFields(ContestContestant $contestant)
 {
     $fields = array();
     $user = $this->getUser();
     $fields['contestant-id'] = array('type' => 'hidden', 'default' => $contestant->getId(), 'id' => 'contest-id');
     $fields['contestant-previous-submission'] = array('type' => 'hidden', 'default' => $contestant->getField('submission'));
     $fields['contestant-submission'] = array('class' => 'ContestSubmissionField', 'label-message' => 'contest-submission-submission', 'validation-callback' => array(__CLASS__, 'validateSubmissionField'), 'options' => array('domains' => implode('|', ContestSettings::get('submissionDomains')), 'value' => $contestant->getField('submission')));
     $fields['contestant-realname'] = array('type' => 'text', 'default' => $user->getRealName(), 'label-message' => 'contest-signup-realname', 'required' => true, 'validation-callback' => array(__CLASS__, 'validateNameField'));
     $fields['contestant-email'] = array('type' => 'email', 'default' => $user->getEmail(), 'label-message' => 'contest-signup-email', 'required' => true, 'validation-callback' => array(__CLASS__, 'validateEmailField'));
     $fields['contestant-country'] = array('type' => 'select', 'default' => $contestant->getField('country'), 'label-message' => 'contest-signup-country', 'required' => true, 'options' => ContestContestant::getCountriesForInput());
     $fields['contestant-challengeid'] = array('type' => 'radio', 'label-message' => 'contest-signup-challenge', 'options' => $this->getChallengesList($contestant), 'default' => $contestant->getField('challenge_id'), 'required' => true, 'validation-callback' => array(__CLASS__, 'validateChallengeField'));
     $fields['contestant-volunteer'] = array('type' => 'check', 'default' => $contestant->getField('volunteer'), 'label-message' => 'contest-signup-volunteer');
     $fields['contestant-wmf'] = array('type' => 'check', 'default' => $contestant->getField('wmf'), 'label-message' => 'contest-signup-wmf');
     $hasWMF = $contestant->hasField('wmf');
     $fields['contestant-cv'] = array('type' => $hasWMF && $contestant->getField('wmf') ? 'text' : 'hidden', 'default' => $hasWMF ? $contestant->getField('cv') : '', 'label-message' => 'contest-signup-cv', 'validation-callback' => array(__CLASS__, 'validateCVField'));
     return $fields;
 }
 /**
  * Display the current rating the judge gave if any and a control to
  * (re)-rate.
  *
  * @since 0.1
  *
  * @param ContestContestant $contestant
  */
 protected function showRating(ContestContestant $contestant)
 {
     $out = $this->getOutput();
     $out->addHTML(Html::element('h2', array(), wfMsg('contest-contestant-rate')));
     $vote = ContestVote::s()->selectRow(array('value', 'id'), array('user_id' => $this->getUser()->getId(), 'contestant_id' => $contestant->getId()));
     if ($vote === false) {
         $message = wfMsg('contest-contestant-not-voted');
     } else {
         $message = wfMsgExt('contest-contestant-voted', 'parsemag', $this->getLanguage()->formatNum($vote->getField('value')));
         $out->addHTML(Html::hidden('contestant-vote-id', $vote->getId()));
     }
     $out->addHTML(Html::element('p', array(), $message));
     foreach (ContestSettings::get('voteValues') as $value) {
         $attribs = array('type' => 'radio', 'value' => $value, 'name' => 'contestant-rating', 'id' => 'contestant-rating-' . $value);
         if ($vote !== false && $value == $vote->getField('value')) {
             $attribs['checked'] = 'checked';
         }
         $out->addHTML(Html::element('input', $attribs) . Html::element('label', array('for' => 'contestant-rating-' . $value), $this->getLanguage()->formatNum($value)));
     }
 }