r109675 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109674‎ | r109675 | r109676 >
Date:05:45, 21 January 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
follow up to r109656 - renaming
Modified paths:
  • /trunk/extensions/EducationProgram/EducationProgram.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPCourse.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPCoursePager.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPMC.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPStudent.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialCourse.php (added) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialCourses.php (added) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialEPPage.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialEditTerm.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialEnroll.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialInstitution.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialMyCourses.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialStudent.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialTerm.php (deleted) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialTerms.php (deleted) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/specials/SpecialTerms.php
@@ -1,46 +0,0 @@
2 -<?php
3 -
4 -/**
5 - * Page listing all courses in a pager with filter control.
6 - * Also has a form for adding new items for those with matching privileges.
7 - *
8 - * @since 0.1
9 - *
10 - * @file SpecialCourses.php
11 - * @ingroup EducationProgram
12 - *
13 - * @licence GNU GPL v3 or later
14 - * @author Jeroen De Dauw < jeroendedauw@gmail.com >
15 - */
16 -class SpecialCourses extends SpecialEPPage {
17 -
18 - /**
19 - * Constructor.
20 - *
21 - * @since 0.1
22 - */
23 - public function __construct() {
24 - parent::__construct( 'Courses' );
25 - }
26 -
27 - /**
28 - * Main method.
29 - *
30 - * @since 0.1
31 - *
32 - * @param string|null $subPage
33 - */
34 - public function execute( $subPage ) {
35 - parent::execute( $subPage );
36 -
37 - if ( $this->subPage === '' ) {
38 - $this->displayNavigation();
39 - EPCourse::displayAddNewRegion( $this->getContext() );
40 - EPCourse::displayPager( $this->getContext() );
41 - }
42 - else {
43 - $this->getOutput()->redirect( SpecialPage::getTitleFor( 'Course', $this->subPage )->getLocalURL() );
44 - }
45 - }
46 -
47 -}
Index: trunk/extensions/EducationProgram/specials/SpecialTerm.php
@@ -1,132 +0,0 @@
2 -<?php
3 -
4 -/**
5 - * Shows the info for a single course, with management and
6 - * enrollment controls depending on the user and his rights.
7 - *
8 - * @since 0.1
9 - *
10 - * @file SpecialCourse.php
11 - * @ingroup EducationProgram
12 - *
13 - * @licence GNU GPL v3 or later
14 - * @author Jeroen De Dauw < jeroendedauw@gmail.com >
15 - */
16 -class SpecialCourse extends SpecialEPPage {
17 -
18 - /**
19 - * Constructor.
20 - *
21 - * @since 0.1
22 - */
23 - public function __construct() {
24 - parent::__construct( 'Course' );
25 - }
26 -
27 - /**
28 - * Main method.
29 - *
30 - * @since 0.1
31 - *
32 - * @param string $subPage
33 - */
34 - public function execute( $subPage ) {
35 - parent::execute( $subPage );
36 -
37 - $out = $this->getOutput();
38 -
39 - if ( trim( $subPage ) === '' ) {
40 - $this->getOutput()->redirect( SpecialPage::getTitleFor( 'Courses' )->getLocalURL() );
41 - }
42 - else {
43 - $out->setPageTitle( wfMsgExt( 'ep-course-title', 'parsemag', $this->subPage ) );
44 -
45 - $course = EPCourse::selectRow( null, array( 'id' => $this->subPage ) );
46 -
47 - if ( $course === false ) {
48 - $this->displayNavigation();
49 -
50 - if ( $this->getUser()->isAllowed( 'ep-term' ) ) {
51 - $out->addWikiMsg( 'ep-course-create', $this->subPage );
52 - EPCourse::displayAddNewRegion( $this->getContext(), array( 'id' => $this->subPage ) );
53 - }
54 - else {
55 - $out->addWikiMsg( 'ep-course-none', $this->subPage );
56 - }
57 - }
58 - else {
59 - $links = array();
60 -
61 - if ( $this->getUser()->isAllowed( 'ep-course' ) ) {
62 - $links[wfMsg( 'ep-course-nav-edit' )] =
63 - array( SpecialPage::getTitleFor( 'EditCourse', $this->subPage ) )
64 - + Linker::tooltipAndAccesskeyAttribs( 'ep-edit-course' );
65 - }
66 -
67 - $this->displayNavigation( $links );
68 -
69 - $this->displaySummary( $course );
70 -
71 - $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-course-description' ) ) );
72 -
73 - $out->addHTML( $this->getOutput()->parse( $course->getField( 'description' ) ) );
74 -
75 - $studentIds = array_map(
76 - function( EPStudent $student ) {
77 - return $student->getId();
78 - },
79 - $course->getStudents( 'id' )
80 - );
81 -
82 - if ( count( $studentIds ) > 0 ) {
83 - $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-course-students' ) ) );
84 - EPStudent::displayPager( $this->getContext(), array( 'id' => $studentIds ) );
85 - }
86 - else {
87 - // TODO
88 - }
89 - }
90 - }
91 - }
92 -
93 - /**
94 - * Gets the summary data.
95 - *
96 - * @since 0.1
97 - *
98 - * @param EPCourse $course
99 - *
100 - * @return array
101 - */
102 - protected function getSummaryData( EPDBObject $course ) {
103 - $stats = array();
104 -
105 - $org = EPOrg::selectFieldsRow( 'name', array( 'id' => $course->getField( 'org_id' ) ) );
106 -
107 - $stats['org'] = Linker::linkKnown(
108 - SpecialPage::getTitleFor( 'Institution', $org ),
109 - htmlspecialchars( $org )
110 - );
111 -
112 - $course = EPCourse::selectFieldsRow( 'name', array( 'id' => $course->getField( 'course_id' ) ) );
113 -
114 - $stats['course'] = Linker::linkKnown(
115 - SpecialPage::getTitleFor( 'Course', $course ),
116 - htmlspecialchars( $course )
117 - );
118 -
119 - $stats['year'] = htmlspecialchars( $this->getLanguage()->formatNum( $course->getField( 'year' ), true ) );
120 - $stats['start'] = htmlspecialchars( $this->getLanguage()->timeanddate( $course->getField( 'start' ), true ) );
121 - $stats['end'] = htmlspecialchars( $this->getLanguage()->timeanddate( $course->getField( 'end' ), true ) );
122 -
123 - if ( $this->getUser()->isAllowed( 'ep-token' ) ) {
124 - $stats['token'] = Linker::linkKnown(
125 - SpecialPage::getTitleFor( 'Enroll', $course->getId() . '/' . $course->getField( 'token' ) ),
126 - htmlspecialchars( $course->getField( 'token' ) )
127 - );
128 - }
129 -
130 - return $stats;
131 - }
132 -
133 -}
Index: trunk/extensions/EducationProgram/specials/SpecialInstitution.php
@@ -100,8 +100,8 @@
101101
102102 $stats['status'] = wfMsgHtml( $org->getField( 'active' ) ? 'ep-institution-active' : 'ep-institution-inactive' );
103103
 104+ $stats['mcs'] = $this->getLanguage()->formatNum( $org->getField( 'mcs' ) );
