Index: trunk/extensions/EducationProgram/specials/SpecialCourse.php |
— | — | @@ -1,221 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/** |
5 | | - * Shows the info for a single course, with management and |
6 | | - * enrollment controls depending on the user and his rights. |
7 | | - * |
8 | | - * @since 0.1 |
9 | | - * |
10 | | - * @file SpecialCourse.php |
11 | | - * @ingroup EducationProgram |
12 | | - * |
13 | | - * @licence GNU GPL v3 or later |
14 | | - * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
15 | | - */ |
16 | | -class SpecialCourse extends SpecialEPPage { |
17 | | - |
18 | | - /** |
19 | | - * Constructor. |
20 | | - * |
21 | | - * @since 0.1 |
22 | | - */ |
23 | | - public function __construct() { |
24 | | - parent::__construct( 'Course' ); |
25 | | - } |
26 | | - |
27 | | - /** |
28 | | - * Main method. |
29 | | - * |
30 | | - * @since 0.1 |
31 | | - * |
32 | | - * @param string $subPage |
33 | | - */ |
34 | | - public function execute( $subPage ) { |
35 | | - parent::execute( $subPage ); |
36 | | - |
37 | | - $out = $this->getOutput(); |
38 | | - |
39 | | - if ( trim( $subPage ) === '' ) { |
40 | | - $this->getOutput()->redirect( SpecialPage::getTitleFor( 'Courses' )->getLocalURL() ); |
41 | | - } |
42 | | - else { |
43 | | - $out->setPageTitle( wfMsgExt( 'ep-course-title', 'parsemag', $this->subPage ) ); |
44 | | - |
45 | | - $course = EPCourse::selectRow( null, array( 'name' => $this->subPage ) ); |
46 | | - |
47 | | - if ( $course === false ) { |
48 | | - $this->displayNavigation(); |
49 | | - |
50 | | - if ( $this->getUser()->isAllowed( 'ep-course' ) ) { |
51 | | - $out->addWikiMsg( 'ep-course-create', $this->subPage ); |
52 | | - EPCourse::displayAddNewRegion( $this->getContext(), array( 'name' => $this->subPage ) ); |
53 | | - } |
54 | | - else { |
55 | | - $out->addWikiMsg( 'ep-course-none', $this->subPage ); |
56 | | - } |
57 | | - } |
58 | | - else { |
59 | | - $links = array(); |
60 | | - |
61 | | - if ( $this->getUser()->isAllowed( 'ep-course' ) ) { |
62 | | - $links[wfMsg( 'ep-course-nav-edit' )] = |
63 | | - array( SpecialPage::getTitleFor( 'EditCourse', $this->subPage ) ) |
64 | | - + Linker::tooltipAndAccesskeyAttribs( 'ep-edit-course' ); |
65 | | - } |
66 | | - |
67 | | - $this->displayNavigation( $links ); |
68 | | - |
69 | | - $this->displaySummary( $course ); |
70 | | - |
71 | | - $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-course-description' ) ) ); |
72 | | - |
73 | | - $out->addHTML( $this->getOutput()->parse( $course->getField( 'description' ) ) ); |
74 | | - |
75 | | - $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-course-terms' ) ) ); |
76 | | - |
77 | | - EPTerm::displayPager( $this->getContext(), array( 'course_id' => $course->getId() ) ); |
78 | | - |
79 | | - if ( $this->getUser()->isAllowed( 'ep-course' ) ) { |
80 | | - $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-course-add-term' ) ) ); |
81 | | - |
82 | | - EPTerm::displayAddNewControl( $this->getContext(), array( 'course' => $course->getId() ) ); |
83 | | - } |
84 | | - } |
85 | | - } |
86 | | - } |
87 | | - |
88 | | - /** |
89 | | - * Gets the summary data. |
90 | | - * |
91 | | - * @since 0.1 |
92 | | - * |
93 | | - * @param EPCourse $course |
94 | | - * |
95 | | - * @return array |
96 | | - */ |
97 | | - protected function getSummaryData( EPDBObject $course ) { |
98 | | - $stats = array(); |
99 | | - |
100 | | - $stats['name'] = htmlspecialchars( $course->getField( 'name' ) ); |
101 | | - |
102 | | - $org = EPOrg::selectFieldsRow( 'name', array( 'id' => $course->getField( 'org_id' ) ) ); |
103 | | - |
104 | | - $stats['org'] = Linker::linkKnown( |
105 | | - SpecialPage::getTitleFor( 'Institution', $org ), |
106 | | - htmlspecialchars( $org ) |
107 | | - ); |
108 | | - |
109 | | - $stats['status'] = wfMsgHtml( $course->getField( 'active' ) ? 'ep-course-active' : 'ep-course-inactive' ); |
110 | | - |
111 | | - $lang = $this->getLanguage(); |
112 | | - |
113 | | - $stats['students'] = htmlspecialchars( $lang->formatNum( $course->getField( 'students' ) ) ); |
114 | | - |
115 | | - $termCount = EPTerm::count( array( 'course_id' => $course->getId() ) ); |
116 | | - $stats['terms'] = htmlspecialchars( $lang->formatNum( $termCount ) ); |
117 | | - |
118 | | - if ( $termCount > 0 ) { |
119 | | - $stats['terms'] = Linker::linkKnown( |
120 | | - SpecialPage::getTitleFor( 'Terms' ), |
121 | | - $stats['terms'], |
122 | | - array(), |
123 | | - array( 'course_id' => $course->getId() ) |
124 | | - ); |
125 | | - } |
126 | | - |
127 | | - $stats['instructors'] = $this->getInstructorsList( $course ) . $this->getInstructorControls( $course ); |
128 | | - |
129 | | - return $stats; |
130 | | - } |
131 | | - |
132 | | - /** |
133 | | - * Returns a list with the instructors for the provided course |
134 | | - * or a message indicating there are none. |
135 | | - * |
136 | | - * @since 0.1 |
137 | | - * |
138 | | - * @param EPCourse $course |
139 | | - * |
140 | | - * @return string |
141 | | - */ |
142 | | - protected function getInstructorsList( EPCourse $course ) { |
143 | | - $instructors = $course->getInstructors(); |
144 | | - |
145 | | - if ( count( $instructors ) > 0 ) { |
146 | | - $instList = array(); |
147 | | - |
148 | | - foreach ( $instructors as /* EPInstructor */ $instructor ) { |
149 | | - $instList[] = $instructor->getUserLink() . $instructor->getToolLinks( $this->getContext(), $course ); |
150 | | - } |
151 | | - |
152 | | - if ( false ) { // count( $instructors ) == 1 |
153 | | - $html = $instList[0]; |
154 | | - } |
155 | | - else { |
156 | | - $html = '<ul><li>' . implode( '</li><li>', $instList ) . '</li></ul>'; |
157 | | - } |
158 | | - } |
159 | | - else { |
160 | | - $html = wfMsgHtml( 'ep-course-no-instructors' ); |
161 | | - } |
162 | | - |
163 | | - return Html::rawElement( |
164 | | - 'div', |
165 | | - array( 'id' => 'ep-course-instructors' ), |
166 | | - $html |
167 | | - ); |
168 | | - } |
169 | | - |
170 | | - /** |
171 | | - * Returns instructor addition controls for the course if the |
172 | | - * current user has the right permissions. |
173 | | - * |
174 | | - * @since 0.1 |
175 | | - * |
176 | | - * @param EPCourse $course |
177 | | - * |
178 | | - * @return string |
179 | | - */ |
180 | | - protected function getInstructorControls( EPCourse $course ) { |
181 | | - $user = $this->getUser(); |
182 | | - $links = array(); |
183 | | - |
184 | | - if ( ( $user->isAllowed( 'ep-instructor' ) || $user->isAllowed( 'ep-beinstructor' ) ) |
185 | | - && !in_array( $user->getId(), $course->getField( 'instructors' ) ) |
186 | | - ) { |
187 | | - $links[] = Html::element( |
188 | | - 'a', |
189 | | - array( |
190 | | - 'href' => '#', |
191 | | - 'class' => 'ep-add-instructor', |
192 | | - 'data-courseid' => $course->getId(), |
193 | | - 'data-coursename' => $course->getField( 'name' ), |
194 | | - 'data-mode' => 'self', |
195 | | - ), |
196 | | - wfMsg( 'ep-course-become-instructor' ) |
197 | | - ); |
198 | | - } |
199 | | - |
200 | | - if ( $user->isAllowed( 'ep-instructor' ) ) { |
201 | | - $links[] = Html::element( |
202 | | - 'a', |
203 | | - array( |
204 | | - 'href' => '#', |
205 | | - 'class' => 'ep-add-instructor', |
206 | | - 'data-courseid' => $course->getId(), |
207 | | - 'data-coursename' => $course->getField( 'name' ), |
208 | | - ), |
209 | | - wfMsg( 'ep-course-add-instructor' ) |
210 | | - ); |
211 | | - } |
212 | | - |
213 | | - if ( count( $links ) > 0 ) { |
214 | | - $this->getOutput()->addModules( 'ep.instructor' ); |
215 | | - return '<br />' . $this->getLanguage()->pipeList( $links ); |
216 | | - } |
217 | | - else { |
218 | | - return ''; |
219 | | - } |
220 | | - } |
221 | | - |
222 | | -} |
Index: trunk/extensions/EducationProgram/specials/SpecialCourses.php |
— | — | @@ -1,46 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/** |
5 | | - * Page listing all courses in a pager with filter control. |
6 | | - * Also has a form for adding new items for those with matching priviliges. |
7 | | - * |
8 | | - * @since 0.1 |
9 | | - * |
10 | | - * @file SpecialCourses.php |
11 | | - * @ingroup EducationProgram |
12 | | - * |
13 | | - * @licence GNU GPL v3 or later |
14 | | - * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
15 | | - */ |
16 | | -class SpecialCourses extends SpecialEPPage { |
17 | | - |
18 | | - /** |
19 | | - * Constructor. |
20 | | - * |
21 | | - * @since 0.1 |
22 | | - */ |
23 | | - public function __construct() { |
24 | | - parent::__construct( 'Courses' ); |
25 | | - } |
26 | | - |
27 | | - /** |
28 | | - * Main method. |
29 | | - * |
30 | | - * @since 0.1 |
31 | | - * |
32 | | - * @param string|null $arg |
33 | | - */ |
34 | | - public function execute( $subPage ) { |
35 | | - parent::execute( $subPage ); |
36 | | - |
37 | | - if ( $this->subPage === '' ) { |
38 | | - $this->displayNavigation(); |
39 | | - EPCourse::displayAddNewRegion( $this->getContext() ); |
40 | | - EPCourse::displayPager( $this->getContext() ); |
41 | | - } |
42 | | - else { |
43 | | - $this->getOutput()->redirect( SpecialPage::getTitleFor( 'Course', $this->subPage )->getLocalURL() ); |
44 | | - } |
45 | | - } |
46 | | - |
47 | | -} |
Index: trunk/extensions/EducationProgram/specials/SpecialTerms.php |
— | — | @@ -1,18 +1,18 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | /** |
5 | | - * Page listing all terms in a pager with filter control. |
6 | | - * Also has a form for adding new items for those with matching priviliges. |
| 5 | + * Page listing all courses in a pager with filter control. |
| 6 | + * Also has a form for adding new items for those with matching privileges. |
7 | 7 | * |
8 | 8 | * @since 0.1 |
9 | 9 | * |
10 | | - * @file SpecialTerms.php |
| 10 | + * @file SpecialCourses.php |
11 | 11 | * @ingroup EducationProgram |
12 | 12 | * |
13 | 13 | * @licence GNU GPL v3 or later |
14 | 14 | * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
15 | 15 | */ |
16 | | -class SpecialTerms extends SpecialEPPage { |
| 16 | +class SpecialCourses extends SpecialEPPage { |
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Constructor. |
— | — | @@ -20,7 +20,7 @@ |
21 | 21 | * @since 0.1 |
22 | 22 | */ |
23 | 23 | public function __construct() { |
24 | | - parent::__construct( 'Terms' ); |
| 24 | + parent::__construct( 'Courses' ); |
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
— | — | @@ -28,18 +28,18 @@ |
29 | 29 | * |
30 | 30 | * @since 0.1 |
31 | 31 | * |
32 | | - * @param string|null $arg |
| 32 | + * @param string|null $subPage |
33 | 33 | */ |
34 | 34 | public function execute( $subPage ) { |
35 | 35 | parent::execute( $subPage ); |
36 | 36 | |
37 | 37 | if ( $this->subPage === '' ) { |
38 | 38 | $this->displayNavigation(); |
39 | | - EPTerm::displayAddNewRegion( $this->getContext() ); |
40 | | - EPTerm::displayPager( $this->getContext() ); |
| 39 | + EPCourse::displayAddNewRegion( $this->getContext() ); |
| 40 | + EPCourse::displayPager( $this->getContext() ); |
41 | 41 | } |
42 | 42 | else { |
43 | | - $this->getOutput()->redirect( SpecialPage::getTitleFor( 'Term', $this->subPage )->getLocalURL() ); |
| 43 | + $this->getOutput()->redirect( SpecialPage::getTitleFor( 'Course', $this->subPage )->getLocalURL() ); |
44 | 44 | } |
45 | 45 | } |
46 | 46 | |
Index: trunk/extensions/EducationProgram/specials/SpecialMasterCourses.php |
— | — | @@ -0,0 +1,46 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Page listing all master courses in a pager with filter control. |
| 6 | + * Also has a form for adding new items for those with matching privileges. |
| 7 | + * |
| 8 | + * @since 0.1 |
| 9 | + * |
| 10 | + * @file SpecialMasterCourses.php |
| 11 | + * @ingroup EducationProgram |
| 12 | + * |
| 13 | + * @licence GNU GPL v3 or later |
| 14 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 15 | + */ |
| 16 | +class SpecialMasterCourses extends SpecialEPPage { |
| 17 | + |
| 18 | + /** |
| 19 | + * Constructor. |
| 20 | + * |
| 21 | + * @since 0.1 |
| 22 | + */ |
| 23 | + public function __construct() { |
| 24 | + parent::__construct( 'MasterCourses' ); |
| 25 | + } |
| 26 | + |
| 27 | + /** |
| 28 | + * Main method. |
| 29 | + * |
| 30 | + * @since 0.1 |
| 31 | + * |
| 32 | + * @param string|null $arg |
| 33 | + */ |
| 34 | + public function execute( $subPage ) { |
| 35 | + parent::execute( $subPage ); |
| 36 | + |
| 37 | + if ( $this->subPage === '' ) { |
| 38 | + $this->displayNavigation(); |
| 39 | + EPMC::displayAddNewRegion( $this->getContext() ); |
| 40 | + EPMC::displayPager( $this->getContext() ); |
| 41 | + } |
| 42 | + else { |
| 43 | + $this->getOutput()->redirect( SpecialPage::getTitleFor( 'MasterCourse', $this->subPage )->getLocalURL() ); |
| 44 | + } |
| 45 | + } |
| 46 | + |
| 47 | +} |
Property changes on: trunk/extensions/EducationProgram/specials/SpecialMasterCourses.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 48 | + native |
Index: trunk/extensions/EducationProgram/specials/SpecialTerm.php |
— | — | @@ -1,18 +1,18 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | /** |
5 | | - * Shows the info for a single term, with management and |
| 5 | + * Shows the info for a single course, with management and |
6 | 6 | * enrollment controls depending on the user and his rights. |
7 | 7 | * |
8 | 8 | * @since 0.1 |
9 | 9 | * |
10 | | - * @file SpecialTerm.php |
| 10 | + * @file SpecialCourse.php |
11 | 11 | * @ingroup EducationProgram |
12 | 12 | * |
13 | 13 | * @licence GNU GPL v3 or later |
14 | 14 | * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
15 | 15 | */ |
16 | | -class SpecialTerm extends SpecialEPPage { |
| 16 | +class SpecialCourse extends SpecialEPPage { |
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Constructor. |
— | — | @@ -20,7 +20,7 @@ |
21 | 21 | * @since 0.1 |
22 | 22 | */ |
23 | 23 | public function __construct() { |
24 | | - parent::__construct( 'Term' ); |
| 24 | + parent::__construct( 'Course' ); |
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
— | — | @@ -36,50 +36,50 @@ |
37 | 37 | $out = $this->getOutput(); |
38 | 38 | |
39 | 39 | if ( trim( $subPage ) === '' ) { |
40 | | - $this->getOutput()->redirect( SpecialPage::getTitleFor( 'Terms' )->getLocalURL() ); |
| 40 | + $this->getOutput()->redirect( SpecialPage::getTitleFor( 'Courses' )->getLocalURL() ); |
41 | 41 | } |
42 | 42 | else { |
43 | | - $out->setPageTitle( wfMsgExt( 'ep-term-title', 'parsemag', $this->subPage ) ); |
| 43 | + $out->setPageTitle( wfMsgExt( 'ep-course-title', 'parsemag', $this->subPage ) ); |
44 | 44 | |
45 | | - $term = EPTerm::selectRow( null, array( 'id' => $this->subPage ) ); |
| 45 | + $course = EPCourse::selectRow( null, array( 'id' => $this->subPage ) ); |
46 | 46 | |
47 | | - if ( $term === false ) { |
| 47 | + if ( $course === false ) { |
48 | 48 | $this->displayNavigation(); |
49 | 49 | |
50 | 50 | if ( $this->getUser()->isAllowed( 'ep-term' ) ) { |
51 | | - $out->addWikiMsg( 'ep-term-create', $this->subPage ); |
52 | | - EPTerm::displayAddNewRegion( $this->getContext(), array( 'id' => $this->subPage ) ); |
| 51 | + $out->addWikiMsg( 'ep-course-create', $this->subPage ); |
| 52 | + EPCourse::displayAddNewRegion( $this->getContext(), array( 'id' => $this->subPage ) ); |
53 | 53 | } |
54 | 54 | else { |
55 | | - $out->addWikiMsg( 'ep-term-none', $this->subPage ); |
| 55 | + $out->addWikiMsg( 'ep-course-none', $this->subPage ); |
56 | 56 | } |
57 | 57 | } |
58 | 58 | else { |
59 | 59 | $links = array(); |
60 | 60 | |
61 | | - if ( $this->getUser()->isAllowed( 'ep-term' ) ) { |
62 | | - $links[wfMsg( 'ep-term-nav-edit' )] = |
63 | | - array( SpecialPage::getTitleFor( 'EditTerm', $this->subPage ) ) |
64 | | - + Linker::tooltipAndAccesskeyAttribs( 'ep-edit-term' ); |
| 61 | + if ( $this->getUser()->isAllowed( 'ep-course' ) ) { |
| 62 | + $links[wfMsg( 'ep-course-nav-edit' )] = |
| 63 | + array( SpecialPage::getTitleFor( 'EditCourse', $this->subPage ) ) |
| 64 | + + Linker::tooltipAndAccesskeyAttribs( 'ep-edit-course' ); |
65 | 65 | } |
66 | 66 | |
67 | 67 | $this->displayNavigation( $links ); |
68 | 68 | |
69 | | - $this->displaySummary( $term ); |
| 69 | + $this->displaySummary( $course ); |
70 | 70 | |
71 | | - $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-term-description' ) ) ); |
| 71 | + $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-course-description' ) ) ); |
72 | 72 | |
73 | | - $out->addHTML( $this->getOutput()->parse( $term->getField( 'description' ) ) ); |
| 73 | + $out->addHTML( $this->getOutput()->parse( $course->getField( 'description' ) ) ); |
74 | 74 | |
75 | 75 | $studentIds = array_map( |
76 | 76 | function( EPStudent $student ) { |
77 | 77 | return $student->getId(); |
78 | 78 | }, |
79 | | - $term->getStudents( 'id' ) |
| 79 | + $course->getStudents( 'id' ) |
80 | 80 | ); |
81 | 81 | |
82 | 82 | if ( count( $studentIds ) > 0 ) { |
83 | | - $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-term-students' ) ) ); |
| 83 | + $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-course-students' ) ) ); |
84 | 84 | EPStudent::displayPager( $this->getContext(), array( 'id' => $studentIds ) ); |
85 | 85 | } |
86 | 86 | else { |
— | — | @@ -94,35 +94,35 @@ |
95 | 95 | * |
96 | 96 | * @since 0.1 |
97 | 97 | * |
98 | | - * @param EPTerm $term |
| 98 | + * @param EPCourse $course |
99 | 99 | * |
100 | 100 | * @return array |
101 | 101 | */ |
102 | | - protected function getSummaryData( EPDBObject $term ) { |
| 102 | + protected function getSummaryData( EPDBObject $course ) { |
103 | 103 | $stats = array(); |
104 | 104 | |
105 | | - $org = EPOrg::selectFieldsRow( 'name', array( 'id' => $term->getField( 'org_id' ) ) ); |
| 105 | + $org = EPOrg::selectFieldsRow( 'name', array( 'id' => $course->getField( 'org_id' ) ) ); |
106 | 106 | |
107 | 107 | $stats['org'] = Linker::linkKnown( |
108 | 108 | SpecialPage::getTitleFor( 'Institution', $org ), |
109 | 109 | htmlspecialchars( $org ) |
110 | 110 | ); |
111 | 111 | |
112 | | - $course = EPCourse::selectFieldsRow( 'name', array( 'id' => $term->getField( 'course_id' ) ) ); |
| 112 | + $course = EPCourse::selectFieldsRow( 'name', array( 'id' => $course->getField( 'course_id' ) ) ); |
113 | 113 | |
114 | 114 | $stats['course'] = Linker::linkKnown( |
115 | 115 | SpecialPage::getTitleFor( 'Course', $course ), |
116 | 116 | htmlspecialchars( $course ) |
117 | 117 | ); |
118 | 118 | |
119 | | - $stats['year'] = htmlspecialchars( $this->getLanguage()->formatNum( $term->getField( 'year' ), true ) ); |
120 | | - $stats['start'] = htmlspecialchars( $this->getLanguage()->timeanddate( $term->getField( 'start' ), true ) ); |
121 | | - $stats['end'] = htmlspecialchars( $this->getLanguage()->timeanddate( $term->getField( 'end' ), true ) ); |
| 119 | + $stats['year'] = htmlspecialchars( $this->getLanguage()->formatNum( $course->getField( 'year' ), true ) ); |
| 120 | + $stats['start'] = htmlspecialchars( $this->getLanguage()->timeanddate( $course->getField( 'start' ), true ) ); |
| 121 | + $stats['end'] = htmlspecialchars( $this->getLanguage()->timeanddate( $course->getField( 'end' ), true ) ); |
122 | 122 | |
123 | 123 | if ( $this->getUser()->isAllowed( 'ep-token' ) ) { |
124 | 124 | $stats['token'] = Linker::linkKnown( |
125 | | - SpecialPage::getTitleFor( 'Enroll', $term->getId() . '/' . $term->getField( 'token' ) ), |
126 | | - htmlspecialchars( $term->getField( 'token' ) ) |
| 125 | + SpecialPage::getTitleFor( 'Enroll', $course->getId() . '/' . $course->getField( 'token' ) ), |
| 126 | + htmlspecialchars( $course->getField( 'token' ) ) |
127 | 127 | ); |
128 | 128 | } |
129 | 129 | |
Index: trunk/extensions/EducationProgram/specials/SpecialMasterCourse.php |
— | — | @@ -0,0 +1,221 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Shows the info for a single master course, with management and |
| 6 | + * enrollment controls depending on the user and his rights. |
| 7 | + * |
| 8 | + * @since 0.1 |
| 9 | + * |
| 10 | + * @file SpecialMasterCourse.php |
| 11 | + * @ingroup EducationProgram |
| 12 | + * |
| 13 | + * @licence GNU GPL v3 or later |
| 14 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 15 | + */ |
| 16 | +class SpecialMasterCourse extends SpecialEPPage { |
| 17 | + |
| 18 | + /** |
| 19 | + * Constructor. |
| 20 | + * |
| 21 | + * @since 0.1 |
| 22 | + */ |
| 23 | + public function __construct() { |
| 24 | + parent::__construct( 'MasterCourse' ); |
| 25 | + } |
| 26 | + |
| 27 | + /** |
| 28 | + * Main method. |
| 29 | + * |
| 30 | + * @since 0.1 |
| 31 | + * |
| 32 | + * @param string $subPage |
| 33 | + */ |
| 34 | + public function execute( $subPage ) { |
| 35 | + parent::execute( $subPage ); |
| 36 | + |
| 37 | + $out = $this->getOutput(); |
| 38 | + |
| 39 | + if ( trim( $subPage ) === '' ) { |
| 40 | + $this->getOutput()->redirect( SpecialPage::getTitleFor( 'MasterCourses' )->getLocalURL() ); |
| 41 | + } |
| 42 | + else { |
| 43 | + $out->setPageTitle( wfMsgExt( 'ep-mc-title', 'parsemag', $this->subPage ) ); |
| 44 | + |
| 45 | + $masterCourse = EPCourse::selectRow( null, array( 'name' => $this->subPage ) ); |
| 46 | + |
| 47 | + if ( $masterCourse === false ) { |
| 48 | + $this->displayNavigation(); |
| 49 | + |
| 50 | + if ( $this->getUser()->isAllowed( 'ep-mc' ) ) { |
| 51 | + $out->addWikiMsg( 'ep-mc-create', $this->subPage ); |
| 52 | + EPCourse::displayAddNewRegion( $this->getContext(), array( 'name' => $this->subPage ) ); |
| 53 | + } |
| 54 | + else { |
| 55 | + $out->addWikiMsg( 'ep-mc-none', $this->subPage ); |
| 56 | + } |
| 57 | + } |
| 58 | + else { |
| 59 | + $links = array(); |
| 60 | + |
| 61 | + if ( $this->getUser()->isAllowed( 'ep-mc' ) ) { |
| 62 | + $links[wfMsg( 'ep-mc-nav-edit' )] = |
| 63 | + array( SpecialPage::getTitleFor( 'EditMasterCourse', $this->subPage ) ) |
| 64 | + + Linker::tooltipAndAccesskeyAttribs( 'ep-edit-mc' ); |
| 65 | + } |
| 66 | + |
| 67 | + $this->displayNavigation( $links ); |
| 68 | + |
| 69 | + $this->displaySummary( $masterCourse ); |
| 70 | + |
| 71 | + $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-mc-description' ) ) ); |
| 72 | + |
| 73 | + $out->addHTML( $this->getOutput()->parse( $masterCourse->getField( 'description' ) ) ); |
| 74 | + |
| 75 | + $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-mc-courses' ) ) ); |
| 76 | + |
| 77 | + EPCourse::displayPager( $this->getContext(), array( 'mc_id' => $masterCourse->getId() ) ); |
| 78 | + |
| 79 | + if ( $this->getUser()->isAllowed( 'ep-mc' ) ) { |
| 80 | + $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-mc-add-term' ) ) ); |
| 81 | + |
| 82 | + EPCourse::displayAddNewControl( $this->getContext(), array( 'mc' => $masterCourse->getId() ) ); |
| 83 | + } |
| 84 | + } |
| 85 | + } |
| 86 | + } |
| 87 | + |
| 88 | + /** |
| 89 | + * Gets the summary data. |
| 90 | + * |
| 91 | + * @since 0.1 |
| 92 | + * |
| 93 | + * @param EPMC $masterCourse |
| 94 | + * |
| 95 | + * @return array |
| 96 | + */ |
| 97 | + protected function getSummaryData( EPDBObject $masterCourse ) { |
| 98 | + $stats = array(); |
| 99 | + |
| 100 | + $stats['name'] = htmlspecialchars( $masterCourse->getField( 'name' ) ); |
| 101 | + |
| 102 | + $org = EPOrg::selectFieldsRow( 'name', array( 'id' => $masterCourse->getField( 'org_id' ) ) ); |
| 103 | + |
| 104 | + $stats['org'] = Linker::linkKnown( |
| 105 | + SpecialPage::getTitleFor( 'Institution', $org ), |
| 106 | + htmlspecialchars( $org ) |
| 107 | + ); |
| 108 | + |
| 109 | + $stats['status'] = wfMsgHtml( $masterCourse->getField( 'active' ) ? 'ep-course-active' : 'ep-course-inactive' ); |
| 110 | + |
| 111 | + $lang = $this->getLanguage(); |
| 112 | + |
| 113 | + $stats['students'] = htmlspecialchars( $lang->formatNum( $masterCourse->getField( 'students' ) ) ); |
| 114 | + |
| 115 | + $courseCount = EPCourse::count( array( 'mc_id' => $masterCourse->getId() ) ); |
| 116 | + $stats['courses'] = htmlspecialchars( $lang->formatNum( $courseCount ) ); |
| 117 | + |
| 118 | + if ( $courseCount > 0 ) { |
| 119 | + $stats['courses'] = Linker::linkKnown( |
| 120 | + SpecialPage::getTitleFor( 'Courses' ), |
| 121 | + $stats['courses'], |
| 122 | + array(), |
| 123 | + array( 'mc_id' => $masterCourse->getId() ) |
| 124 | + ); |
| 125 | + } |
| 126 | + |
| 127 | + $stats['instructors'] = $this->getInstructorsList( $masterCourse ) . $this->getInstructorControls( $masterCourse ); |
| 128 | + |
| 129 | + return $stats; |
| 130 | + } |
| 131 | + |
| 132 | + /** |
| 133 | + * Returns a list with the instructors for the provided course |
| 134 | + * or a message indicating there are none. |
| 135 | + * |
| 136 | + * @since 0.1 |
| 137 | + * |
| 138 | + * @param EPMC $masterCourse |
| 139 | + * |
| 140 | + * @return string |
| 141 | + */ |
| 142 | + protected function getInstructorsList( EPMC $masterCourse ) { |
| 143 | + $instructors = $masterCourse->getInstructors(); |
| 144 | + |
| 145 | + if ( count( $instructors ) > 0 ) { |
| 146 | + $instList = array(); |
| 147 | + |
| 148 | + foreach ( $instructors as /* EPInstructor */ $instructor ) { |
| 149 | + $instList[] = $instructor->getUserLink() . $instructor->getToolLinks( $this->getContext(), $masterCourse ); |
| 150 | + } |
| 151 | + |
| 152 | + if ( false ) { // count( $instructors ) == 1 |
| 153 | + $html = $instList[0]; |
| 154 | + } |
| 155 | + else { |
| 156 | + $html = '<ul><li>' . implode( '</li><li>', $instList ) . '</li></ul>'; |
| 157 | + } |
| 158 | + } |
| 159 | + else { |
| 160 | + $html = wfMsgHtml( 'ep-course-no-instructors' ); |
| 161 | + } |
| 162 | + |
| 163 | + return Html::rawElement( |
| 164 | + 'div', |
| 165 | + array( 'id' => 'ep-course-instructors' ), |
| 166 | + $html |
| 167 | + ); |
| 168 | + } |
| 169 | + |
| 170 | + /** |
| 171 | + * Returns instructor addition controls for the course if the |
| 172 | + * current user has the right permissions. |
| 173 | + * |
| 174 | + * @since 0.1 |
| 175 | + * |
| 176 | + * @param EPMC $masterCourse |
| 177 | + * |
| 178 | + * @return string |
| 179 | + */ |
| 180 | + protected function getInstructorControls( EPMC $masterCourse ) { |
| 181 | + $user = $this->getUser(); |
| 182 | + $links = array(); |
| 183 | + |
| 184 | + if ( ( $user->isAllowed( 'ep-instructor' ) || $user->isAllowed( 'ep-beinstructor' ) ) |
| 185 | + && !in_array( $user->getId(), $masterCourse->getField( 'instructors' ) ) |
| 186 | + ) { |
| 187 | + $links[] = Html::element( |
| 188 | + 'a', |
| 189 | + array( |
| 190 | + 'href' => '#', |
| 191 | + 'class' => 'ep-add-instructor', |
| 192 | + 'data-courseid' => $masterCourse->getId(), |
| 193 | + 'data-coursename' => $masterCourse->getField( 'name' ), |
| 194 | + 'data-mode' => 'self', |
| 195 | + ), |
| 196 | + wfMsg( 'ep-course-become-instructor' ) |
| 197 | + ); |
| 198 | + } |
| 199 | + |
| 200 | + if ( $user->isAllowed( 'ep-instructor' ) ) { |
| 201 | + $links[] = Html::element( |
| 202 | + 'a', |
| 203 | + array( |
| 204 | + 'href' => '#', |
| 205 | + 'class' => 'ep-add-instructor', |
| 206 | + 'data-courseid' => $masterCourse->getId(), |
| 207 | + 'data-coursename' => $masterCourse->getField( 'name' ), |
| 208 | + ), |
| 209 | + wfMsg( 'ep-course-add-instructor' ) |
| 210 | + ); |
| 211 | + } |
| 212 | + |
| 213 | + if ( count( $links ) > 0 ) { |
| 214 | + $this->getOutput()->addModules( 'ep.instructor' ); |
| 215 | + return '<br />' . $this->getLanguage()->pipeList( $links ); |
| 216 | + } |
| 217 | + else { |
| 218 | + return ''; |
| 219 | + } |
| 220 | + } |
| 221 | + |
| 222 | +} |
Property changes on: trunk/extensions/EducationProgram/specials/SpecialMasterCourse.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 223 | + native |
Index: trunk/extensions/EducationProgram/EducationProgram.php |
— | — | @@ -117,7 +117,7 @@ |
118 | 118 | $wgSpecialPages['EducationProgram'] = 'SpecialEducationProgram'; |
119 | 119 | $wgSpecialPages['EditCourse'] = 'SpecialEditCourse'; |
120 | 120 | $wgSpecialPages['EditInstitution'] = 'SpecialEditInstitution'; |
121 | | -$wgSpecialPages['EditMC'] = 'SpecialEditMC'; |
| 121 | +$wgSpecialPages['EditMasterCourse'] = 'SpecialEditMC'; |
122 | 122 | $wgSpecialPages['Enroll'] = 'SpecialEnroll'; |
123 | 123 | $wgSpecialPages['CampusAmbassadors'] = 'SpecialCAs'; |
124 | 124 | $wgSpecialPages['OnlineAmbassadors'] = 'SpecialOAs'; |