r111491 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111490‎ | r111491 | r111492 >
Date:21:17, 14 February 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
follow up to r111469 - pass instance of table instead of DBDataObject class name to the pager
Modified paths:
  • /trunk/extensions/EducationProgram/includes/EPCoursePager.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPOrgPager.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPPager.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/includes/EPOrgPager.php
@@ -20,7 +20,7 @@
2121 * @param array $conds
2222 */
2323 public function __construct( IContextSource $context, array $conds = array() ) {
24 - parent::__construct( $context, $conds, 'EPOrg' );
 24+ parent::__construct( $context, $conds, EPOrgs::singleton() );
2525 $this->context->getOutput()->addModules( 'ep.pager.org' );
2626 }
2727
Index: trunk/extensions/EducationProgram/includes/EPCoursePager.php
@@ -30,7 +30,7 @@
3131 */
3232 public function __construct( IContextSource $context, array $conds = array(), $readOnlyMode = false ) {
3333 $this->readOnlyMode = $readOnlyMode;
34 - parent::__construct( $context, $conds, 'EPCourse' );
 34+ parent::__construct( $context, $conds, EPCourses::singleton() );
3535
3636 $this->context->getOutput()->addModules( 'ep.pager.course' );
3737 }
Index: trunk/extensions/EducationProgram/includes/EPPager.php
@@ -22,11 +22,10 @@
2323 protected $conds;
2424
2525 /**
26 - * Name of the class deriving from DBTable.
2726 * @since 0.1
28 - * @var string
 27+ * @var DBTable
2928 */
30 - protected $tableClass;
 29+ protected $table;
3130
3231 /**
3332 * DBDataObject object constructed from $this->currentRow.
@@ -47,11 +46,11 @@
4847 *
4948 * @param IContextSource $context
5049 * @param array $conds
51 - * @param string $tableClass
 50+ * @param DBTable $table
5251 */
53 - public function __construct( IContextSource $context, array $conds, $tableClass ) {
 52+ public function __construct( IContextSource $context, array $conds, DBTable $table ) {
5453 $this->conds = $conds;
55 - $this->tableClass = $tableClass;
 54+ $this->table = $table;
5655 $this->context = $context;
5756
5857 $this->mDefaultDirection = true;
@@ -66,8 +65,7 @@
6766 * @see TablePager::formatRow()
6867 */
6968 function formatRow( $row ) {
70 - $c = $this->className; // Yeah, this is needed in PHP 5.3 >_>
71 - $this->currentObject = $c::newFromDBResult( $row );
 69+ $this->currentObject = $this->table->newFromDBResult( $row );
7270
7371 $cells = array();
7472
@@ -89,7 +87,7 @@
9088 $value = $this->getLanguage()->pipeList( $this->getControlLinks( $this->currentObject ) );
9189 }
9290 else {
93 - $prefixedField = $c::getPrefixedField( $field );
 91+ $prefixedField = $this->table->getPrefixedField( $field );
9492 $value = isset( $row->$prefixedField ) ? $row->$prefixedField : null;
9593 }
9694
@@ -222,11 +220,10 @@
223221 * @see IndexPager::getQueryInfo()
224222 */
225223 function getQueryInfo() {
226 - $c = $this->className; // Yeah, this is needed in PHP 5.3 >_>
227224 return array(
228 - 'tables' => array( $c::getDBTable() ),
229 - 'fields' => $c::getPrefixedFields( $c::getFieldNames() ),
230 - 'conds' => $c::getPrefixedValues( $this->getConditions() ),
 225+ 'tables' => array( $this->table->getDBTable() ),
 226+ 'fields' => $this->table->getPrefixedFields( $this->table->getFieldNames() ),
 227+ 'conds' => $this->table->getPrefixedValues( $this->getConditions() ),
231228 );
232229 }
233230
@@ -258,16 +255,14 @@
259256 * @see TablePager::isFieldSortable()
260257 */
261258 function isFieldSortable( $name ) {
262 - $c = $this->className; // Yeah, this is needed in PHP 5.3 >_>
263259 return in_array(
264260 $name,
265 - $c::getPrefixedFields( $this->getSortableFields() )
 261+ $this->table->getPrefixedFields( $this->getSortableFields() )
266262 );
267263 }
268264
269265 function getDefaultSort() {
270 - $c = $this->className; // Yeah, this is needed in PHP 5.3 >_>
271 - return $c::getPrefixedField( 'id' );
 266+ return $this->table->getPrefixedField( 'id' );
272267 }
273268
274269 /**
@@ -319,8 +314,7 @@
320315 return $current && ( $data['value'] === '' || is_null( $data['value'] ) );
321316 } , true );
322317
323 - $c = $this->className; // Yeah, this is needed in PHP 5.3 >_>
324 - if ( $noFiltersSet || !$c::has() ) {
 318+ if ( $noFiltersSet || !$this->table->has() ) {
325319 return '';
326320 }
327321 }
@@ -426,7 +420,7 @@
427421 * @return string
428422 */
429423 protected function getMsg( $messageKey ) {
430 - return wfMsg( strtolower( $this->className ) . 'pager-' . str_replace( '_', '-', $messageKey ) );
 424+ return wfMsg( strtolower( $this->table->getDataObjectClass() ) . 'pager-' . str_replace( '_', '-', $messageKey ) );
431425 }
432426
433427 /**
@@ -505,8 +499,7 @@
506500
507501 # Make table header
508502 foreach ( $fields as $field => $name ) {
509 - $c = $this->className; // Yeah, this is needed in PHP 5.3 >_>
510 - $prefixedField = $c::getPrefixedField( $field );
 503+ $prefixedField = $this->table->getPrefixedField( $field );
511504 $name = $name === '' ? '' : $this->getMsg( 'header-' . $name );
512505
513506 if ( $field === '_select' ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r111497follow up to r111491, fix various issues due to refactoringjeroendedauw21:41, 14 February 2012
r111504follow up to r111491, fix various issues due to refactoringjeroendedauw22:55, 14 February 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r111469follow up to r111468jeroendedauw18:12, 14 February 2012

Status & tagging log