/** * Create the filter control and add it to the output. * * @since 0.2 * * @param Contest $contest */ protected function showFilterControl(Contest $contest) { $challenges = array(); foreach ($contest->getChallenges() as $challenge) { $challenges[$challenge->getField('title')] = $challenge->getField('title'); } $yesNo = array('yes' => wfMsg('contest-contest-yes'), 'no' => wfMsg('contest-contest-no')); $noneSome = array('none' => wfMsg('contest-contest-none'), 'some' => wfMsg('contest-contest-some')); $title = $this->getTitle($this->subPage)->getFullText(); $this->getOutput()->addHTML('<fieldset>' . '<legend>' . wfMsgHtml('contest-contest-showonly') . '</legend>' . '<form method="post" action="' . htmlspecialchars(wfAppendQuery($GLOBALS['wgScript'], array('title' => $title))) . '">' . Html::hidden('title', $title) . $this->getDropdownHTML('challenge', $challenges) . $this->getDropdownHTML('volunteer', $yesNo) . $this->getDropdownHTML('wmf', $yesNo) . $this->getDropdownHTML('comments', $noneSome) . $this->getDropdownHTML('rating_count', $noneSome) . $this->getDropdownHTML('submission', $noneSome) . '<input type="submit" value="' . wfMsgHtml('contest-contest-go') . '">' . ' <button class="contest-pager-clear">' . wfMsgHtml('contest-contest-clear') . '</button>' . '</form>' . '</fieldset>'); }
/** * 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 Contest $contest * * @return array */ protected function getChallengesList(Contest $contest) { $list = array(); foreach ($contest->getChallenges() as $challenge) { $list[$challenge->getField('title')] = $challenge->getId(); } return $list; }
/** * Output the needed JS data. * * @since 0.1 * * @param Contest $contest */ protected function addContestJS(Contest $contest) { $challenges = array(); $output = $this->getOutput(); /** * @var $challenge ContestChallenge */ foreach ($contest->getChallenges() as $challenge) { $data = $challenge->toArray(); $data['target'] = $this->getSignupLink($contest->getField('name'), $challenge->getId()); $data['text'] = $output->parse($data['text']); $challenges[] = $data; } $output->addScript(Skin::makeVariablesScript(array('ContestChallenges' => $challenges, 'ContestConfig' => array()))); }