Index: trunk/extensions/EducationProgram/actions/ViewCourseAction.php |
— | — | @@ -48,10 +48,22 @@ |
49 | 49 | |
50 | 50 | if ( count( $studentIds ) > 0 ) { |
51 | 51 | $out->addElement( 'h2', array(), wfMsg( 'ep-course-articles' ) ); |
52 | | - EPArticle::displayPager( $this->getContext(), array( 'course_id' => $course->getId() ) ); |
53 | 52 | |
54 | | - $out->addElement( 'h2', array(), wfMsg( 'ep-course-students' ) ); |
55 | | - EPStudent::displayPager( $this->getContext(), array( 'id' => $studentIds ) ); |
| 53 | + $pager = new EPArticleTable( $this->getContext(), array( 'id' => $studentIds ) ); |
| 54 | + |
| 55 | + if ( $pager->getNumRows() ) { |
| 56 | + $out->addHTML( |
| 57 | + $pager->getFilterControl() . |
| 58 | + $pager->getNavigationBar() . |
| 59 | + $pager->getBody() . |
| 60 | + $pager->getNavigationBar() . |
| 61 | + $pager->getMultipleItemControl() |
| 62 | + ); |
| 63 | + } |
| 64 | + |
| 65 | + // EPArticle::displayPager( $this->getContext(), array( 'course_id' => $course->getId() ) ); |
| 66 | + //$out->addElement( 'h2', array(), wfMsg( 'ep-course-students' ) ); |
| 67 | + |
56 | 68 | } |
57 | 69 | else { |
58 | 70 | // TODO |
Index: trunk/extensions/EducationProgram/includes/EPArticleTable.php |
— | — | @@ -18,12 +18,14 @@ |
19 | 19 | * |
20 | 20 | * @param IContextSource $context |
21 | 21 | * @param array $conds |
| 22 | + * @param array $articleConds |
22 | 23 | */ |
23 | | - public function __construct( IContextSource $context, array $conds = array() ) { |
| 24 | + public function __construct( IContextSource $context, array $conds = array(), $articleConds = array() ) { |
24 | 25 | $this->mDefaultDirection = true; |
| 26 | + $this->articleConds = $articleConds; |
25 | 27 | |
26 | 28 | // when MW 1.19 becomes min, we want to pass an IContextSource $context here. |
27 | | - parent::__construct( $context, $conds, 'EPStudent' ); |
| 29 | + parent::__construct( $context, $conds, EPStudents::singleton() ); |
28 | 30 | } |
29 | 31 | |
30 | 32 | /** |
— | — | @@ -65,6 +67,10 @@ |
66 | 68 | |
67 | 69 | $value = Linker::userLink( $value, $name ) . Linker::userToolLinks( $value, $name ); |
68 | 70 | break; |
| 71 | + case '_articles': |
| 72 | + // TODO |
| 73 | + $value = serialize( $this->articles[$this->currentObject->getField( 'user_id' )] ); |
| 74 | + break; |
69 | 75 | } |
70 | 76 | |
71 | 77 | return $value; |
— | — | @@ -94,9 +100,35 @@ |
95 | 101 | public function getFieldNames() { |
96 | 102 | $fields = parent::getFieldNames(); |
97 | 103 | |
98 | | - //$fields['_courses_current'] = 'current-courses'; |
| 104 | + $fields['_articles'] = 'articles'; |
99 | 105 | |
100 | 106 | return $fields; |
101 | 107 | } |
102 | 108 | |
| 109 | + protected $articles = array(); |
| 110 | + |
| 111 | + protected $articleConds; |
| 112 | + |
| 113 | + /** |
| 114 | + * (non-PHPdoc) |
| 115 | + * @see IndexPager::doBatchLookups() |
| 116 | + */ |
| 117 | + protected function doBatchLookups() { |
| 118 | + $userIds = array(); |
| 119 | + |
| 120 | + while( $student = $this->mResult->fetchObject() ) { |
| 121 | + $field = EPStudents::singleton()->getPrefixedField( 'user_id' ); |
| 122 | + $userIds[] = $student->$field; |
| 123 | + $this->articles[$student->$field] = array(); |
| 124 | + } |
| 125 | + |
| 126 | + $conditions = array_merge( array( 'user_id' => $userIds ), $this->articleConds ); |
| 127 | + |
| 128 | + $articles = EPArticles::singleton()->select( null, $conditions ); |
| 129 | + |
| 130 | + foreach ( $articles as /* EPArticle */ $article ) { |
| 131 | + $this->articles[$article->getField( 'user_id' )][] = $article; |
| 132 | + } |
| 133 | + } |
| 134 | + |
103 | 135 | } |
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php |
— | — | @@ -271,9 +271,11 @@ |
272 | 272 | 'epstudentpager-yes' => 'Yes', |
273 | 273 | 'epstudentpager-no' => 'No', |
274 | 274 | |
| 275 | + // Student article pager |
| 276 | + 'epstudentpager-header-articles' => 'Articles', |
| 277 | + |
275 | 278 | // Article pager |
276 | 279 | 'ep-articles-noresults' => 'There are no articles to list.', |
277 | | - 'ep-articles-noresults' => 'There are no articles to list.', |
278 | 280 | |
279 | 281 | // Campus ambassador pager |
280 | 282 | 'epcapager-header-photo' => 'Photo', |