r98325 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98324‎ | r98325 | r98326 >
Date:16:27, 28 September 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
added contestant pager
Modified paths:
  • /trunk/extensions/Contest/Contest.php (modified) (history)
  • /trunk/extensions/Contest/includes/Contest.class.php (modified) (history)
  • /trunk/extensions/Contest/includes/ContestantPager.php (added) (history)
  • /trunk/extensions/Contest/specials/SpecialContest.php (modified) (history)
  • /trunk/extensions/Contest/specials/SpecialContests.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Contest/specials/SpecialContest.php
@@ -37,4 +37,12 @@
3838
3939 }
4040
 41+ protected function showGeneralInfo( Contest $contest ) {
 42+
 43+ }
 44+
 45+ protected function showParticipants( Contest $contest ) {
 46+
 47+ }
 48+
4149 }
\ No newline at end of file
Index: trunk/extensions/Contest/specials/SpecialContests.php
@@ -136,11 +136,11 @@
137137 foreach ( $contests as $contest ) {
138138 $fields = array();
139139
140 - if ( $user->isAllowed( 'contestjudge' ) ) {
 140+ if ( $user->isAllowed( 'contestparticipant' ) ) {
141141 $name = Html::element(
142142 'a',
143143 array(
144 - 'href' => SpecialPage::getTitleFor( 'Contest', $contest->getField( 'name' ) )->getLocalURL()
 144+ 'href' => SpecialPage::getTitleFor( 'ContestWelcome', $contest->getField( 'name' ) )->getLocalURL()
145145 ),
146146 $contest->getField( 'name' )
147147 );
Index: trunk/extensions/Contest/Contest.php
@@ -52,6 +52,7 @@
5353 $wgAutoloadClasses['ApiDeleteContest'] = dirname( __FILE__ ) . '/api/ApiDeleteContest.php';
5454
5555 $wgAutoloadClasses['Contest'] = dirname( __FILE__ ) . '/includes/Contest.class.php';
 56+$wgAutoloadClasses['ContestantPager'] = dirname( __FILE__ ) . '/includes/ContestantPager.php';
5657 $wgAutoloadClasses['ContestChallange'] = dirname( __FILE__ ) . '/includes/ContestChallange.php';
5758 $wgAutoloadClasses['ContestComment'] = dirname( __FILE__ ) . '/includes/ContestComment.php';
5859 $wgAutoloadClasses['ContestContestant'] = dirname( __FILE__ ) . '/includes/ContestContestant.php';
Index: trunk/extensions/Contest/includes/ContestantPager.php
@@ -0,0 +1,88 @@
 2+<?php
 3+
 4+/**
 5+ * Contestant pager, for on Special:Contestants
 6+ *
 7+ * @since 0.1
 8+ *
 9+ * @file ContestantPager.php
 10+ * @ingroup Contest
 11+ *
 12+ * @licence GNU GPL v3 or later
 13+ * @author Jeroen De Dauw < jeroendedauw@gmail.com >
 14+ */
 15+class ContestantPager extends TablePager {
 16+
 17+ protected $conds;
 18+ protected $page;
 19+
 20+ public function __construct( $page, $conds ) {
 21+ $this->page = $page;
 22+ $this->conds = $conds;
 23+ $this->mDefaultDirection = true;
 24+
 25+ parent::__construct();
 26+ }
 27+
 28+ public function getFieldNames() {
 29+ static $headers = null;
 30+
 31+ if ( is_null( $headers ) ) {
 32+ $headers = array(
 33+ 'contestant_id' => 'contest-contestant-id',
 34+ 'contestant_volunteer' => 'contest-contestant-volunteer',
 35+ 'contestant_wmf' => 'contest-contestant-wmf',
 36+ );
 37+
 38+ $headers = array_map( 'wfMsg', $headers );
 39+ }
 40+
 41+ return $headers;
 42+ }
 43+
 44+ public function formatValue( $name, $value ) {
 45+ return $value;
 46+ }
 47+
 48+ function getQueryInfo() {
 49+ $info = array(
 50+ 'tables' => array( 'contest_contestants' ),
 51+ 'fields' => array(
 52+ 'contestant_id',
 53+ 'contestant_volunteer',
 54+ 'contestant_wmf',
 55+ ),
 56+ 'conds' => $this->conds,
 57+ );
 58+
 59+ return $info;
 60+ }
 61+
 62+ public function getTableClass(){
 63+ return 'TablePager contest-contestants';
 64+ }
 65+
 66+ function getIndexField() {
 67+ return 'contestant_id';
 68+ }
 69+
 70+ function getDefaultSort() {
 71+ return 'contestant_id';
 72+ }
 73+
 74+ function isFieldSortable( $name ) {
 75+ return in_array(
 76+ $name,
 77+ array(
 78+ 'contestant_id',
 79+ 'contestant_volunteer',
 80+ 'contestant_wmf'
 81+ )
 82+ );
 83+ }
 84+
 85+ function getTitle() {
 86+ return $this->page->getTitle();
 87+ }
 88+
 89+}
Property changes on: trunk/extensions/Contest/includes/ContestantPager.php
___________________________________________________________________
Added: svn:eol-style
190 + native
Index: trunk/extensions/Contest/includes/Contest.class.php
@@ -158,4 +158,18 @@
159159 );
160160 }
161161
 162+ /**
 163+ * Gets the contestants for this contest.
 164+ *
 165+ * @since 0.1
 166+ *
 167+ * @return array of ContestContestant
 168+ */
 169+ public function getContestants() {
 170+ return ContestContestant::s()->select(
 171+ null,
 172+ array( 'contest_id' => $this->getId() )
 173+ );
 174+ }
 175+
162176 }
\ No newline at end of file

Status & tagging log