r108118 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108117‎ | r108118 | r108119 >
Date:06:43, 5 January 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
work on special:ambassadors
Modified paths:
  • /trunk/extensions/EducationProgram/EducationProgram.i18n.php (modified) (history)
  • /trunk/extensions/EducationProgram/EducationProgram.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPMentor.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPMentorPager.php (added) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialAmbassadors.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/specials/SpecialAmbassadors.php
@@ -34,7 +34,6 @@
3535
3636 if ( $this->subPage === '' ) {
3737 $this->displayNavigation();
38 - EPMentor::displayAddNewControl( $this->getContext() );
3938 EPMentor::displayPager( $this->getContext() );
4039 }
4140 else {
Index: trunk/extensions/EducationProgram/includes/EPMentor.php
@@ -158,4 +158,30 @@
159159 return count( $this->getTerms( 'id', $conditions ) ) > 0;
160160 }
161161
 162+ /**
 163+ * Display a pager with mentors.
 164+ *
 165+ * @since 0.1
 166+ *
 167+ * @param IContextSource $context
 168+ * @param array $conditions
 169+ */
 170+ public static function displayPager( IContextSource $context, array $conditions = array() ) {
 171+ $pager = new EPMentorPager( $context, $conditions );
 172+
 173+ if ( $pager->getNumRows() ) {
 174+ $context->getOutput()->addHTML(
 175+ $pager->getFilterControl() .
 176+ $pager->getNavigationBar() .
 177+ $pager->getBody() .
 178+ $pager->getNavigationBar() .
 179+ $pager->getMultipleItemControl()
 180+ );
 181+ }
 182+ else {
 183+ $context->getOutput()->addHTML( $pager->getFilterControl( true ) );
 184+ $context->getOutput()->addWikiMsg( 'ep-mentors-noresults' );
 185+ }
 186+ }
 187+
162188 }
Index: trunk/extensions/EducationProgram/includes/EPMentorPager.php
@@ -0,0 +1,112 @@
 2+<?php
 3+
 4+/**
 5+ * Mentor pager, primarily for Special:Mentors.
 6+ *
 7+ * @since 0.1
 8+ *
 9+ * @file EPMentorPager.php
 10+ * @ingroup EductaionProgram
 11+ *
 12+ * @licence GNU GPL v3 or later
 13+ * @author Jeroen De Dauw < jeroendedauw@gmail.com >
 14+ */
 15+class EPMentorPager extends EPPager {
 16+
 17+ /**
 18+ * Constructor.
 19+ *
 20+ * @param IContextSource $context
 21+ * @param array $conds
 22+ */
 23+ public function __construct( IContextSource $context, array $conds = array() ) {
 24+ $this->mDefaultDirection = true;
 25+
 26+ // when MW 1.19 becomes min, we want to pass an IContextSource $context here.
 27+ parent::__construct( $context, $conds, 'EPMentor' );
 28+ }
 29+
 30+ /**
 31+ * (non-PHPdoc)
 32+ * @see EPPager::getFields()
 33+ */
 34+ public function getFields() {
 35+ return array(
 36+ 'id',
 37+ 'user_id',
 38+ );
 39+ }
 40+
 41+ /**
 42+ * (non-PHPdoc)
 43+ * @see TablePager::getRowClass()
 44+ */
 45+ function getRowClass( $row ) {
 46+ return 'ep-mentor-row';
 47+ }
 48+
 49+ /**
 50+ * (non-PHPdoc)
 51+ * @see TablePager::getTableClass()
 52+ */
 53+ public function getTableClass(){
 54+ return 'TablePager ep-mentors';
 55+ }
 56+
 57+ /**
 58+ * (non-PHPdoc)
 59+ * @see EPPager::getFormattedValue()
 60+ */
 61+ protected function getFormattedValue( $name, $value ) {
 62+ switch ( $name ) {
 63+ case 'id':
 64+ $value = $value;
 65+ break;
 66+ case 'user_id':
 67+ $user = User::newFromId( $value );
 68+ $name = $user->getRealName() === '' ? $user->getName() : $user->getRealName();
 69+
 70+ $value = Linker::userLink( $value, $name ) . Linker::userToolLinks( $value, $name );
 71+ break;
 72+ }
 73+
 74+ return $value;
 75+ }
 76+
 77+ /**
 78+ * (non-PHPdoc)
 79+ * @see EPPager::getSortableFields()
 80+ */
 81+ protected function getSortableFields() {
 82+ return array(
 83+ 'id',
 84+ );
 85+ }
 86+
 87+ /**
 88+ * (non-PHPdoc)
 89+ * @see EPPager::getMultipleItemActions()
 90+ */
 91+ protected function getMultipleItemActions() {
 92+ return array();
 93+ }
 94+
 95+ /**
 96+ * (non-PHPdoc)
 97+ * @see EPPager::hasActionsColumn()
 98+ */
 99+ protected function hasActionsColumn() {
 100+ return false;
 101+ }
 102+
 103+ /**
 104+ * (non-PHPdoc)
 105+ * @see EPPager::getFieldNames()
 106+ */
 107+ public function getFieldNames() {
 108+ $fields = parent::getFieldNames();
 109+
 110+ return $fields;
 111+ }
 112+
 113+}
