/** * 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())); } } } }
/** * (non-PHPdoc) * @see EPPager::getFormattedValue() */ public function getFormattedValue($name, $value) { switch ($name) { case 'name': $value = EPCourse::getLinkFor($value); break; case 'org_id': $value = EPOrg::selectRow('name', array('id' => $value))->getLink(); break; case 'term': $value = htmlspecialchars($value); break; case 'lang': $langs = LanguageNames::getNames($this->getLanguage()->getCode()); if (array_key_exists($value, $langs)) { $value = htmlspecialchars($langs[$value]); } else { $value = '<i>' . htmlspecialchars($this->getMsg('invalid-lang')) . '</i>'; } break; case 'start': case 'end': $value = htmlspecialchars($this->getLanguage()->date($value)); break; case '_status': $value = htmlspecialchars(EPCourse::getStatusMessage($this->currentObject->getStatus())); case 'students': $value = htmlspecialchars($this->getLanguage()->formatNum($value)); break; } return $value; }
/** * (non-PHPdoc) * @see EPPager::getFormattedValue() */ protected function getFormattedValue($name, $value) { switch ($name) { case 'name': $value = Linker::linkKnown(SpecialPage::getTitleFor('Course', $value), htmlspecialchars($value)); break; case 'org_id': $value = EPOrg::selectRow('name', array('id' => $value))->getField('name'); $value = Linker::linkKnown(SpecialPage::getTitleFor('Institution', $value), htmlspecialchars($value)); break; case 'students': $value = htmlspecialchars($this->getLanguage()->formatNum($value)); break; case 'active': $value = wfMsgHtml('epcoursepager-' . ($value == '1' ? 'yes' : 'no')); break; } return $value; }
/** * Returns the org associated with this term. * * @since 0.1 * * @param string|array|null $fields * * @return EPOrg */ public function getOrg($fields = null) { if ($this->org === false) { $this->org = EPOrg::selectRow($fields, array('id' => $this->loadAndGetField('org_id'))); } return $this->org; }