r107298 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107297‎ | r107298 | r107299 >
Date:23:01, 25 December 2011
Author:jeroendedauw
Status:deferred
Tags:educationprogram 
Comment:
work on special:term
Modified paths:
  • /trunk/extensions/EducationProgram/EducationProgram.i18n.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPMentor.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPTerm.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialCourse.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialTerm.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/specials/SpecialCourse.php
@@ -59,7 +59,7 @@
6060
6161 $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-course-description' ) ) );
6262
63 - $out->addHTML( '<p>' . $this->getOutput()->parse( $course->getField( 'description' ) ) . '</p>' );
 63+ $out->addHTML( $this->getOutput()->parse( $course->getField( 'description' ) ) );
6464
6565 $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-course-terms' ) ) );
6666
Index: trunk/extensions/EducationProgram/specials/SpecialTerm.php
@@ -55,8 +55,12 @@
5656 }
5757 }
5858 else {
59 - $this->displayInfo( $term );
 59+ $this->displaySummary( $term );
6060
 61+ $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-term-description' ) ) );
 62+
 63+ $out->addHTML( $this->getOutput()->parse( $term->getField( 'description' ) ) );
 64+
6165 $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-term-students' ) ) );
6266
6367 // TODO: students
@@ -65,16 +69,28 @@
6670 }
6771
6872 /**
69 - * Display the terms info.
70 - *
 73+ * Gets the summary data.
 74+ *
7175 * @since 0.1
72 - *
 76+ *
7377 * @param EPTerm $term
 78+ *
 79+ * @return array
7480 */
75 - protected function displayInfo( EPTerm $term ) {
76 - $out = $this->getOutput();
 81+ protected function getSummaryData( EPDBObject $term ) {
 82+ $stats = array();
 83+
 84+ $stats['org'] = EPOrg::selectFieldsRow( 'name', array( 'id' => $term->getField( 'org_id' ) ) );
 85+ $stats['course'] = EPCourse::selectFieldsRow( 'name', array( 'id' => $term->getField( 'course_id' ) ) );
 86+ $stats['year'] = $term->getField( 'year' ); // TODO: how to properly i18n this?
 87+ $stats['start'] = $this->getLanguage()->timeanddate( $term->getField( 'start' ), true );
 88+ $stats['end'] = $this->getLanguage()->timeanddate( $term->getField( 'end' ), true );
7789
 90+ if ( $term->useCanManage( $this->getUser() ) ) {
 91+ $stats['token'] = $term->getField( 'token' );
 92+ }
7893
 94+ return $stats;
7995 }
8096
8197 }
Index: trunk/extensions/EducationProgram/includes/EPMentor.php
@@ -97,7 +97,7 @@
9898 * @return boolean
9999 */
100100 public function hasCourse( array $conditions = array() ) {
101 - return true;
 101+ return true; // TODO
102102 }
103103
104104 /**
Index: trunk/extensions/EducationProgram/includes/EPTerm.php
@@ -233,5 +233,30 @@
234234 $context->getOutput()->addWikiMsg( 'ep-terms-addcoursefirst' );
235235 }
236236 }
 237+
 238+ /**
 239+ * Returns if the provided user can manage the term or not.
 240+ *
 241+ * @since 0.1
 242+ *
 243+ * @param User $user
 244+ *
 245+ * @return boolean
 246+ */
 247+ public function useCanManage( User $user ) {
 248+ if ( $user->isAllowed( 'epadmin' ) ) {
 249+ return true;
 250+ }
 251+
 252+ if ( $user->isAllowed( 'epmentor' ) ) {
 253+ $mentor = EPMentor::selectRow( 'id', array( 'user_id' => $user->getId() ) );
 254+
 255+ if ( $mentor !== false ) {
 256+ return $mentor->hasTerm( array( 'id' => $this->getId() ) );
 257+ }
 258+ }
 259+
 260+ return false;
 261+ }
237262
238263 }
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php
@@ -177,6 +177,13 @@
178178 'ep-term-students' => 'Students',
179179 'ep-term-none' => 'There is no term with id "$1". See [[Special:Terms|here]] for a list of terms.',
180180 'ep-term-create' => 'There is no term with id "$1", but you can create a new one.',
 181+ 'specialterm-summary-org' => 'Institution',
 182+ 'specialterm-summary-course' => 'Course',
 183+ 'specialterm-summary-year' => 'Year',
 184+ 'specialterm-summary-start' => 'Start',
 185+ 'specialterm-summary-end' => 'End',
 186+ 'ep-term-description' => 'description',
 187+ 'specialterm-summary-token' => 'Enrollment token',
181188
182189 // Navigation links
183190 'ep-nav-orgs' => 'Institution list',

Status & tagging log