Index: trunk/extensions/EducationProgram/EducationProgram.php |
— | — | @@ -97,6 +97,8 @@ |
98 | 98 | $wgAutoloadClasses['EPIRole'] = dirname( __FILE__ ) . '/includes/EPIRole.php'; |
99 | 99 | $wgAutoloadClasses['EPRevisionedObject'] = dirname( __FILE__ ) . '/includes/EPRevisionedObject.php'; |
100 | 100 | $wgAutoloadClasses['EPRoleObject'] = dirname( __FILE__ ) . '/includes/EPRoleObject.php'; |
| 101 | +$wgAutoloadClasses['EPArticle'] = dirname( __FILE__ ) . '/includes/EPArticle.php'; |
| 102 | +$wgAutoloadClasses['EPArticlePager'] = dirname( __FILE__ ) . '/includes/EPArticlePager.php'; |
101 | 103 | |
102 | 104 | $wgAutoloadClasses['CoursePage'] = dirname( __FILE__ ) . '/pages/CoursePage.php'; |
103 | 105 | $wgAutoloadClasses['EPPage'] = dirname( __FILE__ ) . '/pages/EPPage.php'; |
— | — | @@ -153,6 +155,7 @@ |
154 | 156 | $egEPDBObjects['EPStudent'] = array( 'table' => 'ep_students', 'prefix' => 'student_' ); |
155 | 157 | $egEPDBObjects['EPOA'] = array( 'table' => 'ep_oas', 'prefix' => 'oa_' ); |
156 | 158 | $egEPDBObjects['EPCA'] = array( 'table' => 'ep_cas', 'prefix' => 'ca_' ); |
| 159 | +$egEPDBObjects['EPArticle'] = array( 'table' => 'ep_articles', 'prefix' => 'article_' ); |
157 | 160 | $egEPDBObjects[] = array( 'table' => 'ep_students_per_course', 'prefix' => 'spc_' ); |
158 | 161 | $egEPDBObjects[] = array( 'table' => 'ep_oas_per_course', 'prefix' => 'opc_' ); |
159 | 162 | $egEPDBObjects[] = array( 'table' => 'ep_cas_per_course', 'prefix' => 'cpc_' ); |
Index: trunk/extensions/EducationProgram/actions/ViewCourseAction.php |
— | — | @@ -39,6 +39,9 @@ |
40 | 40 | ); |
41 | 41 | |
42 | 42 | if ( count( $studentIds ) > 0 ) { |
| 43 | + $out->addElement( 'h2', array(), wfMsg( 'ep-course-articles' ) ); |
| 44 | + EPArticle::displayPager( $this->getContext(), array( 'course_id' => $course->getId() ) ); |
| 45 | + |
43 | 46 | $out->addElement( 'h2', array(), wfMsg( 'ep-course-students' ) ); |
44 | 47 | EPStudent::displayPager( $this->getContext(), array( 'id' => $studentIds ) ); |
45 | 48 | } |
Index: trunk/extensions/EducationProgram/specials/SpecialStudent.php |
— | — | @@ -50,7 +50,7 @@ |
51 | 51 | |
52 | 52 | $this->displaySummary( $student ); |
53 | 53 | |
54 | | - $out->addElement( 'h2', array(), wfMsg( 'ep-student-terms' ) ); |
| 54 | + $out->addElement( 'h2', array(), wfMsg( 'ep-student-courses' ) ); |
55 | 55 | |
56 | 56 | $courseIds = array_map( |
57 | 57 | function( EPCourse $course ) { |
Index: trunk/extensions/EducationProgram/includes/EPArticle.php |
— | — | @@ -0,0 +1,94 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Class representing a single single article being worked upon by a student, |
| 6 | + * and can have zero or more associated reviewers. |
| 7 | + * |
| 8 | + * @since 0.1 |
| 9 | + * |
| 10 | + * @file EPRevision.php |
| 11 | + * @ingroup EducationProgram |
| 12 | + * |
| 13 | + * @licence GNU GPL v3 or later |
| 14 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 15 | + */ |
| 16 | +class EPArticle extends EPDBObject { |
| 17 | + |
| 18 | + /** |
| 19 | + * Cached user object for this revision. |
| 20 | + * |
| 21 | + * @since 0.1 |
| 22 | + * @var User|false |
| 23 | + */ |
| 24 | + protected $user = false; |
| 25 | + |
| 26 | + /** |
| 27 | + * @see parent::getFieldTypes |
| 28 | + * |
| 29 | + * @since 0.1 |
| 30 | + * |
| 31 | + * @return array |
| 32 | + */ |
| 33 | + protected static function getFieldTypes() { |
| 34 | + return array( |
| 35 | + 'id' => 'id', |
| 36 | + |
| 37 | + 'course_id' => 'int', |
| 38 | + 'user_id' => 'int', |
| 39 | + 'page_id' => 'int', |
| 40 | + 'reviewers' => 'array', |
| 41 | + ); |
| 42 | + } |
| 43 | + |
| 44 | + /** |
| 45 | + * (non-PHPdoc) |
| 46 | + * @see EPDBObject::getDefaults() |
| 47 | + */ |
| 48 | + public static function getDefaults() { |
| 49 | + return array( |
| 50 | + 'reviewers' => array(), |
| 51 | + ); |
| 52 | + } |
| 53 | + |
| 54 | + /** |
| 55 | + * Returns the user that authored this revision. |
| 56 | + * |
| 57 | + * @since 0.1 |
| 58 | + * |
| 59 | + * @return User |
| 60 | + */ |
| 61 | + public function getUser() { |
| 62 | + if ( $this->user === false ) { |
| 63 | + $this->user = User::newFromId( $this->loadAndGetField( 'user_id' ) ); |
| 64 | + } |
| 65 | + |
| 66 | + return $this->user; |
| 67 | + } |
| 68 | + |
| 69 | + /** |
| 70 | + * Display a pager with articles. |
| 71 | + * |
| 72 | + * @since 0.1 |
| 73 | + * |
| 74 | + * @param IContextSource $context |
| 75 | + * @param array $conditions |
| 76 | + */ |
| 77 | + public static function displayPager( IContextSource $context, array $conditions = array() ) { |
| 78 | + $pager = new EPArticlePager( $context, $conditions ); |
| 79 | + |
| 80 | + if ( $pager->getNumRows() ) { |
| 81 | + $context->getOutput()->addHTML( |
| 82 | + $pager->getFilterControl() . |
| 83 | + $pager->getNavigationBar() . |
| 84 | + $pager->getBody() . |
| 85 | + $pager->getNavigationBar() . |
| 86 | + $pager->getMultipleItemControl() |
| 87 | + ); |
| 88 | + } |
| 89 | + else { |
| 90 | + $context->getOutput()->addHTML( $pager->getFilterControl( true ) ); |
| 91 | + $context->getOutput()->addWikiMsg( 'ep-articles-noresults' ); |
| 92 | + } |
| 93 | + } |
| 94 | + |
| 95 | +} |
Index: trunk/extensions/EducationProgram/includes/EPCA.php |
— | — | @@ -23,8 +23,8 @@ |
24 | 24 | protected static function getFieldTypes() { |
25 | 25 | return array( |
26 | 26 | 'id' => 'id', |
27 | | - 'user_id' => 'id', |
28 | | - |
| 27 | + |
| 28 | + 'user_id' => 'int', |
29 | 29 | 'bio' => 'str', |
30 | 30 | 'photo' => 'str', |
31 | 31 | ); |
Index: trunk/extensions/EducationProgram/includes/EPStudent.php |
— | — | @@ -23,8 +23,8 @@ |
24 | 24 | protected static function getFieldTypes() { |
25 | 25 | return array( |
26 | 26 | 'id' => 'id', |
27 | | - 'user_id' => 'id', |
28 | 27 | |
| 28 | + 'user_id' => 'int', |
29 | 29 | 'first_enroll' => 'str', // TS_MW |
30 | 30 | |
31 | 31 | 'last_active' => 'str', // TS_MW |
Index: trunk/extensions/EducationProgram/includes/EPRevision.php |
— | — | @@ -45,8 +45,8 @@ |
46 | 46 | return array( |
47 | 47 | 'id' => 'id', |
48 | 48 | |
49 | | - 'object_id' => 'id', |
50 | | - 'user_id' => 'id', |
| 49 | + 'object_id' => 'int', |
| 50 | + 'user_id' => 'int', |
51 | 51 | 'type' => 'str', |
52 | 52 | 'comment' => 'str', |
53 | 53 | 'user_text' => 'str', |
Index: trunk/extensions/EducationProgram/includes/EPOA.php |
— | — | @@ -23,8 +23,8 @@ |
24 | 24 | protected static function getFieldTypes() { |
25 | 25 | return array( |
26 | 26 | 'id' => 'id', |
27 | | - 'user_id' => 'id', |
28 | | - |
| 27 | + |
| 28 | + 'user_id' => 'int', |
29 | 29 | 'bio' => 'str', |
30 | 30 | 'photo' => 'str', |
31 | 31 | ); |
Index: trunk/extensions/EducationProgram/includes/EPCourse.php |
— | — | @@ -98,8 +98,8 @@ |
99 | 99 | protected static function getFieldTypes() { |
100 | 100 | return array( |
101 | 101 | 'id' => 'id', |
102 | | - 'org_id' => 'id', |
103 | 102 | |
| 103 | + 'org_id' => 'int', |
104 | 104 | 'name' => 'str', |
105 | 105 | 'start' => 'str', // TS_MW |
106 | 106 | 'end' => 'str', // TS_MW |
Index: trunk/extensions/EducationProgram/includes/EPArticlePager.php |
— | — | @@ -0,0 +1,98 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Article pager which lists students and their associated articles reviewers for those if any. |
| 6 | + * |
| 7 | + * @since 0.1 |
| 8 | + * |
| 9 | + * @file EPAticlePager.php |
| 10 | + * @ingroup EductaionProgram |
| 11 | + * |
| 12 | + * @licence GNU GPL v3 or later |
| 13 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 14 | + */ |
| 15 | +class EPArticlePager extends EPPager { |
| 16 | + |
| 17 | + /** |
| 18 | + * Constructor. |
| 19 | + * |
| 20 | + * @param IContextSource $context |
| 21 | + * @param array $conds |
| 22 | + */ |
| 23 | + public function __construct( IContextSource $context, array $conds = array() ) { |
| 24 | + $this->mDefaultDirection = true; |
| 25 | + |
| 26 | + // when MW 1.19 becomes min, we want to pass an IContextSource $context here. |
| 27 | + parent::__construct( $context, $conds, 'EPArticle' ); |
| 28 | + } |
| 29 | + |
| 30 | + /** |
| 31 | + * (non-PHPdoc) |
| 32 | + * @see EPPager::getFields() |
| 33 | + */ |
| 34 | + public function getFields() { |
| 35 | + return array( |
| 36 | + 'id', |
| 37 | + 'user_id', |
| 38 | + 'course_id', |
| 39 | + 'page_id', |
| 40 | + 'reviewers', |
| 41 | + ); |
| 42 | + } |
| 43 | + |
| 44 | + /** |
| 45 | + * (non-PHPdoc) |
| 46 | + * @see TablePager::getRowClass() |
| 47 | + */ |
| 48 | + function getRowClass( $row ) { |
| 49 | + return 'ep-article-row'; |
| 50 | + } |
| 51 | + |
| 52 | + /** |
| 53 | + * (non-PHPdoc) |
| 54 | + * @see TablePager::getTableClass() |
| 55 | + */ |
| 56 | + public function getTableClass() { |
| 57 | + return 'TablePager ep-articles'; |
| 58 | + } |
| 59 | + |
| 60 | + /** |
| 61 | + * (non-PHPdoc) |
| 62 | + * @see EPPager::getFormattedValue() |
| 63 | + */ |
| 64 | + protected function getFormattedValue( $name, $value ) { |
| 65 | + switch ( $name ) { |
| 66 | + case 'user_id': |
| 67 | + $user = User::newFromId( $value ); |
| 68 | + $name = $user->getRealName() === '' ? $user->getName() : $user->getRealName(); |
| 69 | + |
| 70 | + $value = Linker::userLink( $value, $name ) . Linker::userToolLinks( $value, $name ); |
| 71 | + break; |
| 72 | + } |
| 73 | + |
| 74 | + return $value; |
| 75 | + } |
| 76 | + |
| 77 | + /** |
| 78 | + * (non-PHPdoc) |
| 79 | + * @see EPPager::getSortableFields() |
| 80 | + */ |
| 81 | + protected function getSortableFields() { |
| 82 | + return array( |
| 83 | + ); |
| 84 | + } |
| 85 | + |
| 86 | + /** |
| 87 | + * (non-PHPdoc) |
| 88 | + * @see EPPager::hasActionsColumn() |
| 89 | + */ |
| 90 | + protected function hasActionsColumn() { |
| 91 | + return false; |
| 92 | + } |
| 93 | + |
| 94 | + function getDefaultSort() { |
| 95 | + $c = $this->className; // Yeah, this is needed in PHP 5.3 >_> |
| 96 | + return $c::getPrefixedField( 'user_id' ); |
| 97 | + } |
| 98 | + |
| 99 | +} |
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php |
— | — | @@ -234,6 +234,10 @@ |
235 | 235 | 'epstudentpager-yes' => 'Yes', |
236 | 236 | 'epstudentpager-no' => 'No', |
237 | 237 | |
| 238 | + // Article pager |
| 239 | + 'ep-articles-noresults' => 'There are no articles to list.', |
| 240 | + 'ep-articles-noresults' => 'There are no articles to list.', |
| 241 | + |
238 | 242 | // Campus ambassador pager |
239 | 243 | 'epcapager-header-photo' => 'Photo', |
240 | 244 | 'epcapager-header-user-id' => 'User', |
— | — | @@ -314,6 +318,7 @@ |
315 | 319 | // Course viewing |
316 | 320 | 'ep-course-title' => 'Course: $1', |
317 | 321 | 'ep-course-students' => 'Students', |
| 322 | + 'ep-course-articles' => 'Articles', |
318 | 323 | 'viewcourseaction-none' => 'There is no course with name "$1". See [[Special:Courses|here]] for a list of courses.', |
319 | 324 | 'ep-course-create' => 'There is no course with name "$1", but you can create a new one.', |
320 | 325 | 'ep-course-description' => 'Description', |