r107764 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107763‎ | r107764 | r107765 >
Date:02:05, 1 January 2012
Author:jeroendedauw
Status:deferred
Tags:educationprogram 
Comment:
work on mycourses
Modified paths:
  • /trunk/extensions/EducationProgram/EducationProgram.i18n.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialEPPage.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialMyCourses.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/specials/SpecialMyCourses.php
@@ -154,8 +154,9 @@
155155 $out = $this->getOutput();
156156
157157 $course = EPCourse::selectRow( null, array( 'name' => $courseName ) );
 158+ $terms = $student->getTerms( null, array( 'course_id' => $course->getId() ) );
158159
159 - if ( $course !== false && $student->hasTerm( array( 'course_id' => $course->getId() ) ) ) {
 160+ if ( $course !== false && count( $terms ) > 0 ) {
160161 $out->addWikiMsg( 'ep-mycourses-show-all' );
161162
162163 $out->setPageTitle( wfMsgExt(
@@ -164,6 +165,8 @@
165166 $courseName,
166167 $course->getOrg( 'name' )->getField( 'name' )
167168 ) );
 169+
 170+ $this->displayCourseSummary( $course, $terms );
168171 }
169172 else {
170173 $this->showError( wfMessage( 'ep-mycourses-no-such-course', $courseName ) );
@@ -171,4 +174,25 @@
172175 }
173176 }
174177
 178+ /**
 179+ * Display the summary for a course.
 180+ *
 181+ * @since 0.1
 182+ *
 183+ * @param EPCourse $course
 184+ * @param array $terms
 185+ */
 186+ protected function displayCourseSummary( EPCourse $course, array /* of EPTerm */ $terms ) {
 187+ $info = array();
 188+
 189+ $info['name'] = $course->getField( 'name' );
 190+ $info['org'] = EPOrg::selectFieldsRow( 'name', array( 'id' => $course->getField( 'org_id' ) ) );
 191+
 192+ foreach ( $info as &$inf ) {
 193+ $inf = htmlspecialchars( $inf );
 194+ }
 195+
 196+ $this->displaySummary( $course, false, $info );
 197+ }
 198+
175199 }
Index: trunk/extensions/EducationProgram/specials/SpecialEPPage.php
@@ -176,8 +176,9 @@
177177 *
178178 * @param EPDBObject $item
179179 * @param boolean $collapsed
 180+ * @param array $summaryData
180181 */
181 - protected function displaySummary( EPDBObject $item, $collapsed = true ) {
 182+ protected function displaySummary( EPDBObject $item, $collapsed = true, array $summaryData = null ) {
182183 $out = $this->getOutput();
183184
184185 $class = 'wikitable ep-summary mw-collapsible';
@@ -189,8 +190,10 @@
190191 $out->addHTML( Html::openElement( 'table', array( 'class' => $class ) ) );
191192
192193 $out->addHTML( '<tr>' . Html::element( 'th', array( 'colspan' => 2 ), wfMsg( 'ep-item-summary' ) ) . '</tr>' );
193 -
194 - foreach ( $this->getSummaryData( $item ) as $stat => $value ) {
 194+
 195+ $summaryData = is_null( $summaryData ) ? $this->getSummaryData( $item ) : $summaryData;
 196+
 197+ foreach ( $summaryData as $stat => $value ) {
195198 $out->addHTML( '<tr>' );
196199
197200 $out->addHTML( Html::element(
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php
@@ -224,6 +224,8 @@
225225 'ep-mycourses-show-all' => 'This page shows one of the courses you are enrolled in. You can also view all [[Special:MyCourses|your courses]].',
226226 'ep-mycourses-no-such-course' => 'You are not enrolled in any course with name "$1". The courses you are enrolled in are listed below.',
227227 'ep-mycourses-course-title' => 'My courses: $1 at $2',
 228+ 'specialmycourses-summary-name' => 'Course name',
 229+ 'specialmycourses-summary-org' => 'Institution name',
228230
229231 // Navigation links
230232 'ep-nav-orgs' => 'Institution list',

Status & tagging log