/** * Show the page content. * * @since 0.1 * * @param ContestContestant $contestant */ protected function showSubmissionPage(ContestContestant $contestant) { $request = $this->getRequest(); $contest = $contestant->getContest(); if ($request->getCheck('new')) { $this->showSuccess('contest-mycontests-signup-success', $contest->getField('name')); } elseif ($request->getCheck('added')) { $this->showSuccess('contest-mycontests-addition-success'); } elseif ($request->getCheck('updated')) { $this->showSuccess('contest-mycontests-updated-success'); } elseif ($request->wasPosted() && !$this->getUser()->matchEditToken($request->getVal('wpEditToken'))) { $this->showError('contest-mycontests-sessionfail'); } $output = $this->getOutput(); $output->setPageTitle($contest->getField('name')); $output->addHTML('<div style="clear:both;"></div>'); $output->addWikiMsg('contest-submission-header', $contest->getField('name')); $form = new HTMLForm($this->getFormFields($contestant), $this->getContext()); $form->setSubmitCallback(array($this, 'handleSubmission')); $form->setSubmitText(wfMsg('contest-submission-submit')); /** * @var $challenge ContestChallenge */ $challenge = ContestChallenge::s()->selectRow(array('title', 'text'), array('id' => $contestant->getField('challenge_id'))); if ($challenge !== false) { $challengeName = $challenge->getField('title'); $challengeDescription = $challenge->getField('text'); $output->addWikiMsg('contest-submission-challenge', $challengeName); $output->addWikiMsg('contest-submission-challenge-description', $challengeName, $challengeDescription); } if ($form->show()) { $query = is_null($this->submissionState) ? '' : $this->submissionState; $output->redirect($this->getTitle($contest->getField('name'))->getLocalURL($query)); } else { $output->addModules('contest.special.submission'); } }
/** * Gets the summary data. * Values are escaped. * * @since 0.1 * * @param ContestContestant $contestant * * @return array */ protected function getSummaryData(ContestContestant $contestant) { $stats = array(); $stats['id'] = htmlspecialchars($contestant->getField('id')); $stats['contest'] = htmlspecialchars($contestant->getContest()->getField('name')); $challengeTitles = ContestChallenge::getTitlesForIds($contestant->getField('challenge_id')); $stats['challenge'] = htmlspecialchars($challengeTitles[$contestant->getField('challenge_id')]); if ($contestant->getField('submission') === '') { $stats['submission'] = htmlspecialchars(wfMsg('contest-contestant-notsubmitted')); } else { $stats['submission'] = Html::element('a', array('href' => $contestant->getField('submission')), $contestant->getField('submission')); } $countries = ContestContestant::getCountries(); $stats['country'] = htmlspecialchars($countries[$contestant->getField('country')]); $stats['wmf'] = htmlspecialchars(wfMsg('contest-contestant-' . ($contestant->getField('wmf') ? 'yes' : 'no'))); $stats['volunteer'] = htmlspecialchars(wfMsg('contest-contestant-' . ($contestant->getField('volunteer') ? 'yes' : 'no'))); $stats['rating'] = htmlspecialchars(wfMsgExt('contest-contestant-rating', 'parsemag', $this->getLanguage()->formatNum($contestant->getField('rating') / 100), $this->getLanguage()->formatNum($contestant->getField('rating_count')))); $stats['comments'] = htmlspecialchars($this->getLanguage()->formatNum($contestant->getField('comments'))); return $stats; }