r111469 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111468‎ | r111469 | r111470 >
Date:18:12, 14 February 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
follow up to r111468
Modified paths:
  • /trunk/extensions/EducationProgram/EducationProgram.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPCA.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPCAs.php (added) (history)
  • /trunk/extensions/EducationProgram/includes/EPCourse.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPCourses.php (added) (history)
  • /trunk/extensions/EducationProgram/includes/EPInstructor.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPInstructors.php (added) (history)
  • /trunk/extensions/EducationProgram/includes/EPOA.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPOAs.php (added) (history)
  • /trunk/extensions/EducationProgram/includes/EPOrg.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPOrgPager.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPOrgs.php (added) (history)
  • /trunk/extensions/EducationProgram/includes/EPPager.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPRevision.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPRevisions.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPRoleObject.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPStudent.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPStudents.php (added) (history)
  • /trunk/extensions/EducationProgram/includes/EPUtils.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/EducationProgram.php
@@ -100,6 +100,13 @@
101101 $wgAutoloadClasses['EPArticlePager'] = dirname( __FILE__ ) . '/includes/EPArticlePager.php';
102102 $wgAutoloadClasses['EPArticleTable'] = dirname( __FILE__ ) . '/includes/EPArticleTable.php';
103103 $wgAutoloadClasses['EPRevisionAction'] = dirname( __FILE__ ) . '/includes/EPRevisionAction.php';
 104+$wgAutoloadClasses['EPOrgs'] = dirname( __FILE__ ) . '/includes/EPOrgs.php';
 105+$wgAutoloadClasses['EPCourses'] = dirname( __FILE__ ) . '/includes/EPCourses.php';
 106+$wgAutoloadClasses['EPStudents'] = dirname( __FILE__ ) . '/includes/EPStudents.php';
 107+$wgAutoloadClasses['EPOAs'] = dirname( __FILE__ ) . '/includes/EPOAs.php';
 108+$wgAutoloadClasses['EPCAs'] = dirname( __FILE__ ) . '/includes/EPCAs.php';
 109+$wgAutoloadClasses['EPInstructors'] = dirname( __FILE__ ) . '/includes/EPInstructors.php';
 110+$wgAutoloadClasses['EPRevisions'] = dirname( __FILE__ ) . '/includes/EPRevisions.php';
104111
105112 $wgAutoloadClasses['CoursePage'] = dirname( __FILE__ ) . '/pages/CoursePage.php';
106113 $wgAutoloadClasses['EPPage'] = dirname( __FILE__ ) . '/pages/EPPage.php';
Index: trunk/extensions/EducationProgram/includes/EPOrgPager.php
@@ -106,8 +106,7 @@
107107 }
108108
109109 function getDefaultSort() {
110 - $c = $this->className; // Yeah, this is needed in PHP 5.3 >_>
111 - return $c::getPrefixedField( 'name' );
 110+ return EPOrgs::singleton()->getPrefixedField( 'name' );
112111 }
113112
114113 /**
Index: trunk/extensions/EducationProgram/includes/EPOrgs.php
@@ -0,0 +1,107 @@
 2+<?php
 3+
 4+/**
 5+ * Class representing the ep_orgs table.
 6+ *
 7+ * @since 0.1
 8+ *
 9+ * @file EPOrgs.php
 10+ * @ingroup EducationProgram
 11+ *
 12+ * @licence GNU GPL v3 or later
 13+ * @author Jeroen De Dauw < jeroendedauw@gmail.com >
 14+ */
 15+class EPOrgs extends DBTable {
 16+
 17+ /**
 18+ * (non-PHPdoc)
 19+ * @see DBTable::getDBTable()
 20+ * @since 0.1
 21+ * @return string
 22+ */
 23+ public function getDBTable() {
 24+ return 'ep_orgs';
 25+ }
 26+
 27+ /**
 28+ * (non-PHPdoc)
 29+ * @see DBTable::getFieldPrefix()
 30+ * @since 0.1
 31+ * @return string
 32+ */
 33+ public function getFieldPrefix() {
 34+ return 'org_';
 35+ }
 36+
 37+ /**
 38+ * (non-PHPdoc)
 39+ * @see DBTable::getDataObjectClass()
 40+ * @since 0.1
 41+ * @return string
 42+ */
 43+ public function getDataObjectClass() {
 44+ return 'EPOrg';
 45+ }
 46+
 47+ /**
 48+ * (non-PHPdoc)
 49+ * @see DBTable::getFieldTypes()
 50+ * @since 0.1
 51+ * @return array
 52+ */
 53+ public function getFieldTypes() {
 54+ return array(
 55+ 'id' => 'id',
 56+
 57+ 'name' => 'str',
 58+ 'city' => 'str',
 59+ 'country' => 'str',
 60+
 61+ 'active' => 'bool',
 62+ 'course_count' => 'int',
 63+ 'student_count' => 'int',
 64+ 'instructor_count' => 'int',
 65+ 'ca_count' => 'int',
 66+ 'oa_count' => 'int',
 67+ );
 68+ }
 69+
 70+ /**
 71+ * (non-PHPdoc)
 72+ * @see DBTable::getDefaults()
 73+ * @since 0.1
 74+ * @return array
 75+ */
 76+ public function getDefaults() {
 77+ return array(
 78+ 'name' => '',
 79+ 'city' => '',
 80+ 'country' => '',
 81+
 82+ 'active' => false,
 83+ 'course_count' => 0,
 84+ 'student_count' => 0,
 85+ 'instructor_count' => 0,
 86+ 'ca_count' => 0,
 87+ 'oa_count' => 0,
 88+ );
 89+ }
 90+
 91+ /**
 92+ * (non-PHPdoc)
 93+ * @see DBTable::getSummaryFields()
 94+ * @since 0.1
 95+ * @return array
 96+ */
 97+ public function getSummaryFields() {
 98+ return array(
 99+ 'active',
 100+ 'course_count',
 101+ 'student_count',
 102+ 'instructor_count',
 103+ 'ca_count',
 104+ 'oa_count',
 105+ );
 106+ }
 107+
 108+}