Property changes on: trunk/extensions/EducationProgram/includes/EPMentorPager.php
___________________________________________________________________
Added: svn:eol-style
1114 + native
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php
@@ -55,9 +55,9 @@
5656 'group-epstudent-member' => '{{GENDER:$1|education program student}}',
5757 'grouppage-epstudent' => '{{ns:project}}:Education_program_students',
5858
59 - 'group-epmentor' => 'Education program mentors',
60 - 'group-epmentor-member' => '{{GENDER:$1|education program mentor}}',
61 - 'grouppage-epmentor' => '{{ns:project}}:Education_program_mentors',
 59+ 'group-epmentor' => 'Education program ambassadors',
 60+ 'group-epmentor-member' => '{{GENDER:$1|education program ambassador}}',
 61+ 'grouppage-epmentor' => '{{ns:project}}:Education_program_ambassadors',
6262
6363 // Special pages
6464 'specialpages-group-education' => 'Education',
@@ -78,6 +78,7 @@
7979 'special-editcourse-add' => 'Add course',
8080 'special-editcourse-edit' => 'Edit course',
8181 'special-enroll' => 'Enroll',
 82+ 'special-ambassadors' => 'Ambassadors',
8283
8384 // Special:Institutions
8485 'ep-institutions-nosuchinstitution' => 'There is no institution with name "$1". Existing institutions are listed below.',
@@ -112,6 +113,9 @@
113114 // Special:Students
114115 'ep-students-noresults' => 'There are no students to list.',
115116
 117+ // Special:Ambassadors
 118+ 'ep-mentors-noresults' => 'There are no ambassadors to list.',
 119+
116120 // Pager
117121 'ep-pager-showonly' => 'Show only items with',
118122 'ep-pager-clear' => 'Clear filters',
Index: trunk/extensions/EducationProgram/EducationProgram.php
@@ -7,6 +7,10 @@
88 * Support https://www.mediawiki.org/wiki/Extension_talk:Education_Program
99 * Source code: http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/EducationProgram
1010 *
 11+ * The source code makes use of a number of terms different from but corresponding to those in the UI:
 12+ * * Org instead of Institution
 13+ * * Mentor instead of Ambassador
 14+ *
1115 * @file EducationProgram.php
1216 * @ingroup EducationProgram
1317 *
@@ -59,13 +63,14 @@
6064 $wgAutoloadClasses['EPCoursePager'] = dirname( __FILE__ ) . '/includes/EPCoursePager.php';
6165 $wgAutoloadClasses['EPDBObject'] = dirname( __FILE__ ) . '/includes/EPDBObject.php';
6266 $wgAutoloadClasses['EPMentor'] = dirname( __FILE__ ) . '/includes/EPMentor.php';
 67+$wgAutoloadClasses['EPMentorPager'] = dirname( __FILE__ ) . '/includes/EPMentorPager.php';
6368 $wgAutoloadClasses['EPOrg'] = dirname( __FILE__ ) . '/includes/EPOrg.php';
6469 $wgAutoloadClasses['EPOrgPager'] = dirname( __FILE__ ) . '/includes/EPOrgPager.php';
6570 $wgAutoloadClasses['EPPager'] = dirname( __FILE__ ) . '/includes/EPPager.php';
6671 $wgAutoloadClasses['EPStudent'] = dirname( __FILE__ ) . '/includes/EPStudent.php';
6772 $wgAutoloadClasses['EPStudentPager'] = dirname( __FILE__ ) . '/includes/EPStudentPager.php';
6873 $wgAutoloadClasses['EPTerm'] = dirname( __FILE__ ) . '/includes/EPTerm.php';
69 -$wgAutoloadClasses['EPTermPager'] = dirname( __FILE__ ) . '/includes/EPTermPager.php';
 74+$wgAutoloadClasses['EPTermPager'] = dirname( __FILE__ ) . '/includes/EPTermPager.php';
7075
7176 $wgAutoloadClasses['SpecialCourse'] = dirname( __FILE__ ) . '/specials/SpecialCourse.php';
7277 $wgAutoloadClasses['SpecialCourses'] = dirname( __FILE__ ) . '/specials/SpecialCourses.php';
@@ -83,6 +88,7 @@
8489 $wgAutoloadClasses['SpecialTerm'] = dirname( __FILE__ ) . '/specials/SpecialTerm.php';
8590 $wgAutoloadClasses['SpecialTerms'] = dirname( __FILE__ ) . '/specials/SpecialTerms.php';
8691 $wgAutoloadClasses['SpecialEnroll'] = dirname( __FILE__ ) . '/specials/SpecialEnroll.php';
 92+$wgAutoloadClasses['SpecialAmbassadors'] = dirname( __FILE__ ) . '/specials/SpecialAmbassadors.php';
8793
8894 // Special pages
8995 $wgSpecialPages['MyCourses'] = 'SpecialMyCourses';

Status & tagging log