r110664 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110663‎ | r110664 | r110665 >
Date:16:58, 3 February 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
work on special:mycourses
Modified paths:
  • /trunk/extensions/EducationProgram/includes/EPCourse.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPPager.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialMyCourses.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/specials/SpecialMyCourses.php
@@ -129,7 +129,7 @@
130130 }
131131 elseif ( count( $courseIds ) > 1 ) {
132132 $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' );
134134 }
135135 }
136136
@@ -145,7 +145,7 @@
146146
147147 if ( count( $courseIds ) > 0 ) {
148148 $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 );
150150 }
151151 else {
152152 $this->getOutput()->addWikiMsg( 'ep-mycourses-noambcourses-' . strtolower( $class ) );
Index: trunk/extensions/EducationProgram/includes/EPPager.php
@@ -56,77 +56,12 @@
5757
5858 $this->mDefaultDirection = true;
5959
60 - if ( method_exists( 'TablePager', 'getUser' ) ) {
61 - parent::__construct( $context );
62 - }
63 - else {
64 - parent::__construct();
65 - }
 60+ parent::__construct( $context );
6661
6762 $this->context->getOutput()->addModules( 'ep.pager' );
6863 }
6964
7065 /**
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 - /**
13166 * (non-PHPdoc)
13267 * @see TablePager::formatRow()
13368 */
@@ -395,7 +330,11 @@
396331 foreach ( $filterOptions as $optionName => $optionData ) {
397332 switch ( $optionData['type'] ) {
398333 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+ );
400339 $select->addOptions( $optionData['options'] );
401340 $control = $select->getHTML();
402341 break;
@@ -436,9 +375,9 @@
437376 $changed = false;
438377
439378 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'] );
443382 $changed = true;
444383
445384 if ( $cast && array_key_exists( 'datatype', $optionData ) ) {
@@ -452,14 +391,24 @@
453392 }
454393 }
455394 }
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 ) );
458397 $changed = true;
459398 }
460399 }
461400
462401 return $changed;
463402 }
 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+ }
464413
465414 /**
466415 * 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 @@
380380 * @param IContextSource $context
381381 * @param array $conditions
382382 * @param boolean $readOnlyMode
 383+ * @param string|false $filterPrefix
383384 */
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 ) {
385386 $pager = new EPCoursePager( $context, $conditions, $readOnlyMode );
386387
 388+ if ( $filterPrefix !== false ) {
 389+ $pager->setFilterPrefix( $filterPrefix );
 390+ }
 391+
387392 if ( $pager->getNumRows() ) {
388393 $context->getOutput()->addHTML(
389394 $pager->getFilterControl() .

Status & tagging log