Index: trunk/extensions/EducationProgram/includes/EPStudentPager.php |
— | — | @@ -0,0 +1,80 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Student pager, primarily for Special:Students. |
| 6 | + * |
| 7 | + * @since 0.1 |
| 8 | + * |
| 9 | + * @file EPStudentPager.php |
| 10 | + * @ingroup EductaionProgram |
| 11 | + * |
| 12 | + * @licence GNU GPL v3 or later |
| 13 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 14 | + */ |
| 15 | +class EPStudentPager extends EPPager { |
| 16 | + |
| 17 | + /** |
| 18 | + * Constructor. |
| 19 | + * |
| 20 | + * @param array $conds |
| 21 | + */ |
| 22 | + public function __construct( array $conds ) { |
| 23 | + $this->mDefaultDirection = true; |
| 24 | + |
| 25 | + // when MW 1.19 becomes min, we want to pass an IContextSource $context here. |
| 26 | + parent::__construct( $conds, 'EPStudent' ); |
| 27 | + } |
| 28 | + |
| 29 | + /** |
| 30 | + * (non-PHPdoc) |
| 31 | + * @see TablePager::getFieldNames() |
| 32 | + */ |
| 33 | + public function getFieldNames() { |
| 34 | + return parent::getFieldNameList( array( |
| 35 | + // TODO |
| 36 | + ) ); |
| 37 | + } |
| 38 | + |
| 39 | + /** |
| 40 | + * (non-PHPdoc) |
| 41 | + * @see TablePager::getRowClass() |
| 42 | + */ |
| 43 | + function getRowClass( $row ) { |
| 44 | + return 'ep-student-row'; |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * (non-PHPdoc) |
| 49 | + * @see TablePager::getTableClass() |
| 50 | + */ |
| 51 | + public function getTableClass(){ |
| 52 | + return 'TablePager ep-students'; |
| 53 | + } |
| 54 | + |
| 55 | + /** |
| 56 | + * (non-PHPdoc) |
| 57 | + * @see TablePager::formatValue() |
| 58 | + */ |
| 59 | + public function formatValue( $name, $value ) { |
| 60 | + switch ( $name ) { |
| 61 | + case '': // TODO |
| 62 | + $value = $value; |
| 63 | + break; |
| 64 | + } |
| 65 | + |
| 66 | + return $value; |
| 67 | + } |
| 68 | + |
| 69 | + function getDefaultSort() { |
| 70 | + return ''; // TODO |
| 71 | + } |
| 72 | + |
| 73 | + /** |
| 74 | + * (non-PHPdoc) |
| 75 | + * @see EPPager::getSortableFields() |
| 76 | + */ |
| 77 | + protected function getSortableFields() { |
| 78 | + return array(); |
| 79 | + } |
| 80 | + |
| 81 | +} |
Property changes on: trunk/extensions/EducationProgram/includes/EPStudentPager.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 82 | + native |
Index: trunk/extensions/EducationProgram/includes/EPOrgPager.php |
— | — | @@ -0,0 +1,80 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Org pager, primarily for Special:Institutions. |
| 6 | + * |
| 7 | + * @since 0.1 |
| 8 | + * |
| 9 | + * @file EPOrgPager.php |
| 10 | + * @ingroup EductaionProgram |
| 11 | + * |
| 12 | + * @licence GNU GPL v3 or later |
| 13 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 14 | + */ |
| 15 | +class EPOrgPager extends EPPager { |
| 16 | + |
| 17 | + /** |
| 18 | + * Constructor. |
| 19 | + * |
| 20 | + * @param array $conds |
| 21 | + */ |
| 22 | + public function __construct( array $conds ) { |
| 23 | + $this->mDefaultDirection = true; |
| 24 | + |
| 25 | + // when MW 1.19 becomes min, we want to pass an IContextSource $context here. |
| 26 | + parent::__construct( $conds, 'EPOrg' ); |
| 27 | + } |
| 28 | + |
| 29 | + /** |
| 30 | + * (non-PHPdoc) |
| 31 | + * @see TablePager::getFieldNames() |
| 32 | + */ |
| 33 | + public function getFieldNames() { |
| 34 | + return parent::getFieldNameList( array( |
| 35 | + // TODO |
| 36 | + ) ); |
| 37 | + } |
| 38 | + |
| 39 | + /** |
| 40 | + * (non-PHPdoc) |
| 41 | + * @see TablePager::getRowClass() |
| 42 | + */ |
| 43 | + function getRowClass( $row ) { |
| 44 | + return 'ep-org-row'; |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * (non-PHPdoc) |
| 49 | + * @see TablePager::getTableClass() |
| 50 | + */ |
| 51 | + public function getTableClass(){ |
| 52 | + return 'TablePager ep-orgs'; |
| 53 | + } |
| 54 | + |
| 55 | + /** |
| 56 | + * (non-PHPdoc) |
| 57 | + * @see TablePager::formatValue() |
| 58 | + */ |
| 59 | + public function formatValue( $name, $value ) { |
| 60 | + switch ( $name ) { |
| 61 | + case '': // TODO |
| 62 | + $value = $value; |
| 63 | + break; |
| 64 | + } |
| 65 | + |
| 66 | + return $value; |
| 67 | + } |
| 68 | + |
| 69 | + function getDefaultSort() { |
| 70 | + return ''; // TODO |
| 71 | + } |
| 72 | + |
| 73 | + /** |
| 74 | + * (non-PHPdoc) |
| 75 | + * @see EPPager::getSortableFields() |
| 76 | + */ |
| 77 | + protected function getSortableFields() { |
| 78 | + return array(); |
| 79 | + } |
| 80 | + |
| 81 | +} |
Property changes on: trunk/extensions/EducationProgram/includes/EPOrgPager.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 82 | + native |
Index: trunk/extensions/EducationProgram/includes/EPPager.php |
— | — | @@ -0,0 +1,151 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Abstract class extensing the TablePager with common functions |
| 6 | + * for pagers listing EPDBObject deriving classes and some compatibility helpers. |
| 7 | + * |
| 8 | + * @since 0.1 |
| 9 | + * |
| 10 | + * @file EPPager.php |
| 11 | + * @ingroup EducationProgram |
| 12 | + * |
| 13 | + * @licence GNU GPL v3 or later |
| 14 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 15 | + */ |
| 16 | +abstract class EPPager extends TablePager { |
| 17 | + |
| 18 | + /** |
| 19 | + * Query conditions, full field names (inc prefix). |
| 20 | + * @since 0.1 |
| 21 | + * @var array |
| 22 | + */ |
| 23 | + protected $conds; |
| 24 | + |
| 25 | + /** |
| 26 | + * Name of the class deriving from EPDBObject. |
| 27 | + * @since 0.1 |
| 28 | + * @var string |
| 29 | + */ |
| 30 | + protected $className; |
| 31 | + |
| 32 | + /** |
| 33 | + * EPDBObject object constructed from $this->currentRow. |
| 34 | + * @since 0.1 |
| 35 | + * @var EPDBObject |
| 36 | + */ |
| 37 | + protected $currentObject; |
| 38 | + |
| 39 | + /** |
| 40 | + * Constructor. |
| 41 | + * |
| 42 | + * @param array $conds |
| 43 | + */ |
| 44 | + public function __construct( array $conds, $className ) { |
| 45 | + $this->conds = $conds; |
| 46 | + $this->className = $className; |
| 47 | + |
| 48 | + // when MW 1.19 becomes min, we want to pass an IContextSource $context here. |
| 49 | + parent::__construct(); |
| 50 | + } |
| 51 | + |
| 52 | + /** |
| 53 | + * Get the OutputPage being used for this instance. |
| 54 | + * IndexPager extends ContextSource as of 1.19. |
| 55 | + * |
| 56 | + * @since 0.1 |
| 57 | + * |
| 58 | + * @return OutputPage |
| 59 | + */ |
| 60 | + public function getOutput() { |
| 61 | + return version_compare( $GLOBALS['wgVersion'], '1.18', '>' ) ? parent::getOutput() : $GLOBALS['wgOut']; |
| 62 | + } |
| 63 | + |
| 64 | + /** |
| 65 | + * Get the Language being used for this instance. |
| 66 | + * IndexPager extends ContextSource as of 1.19. |
| 67 | + * |
| 68 | + * @since 0.1 |
| 69 | + * |
| 70 | + * @return Language |
| 71 | + */ |
| 72 | + public function getLanguage() { |
| 73 | + return version_compare( $GLOBALS['wgVersion'], '1.18', '>' ) ? parent::getLanguage() : $GLOBALS['wgLang']; |
| 74 | + } |
| 75 | + |
| 76 | + /** |
| 77 | + * Get the User being used for this instance. |
| 78 | + * IndexPager extends ContextSource as of 1.19. |
| 79 | + * |
| 80 | + * @since 0.1 |
| 81 | + * |
| 82 | + * @return User |
| 83 | + */ |
| 84 | + public function getUser() { |
| 85 | + return version_compare( $GLOBALS['wgUser'], '1.18', '>' ) ? parent::getUser() : $GLOBALS['wgUser']; |
| 86 | + } |
| 87 | + |
| 88 | + /** |
| 89 | + * (non-PHPdoc) |
| 90 | + * @see TablePager::formatRow() |
| 91 | + */ |
| 92 | + function formatRow( $row ) { |
| 93 | + $c = $this->className; // Yeah, this is needed in PHP 5.3 >_> |
| 94 | + $this->currentReview = $c::newFromDBResult( $row ); |
| 95 | + return parent::formatRow( $row ); |
| 96 | + } |
| 97 | + |
| 98 | + function getIndexField() { |
| 99 | + $c = $this->className; // Yeah, this is needed in PHP 5.3 >_> |
| 100 | + return $c::getPrefixedField( 'id' ); |
| 101 | + } |
| 102 | + |
| 103 | + function getQueryInfo() { |
| 104 | + $c = $this->className; // Yeah, this is needed in PHP 5.3 >_> |
| 105 | + return array( |
| 106 | + 'tables' => array( $c::getDBTable() ), |
| 107 | + 'fields' => $c::getFieldNames(), |
| 108 | + 'conds' => $this->conds, |
| 109 | + ); |
| 110 | + } |
| 111 | + |
| 112 | + function isFieldSortable( $name ) { |
| 113 | + $c = $this->className; // Yeah, this is needed in PHP 5.3 >_> |
| 114 | + return in_array( |
| 115 | + $name, |
| 116 | + $c::getPrefixedFields( 'id' ) |
| 117 | + ); |
| 118 | + } |
| 119 | + |
| 120 | + /** |
| 121 | + * Takes a list of (unprefixed) field names and return them in an associative array where |
| 122 | + * the keys are the prefixed field names and the values are header messages. |
| 123 | + * |
| 124 | + * @since 0.1 |
| 125 | + * |
| 126 | + * @param array $fields |
| 127 | + * |
| 128 | + * @return array |
| 129 | + */ |
| 130 | + protected function getFieldNameList( array $fields ) { |
| 131 | + $headers = array(); |
| 132 | + $c = $this->className; |
| 133 | + |
| 134 | + foreach ( $fields as $fieldName ) { |
| 135 | + $headers[$c::getPrefixedField( $fieldName )] = wfMsg( |
| 136 | + 'educationprogram-pager-' . strtolower( $c ) . '-' . str_replace( '_', '-', $fieldName ) |
| 137 | + ); |
| 138 | + } |
| 139 | + |
| 140 | + return array_map( 'wfMsg', $headers ); |
| 141 | + } |
| 142 | + |
| 143 | + /** |
| 144 | + * Should return an array with the names of the fields that are sortable. |
| 145 | + * |
| 146 | + * @since 0.1 |
| 147 | + * |
| 148 | + * @return array of string |
| 149 | + */ |
| 150 | + protected abstract function getSortableFields(); |
| 151 | + |
| 152 | +} |
Property changes on: trunk/extensions/EducationProgram/includes/EPPager.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 153 | + native |
Index: trunk/extensions/EducationProgram/includes/EPCoursePager.php |
— | — | @@ -0,0 +1,80 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Course pager, primarily for Special:Courses. |
| 6 | + * |
| 7 | + * @since 0.1 |
| 8 | + * |
| 9 | + * @file EPCoursePager.php |
| 10 | + * @ingroup EductaionProgram |
| 11 | + * |
| 12 | + * @licence GNU GPL v3 or later |
| 13 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 14 | + */ |
| 15 | +class EPCoursePager extends EPPager { |
| 16 | + |
| 17 | + /** |
| 18 | + * Constructor. |
| 19 | + * |
| 20 | + * @param array $conds |
| 21 | + */ |
| 22 | + public function __construct( array $conds ) { |
| 23 | + $this->mDefaultDirection = true; |
| 24 | + |
| 25 | + // when MW 1.19 becomes min, we want to pass an IContextSource $context here. |
| 26 | + parent::__construct( $conds, 'EPCourse' ); |
| 27 | + } |
| 28 | + |
| 29 | + /** |
| 30 | + * (non-PHPdoc) |
| 31 | + * @see TablePager::getFieldNames() |
| 32 | + */ |
| 33 | + public function getFieldNames() { |
| 34 | + return parent::getFieldNameList( array( |
| 35 | + // TODO |
| 36 | + ) ); |
| 37 | + } |
| 38 | + |
| 39 | + /** |
| 40 | + * (non-PHPdoc) |
| 41 | + * @see TablePager::getRowClass() |
| 42 | + */ |
| 43 | + function getRowClass( $row ) { |
| 44 | + return 'ep-course-row'; |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * (non-PHPdoc) |
| 49 | + * @see TablePager::getTableClass() |
| 50 | + */ |
| 51 | + public function getTableClass(){ |
| 52 | + return 'TablePager ep-courses'; |
| 53 | + } |
| 54 | + |
| 55 | + /** |
| 56 | + * (non-PHPdoc) |
| 57 | + * @see TablePager::formatValue() |
| 58 | + */ |
| 59 | + public function formatValue( $name, $value ) { |
| 60 | + switch ( $name ) { |
| 61 | + case '': // TODO |
| 62 | + $value = $value; |
| 63 | + break; |
| 64 | + } |
| 65 | + |
| 66 | + return $value; |
| 67 | + } |
| 68 | + |
| 69 | + function getDefaultSort() { |
| 70 | + return ''; // TODO |
| 71 | + } |
| 72 | + |
| 73 | + /** |
| 74 | + * (non-PHPdoc) |
| 75 | + * @see EPPager::getSortableFields() |
| 76 | + */ |
| 77 | + protected function getSortableFields() { |
| 78 | + return array(); |
| 79 | + } |
| 80 | + |
| 81 | +} |
Property changes on: trunk/extensions/EducationProgram/includes/EPCoursePager.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 82 | + native |
Index: trunk/extensions/EducationProgram/EducationProgram.php |
— | — | @@ -50,10 +50,14 @@ |
51 | 51 | $wgAutoloadClasses['EPSettings'] = dirname( __FILE__ ) . '/EducationProgram.settings.php'; |
52 | 52 | |
53 | 53 | $wgAutoloadClasses['EPCourse'] = dirname( __FILE__ ) . '/includes/EPCourse.php'; |
| 54 | +$wgAutoloadClasses['EPCoursePager'] = dirname( __FILE__ ) . '/includes/EPCoursePager.php'; |
54 | 55 | $wgAutoloadClasses['EPDBObject'] = dirname( __FILE__ ) . '/includes/EPDBObject.php'; |
55 | 56 | $wgAutoloadClasses['EPMentor'] = dirname( __FILE__ ) . '/includes/EPMentor.php'; |
56 | 57 | $wgAutoloadClasses['EPOrg'] = dirname( __FILE__ ) . '/includes/EPOrg.php'; |
| 58 | +$wgAutoloadClasses['EPOrgPager'] = dirname( __FILE__ ) . '/includes/EPOrgPager.php'; |
| 59 | +$wgAutoloadClasses['EPPager'] = dirname( __FILE__ ) . '/includes/EPPager.php'; |
57 | 60 | $wgAutoloadClasses['EPStudent'] = dirname( __FILE__ ) . '/includes/EPStudent.php'; |
| 61 | +$wgAutoloadClasses['EPStudentPager'] = dirname( __FILE__ ) . '/includes/EPStudentPager.php'; |
58 | 62 | |
59 | 63 | $wgAutoloadClasses['SpecialCourse'] = dirname( __FILE__ ) . '/specials/SpecialCourse.php'; |
60 | 64 | $wgAutoloadClasses['SpecialCourses'] = dirname( __FILE__ ) . '/specials/SpecialCourses.php'; |