Index: trunk/extensions/EducationProgram/specials/SpecialMyCourses.php |
— | — | @@ -129,7 +129,7 @@ |
130 | 130 | } |
131 | 131 | elseif ( count( $courseIds ) > 1 ) { |
132 | 132 | $this->getOutput()->addElement( 'h2', array(), wfMsg( 'ep-mycourses-enrollment' ) ); |
133 | | - EPCourse::displayPager( $this->getContext(), array( 'id' => $courseIds ), true ); |
| 133 | + EPCourse::displayPager( $this->getContext(), array( 'id' => $courseIds ), true, 'enrollment' ); |
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
— | — | @@ -145,7 +145,7 @@ |
146 | 146 | |
147 | 147 | if ( count( $courseIds ) > 0 ) { |
148 | 148 | $this->getOutput()->addElement( 'h2', array(), wfMsg( 'ep-mycourses-ambcourses-' . strtolower( $class ) ) ); |
149 | | - EPCourse::displayPager( $this->getContext(), array( 'id' => $courseIds ), true ); |
| 149 | + EPCourse::displayPager( $this->getContext(), array( 'id' => $courseIds ), true, $class ); |
150 | 150 | } |
151 | 151 | else { |
152 | 152 | $this->getOutput()->addWikiMsg( 'ep-mycourses-noambcourses-' . strtolower( $class ) ); |
Index: trunk/extensions/EducationProgram/includes/EPPager.php |
— | — | @@ -56,77 +56,12 @@ |
57 | 57 | |
58 | 58 | $this->mDefaultDirection = true; |
59 | 59 | |
60 | | - if ( method_exists( 'TablePager', 'getUser' ) ) { |
61 | | - parent::__construct( $context ); |
62 | | - } |
63 | | - else { |
64 | | - parent::__construct(); |
65 | | - } |
| 60 | + parent::__construct( $context ); |
66 | 61 | |
67 | 62 | $this->context->getOutput()->addModules( 'ep.pager' ); |
68 | 63 | } |
69 | 64 | |
70 | 65 | /** |
71 | | - * Get the OutputPage being used for this instance. |
72 | | - * IndexPager extends ContextSource as of 1.19. |
73 | | - * |
74 | | - * @since 0.1 |
75 | | - * |
76 | | - * @return OutputPage |
77 | | - */ |
78 | | - public function getOutput() { |
79 | | - return $this->context->getOutput(); |
80 | | - } |
81 | | - |
82 | | - /** |
83 | | - * Get the Language being used for this instance. |
84 | | - * IndexPager extends ContextSource as of 1.19. |
85 | | - * |
86 | | - * @since 0.1 |
87 | | - * |
88 | | - * @return Language |
89 | | - */ |
90 | | - public function getLanguage() { |
91 | | - return $this->context->getLanguage(); |
92 | | - } |
93 | | - |
94 | | - /** |
95 | | - * Get the User being used for this instance. |
96 | | - * IndexPager extends ContextSource as of 1.19. |
97 | | - * |
98 | | - * @since 0.1 |
99 | | - * |
100 | | - * @return User |
101 | | - */ |
102 | | - public function getUser() { |
103 | | - return $this->context->getUser(); |
104 | | - } |
105 | | - |
106 | | - /** |
107 | | - * Get the WebRequest being used for this instance. |
108 | | - * IndexPager extends ContextSource as of 1.19. |
109 | | - * |
110 | | - * @since 0.1 |
111 | | - * |
112 | | - * @return WebRequest |
113 | | - */ |
114 | | - public function getRequest() { |
115 | | - return $this->context->getRequest(); |
116 | | - } |
117 | | - |
118 | | - /** |
119 | | - * Get the Title being used for this instance. |
120 | | - * IndexPager extends ContextSource as of 1.19. |
121 | | - * |
122 | | - * @since 0.1 |
123 | | - * |
124 | | - * @return Title |
125 | | - */ |
126 | | - public function getTitle() { |
127 | | - return $this->context->getTitle(); |
128 | | - } |
129 | | - |
130 | | - /** |
131 | 66 | * (non-PHPdoc) |
132 | 67 | * @see TablePager::formatRow() |
133 | 68 | */ |
— | — | @@ -395,7 +330,11 @@ |
396 | 331 | foreach ( $filterOptions as $optionName => $optionData ) { |
397 | 332 | switch ( $optionData['type'] ) { |
398 | 333 | case 'select': |
399 | | - $select = new XmlSelect( $optionName, $optionName, $optionData['value'] ); |
| 334 | + $select = new XmlSelect( |
| 335 | + $this->filterPrefix . $optionName, |
| 336 | + $this->filterPrefix . $optionName, |
| 337 | + $optionData['value'] |
| 338 | + ); |
400 | 339 | $select->addOptions( $optionData['options'] ); |
401 | 340 | $control = $select->getHTML(); |
402 | 341 | break; |
— | — | @@ -436,9 +375,9 @@ |
437 | 376 | $changed = false; |
438 | 377 | |
439 | 378 | foreach ( $filterOptions as $optionName => &$optionData ) { |
440 | | - if ( $req->getCheck( $optionName ) ) { |
441 | | - $optionData['value'] = $req->getVal( $optionName ); |
442 | | - $req->setSessionData( get_called_class() . $optionName, $optionData['value'] ); |
| 379 | + if ( $req->getCheck( $this->filterPrefix . $optionName ) ) { |
| 380 | + $optionData['value'] = $req->getVal( $this->filterPrefix . $optionName ); |
| 381 | + $req->setSessionData( $this->getNameForSession( $optionName ), $optionData['value'] ); |
443 | 382 | $changed = true; |
444 | 383 | |
445 | 384 | if ( $cast && array_key_exists( 'datatype', $optionData ) ) { |
— | — | @@ -452,14 +391,24 @@ |
453 | 392 | } |
454 | 393 | } |
455 | 394 | } |
456 | | - elseif ( !is_null( $req->getSessionData( get_called_class() . $optionName ) ) ) { |
457 | | - $optionData['value'] = $req->getSessionData( get_called_class() . $optionName ); |
| 395 | + elseif ( !is_null( $req->getSessionData( $this->getNameForSession( $optionName ) ) ) ) { |
| 396 | + $optionData['value'] = $req->getSessionData( $this->getNameForSession( $optionName ) ); |
458 | 397 | $changed = true; |
459 | 398 | } |
460 | 399 | } |
461 | 400 | |
462 | 401 | return $changed; |
463 | 402 | } |
| 403 | + |
| 404 | + protected function getNameForSession( $optionName ) { |
| 405 | + return $this->filterPrefix . get_called_class() . $optionName; |
| 406 | + } |
| 407 | + |
| 408 | + protected $filterPrefix = ''; |
| 409 | + |
| 410 | + public function setFilterPrefix( $filterPrefix ) { |
| 411 | + $this->filterPrefix = $filterPrefix; |
| 412 | + } |
464 | 413 | |
465 | 414 | /** |
466 | 415 | * Takes a message key and prefixes it with the extension name and name of the pager, |
Index: trunk/extensions/EducationProgram/includes/EPCourse.php |
— | — | @@ -379,10 +379,15 @@ |
380 | 380 | * @param IContextSource $context |
381 | 381 | * @param array $conditions |
382 | 382 | * @param boolean $readOnlyMode |
| 383 | + * @param string|false $filterPrefix |
383 | 384 | */ |
384 | | - public static function displayPager( IContextSource $context, array $conditions = array(), $readOnlyMode = false ) { |
| 385 | + public static function displayPager( IContextSource $context, array $conditions = array(), $readOnlyMode = false, $filterPrefix = false ) { |
385 | 386 | $pager = new EPCoursePager( $context, $conditions, $readOnlyMode ); |
386 | 387 | |
| 388 | + if ( $filterPrefix !== false ) { |
| 389 | + $pager->setFilterPrefix( $filterPrefix ); |
| 390 | + } |
| 391 | + |
387 | 392 | if ( $pager->getNumRows() ) { |
388 | 393 | $context->getOutput()->addHTML( |
389 | 394 | $pager->getFilterControl() . |