| Index: trunk/extensions/EducationProgram/includes/EPStudentPager.php |
| — | — | @@ -67,8 +67,13 @@ |
| 68 | 68 | $name = $user->getRealName() === '' ? $user->getName() : $user->getRealName(); |
| 69 | 69 | |
| 70 | 70 | $value = Linker::userLink( $value, $name ) . Linker::userToolLinks( $value, $name ); |
| 71 | | - |
| 72 | 71 | break; |
| | 72 | + case '_courses_current': |
| | 73 | + $value = 'foo'; // TODO |
| | 74 | + break; |
| | 75 | + case '_courses_passed': |
| | 76 | + $value = 'bar'; // TODO |
| | 77 | + break; |
| 73 | 78 | } |
| 74 | 79 | |
| 75 | 80 | return $value; |
| — | — | @@ -92,4 +97,25 @@ |
| 93 | 98 | return array(); |
| 94 | 99 | } |
| 95 | 100 | |
| | 101 | + /** |
| | 102 | + * (non-PHPdoc) |
| | 103 | + * @see EPPager::hasActionsColumn() |
| | 104 | + */ |
| | 105 | + protected function hasActionsColumn() { |
| | 106 | + return false; |
| | 107 | + } |
| | 108 | + |
| | 109 | + /** |
| | 110 | + * (non-PHPdoc) |
| | 111 | + * @see EPPager::getFieldNames() |
| | 112 | + */ |
| | 113 | + public function getFieldNames() { |
| | 114 | + $fields = parent::getFieldNames(); |
| | 115 | + |
| | 116 | + $fields['_courses_current'] = 'current-courses'; |
| | 117 | + $fields['_courses_passed'] = 'passed-courses'; |
| | 118 | + |
| | 119 | + return $fields; |
| | 120 | + } |
| | 121 | + |
| 96 | 122 | } |
| Index: trunk/extensions/EducationProgram/includes/EPPager.php |
| — | — | @@ -154,7 +154,8 @@ |
| 155 | 155 | $value = $this->getLanguage()->pipeList( $this->getControlLinks( $this->currentObject ) ); |
| 156 | 156 | } |
| 157 | 157 | else { |
| 158 | | - $value = isset( $row->$field ) ? $row->$field : null; |
| | 158 | + $prefixedField = $c::getPrefixedField( $field ); |
| | 159 | + $value = isset( $row->$prefixedField ) ? $row->$prefixedField : null; |
| 159 | 160 | } |
| 160 | 161 | |
| 161 | 162 | $formatted = strval( $this->formatValue( $field, $value ) ); |
| — | — | @@ -177,20 +178,22 @@ |
| 178 | 179 | * @return array |
| 179 | 180 | */ |
| 180 | 181 | public function getFieldNames() { |
| 181 | | - $conds = $this->conds; // Yeah, this is needed in PHP 5.3 >_> |
| 182 | | - $fields = array_filter( $this->getFields(), function( $name ) use ( $conds ) { |
| 183 | | - return !array_key_exists( $name, $conds ); |
| 184 | | - } ); |
| 185 | | - |
| 186 | | - $fields = $this->getFieldNameList( $fields ); |
| 187 | | - |
| | 182 | + $fields = array(); |
| | 183 | + |
| 188 | 184 | if ( $this->hasMultipleItemControl() ) { |
| 189 | | - // This is a hack to get an extra column for select all control. |
| 190 | | - $fields = array_merge( array( '_select' => '' ), $fields ); |
| | 185 | + $fields['_select'] = ''; |
| 191 | 186 | } |
| 192 | | - |
| 193 | | - $fields['_controls'] = ''; // This is a hack to get an extra column for the control links. |
| 194 | | - |
| | 187 | + |
| | 188 | + foreach ( $this->getFields() as $field ) { |
| | 189 | + if ( !array_key_exists( $field, $this->conds ) ) { |
| | 190 | + $fields[$field] = $field; |
| | 191 | + } |
| | 192 | + } |
| | 193 | + |
| | 194 | + if ( $this->hasActionsColumn() ) { |
| | 195 | + $fields['_controls'] = ''; |
| | 196 | + } |
| | 197 | + |
| 195 | 198 | return $fields; |
| 196 | 199 | } |
| 197 | 200 | |
| — | — | @@ -255,6 +258,7 @@ |
| 256 | 259 | } |
| 257 | 260 | |
| 258 | 261 | /** |
| | 262 | + * Returns whether the pager has multiple item actions and therefore should show the multiple items control. |
| 259 | 263 | * |
| 260 | 264 | * @since 0.1 |
| 261 | 265 | * |
| — | — | @@ -263,6 +267,17 @@ |
| 264 | 268 | protected function hasMultipleItemControl() { |
| 265 | 269 | return count( $this->getMultipleItemActions() ) > 0; |
| 266 | 270 | } |
| | 271 | + |
| | 272 | + /** |
| | 273 | + * Returns whether the pager should show an extra column for item actions. |
| | 274 | + * |
| | 275 | + * @since 0.1 |
| | 276 | + * |
| | 277 | + * @return boolean |
| | 278 | + */ |
| | 279 | + protected function hasActionsColumn() { |
| | 280 | + return true; |
| | 281 | + } |
| 267 | 282 | |
| 268 | 283 | /** |
| 269 | 284 | * Returns the fields to display. |
| — | — | @@ -297,7 +312,6 @@ |
| 298 | 313 | * @return array |
| 299 | 314 | */ |
| 300 | 315 | protected function getConditions() { |
| 301 | | - $req = $this->getRequest(); |
| 302 | 316 | $conds = array(); |
| 303 | 317 | |
| 304 | 318 | $filterOptions = $this->getFilterOptions(); |
| — | — | @@ -330,28 +344,6 @@ |
| 331 | 345 | } |
| 332 | 346 | |
| 333 | 347 | /** |
| 334 | | - * Takes a list of (unprefixed) field names and return them in an associative array where |
| 335 | | - * the keys are the prefixed field names and the values are header messages. |
| 336 | | - * |
| 337 | | - * @since 0.1 |
| 338 | | - * |
| 339 | | - * @param array $fields |
| 340 | | - * |
| 341 | | - * @return array |
| 342 | | - */ |
| 343 | | - protected function getFieldNameList( array $fields ) { |
| 344 | | - $headers = array(); |
| 345 | | - $c = $this->className; |
| 346 | | - |
| 347 | | - foreach ( $fields as $fieldName => $fieldLabel ) { |
| 348 | | - $message = $fieldLabel === '' ? '' : $this->getMsg( 'header-' . $fieldLabel ); |
| 349 | | - $headers[$c::getPrefixedField( $fieldLabel )] = $message; |
| 350 | | - } |
| 351 | | - |
| 352 | | - return $headers; |
| 353 | | - } |
| 354 | | - |
| 355 | | - /** |
| 356 | 348 | * Should return an array with the names of the fields that are sortable. |
| 357 | 349 | * |
| 358 | 350 | * @since 0.1 |
| — | — | @@ -495,8 +487,7 @@ |
| 496 | 488 | * @see TablePager::formatValue() |
| 497 | 489 | */ |
| 498 | 490 | public final function formatValue( $name, $value ) { |
| 499 | | - $c = $this->className; // Yeah, this is needed in PHP 5.3 >_> |
| 500 | | - return $this->getFormattedValue( $c::unprefixFieldName( $name ), $value ); |
| | 491 | + return $this->getFormattedValue( $name, $value ); |
| 501 | 492 | } |
| 502 | 493 | |
| 503 | 494 | /** |
| — | — | @@ -565,6 +556,10 @@ |
| 566 | 557 | |
| 567 | 558 | # Make table header |
| 568 | 559 | foreach ( $fields as $field => $name ) { |
| | 560 | + $c = $this->className; // Yeah, this is needed in PHP 5.3 >_> |
| | 561 | + $prefixedField = $c::getPrefixedField( $field ); |
| | 562 | + $name = $name === '' ? '' : $this->getMsg( 'header-' . $name ); |
| | 563 | + |
| 569 | 564 | if ( $field === '_select' ) { |
| 570 | 565 | $s .= '<th width="30px">' . Html::element( 'input', array( |
| 571 | 566 | 'type' => 'checkbox', |
| — | — | @@ -575,30 +570,32 @@ |
| 576 | 571 | } |
| 577 | 572 | elseif ( strval( $name ) == '' ) { |
| 578 | 573 | $s .= "<th> </th>\n"; |
| 579 | | - } elseif ( $this->isFieldSortable( $field ) ) { |
| 580 | | - $query = array( 'sort' => $field, 'limit' => $this->mLimit ); |
| 581 | | - if ( $field == $this->mSort ) { |
| | 574 | + } elseif ( $this->isFieldSortable( $prefixedField ) ) { |
| | 575 | + $query = array( 'sort' => $prefixedField, 'limit' => $this->mLimit ); |
| | 576 | + |
| | 577 | + if ( $prefixedField == $this->mSort ) { |
| 582 | 578 | # This is the sorted column |
| 583 | 579 | # Prepare a link that goes in the other sort order |
| 584 | 580 | if ( $this->mDefaultDirection ) { |
| 585 | | - # Descending |
| 586 | | - $image = 'Arr_d.png'; |
| 587 | | - $query['asc'] = '1'; |
| 588 | | - $query['desc'] = ''; |
| 589 | | - $alt = htmlspecialchars( wfMsg( 'descending_abbrev' ) ); |
| | 581 | + # Descending |
| | 582 | + $image = 'Arr_d.png'; |
| | 583 | + $query['asc'] = '1'; |
| | 584 | + $query['desc'] = ''; |
| | 585 | + $alt = htmlspecialchars( wfMsg( 'descending_abbrev' ) ); |
| | 586 | + } else { |
| | 587 | + # Ascending |
| | 588 | + $image = 'Arr_u.png'; |
| | 589 | + $query['asc'] = ''; |
| | 590 | + $query['desc'] = '1'; |
| | 591 | + $alt = htmlspecialchars( wfMsg( 'ascending_abbrev' ) ); |
| | 592 | + } |
| | 593 | + |
| | 594 | + $image = htmlspecialchars( "$wgStylePath/common/images/$image" ); |
| | 595 | + $link = $this->makeLink( |
| | 596 | + "<img width=\"12\" height=\"12\" alt=\"$alt\" src=\"$image\" />" . |
| | 597 | + htmlspecialchars( $name ), $query ); |
| | 598 | + $s .= "<th class=\"$sortClass\">$link</th>\n"; |
| 590 | 599 | } else { |
| 591 | | - # Ascending |
| 592 | | - $image = 'Arr_u.png'; |
| 593 | | - $query['asc'] = ''; |
| 594 | | - $query['desc'] = '1'; |
| 595 | | - $alt = htmlspecialchars( wfMsg( 'ascending_abbrev' ) ); |
| 596 | | - } |
| 597 | | - $image = htmlspecialchars( "$wgStylePath/common/images/$image" ); |
| 598 | | - $link = $this->makeLink( |
| 599 | | - "<img width=\"12\" height=\"12\" alt=\"$alt\" src=\"$image\" />" . |
| 600 | | - htmlspecialchars( $name ), $query ); |
| 601 | | - $s .= "<th class=\"$sortClass\">$link</th>\n"; |
| 602 | | - } else { |
| 603 | 600 | $s .= '<th>' . $this->makeLink( htmlspecialchars( $name ), $query ) . "</th>\n"; |
| 604 | 601 | } |
| 605 | 602 | } |
| Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php |
| — | — | @@ -142,6 +142,8 @@ |
| 143 | 143 | // Student pager |
| 144 | 144 | 'epstudentpager-header-user-id' => 'User', |
| 145 | 145 | 'epstudentpager-header-id' => 'Id', |
| | 146 | + 'epstudentpager-header-current-courses' => 'Current courses', |
| | 147 | + 'epstudentpager-header-passed-courses' => 'Passed courses', |
| 146 | 148 | |
| 147 | 149 | // Special:EditInstitution |
| 148 | 150 | 'editinstitution-text' => 'Enter the institution details below and click submit to save your changes.', |