/** * Gets a list of contests that can be fed directly to the options field of * an HTMLForm radio input. * challenge title => challenge id * * @since 0.1 * * @param ContestContestant $contestant * * @return array */ protected function getChallengesList(ContestContestant $contestant) { $list = array(); $challenges = ContestChallenge::s()->select(array('id', 'title'), array('contest_id' => $contestant->getField('contest_id'))); foreach ($challenges as $challenge) { $list[$challenge->getField('title')] = $challenge->getId(); } return $list; }
/** * 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; }