r111586 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111585‎ | r111586 | r111587 >
Date:21:36, 15 February 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
work on article pager
Modified paths:
  • /trunk/extensions/EducationProgram/EducationProgram.i18n.php (modified) (history)
  • /trunk/extensions/EducationProgram/actions/ViewCourseAction.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPArticleTable.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/actions/ViewCourseAction.php
@@ -48,10 +48,22 @@
4949
5050 if ( count( $studentIds ) > 0 ) {
5151 $out->addElement( 'h2', array(), wfMsg( 'ep-course-articles' ) );
52 - EPArticle::displayPager( $this->getContext(), array( 'course_id' => $course->getId() ) );
5352
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+
5668 }
5769 else {
5870 // TODO
Index: trunk/extensions/EducationProgram/includes/EPArticleTable.php
@@ -18,12 +18,14 @@
1919 *
2020 * @param IContextSource $context
2121 * @param array $conds
 22+ * @param array $articleConds
2223 */
23 - public function __construct( IContextSource $context, array $conds = array() ) {
 24+ public function __construct( IContextSource $context, array $conds = array(), $articleConds = array() ) {
2425 $this->mDefaultDirection = true;
 26+ $this->articleConds = $articleConds;
2527
2628 // 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() );
2830 }
2931
3032 /**
@@ -65,6 +67,10 @@
6668
6769 $value = Linker::userLink( $value, $name ) . Linker::userToolLinks( $value, $name );
6870 break;
 71+ case '_articles':
 72+ // TODO
 73+ $value = serialize( $this->articles[$this->currentObject->getField( 'user_id' )] );
 74+ break;
6975 }
7076
7177 return $value;
@@ -94,9 +100,35 @@
95101 public function getFieldNames() {
96102 $fields = parent::getFieldNames();
97103
98 - //$fields['_courses_current'] = 'current-courses';
 104+ $fields['_articles'] = 'articles';
99105
100106 return $fields;
101107 }
102108
 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+
103135 }
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php
@@ -271,9 +271,11 @@
272272 'epstudentpager-yes' => 'Yes',
273273 'epstudentpager-no' => 'No',
274274
 275+ // Student article pager
 276+ 'epstudentpager-header-articles' => 'Articles',
 277+
275278 // Article pager
276279 'ep-articles-noresults' => 'There are no articles to list.',
277 - 'ep-articles-noresults' => 'There are no articles to list.',
278280
279281 // Campus ambassador pager
280282 'epcapager-header-photo' => 'Photo',

Status & tagging log