/** * Attempt to get the contest to be edited or create the one to be added. * If this works, show the form, if not, redirect to special:contests. * * @since 0.1 * * @param string $subPage */ protected function showContent($subPage) { $isNew = $this->getRequest()->wasPosted() && $this->getUser()->matchEditToken($this->getRequest()->getVal('newEditToken')); $this->getOutput()->addScript(Skin::makeVariablesScript(array('ContestDeletionEnabled' => ContestSettings::get('contestDeletionEnabled')))); if ($isNew) { $data = array('name' => $this->getRequest()->getVal('newcontest')); $contest = Contest::s()->selectRow(null, $data); if ($contest === false) { $contest = new Contest($data, true); } else { $this->showWarning('contest-edit-exists-already'); } } else { $contest = Contest::s()->selectRow(null, array('name' => $subPage)); } if ($contest === false) { $this->getOutput()->redirect(SpecialPage::getTitleFor('Contests')->getLocalURL()); } else { if (!$isNew) { $this->getOutput()->addHTML(SpecialContestPage::getNavigation($contest->getField('name'), $this->getUser(), $this->getLanguage(), $this->getName())); } $this->contest = $contest; $this->showForm(); $this->getOutput()->addModules('contest.special.editcontest'); } }