Index: trunk/extensions/EducationProgram/specials/SpecialInstitution.php |
— | — | @@ -14,8 +14,6 @@ |
15 | 15 | */ |
16 | 16 | class SpecialInstitution extends SpecialEPPage { |
17 | 17 | |
18 | | - protected $org; |
19 | | - |
20 | 18 | /** |
21 | 19 | * Constructor. |
22 | 20 | * |
Index: trunk/extensions/EducationProgram/specials/SpecialTerms.php |
— | — | @@ -33,21 +33,12 @@ |
34 | 34 | public function execute( $subPage ) { |
35 | 35 | parent::execute( $subPage ); |
36 | 36 | |
37 | | - $out = $this->getOutput(); |
38 | | - |
39 | 37 | if ( $this->subPage === '' ) { |
40 | | - $this->displayPage(); |
| 38 | + EPTerm::displayAddNewRegion( $this->getContext() ); |
| 39 | + EPTerm::displayPager( $this->getContext() ); |
41 | 40 | } |
42 | 41 | else { |
43 | | - $org = EPOrg::has( array( 'name' => $this->subPage ) ); |
44 | | - |
45 | | - if ( $org === false ) { |
46 | | - $this->showError( wfMessage( 'ep-terms-nosuchcourses', $this->subPage ) ); |
47 | | - $this->displayPage(); |
48 | | - } |
49 | | - else { |
50 | | - $out->redirect( SpecialPage::getTitleFor( 'Term', $this->subPage )->getLocalURL() ); |
51 | | - } |
| 42 | + $this->getOutput()->redirect( SpecialPage::getTitleFor( 'Term', $this->subPage )->getLocalURL() ); |
52 | 43 | } |
53 | 44 | } |
54 | 45 | |
— | — | @@ -83,50 +74,7 @@ |
84 | 75 | $this->getOutput()->addWikiMsg( 'ep-terms-noresults' ); |
85 | 76 | } |
86 | 77 | } |
87 | | - |
88 | | - /** |
89 | | - * Displays a small form to add a new institution. |
90 | | - * |
91 | | - * @since 0.1 |
92 | | - * |
93 | | - * @param array $courses |
94 | | - */ |
95 | | - protected function displayAddNewControl( array $courses ) { |
96 | | - $out = $this->getOutput(); |
97 | 78 | |
98 | | - $out->addHTML( Html::openElement( |
99 | | - 'form', |
100 | | - array( |
101 | | - 'method' => 'post', |
102 | | - 'action' => SpecialPage::getTitleFor( 'EditTerm' )->getLocalURL(), |
103 | | - ) |
104 | | - ) ); |
105 | 79 | |
106 | | - $out->addHTML( '<fieldset>' ); |
107 | 80 | |
108 | | - $out->addHTML( '<legend>' . wfMsgHtml( 'ep-terms-addnew' ) . '</legend>' ); |
109 | | - |
110 | | - $out = $this->getOutput(); |
111 | | - |
112 | | - $out->addHTML( Html::element( 'p', array(), wfMsg( 'ep-terms-namedoc' ) ) ); |
113 | | - |
114 | | - $out->addHTML( Html::element( 'label', array( 'for' => 'newcourse' ), wfMsg( 'ep-terms-newcourse' ) ) ); |
115 | | - |
116 | | - $select = new XmlSelect( 'newcourse', 'newcourse' ); |
117 | | - $select->addOptions( EPCourse::getCourseOptions( $courses ) ); |
118 | | - $out->addHTML( $select->getHTML() ); |
119 | | - |
120 | | - $out->addHTML( ' ' . Xml::inputLabel( wfMsg( 'ep-terms-newyear' ), 'newyear', 'newyear', 10 ) ); |
121 | | - |
122 | | - $out->addHTML( ' ' . Html::input( |
123 | | - 'addnewterm', |
124 | | - wfMsg( 'ep-terms-add' ), |
125 | | - 'submit' |
126 | | - ) ); |
127 | | - |
128 | | - $out->addHTML( Html::hidden( 'newEditToken', $this->getUser()->editToken() ) ); |
129 | | - |
130 | | - $out->addHTML( '</fieldset></form>' ); |
131 | | - } |
132 | | - |
133 | 81 | } |
Index: trunk/extensions/EducationProgram/specials/SpecialInstitutions.php |
— | — | @@ -33,14 +33,12 @@ |
34 | 34 | public function execute( $subPage ) { |
35 | 35 | parent::execute( $subPage ); |
36 | 36 | |
37 | | - $out = $this->getOutput(); |
38 | | - |
39 | 37 | if ( $this->subPage === '' ) { |
40 | 38 | EPOrg::displayAddNewControl( $this->getContext() ); |
41 | 39 | EPOrg::displayPager( $this->getContext() ); |
42 | 40 | } |
43 | 41 | else { |
44 | | - $out->redirect( SpecialPage::getTitleFor( 'Institution', $this->subPage )->getLocalURL() ); |
| 42 | + $this->getOutput()->redirect( SpecialPage::getTitleFor( 'Institution', $this->subPage )->getLocalURL() ); |
45 | 43 | } |
46 | 44 | } |
47 | 45 | |
Index: trunk/extensions/EducationProgram/specials/SpecialCourse.php |
— | — | @@ -34,8 +34,40 @@ |
35 | 35 | parent::execute( $subPage ); |
36 | 36 | |
37 | 37 | $out = $this->getOutput(); |
38 | | - |
39 | | - // TODO: AUTH |
| 38 | + |
| 39 | + $out->setPageTitle( wfMsgExt( 'ep-course-title', 'parsemag', $this->subPage ) ); |
| 40 | + |
| 41 | + $course = EPCourse::selectRow( null, array( 'name' => $this->subPage ) ); |
| 42 | + |
| 43 | + if ( $course === false ) { |
| 44 | + if ( $this->getUser()->isAllowed( 'epadmin' ) || $this->getUser()->isAllowed( 'epmentor' ) ) { |
| 45 | + $out->addWikiMsg( 'ep-course-create', 'parsemag', $this->subPage ); |
| 46 | + EPCourse::displayAddNewRegion( $this->getContext(), array( 'name' => $this->subPage ) ); |
| 47 | + } |
| 48 | + else { |
| 49 | + $out->addWikiMsg( 'ep-course-none', 'parsemag', $this->subPage ); |
| 50 | + } |
| 51 | + } |
| 52 | + else { |
| 53 | + $this->displayInfo( $course ); |
| 54 | + |
| 55 | + $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-course-terms' ) ) ); |
| 56 | + |
| 57 | + EPTerm::displayPager( $this->getContext(), array( 'course_id' => $course->getId() ) ); |
| 58 | + } |
40 | 59 | } |
| 60 | + |
| 61 | + /** |
| 62 | + * Display the orgs info. |
| 63 | + * |
| 64 | + * @since 0.1 |
| 65 | + * |
| 66 | + * @param EPCourse $course |
| 67 | + */ |
| 68 | + protected function displayInfo( EPCourse $course ) { |
| 69 | + $out = $this->getOutput(); |
| 70 | + |
| 71 | + |
| 72 | + } |
41 | 73 | |
42 | 74 | } |
Index: trunk/extensions/EducationProgram/specials/SpecialCourses.php |
— | — | @@ -33,22 +33,12 @@ |
34 | 34 | public function execute( $subPage ) { |
35 | 35 | parent::execute( $subPage ); |
36 | 36 | |
37 | | - $out = $this->getOutput(); |
38 | | - |
39 | 37 | if ( $this->subPage === '' ) { |
40 | 38 | EPCourse::displayAddNewRegion( $this->getContext() ); |
41 | 39 | EPCourse::displayPager( $this->getContext() ); |
42 | 40 | } |
43 | 41 | else { |
44 | | - $org = EPOrg::has( array( 'name' => $this->subPage ) ); |
45 | | - |
46 | | - if ( $org === false ) { |
47 | | - $this->showError( wfMessage( 'ep-courses-nosuchcourses', $this->subPage ) ); |
48 | | - EPCourse::displayAddNewRegion( $this->getContext(), array( 'name' => $this->subPage ) ); |
49 | | - } |
50 | | - else { |
51 | | - $out->redirect( SpecialPage::getTitleFor( 'Course', $this->subPage )->getLocalURL() ); |
52 | | - } |
| 42 | + $this->getOutput()->redirect( SpecialPage::getTitleFor( 'Course', $this->subPage )->getLocalURL() ); |
53 | 43 | } |
54 | 44 | } |
55 | 45 | |
Index: trunk/extensions/EducationProgram/includes/EPTerm.php |
— | — | @@ -59,5 +59,98 @@ |
60 | 60 | |
61 | 61 | return $success; |
62 | 62 | } |
| 63 | + |
| 64 | + /** |
| 65 | + * Display a pager with terms. |
| 66 | + * |
| 67 | + * @since 0.1 |
| 68 | + * |
| 69 | + * @param IContextSource $context |
| 70 | + * @param array $conditions |
| 71 | + */ |
| 72 | + public static function displayPager( IContextSource $context, array $conditions = array() ) { |
| 73 | + $pager = new EPTermPager( $context, $conditions ); |
| 74 | + |
| 75 | + if ( $pager->getNumRows() ) { |
| 76 | + $context->getOutput()->addHTML( |
| 77 | + $pager->getFilterControl() . |
| 78 | + $pager->getNavigationBar() . |
| 79 | + $pager->getBody() . |
| 80 | + $pager->getNavigationBar() |
| 81 | + ); |
| 82 | + } |
| 83 | + else { |
| 84 | + $context->getOutput()->addHTML( $pager->getFilterControl( true ) ); |
| 85 | + $context->getOutput()->addWikiMsg( 'ep-terms-noresults' ); |
| 86 | + } |
| 87 | + } |
| 88 | + |
| 89 | + /** |
| 90 | + * Adds a control to add a term org to the provided context. |
| 91 | + * Adittional arguments can be provided to set the default values for the control fields. |
| 92 | + * |
| 93 | + * @since 0.1 |
| 94 | + * |
| 95 | + * @param IContextSource $context |
| 96 | + * @param array $args |
| 97 | + */ |
| 98 | + public static function displayAddNewControl( IContextSource $context, array $courses ) { |
| 99 | + $out = $context->getOutput(); |
63 | 100 | |
| 101 | + $out->addHTML( Html::openElement( |
| 102 | + 'form', |
| 103 | + array( |
| 104 | + 'method' => 'post', |
| 105 | + 'action' => SpecialPage::getTitleFor( 'EditTerm' )->getLocalURL(), |
| 106 | + ) |
| 107 | + ) ); |
| 108 | + |
| 109 | + $out->addHTML( '<fieldset>' ); |
| 110 | + |
| 111 | + $out->addHTML( '<legend>' . wfMsgHtml( 'ep-terms-addnew' ) . '</legend>' ); |
| 112 | + |
| 113 | + $out->addHTML( Html::element( 'p', array(), wfMsg( 'ep-terms-namedoc' ) ) ); |
| 114 | + |
| 115 | + $out->addHTML( Html::element( 'label', array( 'for' => 'newcourse' ), wfMsg( 'ep-terms-newcourse' ) ) ); |
| 116 | + |
| 117 | + $select = new XmlSelect( 'newcourse', 'newcourse' ); |
| 118 | + $select->addOptions( EPCourse::getCourseOptions( $courses ) ); |
| 119 | + $out->addHTML( $select->getHTML() ); |
| 120 | + |
| 121 | + $out->addHTML( ' ' . Xml::inputLabel( wfMsg( 'ep-terms-newyear' ), 'newyear', 'newyear', 10 ) ); |
| 122 | + |
| 123 | + $out->addHTML( ' ' . Html::input( |
| 124 | + 'addnewterm', |
| 125 | + wfMsg( 'ep-terms-add' ), |
| 126 | + 'submit' |
| 127 | + ) ); |
| 128 | + |
| 129 | + $out->addHTML( Html::hidden( 'newEditToken', $context->getUser()->editToken() ) ); |
| 130 | + |
| 131 | + $out->addHTML( '</fieldset></form>' ); |
| 132 | + } |
| 133 | + |
| 134 | + /** |
| 135 | + * Adds a control to add a new term to the provided context |
| 136 | + * or show a message if this is not possible for some reason. |
| 137 | + * |
| 138 | + * @since 0.1 |
| 139 | + * |
| 140 | + * @param IContextSource $context |
| 141 | + * @param array $args |
| 142 | + */ |
| 143 | + public static function displayAddNewRegion( IContextSource $context, array $args = array() ) { |
| 144 | + $courses = EPCourse::getEditableCourses( $context->getUser() ); |
| 145 | + |
| 146 | + if ( count( $courses ) > 0 ) { |
| 147 | + EPTerm::displayAddNewControl( $context, $args ); |
| 148 | + } |
| 149 | + elseif ( $context->getUser()->isAllowed( 'epadmin' ) ) { |
| 150 | + $context->getOutput()->addWikiMsg( 'ep-terms-nocourses' ); |
| 151 | + } |
| 152 | + elseif ( $context->getUser()->isAllowed( 'epmentor' ) ) { |
| 153 | + $context->getOutput()->addWikiMsg( 'ep-terms-addcoursefirst' ); |
| 154 | + } |
| 155 | + } |
| 156 | + |
64 | 157 | } |
Index: trunk/extensions/EducationProgram/includes/EPCourse.php |
— | — | @@ -132,7 +132,7 @@ |
133 | 133 | * @param array $args |
134 | 134 | */ |
135 | 135 | public static function displayAddNewControl( IContextSource $context, array $args = array() ) { |
136 | | - $out = $this->getOutput(); |
| 136 | + $out = $context->getOutput(); |
137 | 137 | |
138 | 138 | $out->addHTML( Html::openElement( |
139 | 139 | 'form', |
— | — | @@ -179,7 +179,7 @@ |
180 | 180 | 'submit' |
181 | 181 | ) ); |
182 | 182 | |
183 | | - $out->addHTML( Html::hidden( 'newEditToken', $this->getUser()->editToken() ) ); |
| 183 | + $out->addHTML( Html::hidden( 'newEditToken', $context->getUser()->editToken() ) ); |
184 | 184 | |
185 | 185 | $out->addHTML( '</fieldset></form>' ); |
186 | 186 | } |
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php |
— | — | @@ -152,10 +152,16 @@ |
153 | 153 | 'ep-pager-delete-fail' => 'Could not delete this item.', |
154 | 154 | |
155 | 155 | // Special:Institution |
156 | | - 'ep-institution-none' => 'There is no institution with name "$1".', |
| 156 | + 'ep-institution-none' => 'There is no institution with name "$1". See [[Special:Institution|here]] for a list of institutions.', |
157 | 157 | 'ep-institution-create' => 'There is no institution with name "$1" yet, but you can create it.', |
158 | 158 | 'ep-institution-title' => 'Institution: $1', |
159 | 159 | 'ep-institution-courses' => 'Courses', |
| 160 | + |
| 161 | + // Special:Course |
| 162 | + 'ep-course-title' => 'Course: $1', |
| 163 | + 'ep-course-terms' => 'Terms', |
| 164 | + 'ep-course-none' => 'There is no course with name "$1". See [[Special:Course|here]] for a list of courses.', |
| 165 | + 'ep-course-create' => 'There is no course with name "$1" yet, but you can create it.', |
160 | 166 | ); |
161 | 167 | |
162 | 168 | /** Message documentation (Message documentation) |