r112246 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112245‎ | r112246 | r112247 >
Date:21:47, 23 February 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
work on course listing for instructors on special mycourses
Modified paths:
  • /trunk/extensions/EducationProgram/actions/EPDeleteAction.php (modified) (history)
  • /trunk/extensions/EducationProgram/resources/ep.formpage.js (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialMyCourses.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/actions/EPDeleteAction.php
@@ -32,6 +32,7 @@
3333 protected function __construct( Page $page, IContextSource $context = null, DBTable $table ) {
3434 $this->table = $table;
3535 parent::__construct( $page, $context );
 36+ $this->getOutput()->addModules( 'ep.formpage' );
3637 }
3738
3839 /**
@@ -111,6 +112,7 @@
112113 $out->addElement(
113114 'button',
114115 array(
 116+ 'id' => 'cancelDelete',
115117 'class' => 'ep-delete-cancel',
116118 'target-url' => $this->getTitle()->getLocalURL(),
117119 ),
Index: trunk/extensions/EducationProgram/specials/SpecialMyCourses.php
@@ -156,17 +156,24 @@
157157 */
158158 protected function displayRoleAssociation( $class ) {
159159 $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 ) {
169163 $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+ }
171178 }
172179 else {
173180 $this->getOutput()->addWikiMsg( 'ep-mycourses-nocourses-' . strtolower( $class ) );
@@ -174,6 +181,35 @@
175182 }
176183
177184 /**
 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+ /**
178214 * Display enrollment info for a single course.
179215 *
180216 * @since 0.1
Index: trunk/extensions/EducationProgram/resources/ep.formpage.js
@@ -12,11 +12,13 @@
1313
1414 $( '#bodyContent' ).find( '[type="submit"]' ).button();
1515
16 - $( '#cancelEdit' ).click( function( event ) {
 16+ $( '#cancelEdit, #cancelDelete' ).click( function( event ) {
1717 window.location = $( this ).attr( 'target-url' );
1818 event.preventDefault();
1919 } );
2020
 21+ $( '#cancelDelete' ).button();
 22+
2123 } );
2224
2325 })( window.jQuery, window.mediaWiki );
\ No newline at end of file

Status & tagging log