Index: trunk/extensions/EducationProgram/includes/EPOrgPager.php |
— | — | @@ -150,7 +150,7 @@ |
151 | 151 | ); |
152 | 152 | |
153 | 153 | $links[] = $this->getDeletionLink( |
154 | | - ApiDeleteEducation::getTypeForClassName( $this->className ), |
| 154 | + ApiDeleteEducation::getTypeForClassName( $this->table->getDataObjectClass() ), |
155 | 155 | $item->getId(), |
156 | 156 | $item->getIdentifier() |
157 | 157 | ); |
— | — | @@ -169,7 +169,7 @@ |
170 | 170 | if ( $this->getUser()->isAllowed( 'ep-org' ) ) { |
171 | 171 | $actions[wfMsg( 'ep-pager-delete-selected' )] = array( |
172 | 172 | 'class' => 'ep-pager-delete-selected', |
173 | | - 'data-type' => ApiDeleteEducation::getTypeForClassName( $this->className ) |
| 173 | + 'data-type' => ApiDeleteEducation::getTypeForClassName( $this->table->getDataObjectClass() ) |
174 | 174 | ); |
175 | 175 | } |
176 | 176 | |
Index: trunk/extensions/EducationProgram/includes/EPOrgs.php |
— | — | @@ -103,5 +103,29 @@ |
104 | 104 | 'oa_count', |
105 | 105 | ); |
106 | 106 | } |
| 107 | + |
| 108 | + |
| 109 | + /** |
| 110 | + * Returns a list of orgs in an array that can be fed to select inputs. |
| 111 | + * |
| 112 | + * @since 0.1 |
| 113 | + * |
| 114 | + * @param array|null $orgs |
| 115 | + * |
| 116 | + * @return array |
| 117 | + */ |
| 118 | + public function getOrgOptions( array /* EPOrg */ $orgs = null ) { |
| 119 | + $options = array(); |
| 120 | + |
| 121 | + if ( is_null( $orgs ) ) { |
| 122 | + $orgs = $this->select( array( 'name', 'id' ) ); |
| 123 | + } |
| 124 | + |
| 125 | + foreach ( $orgs as /* EPOrg */ $org ) { |
| 126 | + $options[$org->getField( 'name' )] = $org->getId(); |
| 127 | + } |
| 128 | + |
| 129 | + return $options; |
| 130 | + } |
107 | 131 | |
108 | 132 | } |
Index: trunk/extensions/EducationProgram/includes/EPRoleObject.php |
— | — | @@ -264,7 +264,7 @@ |
265 | 265 | $courses = array(); |
266 | 266 | |
267 | 267 | foreach ( $result as $course ) { |
268 | | - $courses[] = EPCourse::newFromDBResult( $course ); |
| 268 | + $courses[] = EPCourses::singleton()->newFromDBResult( $course ); |
269 | 269 | } |
270 | 270 | |
271 | 271 | return $courses; |
Index: trunk/extensions/EducationProgram/includes/EPCAPager.php |
— | — | @@ -20,7 +20,7 @@ |
21 | 21 | */ |
22 | 22 | public function __construct( IContextSource $context, array $conds = array() ) { |
23 | 23 | $this->mDefaultDirection = true; |
24 | | - parent::__construct( $context, $conds, 'EPCA' ); |
| 24 | + parent::__construct( $context, $conds, EPCAs::singleton() ); |
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
Index: trunk/extensions/EducationProgram/includes/EPStudentPager.php |
— | — | @@ -23,7 +23,7 @@ |
24 | 24 | $this->mDefaultDirection = true; |
25 | 25 | |
26 | 26 | // when MW 1.19 becomes min, we want to pass an IContextSource $context here. |
27 | | - parent::__construct( $context, $conds, 'EPStudent' ); |
| 27 | + parent::__construct( $context, $conds, EPStudents::singleton() ); |
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
Index: trunk/extensions/EducationProgram/includes/EPOAPager.php |
— | — | @@ -21,7 +21,7 @@ |
22 | 22 | */ |
23 | 23 | public function __construct( IContextSource $context, array $conds = array() ) { |
24 | 24 | $this->mDefaultDirection = true; |
25 | | - parent::__construct( $context, $conds, 'EPOA' ); |
| 25 | + parent::__construct( $context, $conds, EPOAs::singleton() ); |
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
Index: trunk/extensions/EducationProgram/includes/EPCoursePager.php |
— | — | @@ -75,7 +75,7 @@ |
76 | 76 | $value = EPCourse::getLinkFor( $value ); |
77 | 77 | break; |
78 | 78 | case 'org_id': |
79 | | - $org = EPOrg::selectRow( 'name', array( 'id' => $value ) ); |
| 79 | + $org = EPOrgs::singleton()->selectRow( 'name', array( 'id' => $value ) ); |
80 | 80 | |
81 | 81 | // This should not happen. A course should always have an org. |
82 | 82 | // But if something gets messed up somehow, just display the ID rather then throwing a fatal. |
— | — | @@ -141,17 +141,19 @@ |
142 | 142 | protected function getFilterOptions() { |
143 | 143 | $options = array(); |
144 | 144 | |
| 145 | + $orgs = EPOrgs::singleton(); |
| 146 | + |
145 | 147 | $options['org_id'] = array( |
146 | 148 | 'type' => 'select', |
147 | 149 | 'options' => array_merge( |
148 | 150 | array( '' => '' ), |
149 | | - EPOrg::getOrgOptions( EPOrg::select( array( 'name', 'id' ) ) ) |
| 151 | + $orgs->getOrgOptions( $orgs->select( array( 'name', 'id' ) ) ) |
150 | 152 | ), |
151 | 153 | 'value' => '', |
152 | 154 | 'datatype' => 'int', |
153 | 155 | ); |
154 | 156 | |
155 | | - $terms = EPCourse::selectFields( 'term', array(), array( 'DISTINCT' ), true ); |
| 157 | + $terms = EPCourses::singleton()->selectFields( 'term', array(), array( 'DISTINCT' ), true ); |
156 | 158 | |
157 | 159 | natcasesort( $terms ); |
158 | 160 | $terms = array_merge( array( '' ), $terms ); |
— | — | @@ -199,7 +201,7 @@ |
200 | 202 | ); |
201 | 203 | |
202 | 204 | $links[] = $this->getDeletionLink( |
203 | | - ApiDeleteEducation::getTypeForClassName( $this->className ), |
| 205 | + ApiDeleteEducation::getTypeForClassName( $this->table->getDataObjectClass() ), |
204 | 206 | $item->getId(), |
205 | 207 | $item->getIdentifier() |
206 | 208 | ); |
— | — | @@ -218,7 +220,7 @@ |
219 | 221 | if ( !$this->readOnlyMode && $this->getUser()->isAllowed( 'ep-course' ) ) { |
220 | 222 | $actions[wfMsg( 'ep-pager-delete-selected' )] = array( |
221 | 223 | 'class' => 'ep-pager-delete-selected', |
222 | | - 'data-type' => ApiDeleteEducation::getTypeForClassName( $this->className ) |
| 224 | + 'data-type' => ApiDeleteEducation::getTypeForClassName( $this->table->getDataObjectClass() ) |
223 | 225 | ); |
224 | 226 | } |
225 | 227 | |
Index: trunk/extensions/EducationProgram/includes/EPOrg.php |
— | — | @@ -106,29 +106,6 @@ |
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
110 | | - * Returns a list of orgs in an array that can be fed to select inputs. |
111 | | - * |
112 | | - * @since 0.1 |
113 | | - * |
114 | | - * @param array|null $orgs |
115 | | - * |
116 | | - * @return array |
117 | | - */ |
118 | | - public static function getOrgOptions( array /* EPOrg */ $orgs = null ) { |
119 | | - $options = array(); |
120 | | - |
121 | | - if ( is_null( $orgs ) ) { |
122 | | - $orgs = EPOrg::select( array( 'name', 'id' ) ); |
123 | | - } |
124 | | - |
125 | | - foreach ( $orgs as /* EPOrg */ $org ) { |
126 | | - $options[$org->getField( 'name' )] = $org->getId(); |
127 | | - } |
128 | | - |
129 | | - return $options; |
130 | | - } |
131 | | - |
132 | | - /** |
133 | 110 | * Adds a control to add a new org to the provided context. |
134 | 111 | * Adittional arguments can be provided to set the default values for the control fields. |
135 | 112 | * |
Index: trunk/extensions/EducationProgram/includes/EPCourse.php |
— | — | @@ -323,7 +323,7 @@ |
324 | 324 | array_key_exists( 'org', $args ) ? $args['org'] : false |
325 | 325 | ); |
326 | 326 | |
327 | | - $select->addOptions( EPOrg::getOrgOptions() ); |
| 327 | + $select->addOptions( EPOrgs::singleton()->getOrgOptions() ); |
328 | 328 | $out->addHTML( $select->getHTML() ); |
329 | 329 | |
330 | 330 | $out->addHTML( ' ' . Xml::inputLabel( |
— | — | @@ -369,7 +369,7 @@ |
370 | 370 | * @param array $args |
371 | 371 | */ |
372 | 372 | public static function displayAddNewRegion( IContextSource $context, array $args = array() ) { |
373 | | - if ( EPOrg::has() ) { |
| 373 | + if ( EPOrgs::singleton()->has() ) { |
374 | 374 | EPCourse::displayAddNewControl( $context, $args ); |
375 | 375 | } |
376 | 376 | elseif ( $context->getUser()->isAllowed( 'ep-course' ) ) { |