r100403 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100402‎ | r100403 | r100404 >
Date:01:59, 21 October 2011
Author:reedy
Status:ok
Tags:
Comment:
1.18wmf1 MFT r100399, r100402
Modified paths:
  • /branches/wmf/1.18wmf1/extensions/Contest (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Contest/Contest.i18n.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Contest/Contest.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Contest/includes/ContestDBObject.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Contest/includes/ContestantPager.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Contest/specials/SpecialContestant.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.18wmf1/extensions/Contest/Contest.i18n.php
@@ -177,6 +177,7 @@
178178 'contest-contestant-commentcount' => 'Comments',
179179 'contest-contestant-overallrating' => 'Rating',
180180 'contest-contestant-rating' => '$1 ($2 {{PLURAL:$2|vote|votes}})',
 181+ 'contest-contestant-submission' => 'Submission',
181182
182183 // Special:Contestant
183184 'contest-contestant-title' => 'Contestant $1 ($2)',
@@ -277,6 +278,7 @@
278279 'contest-contestant-yes' => 'Table cell value',
279280 'contest-contestant-commentcount' => 'Table column header',
280281 'contest-contestant-overallrating' => 'Table column header',
 282+ 'contest-contestant-submission' => 'Table column header',
281283 'contest-contestant-rating' => '$1 is the avarage rating, $2 is the amount of votes',
282284 'contest-contestant-title' => 'Page title with contestant id $1 and contest name $2',
283285 'contest-contestant-header-id' => 'Table row header',
Index: branches/wmf/1.18wmf1/extensions/Contest/specials/SpecialContestant.php
@@ -46,6 +46,10 @@
4747 $this->handleSubmission( $contestant->getId() );
4848 }
4949
 50+ if ( $this->getRequest()->wasPosted() ) {
 51+ $contestant->setReadDb( DB_MASTER );
 52+ }
 53+
5054 $contestant->loadFields();
5155 $this->showPage( $contestant );
5256 }
@@ -190,11 +194,11 @@
191195 $stats['submission'] = htmlspecialchars( wfMsg( 'contest-contestant-notsubmitted' ) );
192196 }
193197 else {
194 - $stats['submission'] = '<b>' . Html::element(
 198+ $stats['submission'] = Html::element(
195199 'a',
196 - array( 'href' => $contestant->getField( 'submission' ) ),
197 - wfMsg( 'contest-contestant-submission-url' )
198 - ) . '</b>';
 200+ array( 'href' => $contestant->getField( 'submission' ) ),
 201+ $contestant->getField( 'submission' )
 202+ );
199203 }
200204
201205 $countries = ContestContestant::getCountries();
Index: branches/wmf/1.18wmf1/extensions/Contest/Contest.php
@@ -28,7 +28,7 @@
2929 die( '<b>Error:</b> Contest requires MediaWiki 1.18 or above.' );
3030 }
3131
32 -define( 'CONTEST_VERSION', '0.1' );
 32+define( 'CONTEST_VERSION', '0.2 alpha' );
3333
3434 $wgExtensionCredits['other'][] = array(
3535 'path' => __FILE__,
Index: branches/wmf/1.18wmf1/extensions/Contest/includes/ContestDBObject.php
@@ -23,6 +23,14 @@
2424 * @var array
2525 */
2626 protected $fields = array( 'id' => null );
 27+
 28+ /**
 29+ * The database connection to use for read operations.
 30+ *
 31+ * @since 0.2
 32+ * @var integer DB_ enum
 33+ */
 34+ protected $readDb = DB_SLAVE;
2735
2836 /**
2937 * Constructor.
@@ -273,8 +281,29 @@
274282 return $this->insertIntoDB();
275283 }
276284 }
277 -
 285+
278286 /**
 287+ * Get the database type used for read operations.
 288+ *
 289+ * @since 0.2
 290+ * @return integer DB_ enum
 291+ */
 292+ public function getReadDb() {
 293+ return $this->readDb;
 294+ }
 295+
 296+ /**
 297+ * Set the database type to use for read operations.
 298+ *
 299+ * @param integer $db
 300+ *
 301+ * @since 0.2
 302+ */
 303+ public function setReadDb( $db ) {
 304+ $this->readDb = $db;
 305+ }
 306+
 307+ /**
279308 * Updates the object in the database.
280309 *
281310 * @since 0.1
@@ -710,7 +739,7 @@
711740 * @return ResultWrapper
712741 */
713742 public function rawSelect( $fields = null, array $conditions = array(), array $options = array() ) {
714 - $dbr = wfGetDB( DB_SLAVE );
 743+ $dbr = wfGetDB( $this->getReadDb() );
715744
716745 return $dbr->select(
717746 $this->getDBTable(),
Index: branches/wmf/1.18wmf1/extensions/Contest/includes/ContestantPager.php
@@ -131,6 +131,7 @@
132132 'contestant_wmf' => 'contest-contestant-wmf',
133133 'contestant_comments' => 'contest-contestant-commentcount',
134134 'contestant_rating' => 'contest-contestant-overallrating',
 135+ 'contestant_submission' => 'contest-contestant-submission',
135136 );
136137
137138 $headers = array_map( 'wfMsg', $headers );
@@ -217,13 +218,22 @@
218219 $value = htmlspecialchars( $this->getLang()->formatNum( $value ) );
219220 break;
220221 case 'contestant_rating':
221 - $value = htmlspecialchars( wfMsgExt(
 222+ $value = '<div style="white-space:nowrap;">' . htmlspecialchars( wfMsgExt(
222223 'contest-contestant-rating',
223224 'parsemag',
224225 $this->getLang()->formatNum( $value / 100 ),
225226 $this->getLang()->formatNum( $this->mCurrentRow->contestant_rating_count )
226 - ) );
 227+ ) ) . '</div>';
227228 break;
 229+ case 'contestant_submission':
 230+ $value = Html::element(
 231+ 'a',
 232+ array(
 233+ 'href' => $value
 234+ ),
 235+ $value
 236+ );
 237+ break;
228238 }
229239
230240 return $value;
@@ -240,6 +250,7 @@
241251 'contestant_comments',
242252 'contestant_rating',
243253 'contestant_rating_count',
 254+ 'contestant_submission',
244255 ),
245256 'conds' => $this->conds,
246257 );
Property changes on: branches/wmf/1.18wmf1/extensions/Contest
___________________________________________________________________
Modified: svn:mergeinfo
247258 Merged /trunk/extensions/Contest:r100399,100402

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r100399diplay submission url and added it to contestant pagerjeroendedauw00:40, 21 October 2011
r100402use master db after submission so results do not get omitted due to rep lagjeroendedauw01:53, 21 October 2011

Status & tagging log