Index: trunk/extensions/EducationProgram/actions/EPDeleteAction.php |
— | — | @@ -32,6 +32,7 @@ |
33 | 33 | protected function __construct( Page $page, IContextSource $context = null, DBTable $table ) { |
34 | 34 | $this->table = $table; |
35 | 35 | parent::__construct( $page, $context ); |
| 36 | + $this->getOutput()->addModules( 'ep.formpage' ); |
36 | 37 | } |
37 | 38 | |
38 | 39 | /** |
— | — | @@ -111,6 +112,7 @@ |
112 | 113 | $out->addElement( |
113 | 114 | 'button', |
114 | 115 | array( |
| 116 | + 'id' => 'cancelDelete', |
115 | 117 | 'class' => 'ep-delete-cancel', |
116 | 118 | 'target-url' => $this->getTitle()->getLocalURL(), |
117 | 119 | ), |
Index: trunk/extensions/EducationProgram/specials/SpecialMyCourses.php |
— | — | @@ -156,17 +156,24 @@ |
157 | 157 | */ |
158 | 158 | protected function displayRoleAssociation( $class ) { |
159 | 159 | $ambassador = $class::newFromUser( $this->getUser() ); |
160 | | - |
161 | | - $courseIds = array_map( |
162 | | - function( EPCourse $course ) { |
163 | | - return $course->getId(); |
164 | | - }, |
165 | | - $ambassador->getCourses( 'id' ) |
166 | | - ); |
167 | | - |
168 | | - if ( count( $courseIds ) > 0 ) { |
| 160 | + $courses = $ambassador->getCourses( array( 'id', 'name' ) ); |
| 161 | + |
| 162 | + if ( count( $courses ) > 0 ) { |
169 | 163 | $this->getOutput()->addElement( 'h2', array(), wfMsg( 'ep-mycourses-courses-' . strtolower( $class ) ) ); |
170 | | - EPCourse::displayPager( $this->getContext(), array( 'id' => $courseIds ), true, $class ); |
| 164 | + |
| 165 | + if ( $class == 'EPInstructor' ) { |
| 166 | + $this->displayCourseTables( $courses ); |
| 167 | + } |
| 168 | + else { |
| 169 | + $courseIds = array_map( |
| 170 | + function( EPCourse $course ) { |
| 171 | + return $course->getId(); |
| 172 | + }, |
| 173 | + $courses |
| 174 | + ); |
| 175 | + |
| 176 | + EPCourse::displayPager( $this->getContext(), array( 'id' => $courseIds ), true, $class ); |
| 177 | + } |
171 | 178 | } |
172 | 179 | else { |
173 | 180 | $this->getOutput()->addWikiMsg( 'ep-mycourses-nocourses-' . strtolower( $class ) ); |
— | — | @@ -174,6 +181,35 @@ |
175 | 182 | } |
176 | 183 | |
177 | 184 | /** |
| 185 | + * Display a list of courses, each as a h3 section with the student/article table in it. |
| 186 | + * |
| 187 | + * @param array $courses |
| 188 | + */ |
| 189 | + protected function displayCourseTables( array $courses ) { |
| 190 | + $out = $this->getOutput(); |
| 191 | + |
| 192 | + foreach ( $courses as /* EPCourse */ $course ) { |
| 193 | + $out->addElement( 'h3', array(), $course->getField( 'name' ) ); |
| 194 | + |
| 195 | + $pager = new EPArticleTable( |
| 196 | + $this->getContext(), |
| 197 | + array( 'id' => $this->getUser()->getId() ), |
| 198 | + array( 'course_id' => $course->getId() ) |
| 199 | + ); |
| 200 | + |
| 201 | + if ( $pager->getNumRows() ) { |
| 202 | + $out->addHTML( |
| 203 | + $pager->getFilterControl() . |
| 204 | + $pager->getNavigationBar() . |
| 205 | + $pager->getBody() . |
| 206 | + $pager->getNavigationBar() . |
| 207 | + $pager->getMultipleItemControl() |
| 208 | + ); |
| 209 | + } |
| 210 | + } |
| 211 | + } |
| 212 | + |
| 213 | + /** |
178 | 214 | * Display enrollment info for a single course. |
179 | 215 | * |
180 | 216 | * @since 0.1 |
Index: trunk/extensions/EducationProgram/resources/ep.formpage.js |
— | — | @@ -12,11 +12,13 @@ |
13 | 13 | |
14 | 14 | $( '#bodyContent' ).find( '[type="submit"]' ).button(); |
15 | 15 | |
16 | | - $( '#cancelEdit' ).click( function( event ) { |
| 16 | + $( '#cancelEdit, #cancelDelete' ).click( function( event ) { |
17 | 17 | window.location = $( this ).attr( 'target-url' ); |
18 | 18 | event.preventDefault(); |
19 | 19 | } ); |
20 | 20 | |
| 21 | + $( '#cancelDelete' ).button(); |
| 22 | + |
21 | 23 | } ); |
22 | 24 | |
23 | 25 | })( window.jQuery, window.mediaWiki ); |
\ No newline at end of file |