r109674 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109673‎ | r109674 | r109675 >
Date:05:28, 21 January 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
follow up to r109656 - renaming
Modified paths:
  • /trunk/extensions/EducationProgram/EducationProgram.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialCourse.php (deleted) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialCourses.php (deleted) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialMasterCourse.php (added) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialMasterCourses.php (added) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialTerm.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialTerms.php (modified) (history)

Diff [purge]

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 @@
22 <?php
33
44 /**
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.
77 *
88 * @since 0.1
99 *
10 - * @file SpecialTerms.php
 10+ * @file SpecialCourses.php
1111 * @ingroup EducationProgram
1212 *
1313 * @licence GNU GPL v3 or later
1414 * @author Jeroen De Dauw < jeroendedauw@gmail.com >
1515 */
16 -class SpecialTerms extends SpecialEPPage {
 16+class SpecialCourses extends SpecialEPPage {
1717
1818 /**
1919 * Constructor.
@@ -20,7 +20,7 @@
2121 * @since 0.1
2222 */
2323 public function __construct() {
24 - parent::__construct( 'Terms' );
 24+ parent::__construct( 'Courses' );
2525 }
2626
2727 /**
@@ -28,18 +28,18 @@
2929 *
3030 * @since 0.1
3131 *
32 - * @param string|null $arg
 32+ * @param string|null $subPage
3333 */
3434 public function execute( $subPage ) {
3535 parent::execute( $subPage );
3636
3737 if ( $this->subPage === '' ) {
3838 $this->displayNavigation();
39 - EPTerm::displayAddNewRegion( $this->getContext() );
40 - EPTerm::displayPager( $this->getContext() );
 39+ EPCourse::displayAddNewRegion( $this->getContext() );
 40+ EPCourse::displayPager( $this->getContext() );
4141 }
4242 else {
43 - $this->getOutput()->redirect( SpecialPage::getTitleFor( 'Term', $this->subPage )->getLocalURL() );
 43+ $this->getOutput()->redirect( SpecialPage::getTitleFor( 'Course', $this->subPage )->getLocalURL() );
4444 }
4545 }
4646
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
148 + native
Index: trunk/extensions/EducationProgram/specials/SpecialTerm.php
@@ -1,18 +1,18 @@
22 <?php
33
44 /**
5 - * Shows the info for a single term, with management and
 5+ * Shows the info for a single course, with management and
66 * enrollment controls depending on the user and his rights.
77 *
88 * @since 0.1
99 *
10 - * @file SpecialTerm.php
 10+ * @file SpecialCourse.php
1111 * @ingroup EducationProgram
1212 *
1313 * @licence GNU GPL v3 or later
1414 * @author Jeroen De Dauw < jeroendedauw@gmail.com >
1515 */
16 -class SpecialTerm extends SpecialEPPage {
 16+class SpecialCourse extends SpecialEPPage {
1717
1818 /**
1919 * Constructor.
@@ -20,7 +20,7 @@
2121 * @since 0.1
2222 */
2323 public function __construct() {
24 - parent::__construct( 'Term' );
 24+ parent::__construct( 'Course' );
2525 }
2626
2727 /**
@@ -36,50 +36,50 @@
3737 $out = $this->getOutput();
3838
3939 if ( trim( $subPage ) === '' ) {
40 - $this->getOutput()->redirect( SpecialPage::getTitleFor( 'Terms' )->getLocalURL() );
 40+ $this->getOutput()->redirect( SpecialPage::getTitleFor( 'Courses' )->getLocalURL() );
4141 }
4242 else {
43 - $out->setPageTitle( wfMsgExt( 'ep-term-title', 'parsemag', $this->subPage ) );
 43+ $out->setPageTitle( wfMsgExt( 'ep-course-title', 'parsemag', $this->subPage ) );
4444
45 - $term = EPTerm::selectRow( null, array( 'id' => $this->subPage ) );
 45+ $course = EPCourse::selectRow( null, array( 'id' => $this->subPage ) );
4646
47 - if ( $term === false ) {
 47+ if ( $course === false ) {
4848 $this->displayNavigation();
4949
5050 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 ) );
5353 }
5454 else {
55 - $out->addWikiMsg( 'ep-term-none', $this->subPage );
 55+ $out->addWikiMsg( 'ep-course-none', $this->subPage );
5656 }
5757 }
5858 else {
5959 $links = array();
6060
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' );
6565 }
6666
6767 $this->displayNavigation( $links );
6868
69 - $this->displaySummary( $term );
 69+ $this->displaySummary( $course );
7070
71 - $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-term-description' ) ) );
 71+ $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-course-description' ) ) );
7272
73 - $out->addHTML( $this->getOutput()->parse( $term->getField( 'description' ) ) );
 73+ $out->addHTML( $this->getOutput()->parse( $course->getField( 'description' ) ) );
7474
7575 $studentIds = array_map(
7676 function( EPStudent $student ) {
7777 return $student->getId();
7878 },
79 - $term->getStudents( 'id' )
 79+ $course->getStudents( 'id' )
8080 );
8181
8282 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' ) ) );
8484 EPStudent::displayPager( $this->getContext(), array( 'id' => $studentIds ) );
8585 }
8686 else {
@@ -94,35 +94,35 @@
9595 *
9696 * @since 0.1
9797 *
98 - * @param EPTerm $term
 98+ * @param EPCourse $course
9999 *
100100 * @return array
101101 */
102 - protected function getSummaryData( EPDBObject $term ) {
 102+ protected function getSummaryData( EPDBObject $course ) {
103103 $stats = array();
104104
105 - $org = EPOrg::selectFieldsRow( 'name', array( 'id' => $term->getField( 'org_id' ) ) );
 105+ $org = EPOrg::selectFieldsRow( 'name', array( 'id' => $course->getField( 'org_id' ) ) );
106106
107107 $stats['org'] = Linker::linkKnown(
108108 SpecialPage::getTitleFor( 'Institution', $org ),
109109 htmlspecialchars( $org )
110110 );
111111
112 - $course = EPCourse::selectFieldsRow( 'name', array( 'id' => $term->getField( 'course_id' ) ) );
 112+ $course = EPCourse::selectFieldsRow( 'name', array( 'id' => $course->getField( 'course_id' ) ) );
113113
114114 $stats['course'] = Linker::linkKnown(
115115 SpecialPage::getTitleFor( 'Course', $course ),
116116 htmlspecialchars( $course )
117117 );
118118
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 ) );
122122
123123 if ( $this->getUser()->isAllowed( 'ep-token' ) ) {
124124 $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' ) )
127127 );
128128 }
129129
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
1223 + native
Index: trunk/extensions/EducationProgram/EducationProgram.php
@@ -117,7 +117,7 @@
118118 $wgSpecialPages['EducationProgram'] = 'SpecialEducationProgram';
119119 $wgSpecialPages['EditCourse'] = 'SpecialEditCourse';
120120 $wgSpecialPages['EditInstitution'] = 'SpecialEditInstitution';
121 -$wgSpecialPages['EditMC'] = 'SpecialEditMC';
 121+$wgSpecialPages['EditMasterCourse'] = 'SpecialEditMC';
122122 $wgSpecialPages['Enroll'] = 'SpecialEnroll';
123123 $wgSpecialPages['CampusAmbassadors'] = 'SpecialCAs';
124124 $wgSpecialPages['OnlineAmbassadors'] = 'SpecialOAs';

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r109656schema changes currently completely breaking the extension and added hook to ...jeroendedauw22:24, 20 January 2012

Status & tagging log