Index: trunk/extensions/EducationProgram/includes/EPOrgPager.php |
— | — | @@ -25,17 +25,14 @@ |
26 | 26 | |
27 | 27 | /** |
28 | 28 | * (non-PHPdoc) |
29 | | - * @see TablePager::getFieldNames() |
| 29 | + * @see EPPager::getFields() |
30 | 30 | */ |
31 | | - public function getFieldNames() { |
32 | | - $fields = parent::getFieldNameList( array( |
| 31 | + public function getFields() { |
| 32 | + return array( |
33 | 33 | 'name', |
34 | 34 | 'city', |
35 | 35 | 'country', |
36 | | - ) ); |
37 | | - |
38 | | - $fields[0] = ''; // This is a hack to get an extra colum for the control links. |
39 | | - return $fields; |
| 36 | + ); |
40 | 37 | } |
41 | 38 | |
42 | 39 | /** |
Index: trunk/extensions/EducationProgram/includes/EPTermPager.php |
— | — | @@ -25,19 +25,16 @@ |
26 | 26 | |
27 | 27 | /** |
28 | 28 | * (non-PHPdoc) |
29 | | - * @see TablePager::getFieldNames() |
| 29 | + * @see EPPager::getFields() |
30 | 30 | */ |
31 | | - public function getFieldNames() { |
32 | | - $fields = parent::getFieldNameList( array( |
| 31 | + public function getFields() { |
| 32 | + return array( |
33 | 33 | 'id', |
34 | 34 | 'course_id', |
35 | 35 | 'year', |
36 | 36 | 'start', |
37 | 37 | 'end', |
38 | | - ) ); |
39 | | - |
40 | | - $fields[0] = ''; // This is a hack to get an extra colum for the control links. |
41 | | - return $fields; |
| 38 | + ); |
42 | 39 | } |
43 | 40 | |
44 | 41 | /** |
Index: trunk/extensions/EducationProgram/includes/EPPager.php |
— | — | @@ -111,6 +111,7 @@ |
112 | 112 | $this->currentObject = $c::newFromDBResult( $row ); |
113 | 113 | |
114 | 114 | $cells = array(); |
| 115 | + $fields = $this->getFieldNames(); |
115 | 116 | |
116 | 117 | foreach ( $this->getFieldNames() as $field => $name ) { |
117 | 118 | if ( $field === 0 ) { |
— | — | @@ -144,6 +145,37 @@ |
145 | 146 | } |
146 | 147 | |
147 | 148 | /** |
| 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 | + /** |
148 | 180 | * (non-PHPdoc) |
149 | 181 | * @see IndexPager::getQueryInfo() |
150 | 182 | */ |
Index: trunk/extensions/EducationProgram/includes/EPCoursePager.php |
— | — | @@ -25,16 +25,13 @@ |
26 | 26 | |
27 | 27 | /** |
28 | 28 | * (non-PHPdoc) |
29 | | - * @see TablePager::getFieldNames() |
| 29 | + * @see EPPager::getFields() |
30 | 30 | */ |
31 | | - public function getFieldNames() { |
32 | | - $fields = parent::getFieldNameList( array( |
| 31 | + public function getFields() { |
| 32 | + return array( |
33 | 33 | 'name', |
34 | 34 | 'org_id', |
35 | | - ) ); |
36 | | - |
37 | | - $fields[0] = ''; // This is a hack to get an extra colum for the control links. |
38 | | - return $fields; |
| 35 | + ); |
39 | 36 | } |
40 | 37 | |
41 | 38 | /** |