Property changes on: trunk/extensions/EducationProgram/includes/EPOrgs.php
___________________________________________________________________
Added: svn:eol-style
1109 + native
Index: trunk/extensions/EducationProgram/includes/EPCA.php
@@ -14,50 +14,6 @@
1515 class EPCA extends EPRoleObject implements EPIRole {
1616
1717 /**
18 - * (non-PHPdoc)
19 - * @see DBDataObject::getDBTable()
20 - */
21 - public static function getDBTable() {
22 - return 'ep_cas';
23 - }
24 -
25 - /**
26 - * (non-PHPdoc)
27 - * @see DBDataObject::getFieldPrefix()
28 - */
29 - public static function getFieldPrefix() {
30 - return 'ca_';
31 - }
32 -
33 - /**
34 - * @see parent::getFieldTypes
35 - *
36 - * @since 0.1
37 - *
38 - * @return array
39 - */
40 - protected static function getFieldTypes() {
41 - return array(
42 - 'id' => 'id',
43 -
44 - 'user_id' => 'int',
45 - 'bio' => 'str',
46 - 'photo' => 'str',
47 - );
48 - }
49 -
50 - /**
51 - * (non-PHPdoc)
52 - * @see DBDataObject::getDefaults()
53 - */
54 - public static function getDefaults() {
55 - return array(
56 - 'bio' => '',
57 - 'photo' => '',
58 - );
59 - }
60 -
61 - /**
6218 * Display a pager with campus ambassadors.
6319 *
6420 * @since 0.1
Index: trunk/extensions/EducationProgram/includes/EPRoleObject.php
@@ -41,8 +41,19 @@
4242 */
4343 public static function newFromUserId( $userId, $fields = null ) {
4444 $data = array( 'user_id' => $userId );
45 - $userRole = static::selectRow( null, $data );
46 - return $userRole === false ? new static( $data, true ) : $userRole;
 45+
 46+ $map = array(
 47+ 'EPOA' => 'EPOAs',
 48+ 'EPCA' => 'EPCAs',
 49+ 'EPStudent' => 'EPStudents',
 50+ 'EPInstructor' => 'EPInstructors',
 51+ ); // TODO: this is lame
 52+
 53+ $class = $map[get_called_class()];
 54+ $table = $class::singleton();
 55+
 56+ $userRole = $table->selectRow( null, $data );
 57+ return $userRole === false ? new static( $table, $data, true ) : $userRole;
4758 }
4859
4960 /**
@@ -234,9 +245,11 @@
235246 * @return array of EPCourse
236247 */
237248 protected function doGetCourses( $fields, array $conditions ) {
 249+ $courseTable = EPCourses::singleton();
 250+
238251 $result = wfGetDB( DB_SLAVE )->select(
239252 array( 'ep_courses', 'ep_users_per_course' ),
240 - EPCourse::getPrefixedFields( is_null( $fields ) ? EPCourse::getFieldNames() : (array)$fields ),
 253+ $courseTable->getPrefixedFields( is_null( $fields ) ? $courseTable->getFieldNames() : (array)$fields ),
241254 array(
242255 'upc_role' => $this->getRoleId(),
243256 'upc_user_id' => $this->getField( 'user_id' ),
Index: trunk/extensions/EducationProgram/includes/EPOA.php
@@ -14,50 +14,6 @@
1515 class EPOA extends EPRoleObject implements EPIRole {
1616
1717 /**
18 - * (non-PHPdoc)
19 - * @see DBDataObject::getDBTable()
20 - */
21 - public static function getDBTable() {
22 - return 'ep_oas';
23 - }
24 -
25 - /**
26 - * (non-PHPdoc)
27 - * @see DBDataObject::getFieldPrefix()
28 - */
29 - public static function getFieldPrefix() {
30 - return 'oa_';
31 - }
32 -
33 - /**
34 - * @see parent::getFieldTypes
35 - *
36 - * @since 0.1
37 - *
38 - * @return array
39 - */
40 - protected static function getFieldTypes() {
41 - return array(
42 - 'id' => 'id',
43 -
44 - 'user_id' => 'int',
45 - 'bio' => 'str',
46 - 'photo' => 'str',
47 - );
48 - }
49 -
50 - /**
51 - * (non-PHPdoc)
52 - * @see DBDataObject::getDefaults()
53 - */
54 - public static function getDefaults() {
55 - return array(
56 - 'bio' => '',
57 - 'photo' => '',
58 - );
59 - }
60 -
61 - /**
6218 * Display a pager with online ambassadors.
6319 *
6420 * @since 0.1
Index: trunk/extensions/EducationProgram/includes/EPInstructors.php
@@ -0,0 +1,60 @@
 2+<?php
 3+
 4+/**
 5+ * Class representing the ep_instructors table.
 6+ *
 7+ * @since 0.1
 8+ *
 9+ * @file EPInstructors.php
 10+ * @ingroup EducationProgram
 11+ *
 12+ * @licence GNU GPL v3 or later
 13+ * @author Jeroen De Dauw < jeroendedauw@gmail.com >
 14+ */
 15+class EPInstructors extends DBTable {
 16+
 17+ /**
 18+ * (non-PHPdoc)
 19+ * @see DBTable::getDBTable()
 20+ * @since 0.1
 21+ * @return string
 22+ */
 23+ public function getDBTable() {
 24+ return 'ep_instructors';
 25+ }
 26+
 27+ /**
 28+ * (non-PHPdoc)
 29+ * @see DBTable::getFieldPrefix()
 30+ * @since 0.1
 31+ * @return string
 32+ */
 33+ public function getFieldPrefix() {
 34+ return 'instructor_';
 35+ }
 36+
 37+ /**
 38+ * (non-PHPdoc)
 39+ * @see DBTable::getDataObjectClass()
 40+ * @since 0.1
 41+ * @return string
 42+ */
 43+ public function getDataObjectClass() {
 44+ return 'EPInstructor';
 45+ }
 46+
 47+ /**
 48+ * (non-PHPdoc)
 49+ * @see DBTable::getFieldTypes()
 50+ * @since 0.1
 51+ * @return array
 52+ */
 53+ public function getFieldTypes() {
 54+ return array(
 55+ 'id' => 'id',
 56+
 57+ 'user_id' => 'int',
 58+ );
 59+ }
 60+
 61+}
Property changes on: trunk/extensions/EducationProgram/includes/EPInstructors.php
___________________________________________________________________
Added: svn:eol-style
162 + native
Index: trunk/extensions/EducationProgram/includes/EPUtils.php
@@ -194,7 +194,7 @@
195195
196196 $user = $context->getUser();
197197
198 - if ( EPStudent::has( array( 'user_id' => $user->getId() ) ) ) {
 198+ if ( EPStudents::singleton()->has( array( 'user_id' => $user->getId() ) ) ) {
199199 $items[wfMsg( 'ep-nav-mycourses' )] = SpecialPage::getTitleFor( 'MyCourses' );
200200 }
201201
Index: trunk/extensions/EducationProgram/includes/EPCAs.php
@@ -0,0 +1,75 @@
 2+<?php
 3+
 4+/**
 5+ * Class representing the ep_cas table.
 6+ *
 7+ * @since 0.1
 8+ *
 9+ * @file EPCAs.php
 10+ * @ingroup EducationProgram
 11+ *
 12+ * @licence GNU GPL v3 or later
 13+ * @author Jeroen De Dauw < jeroendedauw@gmail.com >
 14+ */
 15+class EPCAs extends DBTable {
 16+
 17+ /**
 18+ * (non-PHPdoc)
 19+ * @see DBTable::getDBTable()
 20+ * @since 0.1
 21+ * @return string
 22+ */
 23+ public function getDBTable() {
 24+ return 'ep_cas';
 25+ }
 26+
 27+ /**
 28+ * (non-PHPdoc)
 29+ * @see DBTable::getFieldPrefix()
 30+ * @since 0.1
 31+ * @return string
 32+ */
 33+ public function getFieldPrefix() {
 34+ return 'ca_';
 35+ }
 36+
 37+ /**
 38+ * (non-PHPdoc)
 39+ * @see DBTable::getDataObjectClass()
 40+ * @since 0.1
 41+ * @return string
 42+ */
 43+ public function getDataObjectClass() {
 44+ return 'EPCA';
 45+ }
 46+
 47+ /**
 48+ * (non-PHPdoc)
 49+ * @see DBTable::getFieldTypes()
 50+ * @since 0.1
 51+ * @return array
 52+ */
 53+ public function getFieldTypes() {
 54+ return array(
 55+ 'id' => 'id',
 56+
 57+ 'user_id' => 'int',
 58+ 'bio' => 'str',
 59+ 'photo' => 'str',
 60+ );
 61+ }
 62+
 63+ /**
 64+ * (non-PHPdoc)
 65+ * @see DBTable::getDefaults()
 66+ * @since 0.1
 67+ * @return array
 68+ */
 69+ public function getDefaults() {
 70+ return array(
 71+ 'bio' => '',
 72+ 'photo' => '',
 73+ );
 74+ }
 75+
 76+}
Property changes on: trunk/extensions/EducationProgram/includes/EPCAs.php
___________________________________________________________________
Added: svn:eol-style
177 + native
Index: trunk/extensions/EducationProgram/includes/EPStudents.php
@@ -0,0 +1,64 @@
 2+<?php
 3+
 4+/**
 5+ * Class representing the ep_students table.
 6+ *
 7+ * @since 0.1
 8+ *
 9+ * @file EPStudents.php
 10+ * @ingroup EducationProgram
 11+ *
 12+ * @licence GNU GPL v3 or later
 13+ * @author Jeroen De Dauw < jeroendedauw@gmail.com >
 14+ */
 15+class EPStudents extends DBTable {
 16+
 17+ /**
 18+ * (non-PHPdoc)
 19+ * @see DBTable::getDBTable()
 20+ * @since 0.1
 21+ * @return string
 22+ */
 23+ public function getDBTable() {
 24+ return 'ep_students';
 25+ }
 26+
 27+ /**
 28+ * (non-PHPdoc)
 29+ * @see DBTable::getFieldPrefix()
 30+ * @since 0.1
 31+ * @return string
 32+ */
 33+ public function getFieldPrefix() {
 34+ return 'student_';
 35+ }
 36+
 37+ /**
 38+ * (non-PHPdoc)
 39+ * @see DBTable::getDataObjectClass()
 40+ * @since 0.1
 41+ * @return string
 42+ */
 43+ public function getDataObjectClass() {
 44+ return 'EPStudent';
 45+ }
 46+
 47+ /**
 48+ * (non-PHPdoc)
 49+ * @see DBTable::getFieldTypes()
 50+ * @since 0.1
 51+ * @return array
 52+ */
 53+ public function getFieldTypes() {
 54+ return array(
 55+ 'id' => 'id',
 56+
 57+ 'user_id' => 'int',
 58+ 'first_enroll' => 'str', // TS_MW
 59+
 60+ 'last_active' => 'str', // TS_MW
 61+ 'active_enroll' => 'bool',
 62+ );
 63+ }
 64+
 65+}
Property changes on: trunk/extensions/EducationProgram/includes/EPStudents.php
___________________________________________________________________
Added: svn:eol-style
166 + native
Index: trunk/extensions/EducationProgram/includes/EPInstructor.php
@@ -14,38 +14,7 @@
1515 class EPInstructor extends EPRoleObject implements EPIRole {
1616
1717 /**
18 - * (non-PHPdoc)
19 - * @see DBDataObject::getDBTable()
20 - */
21 - public static function getDBTable() {
22 - return 'ep_instructors';
23 - }
24 -
25 - /**
26 - * (non-PHPdoc)
27 - * @see DBDataObject::getFieldPrefix()
28 - */
29 - public static function getFieldPrefix() {
30 - return 'instructor_';
31 - }
32 -
33 - /**
34 - * @see parent::getFieldTypes
35 - *
3618 * @since 0.1
37 - *
38 - * @return array
39 - */
40 - protected static function getFieldTypes() {
41 - return array(
42 - 'id' => 'id',
43 -
44 - 'user_id' => 'int',
45 - );
46 - }
47 -
48 - /**
49 - * @since 0.1
5019 * @see EPIRole::getRoleName
5120 */
5221 public function getRoleName() {
Index: trunk/extensions/EducationProgram/includes/EPRevisions.php
@@ -1,7 +1,7 @@
22 <?php
33
44 /**
5 - * Static class for storing and retrieving revisions of DBDataObjects.
 5+ * Class representing the ep_revisions table.
66 *
77 * @since 0.1
88 *
@@ -11,14 +11,59 @@
1212 * @licence GNU GPL v3 or later
1313 * @author Jeroen De Dauw < jeroendedauw@gmail.com >
1414 */
15 -final class EPRevisions {
 15+class EPRevisions extends DBTable {
1616
17 - public static function storeRevision() {
18 -
 17+ /**
 18+ * (non-PHPdoc)
 19+ * @see DBTable::getDBTable()
 20+ * @since 0.1
 21+ * @return string
 22+ */
 23+ public function getDBTable() {
 24+ return 'ep_revisions';
1925 }
 26+
 27+ /**
 28+ * (non-PHPdoc)
 29+ * @see DBTable::getFieldPrefix()
 30+ * @since 0.1
 31+ * @return string
 32+ */
 33+ public function getFieldPrefix() {
 34+ return 'rev_';
 35+ }
 36+
 37+ /**
 38+ * (non-PHPdoc)
 39+ * @see DBTable::getDataObjectClass()
 40+ * @since 0.1
 41+ * @return string
 42+ */
 43+ public function getDataObjectClass() {
 44+ return 'EPRevision';
 45+ }
 46+
 47+ /**
 48+ * (non-PHPdoc)
 49+ * @see DBTable::getFieldTypes()
 50+ * @since 0.1
 51+ * @return array
 52+ */
 53+ public function getFieldTypes() {
 54+ return array(
 55+ 'id' => 'id',
2056
21 - public static function getRevision() {
22 -
 57+ 'object_id' => 'int',
 58+ 'object_identifier' => 'str',
 59+ 'user_id' => 'int',
 60+ 'type' => 'str',
 61+ 'comment' => 'str',
 62+ 'user_text' => 'str',
 63+ 'minor_edit' => 'bool',
 64+ 'time' => 'str', // TS_MW
 65+ 'deleted' => 'bool',
 66+ 'data' => 'blob',
 67+ );
2368 }
24 -
 69+
2570 }
Index: trunk/extensions/EducationProgram/includes/EPOAs.php
@@ -0,0 +1,75 @@
 2+<?php
 3+
 4+/**
 5+ * Class representing the ep_oas table.
 6+ *
 7+ * @since 0.1
 8+ *
 9+ * @file EPOAs.php
 10+ * @ingroup EducationProgram
 11+ *
 12+ * @licence GNU GPL v3 or later
 13+ * @author Jeroen De Dauw < jeroendedauw@gmail.com >
 14+ */
 15+class EPOAs extends DBTable {
 16+
 17+ /**
 18+ * (non-PHPdoc)
 19+ * @see DBTable::getDBTable()
 20+ * @since 0.1
 21+ * @return string
 22+ */
 23+ public function getDBTable() {
 24+ return 'ep_oas';
 25+ }
 26+
 27+ /**
 28+ * (non-PHPdoc)
 29+ * @see DBTable::getFieldPrefix()
 30+ * @since 0.1
 31+ * @return string
 32+ */
 33+ public function getFieldPrefix() {
 34+ return 'oa_';
 35+ }
 36+
 37+ /**
 38+ * (non-PHPdoc)
 39+ * @see DBTable::getDataObjectClass()
 40+ * @since 0.1
 41+ * @return string
 42+ */
 43+ public function getDataObjectClass() {
 44+ return 'EPOA';
 45+ }
 46+
 47+ /**
 48+ * (non-PHPdoc)
 49+ * @see DBTable::getFieldTypes()
 50+ * @since 0.1
 51+ * @return array
 52+ */
 53+ public function getFieldTypes() {
 54+ return array(
 55+ 'id' => 'id',
 56+
 57+ 'user_id' => 'int',
 58+ 'bio' => 'str',
 59+ 'photo' => 'str',
 60+ );
 61+ }
 62+
 63+ /**
 64+ * (non-PHPdoc)
 65+ * @see DBTable::getDefaults()
 66+ * @since 0.1
 67+ * @return array
 68+ */
 69+ public function getDefaults() {
 70+ return array(
 71+ 'bio' => '',
 72+ 'photo' => '',
 73+ );
 74+ }
 75+
 76+}
Property changes on: trunk/extensions/EducationProgram/includes/EPOAs.php
___________________________________________________________________
Added: svn:eol-style
177 + native
Index: trunk/extensions/EducationProgram/includes/EPCourses.php
@@ -0,0 +1,124 @@
 2+<?php
 3+
 4+/**
 5+ * Class representing the ep_courses table.
 6+ *
 7+ * @since 0.1
 8+ *
 9+ * @file EPCourses.php
 10+ * @ingroup EducationProgram
 11+ *
 12+ * @licence GNU GPL v3 or later
 13+ * @author Jeroen De Dauw < jeroendedauw@gmail.com >
 14+ */
 15+class EPCourses extends DBTable {
 16+
 17+ /**
 18+ * (non-PHPdoc)
 19+ * @see DBTable::getDBTable()
 20+ * @since 0.1
 21+ * @return string
 22+ */
 23+ public function getDBTable() {
 24+ return 'ep_courses';
 25+ }
 26+
 27+ /**
 28+ * (non-PHPdoc)
 29+ * @see DBTable::getFieldPrefix()
 30+ * @since 0.1
 31+ * @return string
 32+ */
 33+ public function getFieldPrefix() {
 34+ return 'course_';
 35+ }
 36+
 37+ /**
 38+ * (non-PHPdoc)
 39+ * @see DBTable::getDataObjectClass()
 40+ * @since 0.1
 41+ * @return string
 42+ */
 43+ public function getDataObjectClass() {
 44+ return 'EPCourse';
 45+ }
 46+
 47+ /**
 48+ * (non-PHPdoc)
 49+ * @see DBTable::getFieldTypes()
 50+ * @since 0.1
 51+ * @return array
 52+ */
 53+ public function getFieldTypes() {
 54+ return array(
 55+ 'id' => 'id',
 56+
 57+ 'org_id' => 'int',
 58+ 'name' => 'str',
 59+ 'start' => 'str', // TS_MW
 60+ 'end' => 'str', // TS_MW
 61+ 'description' => 'str',
 62+ 'token' => 'str',
 63+ 'students' => 'array',
 64+ 'instructors' => 'array',
 65+ 'online_ambs' => 'array',
 66+ 'campus_ambs' => 'array',
 67+ 'field' => 'str',
 68+ 'level' => 'str',
 69+ 'term' => 'str',
 70+ 'lang' => 'str',
 71+ 'mc' => 'str',
 72+
 73+ 'student_count' => 'int',
 74+ 'instructor_count' => 'int',
 75+ 'oa_count' => 'int',
 76+ 'ca_count' => 'int',
 77+ );
 78+ }
 79+
 80+ /**
 81+ * (non-PHPdoc)
 82+ * @see DBTable::getDefaults()
 83+ * @since 0.1
 84+ * @return array
 85+ */
 86+ public function getDefaults() {
 87+ return array(
 88+ 'name' => '',
 89+ 'start' => wfTimestamp( TS_MW ),
 90+ 'end' => wfTimestamp( TS_MW ),
 91+ 'description' => '',
 92+ 'token' => '',
 93+ 'students' => array(),
 94+ 'instructors' => array(),
 95+ 'online_ambs' => array(),
 96+ 'campus_ambs' => array(),
 97+ 'field' => '',
 98+ 'level' => '',
 99+ 'term' => '',
 100+ 'lang' => '',
 101+ 'mc' => '',
 102+
 103+ 'student_count' => 0,
 104+ 'instructor_count' => 0,
 105+ 'oa_count' => 0,
 106+ 'ca_count' => 0,
 107+ );
 108+ }
 109+
 110+ /**
 111+ * (non-PHPdoc)
 112+ * @see DBTable::getSummaryFields()
 113+ * @since 0.1
 114+ * @return array
 115+ */
 116+ public function getSummaryFields() {
 117+ return array(
 118+ 'student_count',
 119+ 'instructor_count',
 120+ 'oa_count',
 121+ 'ca_count',
 122+ );
 123+ }
 124+
 125+}
Property changes on: trunk/extensions/EducationProgram/includes/EPCourses.php
___________________________________________________________________
Added: svn:eol-style
1126 + native
Index: trunk/extensions/EducationProgram/includes/EPStudent.php
@@ -14,41 +14,6 @@
1515 class EPStudent extends EPRoleObject {
1616
1717 /**
18 - * (non-PHPdoc)
19 - * @see DBDataObject::getDBTable()
20 - */
21 - public static function getDBTable() {
22 - return 'ep_students';
23 - }
24 -
25 - /**
26 - * (non-PHPdoc)
27 - * @see DBDataObject::getFieldPrefix()
28 - */
29 - public static function getFieldPrefix() {
30 - return 'student_';
31 - }
32 -
33 - /**
34 - * @see parent::getFieldTypes
35 - *
36 - * @since 0.1
37 - *
38 - * @return array
39 - */
40 - protected static function getFieldTypes() {
41 - return array(
42 - 'id' => 'id',
43 -
44 - 'user_id' => 'int',
45 - 'first_enroll' => 'str', // TS_MW
46 -
47 - 'last_active' => 'str', // TS_MW
48 - 'active_enroll' => 'bool',
49 - );
50 - }
51 -
52 - /**
5318 * Display a pager with students.
5419 *
5520 * @since 0.1
Index: trunk/extensions/EducationProgram/includes/EPOrg.php
@@ -23,80 +23,6 @@
2424
2525 /**
2626 * (non-PHPdoc)
27 - * @see DBDataObject::getDBTable()
28 - */
29 - public static function getDBTable() {
30 - return 'ep_orgs';
31 - }
32 -
33 - /**
34 - * (non-PHPdoc)
35 - * @see DBDataObject::getFieldPrefix()
36 - */
37 - public static function getFieldPrefix() {
38 - return 'org_';
39 - }
40 -
41 - /**
42 - * @see parent::getFieldTypes
43 - *
44 - * @since 0.1
45 - *
46 - * @return array
47 - */
48 - protected static function getFieldTypes() {
49 - return array(
50 - 'id' => 'id',
51 -
52 - 'name' => 'str',
53 - 'city' => 'str',
54 - 'country' => 'str',
55 -
56 - 'active' => 'bool',
57 - 'course_count' => 'int',
58 - 'student_count' => 'int',
59 - 'instructor_count' => 'int',
60 - 'ca_count' => 'int',
61 - 'oa_count' => 'int',
62 - );
63 - }
64 -
65 - /**
66 - * (non-PHPdoc)
67 - * @see DBDataObject::getDefaults()
68 - */
69 - public static function getDefaults() {
70 - return array(
71 - 'name' => '',
72 - 'city' => '',
73 - 'country' => '',
74 -
75 - 'active' => false,
76 - 'course_count' => 0,
77 - 'student_count' => 0,
78 - 'instructor_count' => 0,
79 - 'ca_count' => 0,
80 - 'oa_count' => 0,
81 - );
82 - }
83 -
84 - /**
85 - * (non-PHPdoc)
86 - * @see DBDataObject::getSummaryFields()
87 - */
88 - public static function getSummaryFields() {
89 - return array(
90 - 'active',
91 - 'course_count',
92 - 'student_count',
93 - 'instructor_count',
94 - 'ca_count',
95 - 'oa_count',
96 - );
97 - }
98 -
99 - /**
100 - * (non-PHPdoc)
10127 * @see DBDataObject::loadSummaryFields()
10228 */
10329 public function loadSummaryFields( $summaryFields = null ) {
Index: trunk/extensions/EducationProgram/includes/EPPager.php
@@ -22,11 +22,11 @@
2323 protected $conds;
2424
2525 /**
26 - * Name of the class deriving from DBDataObject.
 26+ * Name of the class deriving from DBTable.
2727 * @since 0.1
2828 * @var string
2929 */
30 - protected $className;
 30+ protected $tableClass;
3131
3232 /**
3333 * DBDataObject object constructed from $this->currentRow.
@@ -47,11 +47,11 @@
4848 *
4949 * @param IContextSource $context
5050 * @param array $conds
51 - * @param string $className
 51+ * @param string $tableClass
5252 */
53 - public function __construct( IContextSource $context, array $conds, $className ) {
 53+ public function __construct( IContextSource $context, array $conds, $tableClass ) {
5454 $this->conds = $conds;
55 - $this->className = $className;
 55+ $this->tableClass = $tableClass;
5656 $this->context = $context;
5757
5858 $this->mDefaultDirection = true;
Index: trunk/extensions/EducationProgram/includes/EPRevision.php
@@ -35,46 +35,6 @@
3636 }
3737
3838 /**
39 - * (non-PHPdoc)
40 - * @see DBDataObject::getDBTable()
41 - */
42 - public static function getDBTable() {
43 - return 'ep_revisions';
44 - }
45 -
46 - /**
47 - * (non-PHPdoc)
48 - * @see DBDataObject::getFieldPrefix()
49 - */
50 - public static function getFieldPrefix() {
51 - return 'rev_';
52 - }
53 -
54 - /**
55 - * @see parent::getFieldTypes
56 - *
57 - * @since 0.1
58 - *
59 - * @return array
60 - */
61 - protected static function getFieldTypes() {
62 - return array(
63 - 'id' => 'id',
64 -
65 - 'object_id' => 'int',
66 - 'object_identifier' => 'str',
67 - 'user_id' => 'int',
68 - 'type' => 'str',
69 - 'comment' => 'str',
70 - 'user_text' => 'str',
71 - 'minor_edit' => 'bool',
72 - 'time' => 'str', // TS_MW
73 - 'deleted' => 'bool',
74 - 'data' => 'blob',
75 - );
76 - }
77 -
78 - /**
7939 * Create a new revision object for the provided EPRevisionedObject.
8040 * The EPRevisionedObject should have all it's fields loaded.
8141 *
Index: trunk/extensions/EducationProgram/includes/EPCourse.php
@@ -88,97 +88,6 @@
8989 return $map[$status];
9090 }
9191
92 - /**
93 - * (non-PHPdoc)
94 - * @see DBDataObject::getDBTable()
95 - */
96 - public static function getDBTable() {
97 - return 'ep_courses';
98 - }
99 -
100 - /**
101 - * (non-PHPdoc)
102 - * @see DBDataObject::getFieldPrefix()
103 - */
104 - public static function getFieldPrefix() {
105 - return 'course_';
106 - }
107 -
108 - /**
109 - * @see parent::getFieldTypes
110 - *
111 - * @since 0.1
112 - *
113 - * @return array
114 - */
115 - protected static function getFieldTypes() {
116 - return array(
117 - 'id' => 'id',
118 -
119 - 'org_id' => 'int',
120 - 'name' => 'str',
121 - 'start' => 'str', // TS_MW
122 - 'end' => 'str', // TS_MW
123 - 'description' => 'str',
124 - 'token' => 'str',
125 - 'students' => 'array',
126 - 'instructors' => 'array',
127 - 'online_ambs' => 'array',
128 - 'campus_ambs' => 'array',
129 - 'field' => 'str',
130 - 'level' => 'str',
131 - 'term' => 'str',
132 - 'lang' => 'str',
133 - 'mc' => 'str',
134 -
135 - 'student_count' => 'int',
136 - 'instructor_count' => 'int',
137 - 'oa_count' => 'int',
138 - 'ca_count' => 'int',
139 - );
140 - }
141 -
142 - /**
143 - * (non-PHPdoc)
144 - * @see DBDataObject::getDefaults()
145 - */
146 - public static function getDefaults() {
147 - return array(
148 - 'name' => '',
149 - 'start' => wfTimestamp( TS_MW ),
150 - 'end' => wfTimestamp( TS_MW ),
151 - 'description' => '',
152 - 'token' => '',
153 - 'students' => array(),
154 - 'instructors' => array(),
155 - 'online_ambs' => array(),
156 - 'campus_ambs' => array(),
157 - 'field' => '',
158 - 'level' => '',
159 - 'term' => '',
160 - 'lang' => '',
161 - 'mc' => '',
162 -
163 - 'student_count' => 0,
164 - 'instructor_count' => 0,
165 - 'oa_count' => 0,
166 - 'ca_count' => 0,
167 - );
168 - }
169 -
170 - /**
171 - * (non-PHPdoc)
172 - * @see DBDataObject::getSummaryFields()
173 - */
174 - public static function getSummaryFields() {
175 - return array(
176 - 'student_count',
177 - 'instructor_count',
178 - 'oa_count',
179 - 'ca_count',
180 - );
181 - }
182 -
18392 protected static $countMap = array(
18493 'student_count' => 'students',
18594 'instructor_count' => 'instructors',

Follow-up revisions

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

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r111468follow up to r111264; split up class into one representing a table and one re...jeroendedauw18:11, 14 February 2012

Status & tagging log