104105 $stats['courses'] = $this->getLanguage()->formatNum( $org->getField( 'courses' ) );
105 - $stats['terms'] = $this->getLanguage()->formatNum( $org->getField( 'terms' ) );
106106 $stats['students'] = $this->getLanguage()->formatNum( $org->getField( 'students' ) );
107107
108108 foreach ( $stats as &$stat ) {
@@ -117,10 +117,10 @@
118118 );
119119 }
120120
121 - if ( $org->getField( 'terms' ) > 0 ) {
122 - $stats['terms'] = Linker::linkKnown(
123 - SpecialPage::getTitleFor( 'Terms' ),
124 - $stats['terms'],
 121+ if ( $org->getField( 'mcs' ) > 0 ) {
 122+ $stats['mcs'] = Linker::linkKnown(
 123+ SpecialPage::getTitleFor( 'MasterCourses' ),
 124+ $stats['mcs'],
125125 array(),
126126 array( 'org_id' => $org->getId() )
127127 );
Index: trunk/extensions/EducationProgram/specials/SpecialMyCourses.php
@@ -69,19 +69,19 @@
7070
7171 if ( $student->hasTerm() ) {
7272 if ( $this->getRequest()->getCheck( 'enrolled' ) ) {
73 - $term = EPTerm::selectRow( null, array( 'id' => $this->getRequest()->getInt( 'enrolled' ) ) );
 73+ $course = EPCourse::selectRow( null, array( 'id' => $this->getRequest()->getInt( 'enrolled' ) ) );
7474
75 - if ( $term !== false ) {
 75+ if ( $course !== false ) {
7676 $this->showSuccess( wfMessage(
7777 'ep-mycourses-enrolled',
78 - $term->getCourse()->getField( 'name' ),
79 - $term->getOrg()->getField( 'name' )
 78+ $course->getMasterCourse()->getField( 'name' ),
 79+ $course->getOrg()->getField( 'name' )
8080 ) );
8181 }
8282 }
8383
84 - $currentCourses = $student->getCurrentCourses();
85 - $passedCourses = $student->getPassedCourses();
 84+ $currentCourses = $student->getCurrentMasterCourses();
 85+ $passedCourses = $student->getPassedMasterCourses();
8686
8787 if ( count( $currentCourses ) > 0 ) {
8888 $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-mycourses-current' ) ) );
@@ -105,7 +105,7 @@
106106 *
107107 * @param array $courses
108108 */
109 - protected function displayCoursesList( array /* of EPCourse */ $courses ) {
 109+ protected function displayCoursesList( array /* of EPMC */ $courses ) {
110110 $out = $this->getOutput();
111111
112112 $out->addHTML( Xml::openElement(
@@ -122,7 +122,7 @@
123123
124124 $out->addHTML( '<tbody>' );
125125
126 - foreach ( $courses as /* EPCourse */ $course ) {
 126+ foreach ( $courses as /* EPMC */ $course ) {
127127 $fields = array();
128128
129129 $fields[] = Linker::link(
@@ -183,20 +183,20 @@
184184 *
185185 * @since 0.1
186186 *
187 - * @param EPCourse $course
188 - * @param array $terms
 187+ * @param EPCourse $masterCourse
 188+ * @param array $courses
189189 */
190 - protected function displayCourseSummary( EPCourse $course, array /* of EPTerm */ $terms ) {
 190+ protected function displayCourseSummary( EPCourse $masterCourse, array /* of EPCourse */ $courses ) {
191191 $info = array();
192192
193 - $info['name'] = $course->getField( 'name' );
194 - $info['org'] = EPOrg::selectFieldsRow( 'name', array( 'id' => $course->getField( 'org_id' ) ) );
 193+ $info['name'] = $masterCourse->getField( 'name' );
 194+ $info['org'] = EPOrg::selectFieldsRow( 'name', array( 'id' => $masterCourse->getField( 'org_id' ) ) );
195195
196196 foreach ( $info as &$inf ) {
197197 $inf = htmlspecialchars( $inf );
198198 }
199199
200 - $this->displaySummary( $course, false, $info );
 200+ $this->displaySummary( $masterCourse, false, $info );
201201 }
202202
203203 /**
Index: trunk/extensions/EducationProgram/specials/SpecialEnroll.php
@@ -1,8 +1,8 @@
22 <?php
33
44 /**
 5+ * Enrollment page for students.
56 *
6 - *
77 * @since 0.1
88 *
99 * @file SpecialEnroll.php
@@ -15,9 +15,9 @@
1616
1717 /**
1818 * @since 0.1
19 - * @var EPTerm
 19+ * @var EPCourse
2020 */
21 - protected $term;
 21+ protected $course;
2222
2323 /**
2424 * Constructor.
@@ -45,14 +45,14 @@
4646 $this->showWarning( wfMessage( $args[0] === '' ? 'ep-enroll-no-id' : 'ep-enroll-invalid-id' ) );
4747 }
4848 else {
49 - $term = EPTerm::selectRow( null, array( 'id' => $args[0] ) );
 49+ $course = EPCourse::selectRow( null, array( 'id' => $args[0] ) );
5050
51 - if ( $term === false ) {
 51+ if ( $course === false ) {
5252 $this->showWarning( wfMessage( 'ep-enroll-invalid-id' ) );
5353 }
54 - elseif ( $term->getStatus() === 'current' ) {
 54+ elseif ( $course->getStatus() === 'current' ) {
5555 $token = '';
56 - $tokenIsValid = $term->getField( 'token' ) === '';
 56+ $tokenIsValid = $course->getField( 'token' ) === '';
5757
5858 if ( !$tokenIsValid ) {
5959 if ( count( $args ) === 2 ) {
@@ -62,11 +62,11 @@
6363 $token = $this->getRequest()->getText( 'wptoken' );
6464 }
6565
66 - $tokenIsValid = $term->getField( 'token' ) === $token;
 66+ $tokenIsValid = $course->getField( 'token' ) === $token;
6767 }
6868
6969 if ( $tokenIsValid ) {
70 - $this->showEnrollmentView( $term );
 70+ $this->showEnrollmentView( $course );
7171 }
7272 else {
7373 if ( $token !== '' ) {
@@ -77,23 +77,23 @@
7878 }
7979 }
8080 else {
81 - $this->showWarning( wfMessage( 'ep-enroll-term-' . $term->getStatus() ) );
 81+ $this->showWarning( wfMessage( 'ep-enroll-course-' . $course->getStatus() ) );
8282 }
8383 }
8484 }
8585
8686 /**
87 - * Shows the actuall enrollment view.
 87+ * Shows the actual enrollment view.
8888 * Should only be called after everything checks out, ie the user can enroll in the term.
8989 *
9090 * @since 0.1
9191 *
92 - * @param EPTerm $term
 92+ * @param EPCourse $course
9393 */
94 - protected function showEnrollmentView( EPTerm $term ) {
95 - $this->term = $term;
 94+ protected function showEnrollmentView( EPCourse $course ) {
 95+ $this->course = $course;
9696
97 - $this->setPageTitle( $term );
 97+ $this->setPageTitle( $course );
9898
9999 if ( $this->getUser()->isLoggedIn() ) {
100100 if ( $this->getUser()->isAllowed( 'ep-enroll' ) ) {
@@ -101,11 +101,11 @@
102102 $hasFields = trim( $user->getRealName() ) !== '' && $user->getOption( 'gender' ) !== 'unknown';
103103
104104 if ( $hasFields ) {
105 - $this->doEnroll( $term );
 105+ $this->doEnroll( $course );
106106 $this->onSuccess();
107107 }
108108 else {
109 - $this->showEnrollmentForm( $term );
 109+ $this->showEnrollmentForm( $course );
110110 }
111111 }
112112 else {
@@ -155,14 +155,14 @@
156156 *
157157 * @since 0.1
158158 *
159 - * @param EPTerm $term
 159+ * @param EPCourse $course
160160 */
161 - protected function setPageTitle( EPTerm $term ) {
 161+ protected function setPageTitle( EPCourse $course ) {
162162 $this->getOutput()->setPageTitle( wfMsgExt(
163163 'ep-enroll-title',
164164 'parsemag',
165 - $term->getCourse( 'name' )->getField( 'name' ),
166 - $term->getOrg( 'name' )->getField( 'name' )
 165+ $course->getMasterCourse( 'name' )->getField( 'name' ),
 166+ $course->getOrg( 'name' )->getField( 'name' )
167167 ) );
168168 }
169169
@@ -207,11 +207,11 @@
208208 *
209209 * @since 0.1
210210 *
211 - * @param EPTerm $term
 211+ * @param EPCourse $course
212212 *
213213 * @return boolean Success indicator
214214 */
215 - protected function doEnroll( EPTerm $term ) {
 215+ protected function doEnroll( EPCourse $course ) {
216216 $student = EPStudent::newFromUser( $this->getUser(), array( 'id' ) );
217217 $hadStudent = $student !== false;
218218
@@ -229,7 +229,7 @@
230230 $success = $student->writeToDB();
231231
232232 if ( $success ) {
233 - $success = $student->associateWithTerms( array( $term ) ) && $success;
 233+ $success = $student->associateWithCourses( array( $course ) ) && $success;
234234
235235 if ( !$hadStudent ) {
236236 $this->getUser()->setOption( 'ep_showtoplink', true );
@@ -245,9 +245,9 @@
246246 *
247247 * @since 0.1
248248 *
249 - * @param EPTerm $term
 249+ * @param EPCourse $course
250250 */
251 - protected function showEnrollmentForm( EPTerm $term ) {
 251+ protected function showEnrollmentForm( EPCourse $course ) {
252252 $this->getOutput()->addWikiMsg( 'ep-enroll-header' );
253253
254254 $form = new HTMLForm( $this->getFormFields(), $this->getContext() );
Index: trunk/extensions/EducationProgram/specials/SpecialCourse.php
@@ -0,0 +1,132 @@
 2+<?php
 3+
 4+/**
 5+ * Shows the info for a single course, with management and
 6+ * enrollment controls depending on the user and his rights.
 7+ *
 8+ * @since 0.1
 9+ *
 10+ * @file SpecialCourse.php
 11+ * @ingroup EducationProgram
 12+ *
 13+ * @licence GNU GPL v3 or later
 14+ * @author Jeroen De Dauw < jeroendedauw@gmail.com >
 15+ */
 16+class SpecialCourse extends SpecialEPPage {
 17+
 18+ /**
 19+ * Constructor.
 20+ *
 21+ * @since 0.1
 22+ */
 23+ public function __construct() {
 24+ parent::__construct( 'Course' );
 25+ }
 26+
 27+ /**
 28+ * Main method.
 29+ *
 30+ * @since 0.1
 31+ *
 32+ * @param string $subPage
 33+ */
 34+ public function execute( $subPage ) {
 35+ parent::execute( $subPage );
 36+
 37+ $out = $this->getOutput();
 38+
 39+ if ( trim( $subPage ) === '' ) {
 40+ $this->getOutput()->redirect( SpecialPage::getTitleFor( 'Courses' )->getLocalURL() );
 41+ }
 42+ else {
 43+ $out->setPageTitle( wfMsgExt( 'ep-course-title', 'parsemag', $this->subPage ) );
 44+
 45+ $course = EPCourse::selectRow( null, array( 'id' => $this->subPage ) );
 46+
 47+ if ( $course === false ) {
 48+ $this->displayNavigation();
 49+
 50+ if ( $this->getUser()->isAllowed( 'ep-term' ) ) {
 51+ $out->addWikiMsg( 'ep-course-create', $this->subPage );
 52+ EPCourse::displayAddNewRegion( $this->getContext(), array( 'id' => $this->subPage ) );
 53+ }
 54+ else {
 55+ $out->addWikiMsg( 'ep-course-none', $this->subPage );
 56+ }
 57+ }
 58+ else {
 59+ $links = array();
 60+
 61+ if ( $this->getUser()->isAllowed( 'ep-course' ) ) {
 62+ $links[wfMsg( 'ep-course-nav-edit' )] =
 63+ array( SpecialPage::getTitleFor( 'EditCourse', $this->subPage ) )
 64+ + Linker::tooltipAndAccesskeyAttribs( 'ep-edit-course' );
 65+ }
 66+
 67+ $this->displayNavigation( $links );
 68+
 69+ $this->displaySummary( $course );
 70+
 71+ $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-course-description' ) ) );
 72+
 73+ $out->addHTML( $this->getOutput()->parse( $course->getField( 'description' ) ) );
 74+
 75+ $studentIds = array_map(
 76+ function( EPStudent $student ) {
 77+ return $student->getId();
 78+ },
 79+ $course->getStudents( 'id' )
 80+ );
 81+
 82+ if ( count( $studentIds ) > 0 ) {
 83+ $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-course-students' ) ) );
 84+ EPStudent::displayPager( $this->getContext(), array( 'id' => $studentIds ) );
 85+ }
 86+ else {
 87+ // TODO
 88+ }
 89+ }
 90+ }
 91+ }
 92+
 93+ /**
 94+ * Gets the summary data.
 95+ *
 96+ * @since 0.1
 97+ *
 98+ * @param EPCourse $course
 99+ *
 100+ * @return array
 101+ */
 102+ protected function getSummaryData( EPDBObject $course ) {
 103+ $stats = array();
 104+
 105+ $org = EPOrg::selectFieldsRow( 'name', array( 'id' => $course->getField( 'org_id' ) ) );
 106+
 107+ $stats['org'] = Linker::linkKnown(
 108+ SpecialPage::getTitleFor( 'Institution', $org ),
 109+ htmlspecialchars( $org )
 110+ );
 111+
 112+ $course = EPCourse::selectFieldsRow( 'name', array( 'id' => $course->getField( 'course_id' ) ) );
 113+
 114+ $stats['course'] = Linker::linkKnown(
 115+ SpecialPage::getTitleFor( 'Course', $course ),
 116+ htmlspecialchars( $course )
 117+ );
 118+
 119+ $stats['year'] = htmlspecialchars( $this->getLanguage()->formatNum( $course->getField( 'year' ), true ) );
 120+ $stats['start'] = htmlspecialchars( $this->getLanguage()->timeanddate( $course->getField( 'start' ), true ) );
 121+ $stats['end'] = htmlspecialchars( $this->getLanguage()->timeanddate( $course->getField( 'end' ), true ) );
 122+
 123+ if ( $this->getUser()->isAllowed( 'ep-token' ) ) {
 124+ $stats['token'] = Linker::linkKnown(
 125+ SpecialPage::getTitleFor( 'Enroll', $course->getId() . '/' . $course->getField( 'token' ) ),
 126+ htmlspecialchars( $course->getField( 'token' ) )
 127+ );
 128+ }
 129+
 130+ return $stats;
 131+ }
 132+
 133+}
Property changes on: trunk/extensions/EducationProgram/specials/SpecialCourse.php
___________________________________________________________________
Added: svn:eol-style
1134 + native
Index: trunk/extensions/EducationProgram/specials/SpecialEPPage.php
@@ -168,8 +168,8 @@
169169 protected function getDefaultNavigationItems() {
170170 $items = array(
171171 wfMsg( 'ep-nav-orgs' ) => SpecialPage::getTitleFor( 'Institutions' ),
 172+ wfMsg( 'ep-nav-mcs' ) => SpecialPage::getTitleFor( 'MasterCourses' ),
172173 wfMsg( 'ep-nav-courses' ) => SpecialPage::getTitleFor( 'Courses' ),
173 - wfMsg( 'ep-nav-terms' ) => SpecialPage::getTitleFor( 'Terms' ),
174174 );
175175
176176 $items[wfMsg( 'ep-nav-students' )] = SpecialPage::getTitleFor( 'Students' );
Index: trunk/extensions/EducationProgram/specials/SpecialEditTerm.php
@@ -19,7 +19,7 @@
2020 * @since 0.1
2121 */
2222 public function __construct() {
23 - parent::__construct( 'EditTerm', 'ep-term', 'EPTerm', 'Terms' );
 23+ parent::__construct( 'EditCourse', 'ep-term', 'EPCourse', 'Courses' );
2424
2525 $this->getOutput()->addModules( 'ep.datepicker' );
2626 }
Index: trunk/extensions/EducationProgram/specials/SpecialCourses.php
@@ -0,0 +1,46 @@
 2+<?php
 3+
 4+/**
 5+ * Page listing all courses in a pager with filter control.
 6+ * Also has a form for adding new items for those with matching privileges.
 7+ *
 8+ * @since 0.1
 9+ *
 10+ * @file SpecialCourses.php
 11+ * @ingroup EducationProgram
 12+ *
 13+ * @licence GNU GPL v3 or later
 14+ * @author Jeroen De Dauw < jeroendedauw@gmail.com >
 15+ */
 16+class SpecialCourses extends SpecialEPPage {
 17+
 18+ /**
 19+ * Constructor.
 20+ *
 21+ * @since 0.1
 22+ */
 23+ public function __construct() {
 24+ parent::__construct( 'Courses' );
 25+ }
 26+
 27+ /**
 28+ * Main method.
 29+ *
 30+ * @since 0.1
 31+ *
 32+ * @param string|null $subPage
 33+ */
 34+ public function execute( $subPage ) {
 35+ parent::execute( $subPage );
 36+
 37+ if ( $this->subPage === '' ) {
 38+ $this->displayNavigation();
 39+ EPCourse::displayAddNewRegion( $this->getContext() );
 40+ EPCourse::displayPager( $this->getContext() );
 41+ }
 42+ else {
 43+ $this->getOutput()->redirect( SpecialPage::getTitleFor( 'Course', $this->subPage )->getLocalURL() );
 44+ }
 45+ }
 46+
 47+}
Property changes on: trunk/extensions/EducationProgram/specials/SpecialCourses.php
___________________________________________________________________
Added: svn:eol-style
148 + native
Index: trunk/extensions/EducationProgram/specials/SpecialStudent.php
@@ -52,14 +52,14 @@
5353
5454 $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-student-terms' ) ) );
5555
56 - $termIds = array_map(
57 - function( EPTerm $term ) {
58 - return $term->getId();
 56+ $courseIds = array_map(
 57+ function( EPCourse $course ) {
 58+ return $course->getId();
5959 },
60 - $student->getTerms( 'id' )
 60+ $student->getCourses( 'id' )
6161 );
6262
63 - EPTerm::displayPager( $this->getContext(), array( 'id' => $termIds ) );
 63+ EPCourse::displayPager( $this->getContext(), array( 'id' => $courseIds ) );
6464 }
6565 }
6666 }
Index: trunk/extensions/EducationProgram/includes/EPCoursePager.php
@@ -1,7 +1,7 @@
22 <?php
33
44 /**
5 - * Term pager, primarily for Special:Terms.
 5+ * Course pager.
66 *
77 * @since 0.1
88 *
@@ -81,7 +81,7 @@
8282 $value = htmlspecialchars( $this->getLanguage()->date( $value ) );
8383 break;
8484 case '_status':
85 - $value = htmlspecialchars( EPTerm::getStatusMessage( $this->currentObject->getStatus() ) );
 85+ $value = htmlspecialchars( EPCourse::getStatusMessage( $this->currentObject->getStatus() ) );
8686 case 'students':
8787 $value = htmlspecialchars( $this->getLanguage()->formatNum( $value ) );
8888 break;
@@ -132,7 +132,7 @@
133133 'type' => 'select',
134134 'options' => array_merge(
135135 array( '' => '' ),
136 - EPMC::getCourseOptions( EPMC::select( array( 'name', 'id' ) ) )
 136+ EPMC::getMasterCourseOptions( EPMC::select( array( 'name', 'id' ) ) )
137137 ),
138138 'value' => '',
139139 'datatype' => 'int',
Index: trunk/extensions/EducationProgram/includes/EPStudent.php
@@ -71,7 +71,7 @@
7272 *
7373 * @return bool
7474 */
75 - public function associateWithTerms( array /* of EPCourse */ $courses ) {
 75+ public function associateWithCourses( array /* of EPCourse */ $courses ) {
7676 $dbw = wfGetDB( DB_MASTER );
7777
7878 $success = true;
@@ -202,7 +202,7 @@
203203 protected function doGetCourses( $fields, array $conditions ) {
204204 $conditions[] = array( array( 'ep_students', 'id' ), $this->getId() );
205205
206 - return EPTerm::select(
 206+ return EPCourse::select(
207207 $fields,
208208 $conditions,
209209 array(),
Index: trunk/extensions/EducationProgram/includes/EPMC.php
@@ -81,7 +81,7 @@
8282 $fields = array();
8383
8484 if ( in_array( 'students', $summaryFields ) ) {
85 - $termIds = EPTerm::selectFields( 'id', array( 'course_id' => $this->getId() ) );
 85+ $termIds = EPCourse::selectFields( 'id', array( 'mc_id' => $this->getId() ) );
8686
8787 if ( count( $termIds ) > 0 ) {
8888 $fields['students'] = wfGetDB( DB_SLAVE )->select(
@@ -100,8 +100,8 @@
101101 if ( in_array( 'active', $summaryFields ) ) {
102102 $now = wfGetDB( DB_SLAVE )->addQuotes( wfTimestampNow() );
103103
104 - $fields['active'] = EPTerm::has( array(
105 - 'course_id' => $this->getId(),
 104+ $fields['active'] = EPCourse::has( array(
 105+ 'mc_id' => $this->getId(),
106106 'end >= ' . $now,
107107 'start <= ' . $now,
108108 ) );
@@ -125,14 +125,14 @@
126126 $success = parent::removeFromDB();
127127
128128 if ( $success ) {
129 - foreach ( EPTerm::select( 'id', array( 'course_id' => $id ) ) as /* EPTerm */ $term ) {
130 - $term->setUpdateSummaries( false );
131 - $success = $term->removeFromDB() && $success;
 129+ foreach ( EPCourse::select( 'id', array( 'mc_id' => $id ) ) as /* EPCourse */ $course ) {
 130+ $course->setUpdateSummaries( false );
 131+ $success = $course->removeFromDB() && $success;
132132 }
133133 }
134134
135135 if ( $this->updateSummaries && $orgId !== false ) {
136 - EPOrg::updateSummaryFields( array( 'terms', 'students', 'courses', 'active' ), array( 'id' => $orgId ) );
 136+ EPCourse::updateSummaryFields( array( 'mcs', 'students', 'courses', 'active' ), array( 'id' => $orgId ) );
137137 }
138138
139139 return $success;
@@ -163,8 +163,8 @@
164164
165165 if ( $this->updateSummaries && $success && $oldOrgId !== false && $oldOrgId !== $this->getField( 'org_id' ) ) {
166166 $conds = array( 'id' => array( $oldOrgId, $this->getField( 'org_id' ) ) );
167 - EPTerm::updateSummaryFields( 'org_id', array( 'course_id' => $this->getId() ) );
168 - EPOrg::updateSummaryFields( array( 'terms', 'students', 'courses', 'active' ), $conds );
 167+ EPCourse::updateSummaryFields( 'org_id', array( 'mc_id' => $this->getId() ) );
 168+ EPOrg::updateSummaryFields( array( 'mcs', 'students', 'courses', 'active' ), $conds );
169169 }
170170
171171 return $success;
Index: trunk/extensions/EducationProgram/includes/EPCourse.php
@@ -324,7 +324,7 @@
325325 * @param array $conditions
326326 */
327327 public static function displayPager( IContextSource $context, array $conditions = array() ) {
328 - $pager = new EPTermPager( $context, $conditions );
 328+ $pager = new EPCoursePager( $context, $conditions );
329329
330330 if ( $pager->getNumRows() ) {
331331 $context->getOutput()->addHTML(
@@ -410,7 +410,7 @@
411411 */
412412 public static function displayAddNewRegion( IContextSource $context, array $args = array() ) {
413413 if ( EPCourse::has() ) {
414 - EPTerm::displayAddNewControl( $context, $args );
 414+ EPCourse::displayAddNewControl( $context, $args );
415415 }
416416 elseif ( $context->getUser()->isAllowed( 'ep-course' ) ) {
417417 $context->getOutput()->addWikiMsg( 'ep-terms-addcoursefirst' );
Index: trunk/extensions/EducationProgram/EducationProgram.php
@@ -75,8 +75,6 @@
7676 $wgAutoloadClasses['EPPager'] = dirname( __FILE__ ) . '/includes/EPPager.php';
7777 $wgAutoloadClasses['EPStudent'] = dirname( __FILE__ ) . '/includes/EPStudent.php';
7878 $wgAutoloadClasses['EPStudentPager'] = dirname( __FILE__ ) . '/includes/EPStudentPager.php';
79 -$wgAutoloadClasses['EPTerm'] = dirname( __FILE__ ) . '/includes/EPTerm.php';
80 -$wgAutoloadClasses['EPTermPager'] = dirname( __FILE__ ) . '/includes/EPTermPager.php';
8179 $wgAutoloadClasses['EPUtils'] = dirname( __FILE__ ) . '/includes/EPUtils.php';
8280 $wgAutoloadClasses['EPOA'] = dirname( __FILE__ ) . '/includes/EPOA.php';
8381 $wgAutoloadClasses['EPOAPager'] = dirname( __FILE__ ) . '/includes/EPOAPager.php';

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r109656schema changes currently completely breaking the extension and added hook to ...jeroendedauw22:24, 20 January 2012

Status & tagging log