/**
  * 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('Courses')->getLocalURL());
     } else {
         $out->setPageTitle(wfMsgExt('ep-course-title', 'parsemag', $this->subPage));
         $course = EPCourse::selectRow(null, array('name' => $this->subPage));
         if ($course === false) {
             $this->displayNavigation();
             if ($this->getUser()->isAllowed('ep-course')) {
                 $out->addWikiMsg('ep-course-create', $this->subPage);
                 EPCourse::displayAddNewRegion($this->getContext(), array('name' => $this->subPage));
             } else {
                 $out->addWikiMsg('ep-course-none', $this->subPage);
             }
         } else {
             $links = array();
             if ($this->getUser()->isAllowed('ep-course')) {
                 $links[wfMsg('ep-course-nav-edit')] = SpecialPage::getTitleFor('EditCourse', $this->subPage);
             }
             $this->displayNavigation($links);
             $this->displaySummary($course);
             $out->addHTML(Html::element('h2', array(), wfMsg('ep-course-description')));
             $out->addHTML($this->getOutput()->parse($course->getField('description')));
             $out->addHTML(Html::element('h2', array(), wfMsg('ep-course-terms')));
             EPTerm::displayPager($this->getContext(), array('course_id' => $course->getId()));
             if ($this->getUser()->isAllowed('ep-course')) {
                 $out->addHTML(Html::element('h2', array(), wfMsg('ep-course-add-term')));
                 EPTerm::displayAddNewControl($this->getContext(), array('course' => $course->getId()));
             }
         }
     }
 }
示例#2
0
 /**
  * Adds a control to add a new term 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 (EPCourse::has()) {
         EPTerm::displayAddNewControl($context, $args);
     } elseif ($context->getUser()->isAllowed('ep-course')) {
         $context->getOutput()->addWikiMsg('ep-terms-addcoursefirst');
     }
 }