r111497 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111496‎ | r111497 | r111498 >
Date:21:41, 14 February 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
follow up to r111491, fix various issues due to refactoring
Modified paths:
  • /trunk/extensions/EducationProgram/includes/EPCAPager.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPCourse.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPCoursePager.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPOAPager.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPOrg.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPOrgPager.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPOrgs.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPRoleObject.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPStudentPager.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/includes/EPOrgPager.php
@@ -150,7 +150,7 @@
151151 );
152152
153153 $links[] = $this->getDeletionLink(
154 - ApiDeleteEducation::getTypeForClassName( $this->className ),
 154+ ApiDeleteEducation::getTypeForClassName( $this->table->getDataObjectClass() ),
155155 $item->getId(),
156156 $item->getIdentifier()
157157 );
@@ -169,7 +169,7 @@
170170 if ( $this->getUser()->isAllowed( 'ep-org' ) ) {
171171 $actions[wfMsg( 'ep-pager-delete-selected' )] = array(
172172 'class' => 'ep-pager-delete-selected',
173 - 'data-type' => ApiDeleteEducation::getTypeForClassName( $this->className )
 173+ 'data-type' => ApiDeleteEducation::getTypeForClassName( $this->table->getDataObjectClass() )
174174 );
175175 }
176176
Index: trunk/extensions/EducationProgram/includes/EPOrgs.php
@@ -103,5 +103,29 @@
104104 'oa_count',
105105 );
106106 }
 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+ }
107131
108132 }
Index: trunk/extensions/EducationProgram/includes/EPRoleObject.php
@@ -264,7 +264,7 @@
265265 $courses = array();
266266
267267 foreach ( $result as $course ) {
268 - $courses[] = EPCourse::newFromDBResult( $course );
 268+ $courses[] = EPCourses::singleton()->newFromDBResult( $course );
269269 }
270270
271271 return $courses;
Index: trunk/extensions/EducationProgram/includes/EPCAPager.php
@@ -20,7 +20,7 @@
2121 */
2222 public function __construct( IContextSource $context, array $conds = array() ) {
2323 $this->mDefaultDirection = true;
24 - parent::__construct( $context, $conds, 'EPCA' );
 24+ parent::__construct( $context, $conds, EPCAs::singleton() );
2525 }
2626
2727 /**
Index: trunk/extensions/EducationProgram/includes/EPStudentPager.php
@@ -23,7 +23,7 @@
2424 $this->mDefaultDirection = true;
2525
2626 // 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() );
2828 }
2929
3030 /**
Index: trunk/extensions/EducationProgram/includes/EPOAPager.php
@@ -21,7 +21,7 @@
2222 */
2323 public function __construct( IContextSource $context, array $conds = array() ) {
2424 $this->mDefaultDirection = true;
25 - parent::__construct( $context, $conds, 'EPOA' );
 25+ parent::__construct( $context, $conds, EPOAs::singleton() );
2626 }
2727
2828 /**
Index: trunk/extensions/EducationProgram/includes/EPCoursePager.php
@@ -75,7 +75,7 @@
7676 $value = EPCourse::getLinkFor( $value );
7777 break;
7878 case 'org_id':
79 - $org = EPOrg::selectRow( 'name', array( 'id' => $value ) );
 79+ $org = EPOrgs::singleton()->selectRow( 'name', array( 'id' => $value ) );
8080
8181 // This should not happen. A course should always have an org.
8282 // But if something gets messed up somehow, just display the ID rather then throwing a fatal.
@@ -141,17 +141,19 @@
142142 protected function getFilterOptions() {
143143 $options = array();
144144
 145+ $orgs = EPOrgs::singleton();
 146+
145147 $options['org_id'] = array(
146148 'type' => 'select',
147149 'options' => array_merge(
148150 array( '' => '' ),
149 - EPOrg::getOrgOptions( EPOrg::select( array( 'name', 'id' ) ) )
 151+ $orgs->getOrgOptions( $orgs->select( array( 'name', 'id' ) ) )
150152 ),
151153 'value' => '',
152154 'datatype' => 'int',
153155 );
154156
155 - $terms = EPCourse::selectFields( 'term', array(), array( 'DISTINCT' ), true );
 157+ $terms = EPCourses::singleton()->selectFields( 'term', array(), array( 'DISTINCT' ), true );
156158
157159 natcasesort( $terms );
158160 $terms = array_merge( array( '' ), $terms );
@@ -199,7 +201,7 @@
200202 );
201203
202204 $links[] = $this->getDeletionLink(
203 - ApiDeleteEducation::getTypeForClassName( $this->className ),
 205+ ApiDeleteEducation::getTypeForClassName( $this->table->getDataObjectClass() ),
204206 $item->getId(),
205207 $item->getIdentifier()
206208 );
@@ -218,7 +220,7 @@
219221 if ( !$this->readOnlyMode && $this->getUser()->isAllowed( 'ep-course' ) ) {
220222 $actions[wfMsg( 'ep-pager-delete-selected' )] = array(
221223 'class' => 'ep-pager-delete-selected',
222 - 'data-type' => ApiDeleteEducation::getTypeForClassName( $this->className )
 224+ 'data-type' => ApiDeleteEducation::getTypeForClassName( $this->table->getDataObjectClass() )
223225 );
224226 }
225227
Index: trunk/extensions/EducationProgram/includes/EPOrg.php
@@ -106,29 +106,6 @@
107107 }
108108
109109 /**
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 - /**
133110 * Adds a control to add a new org to the provided context.
134111 * Adittional arguments can be provided to set the default values for the control fields.
135112 *
Index: trunk/extensions/EducationProgram/includes/EPCourse.php
@@ -323,7 +323,7 @@
324324 array_key_exists( 'org', $args ) ? $args['org'] : false
325325 );
326326
327 - $select->addOptions( EPOrg::getOrgOptions() );
 327+ $select->addOptions( EPOrgs::singleton()->getOrgOptions() );
328328 $out->addHTML( $select->getHTML() );
329329
330330 $out->addHTML( ' ' . Xml::inputLabel(
@@ -369,7 +369,7 @@
370370 * @param array $args
371371 */
372372 public static function displayAddNewRegion( IContextSource $context, array $args = array() ) {
373 - if ( EPOrg::has() ) {
 373+ if ( EPOrgs::singleton()->has() ) {
374374 EPCourse::displayAddNewControl( $context, $args );
375375 }
376376 elseif ( $context->getUser()->isAllowed( 'ep-course' ) ) {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r111491follow up to r111469 - pass instance of table instead of DBDataObject class n...jeroendedauw21:17, 14 February 2012

Status & tagging log