r107201 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107200‎ | r107201 | r107202 >
Date:02:19, 24 December 2011
Author:jeroendedauw
Status:deferred
Tags:educationprogram 
Comment:
do not display non-relevant fields in pagers
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)
  • /trunk/extensions/EducationProgram/includes/EPTermPager.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/includes/EPOrgPager.php
@@ -25,17 +25,14 @@
2626
2727 /**
2828 * (non-PHPdoc)
29 - * @see TablePager::getFieldNames()
 29+ * @see EPPager::getFields()
3030 */
31 - public function getFieldNames() {
32 - $fields = parent::getFieldNameList( array(
 31+ public function getFields() {
 32+ return array(
3333 'name',
3434 'city',
3535 'country',
36 - ) );
37 -
38 - $fields[0] = ''; // This is a hack to get an extra colum for the control links.
39 - return $fields;
 36+ );
4037 }
4138
4239 /**
Index: trunk/extensions/EducationProgram/includes/EPTermPager.php
@@ -25,19 +25,16 @@
2626
2727 /**
2828 * (non-PHPdoc)
29 - * @see TablePager::getFieldNames()
 29+ * @see EPPager::getFields()
3030 */
31 - public function getFieldNames() {
32 - $fields = parent::getFieldNameList( array(
 31+ public function getFields() {
 32+ return array(
3333 'id',
3434 'course_id',
3535 'year',
3636 'start',
3737 'end',
38 - ) );
39 -
40 - $fields[0] = ''; // This is a hack to get an extra colum for the control links.
41 - return $fields;
 38+ );
4239 }
4340
4441 /**
Index: trunk/extensions/EducationProgram/includes/EPPager.php
@@ -111,6 +111,7 @@
112112 $this->currentObject = $c::newFromDBResult( $row );
113113
114114 $cells = array();
 115+ $fields = $this->getFieldNames();
115116
116117 foreach ( $this->getFieldNames() as $field => $name ) {
117118 if ( $field === 0 ) {
@@ -144,6 +145,37 @@
145146 }
146147
147148 /**
 149+ * Returns the relevant field names.
 150+ *
 151+ * @since 0.1
 152+ *
 153+ * @return array
 154+ */
 155+ public function getFieldNames() {
 156+ $c = $this->className; // Yeah, this is needed in PHP 5.3 >_>
 157+ $conds = $this->conds; // Indeed, this is also needed >_>
 158+ $fields = array_filter( $this->getFields(), function( $name ) use ( $conds ) {
 159+ return !array_key_exists( $name, $conds );
 160+ } );
 161+
 162+ $fields = $this->getFieldNameList( $fields );
 163+ $fields[0] = ''; // This is a hack to get an extra colum for the control links.
 164+
 165+ return $fields;
 166+ }
 167+
 168+ /**
 169+ * Returns the fields to display.
 170+ * Similar to @see getFieldNames, but fields should not be prefixed, and
 171+ * non-relevant fields will be removed.
 172+ *
 173+ * @since 0.1
 174+ *
 175+ * @return array
 176+ */
 177+ protected abstract function getFields();
 178+
 179+ /**
148180 * (non-PHPdoc)
149181 * @see IndexPager::getQueryInfo()
150182 */
Index: trunk/extensions/EducationProgram/includes/EPCoursePager.php
@@ -25,16 +25,13 @@
2626
2727 /**
2828 * (non-PHPdoc)
29 - * @see TablePager::getFieldNames()
 29+ * @see EPPager::getFields()
3030 */
31 - public function getFieldNames() {
32 - $fields = parent::getFieldNameList( array(
 31+ public function getFields() {
 32+ return array(
3333 'name',
3434 'org_id',
35 - ) );
36 -
37 - $fields[0] = ''; // This is a hack to get an extra colum for the control links.
38 - return $fields;
 35+ );
3936 }
4037
4138 /**

Status & tagging log