Index: trunk/extensions/EducationProgram/includes/EPOrgPager.php |
— | — | @@ -56,17 +56,17 @@ |
57 | 57 | |
58 | 58 | /** |
59 | 59 | * (non-PHPdoc) |
60 | | - * @see TablePager::formatValue() |
| 60 | + * @see EPPager::getFormattedValue() |
61 | 61 | */ |
62 | | - public function formatValue( $name, $value ) { |
| 62 | + public function getFormattedValue( $name, $value ) { |
63 | 63 | switch ( $name ) { |
64 | | - case 'org_name': |
| 64 | + case 'name': |
65 | 65 | $value = Linker::linkKnown( |
66 | 66 | SpecialPage::getTitleFor( 'Institution', $value ), |
67 | 67 | $value |
68 | 68 | ); |
69 | 69 | break; |
70 | | - case 'org_country': |
| 70 | + case 'country': |
71 | 71 | $countries = array_flip( efEpGetCountryOptions() ); |
72 | 72 | $value = $countries[$value]; |
73 | 73 | break; |
Index: trunk/extensions/EducationProgram/includes/EPDBObject.php |
— | — | @@ -735,6 +735,9 @@ |
736 | 736 | if ( is_null( $fields ) ) { |
737 | 737 | $fields = array_keys( static::getFieldTypes() ); |
738 | 738 | } |
| 739 | + else { |
| 740 | + $fields = (array)$fields; |
| 741 | + } |
739 | 742 | |
740 | 743 | $tables = array( static::getDBTable() ); |
741 | 744 | $joinConds = static::getProcessedJoinConds( $joinConds, $tables ); |
Index: trunk/extensions/EducationProgram/includes/EPPager.php |
— | — | @@ -271,11 +271,22 @@ |
272 | 272 | foreach ( $filterOptions as $optionName => &$optionData ) { |
273 | 273 | if ( $req->getCheck( $optionName ) ) { |
274 | 274 | $optionData['value'] = $req->getVal( $optionName ); |
275 | | - $req->setSessionData( __CLASS__ . $optionName, $optionData['value'] ); |
| 275 | + $req->setSessionData( get_called_class() . $optionName, $optionData['value'] ); |
276 | 276 | $changed = true; |
| 277 | + |
| 278 | + if ( array_key_exists( 'datatype', $optionData ) ) { |
| 279 | + switch ( $optionData['datatype'] ) { |
| 280 | + case 'int': |
| 281 | + $optionData['value'] = (int)$optionData['value']; |
| 282 | + break; |
| 283 | + case 'float': |
| 284 | + $optionData['value'] = (float)$optionData['value']; |
| 285 | + break; |
| 286 | + } |
| 287 | + } |
277 | 288 | } |
278 | | - elseif ( !is_null( $req->getSessionData( __CLASS__ . $optionName ) ) ) { |
279 | | - $optionData['value'] = $req->getSessionData( __CLASS__ . $optionName ); |
| 289 | + elseif ( !is_null( $req->getSessionData( get_called_class() . $optionName ) ) ) { |
| 290 | + $optionData['value'] = $req->getSessionData( get_called_class() . $optionName ); |
280 | 291 | $changed = true; |
281 | 292 | } |
282 | 293 | } |
— | — | @@ -296,5 +307,24 @@ |
297 | 308 | protected function getMsg( $messageKey ) { |
298 | 309 | return wfMsg( strtolower( $this->className ) . 'pager-' . str_replace( '_', '-', $messageKey ) ); |
299 | 310 | } |
| 311 | + |
| 312 | + /** |
| 313 | + * (non-PHPdoc) |
| 314 | + * @see TablePager::formatValue() |
| 315 | + */ |
| 316 | + public final function formatValue( $name, $value ) { |
| 317 | + $c = $this->className; // Yeah, this is needed in PHP 5.3 >_> |
| 318 | + return $this->getFormattedValue( $c::unprefixFieldName( $name ), $value ); |
| 319 | + } |
| 320 | + |
| 321 | + /** |
| 322 | + * Similar to TablePager::formatValue, but passes along the name of the field without prefix. |
| 323 | + * |
| 324 | + * @param string $name |
| 325 | + * @param string $value |
| 326 | + * |
| 327 | + * @return string |
| 328 | + */ |
| 329 | + protected abstract function getFormattedValue( $name, $value ); |
300 | 330 | |
301 | 331 | } |
Index: trunk/extensions/EducationProgram/includes/EPCoursePager.php |
— | — | @@ -32,7 +32,8 @@ |
33 | 33 | */ |
34 | 34 | public function getFieldNames() { |
35 | 35 | return parent::getFieldNameList( array( |
36 | | - // TODO |
| 36 | + 'org_id', |
| 37 | + 'name', |
37 | 38 | ) ); |
38 | 39 | } |
39 | 40 | |
— | — | @@ -54,20 +55,31 @@ |
55 | 56 | |
56 | 57 | /** |
57 | 58 | * (non-PHPdoc) |
58 | | - * @see TablePager::formatValue() |
| 59 | + * @see EPPager::getFormattedValue() |
59 | 60 | */ |
60 | | - public function formatValue( $name, $value ) { |
| 61 | + protected function getFormattedValue( $name, $value ) { |
61 | 62 | switch ( $name ) { |
62 | | - case '': // TODO |
63 | | - $value = $value; |
| 63 | + case 'name': |
| 64 | + $value = Linker::linkKnown( |
| 65 | + SpecialPage::getTitleFor( 'Course', $value ), |
| 66 | + $value |
| 67 | + ); |
64 | 68 | break; |
| 69 | + case 'org_id': |
| 70 | + $value = EPOrg::selectRow( 'name', array( 'id' => $value ) )->getField( 'name' ); |
| 71 | + |
| 72 | + $value = Linker::linkKnown( |
| 73 | + SpecialPage::getTitleFor( 'Institution', $value ), |
| 74 | + $value |
| 75 | + ); |
| 76 | + break; |
65 | 77 | } |
66 | 78 | |
67 | 79 | return $value; |
68 | 80 | } |
69 | 81 | |
70 | 82 | function getDefaultSort() { |
71 | | - return ''; // TODO |
| 83 | + return 'asc'; |
72 | 84 | } |
73 | 85 | |
74 | 86 | /** |
— | — | @@ -75,7 +87,27 @@ |
76 | 88 | * @see EPPager::getSortableFields() |
77 | 89 | */ |
78 | 90 | protected function getSortableFields() { |
79 | | - return array(); |
| 91 | + return array( |
| 92 | + 'name', |
| 93 | + ); |
80 | 94 | } |
| 95 | + |
| 96 | + /** |
| 97 | + * (non-PHPdoc) |
| 98 | + * @see EPPager::getFilterOptions() |
| 99 | + */ |
| 100 | + protected function getFilterOptions() { |
| 101 | + return array( |
| 102 | + 'org_id' => array( |
| 103 | + 'type' => 'select', |
| 104 | + 'options' => array_merge( |
| 105 | + array( '' => '' ), |
| 106 | + EPOrg::getOrgOptions( EPOrg::select( array( 'name', 'id' ) ) ) |
| 107 | + ), |
| 108 | + 'value' => '', |
| 109 | + 'datatype' => 'int', |
| 110 | + ), |
| 111 | + ); |
| 112 | + } |
81 | 113 | |
82 | 114 | } |
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php |
— | — | @@ -98,6 +98,11 @@ |
99 | 99 | 'eporgpager-header-country' => 'Country', |
100 | 100 | 'eporgpager-filter-country' => 'Country', |
101 | 101 | |
| 102 | + // Institution pager |
| 103 | + 'epcoursepager-header-name' => 'Name', |
| 104 | + 'epcoursepager-header-org-id' => 'Institution', |
| 105 | + 'epcoursepager-filter-org-id' => 'Institution', |
| 106 | + |
102 | 107 | // Special:EditInstitution |
103 | 108 | 'editinstitution-text' => 'Enter the institution details below and click submit to save your changes.', |
104 | 109 | 'educationprogram-org-edit-name' => 'Institution name', |