/** * Main method. * * @since 0.1 * * @param string $subPage */ public function execute($subPage) { parent::execute($subPage); $out = $this->getOutput(); if (trim($subPage) === '') { $this->getOutput()->redirect(SpecialPage::getTitleFor('Institutions')->getLocalURL()); } else { $out->setPageTitle(wfMsgExt('ep-institution-title', 'parsemag', $this->subPage)); $org = EPOrg::selectRow(null, array('name' => $this->subPage)); if ($org === false) { $this->displayNavigation(); if ($this->getUser()->isAllowed('ep-org')) { $out->addWikiMsg('ep-institution-create', $this->subPage); EPOrg::displayAddNewControl($this->getContext(), array('name' => $this->subPage)); } else { $out->addWikiMsg('ep-institution-none', $this->subPage); } } else { $links = array(); if ($this->getUser()->isAllowed('ep-org')) { $links[wfMsg('ep-institution-nav-edit')] = SpecialPage::getTitleFor('EditInstitution', $this->subPage); } $this->displayNavigation($links); $this->displaySummary($org); $out->addHTML(Html::element('h2', array(), wfMsg('ep-institution-courses'))); EPCourse::displayPager($this->getContext(), array('org_id' => $org->getId())); if ($this->getUser()->isAllowed('ep-course')) { $out->addHTML(Html::element('h2', array(), wfMsg('ep-institution-add-course'))); EPCourse::displayAddNewControl($this->getContext(), array('org' => $org->getId())); } } } }
protected function displayPage(EPDBObject $org) { parent::displayPage($org); $out = $this->getOutput(); $out->addElement('h2', array(), wfMsg('ep-institution-courses')); EPCourse::displayPager($this->getContext(), array('org_id' => $org->getId())); if ($this->getUser()->isAllowed('ep-course')) { $out->addElement('h2', array(), wfMsg('ep-institution-add-course')); EPCourse::displayAddNewControl($this->getContext(), array('org' => $org->getId())); } }
/** * Adds a control to add a new course to the provided context * or show a message if this is not possible for some reason. * * @since 0.1 * * @param IContextSource $context * @param array $args */ public static function displayAddNewRegion(IContextSource $context, array $args = array()) { if (EPOrg::has()) { EPCourse::displayAddNewControl($context, $args); } elseif ($context->getUser()->isAllowed('ep-org')) { $context->getOutput()->addWikiMsg('ep-courses-addorgfirst'); } }