Index: trunk/extensions/EducationProgram/EducationProgram.php |
— | — | @@ -100,6 +100,13 @@ |
101 | 101 | $wgAutoloadClasses['EPArticlePager'] = dirname( __FILE__ ) . '/includes/EPArticlePager.php'; |
102 | 102 | $wgAutoloadClasses['EPArticleTable'] = dirname( __FILE__ ) . '/includes/EPArticleTable.php'; |
103 | 103 | $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'; |
104 | 111 | |
105 | 112 | $wgAutoloadClasses['CoursePage'] = dirname( __FILE__ ) . '/pages/CoursePage.php'; |
106 | 113 | $wgAutoloadClasses['EPPage'] = dirname( __FILE__ ) . '/pages/EPPage.php'; |
Index: trunk/extensions/EducationProgram/includes/EPOrgPager.php |
— | — | @@ -106,8 +106,7 @@ |
107 | 107 | } |
108 | 108 | |
109 | 109 | 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' ); |
112 | 111 | } |
113 | 112 | |
114 | 113 | /** |
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 |
1 | 109 | + native |
Index: trunk/extensions/EducationProgram/includes/EPCA.php |
— | — | @@ -14,50 +14,6 @@ |
15 | 15 | class EPCA extends EPRoleObject implements EPIRole { |
16 | 16 | |
17 | 17 | /** |
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 | | - /** |
62 | 18 | * Display a pager with campus ambassadors. |
63 | 19 | * |
64 | 20 | * @since 0.1 |
Index: trunk/extensions/EducationProgram/includes/EPRoleObject.php |
— | — | @@ -41,8 +41,19 @@ |
42 | 42 | */ |
43 | 43 | public static function newFromUserId( $userId, $fields = null ) { |
44 | 44 | $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; |
47 | 58 | } |
48 | 59 | |
49 | 60 | /** |
— | — | @@ -234,9 +245,11 @@ |
235 | 246 | * @return array of EPCourse |
236 | 247 | */ |
237 | 248 | protected function doGetCourses( $fields, array $conditions ) { |
| 249 | + $courseTable = EPCourses::singleton(); |
| 250 | + |
238 | 251 | $result = wfGetDB( DB_SLAVE )->select( |
239 | 252 | 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 ), |
241 | 254 | array( |
242 | 255 | 'upc_role' => $this->getRoleId(), |
243 | 256 | 'upc_user_id' => $this->getField( 'user_id' ), |
Index: trunk/extensions/EducationProgram/includes/EPOA.php |
— | — | @@ -14,50 +14,6 @@ |
15 | 15 | class EPOA extends EPRoleObject implements EPIRole { |
16 | 16 | |
17 | 17 | /** |
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 | | - /** |
62 | 18 | * Display a pager with online ambassadors. |
63 | 19 | * |
64 | 20 | * @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 |
1 | 62 | + native |
Index: trunk/extensions/EducationProgram/includes/EPUtils.php |
— | — | @@ -194,7 +194,7 @@ |
195 | 195 | |
196 | 196 | $user = $context->getUser(); |
197 | 197 | |
198 | | - if ( EPStudent::has( array( 'user_id' => $user->getId() ) ) ) { |
| 198 | + if ( EPStudents::singleton()->has( array( 'user_id' => $user->getId() ) ) ) { |
199 | 199 | $items[wfMsg( 'ep-nav-mycourses' )] = SpecialPage::getTitleFor( 'MyCourses' ); |
200 | 200 | } |
201 | 201 | |
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 |
1 | 77 | + 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 |
1 | 66 | + native |
Index: trunk/extensions/EducationProgram/includes/EPInstructor.php |
— | — | @@ -14,38 +14,7 @@ |
15 | 15 | class EPInstructor extends EPRoleObject implements EPIRole { |
16 | 16 | |
17 | 17 | /** |
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 | | - * |
36 | 18 | * @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 |
50 | 19 | * @see EPIRole::getRoleName |
51 | 20 | */ |
52 | 21 | public function getRoleName() { |
Index: trunk/extensions/EducationProgram/includes/EPRevisions.php |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | /** |
5 | | - * Static class for storing and retrieving revisions of DBDataObjects. |
| 5 | + * Class representing the ep_revisions table. |
6 | 6 | * |
7 | 7 | * @since 0.1 |
8 | 8 | * |
— | — | @@ -11,14 +11,59 @@ |
12 | 12 | * @licence GNU GPL v3 or later |
13 | 13 | * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
14 | 14 | */ |
15 | | -final class EPRevisions { |
| 15 | +class EPRevisions extends DBTable { |
16 | 16 | |
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'; |
19 | 25 | } |
| 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', |
20 | 56 | |
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 | + ); |
23 | 68 | } |
24 | | - |
| 69 | + |
25 | 70 | } |
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 |
1 | 77 | + 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 |
1 | 126 | + native |
Index: trunk/extensions/EducationProgram/includes/EPStudent.php |
— | — | @@ -14,41 +14,6 @@ |
15 | 15 | class EPStudent extends EPRoleObject { |
16 | 16 | |
17 | 17 | /** |
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 | | - /** |
53 | 18 | * Display a pager with students. |
54 | 19 | * |
55 | 20 | * @since 0.1 |
Index: trunk/extensions/EducationProgram/includes/EPOrg.php |
— | — | @@ -23,80 +23,6 @@ |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * (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) |
101 | 27 | * @see DBDataObject::loadSummaryFields() |
102 | 28 | */ |
103 | 29 | public function loadSummaryFields( $summaryFields = null ) { |
Index: trunk/extensions/EducationProgram/includes/EPPager.php |
— | — | @@ -22,11 +22,11 @@ |
23 | 23 | protected $conds; |
24 | 24 | |
25 | 25 | /** |
26 | | - * Name of the class deriving from DBDataObject. |
| 26 | + * Name of the class deriving from DBTable. |
27 | 27 | * @since 0.1 |
28 | 28 | * @var string |
29 | 29 | */ |
30 | | - protected $className; |
| 30 | + protected $tableClass; |
31 | 31 | |
32 | 32 | /** |
33 | 33 | * DBDataObject object constructed from $this->currentRow. |
— | — | @@ -47,11 +47,11 @@ |
48 | 48 | * |
49 | 49 | * @param IContextSource $context |
50 | 50 | * @param array $conds |
51 | | - * @param string $className |
| 51 | + * @param string $tableClass |
52 | 52 | */ |
53 | | - public function __construct( IContextSource $context, array $conds, $className ) { |
| 53 | + public function __construct( IContextSource $context, array $conds, $tableClass ) { |
54 | 54 | $this->conds = $conds; |
55 | | - $this->className = $className; |
| 55 | + $this->tableClass = $tableClass; |
56 | 56 | $this->context = $context; |
57 | 57 | |
58 | 58 | $this->mDefaultDirection = true; |
Index: trunk/extensions/EducationProgram/includes/EPRevision.php |
— | — | @@ -35,46 +35,6 @@ |
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
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 | | - /** |
79 | 39 | * Create a new revision object for the provided EPRevisionedObject. |
80 | 40 | * The EPRevisionedObject should have all it's fields loaded. |
81 | 41 | * |
Index: trunk/extensions/EducationProgram/includes/EPCourse.php |
— | — | @@ -88,97 +88,6 @@ |
89 | 89 | return $map[$status]; |
90 | 90 | } |
91 | 91 | |
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 | | - |
183 | 92 | protected static $countMap = array( |
184 | 93 | 'student_count' => 'students', |
185 | 94 | 'instructor_count' => 'instructors', |