r46005 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46004‎ | r46005 | r46006 >
Date:06:15, 22 January 2009
Author:aaron
Status:ok
Tags:
Comment:
Show quick vote stats table after rating with ajax
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/flaggedrevs.css (modified) (history)
  • /trunk/extensions/FlaggedRevs/language/RatingHistory.i18n.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/specialpages/RatingHistory_body.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/specialpages/ReaderFeedback_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -261,7 +261,7 @@
262262 #########
263263
264264 # Bump this number every time you change flaggedrevs.css/flaggedrevs.js
265 -$wgFlaggedRevStyleVersion = 50;
 265+$wgFlaggedRevStyleVersion = 51;
266266
267267 $wgExtensionFunctions[] = 'efLoadFlaggedRevs';
268268
Index: trunk/extensions/FlaggedRevs/flaggedrevs.css
@@ -352,3 +352,7 @@
353353 overflow: auto;
354354 font-size: 90%;
355355 }
 356+
 357+.fr_reader_feedback_stats {
 358+ font-size: 85%;
 359+}
Index: trunk/extensions/FlaggedRevs/language/RatingHistory.i18n.php
@@ -19,7 +19,7 @@
2020 'ratinghistory-year' => 'last year',
2121 'ratinghistory-3years' => 'last 3 years',
2222 'ratinghistory-chart' => 'Reader feedback rating over time',
23 - 'ratinghistory-table' => 'Overview of last month',
 23+ 'ratinghistory-table' => 'Overview of ratings last month',
2424 'ratinghistory-users' => 'Users who gave ratings',
2525 'ratinghistory-graph' => '$2 of "$3" ($1 {{PLURAL:$1|review|reviews}})',
2626 'readerfeedback-svg' => 'View as SVG',
Index: trunk/extensions/FlaggedRevs/specialpages/RatingHistory_body.php
@@ -70,7 +70,7 @@
7171 protected function showTable() {
7272 global $wgOut;
7373 # Show latest month of results
74 - $html = $this->getVoteAggregates( 31 );
 74+ $html = self::getVoteAggregates( $this->page, 31 );
7575 if( $html ) {
7676 $wgOut->addHTML( '<h2>'.wfMsgHtml('ratinghistory-table')."</h2>\n".$html );
7777 }
@@ -619,7 +619,7 @@
620620 return $html;
621621 }
622622
623 - public function getVoteAggregates( $period ) {
 623+ public static function getVoteAggregates( $page, $period ) {
624624 // Set cutoff time for period
625625 $dbr = wfGetDB( DB_SLAVE );
626626 $cutoff_unixtime = time() - ($period * 24 * 3600);
@@ -628,14 +628,14 @@
629629 // Get the first revision possibly voted on in the range
630630 $firstRevTS = $dbr->selectField( 'revision',
631631 'rev_timestamp',
632 - array( 'rev_page' => $this->page->getArticleId(), "rev_timestamp <= $cutoff" ),
 632+ array( 'rev_page' => $page->getArticleId(), "rev_timestamp <= $cutoff" ),
633633 __METHOD__,
634634 array( 'ORDER BY' => 'rev_timestamp DESC' )
635635 );
636636 // Find average, median, deviation...
637637 $res = $dbr->select( array( 'revision', 'reader_feedback' ),
638638 array( 'rfb_ratings' ),
639 - array( 'rev_page' => $this->page->getArticleId(),
 639+ array( 'rev_page' => $page->getArticleId(),
640640 "rev_id = rfb_rev_id",
641641 "rfb_timestamp >= $cutoff",
642642 // Trigger INDEX usage
@@ -658,7 +658,7 @@
659659 }
660660 }
661661 // Output multi-column list
662 - $html = "<table class='fr_reader_feedback_stats wikitable' cellspacing='0'><tr>";
 662+ $html = "<table class='wikitable fr_reader_feedback_stats' cellspacing='0'><tr>";
663663 foreach( FlaggedRevs::getFeedbackTags() as $tag => $w ) {
664664 $html .= '<th>'.wfMsgHtml("readerfeedback-$tag").'</th>';
665665 }
@@ -711,11 +711,10 @@
712712 return true;
713713 }
714714 $dbr = wfGetDB( DB_SLAVE );
715 - $tagTimestamp = $dbr->selectField( 'reader_feedback_pages',
716 - 'rfp_touched',
 715+ $tagTimestamp = $dbr->selectField( 'reader_feedback_pages', 'rfp_touched',
717716 array( 'rfp_page_id' => $this->page->getArticleId(), 'rfp_tag' => $tag ),
718717 __METHOD__ );
719 - $tagTimestamp = wfTimestamp( TS_MW, $tagTimestamp );
 718+ $tagTimestamp = wfTimestamp( TS_UNIX, $tagTimestamp );
720719 $file_unixtime = filemtime($path);
721720 # Check max cache time
722721 $cutoff_unixtime = time() - (7 * 24 * 3600);
@@ -724,8 +723,7 @@
725724 return true;
726725 }
727726 # If there are new votes, graph is stale
728 - $fileTimestamp = wfTimestamp( TS_MW, $file_unixtime );
729 - return ( $fileTimestamp < $tagTimestamp);
 727+ return ( $file_unixtime < $tagTimestamp );
730728 }
731729
732730 /**
Index: trunk/extensions/FlaggedRevs/specialpages/ReaderFeedback_body.php
@@ -168,12 +168,16 @@
169169 $dbw->begin();
170170 $ok = ( $bot || $form->submit() ); // don't submit for mindless drones
171171 $dbw->commit();
 172+
 173+ wfLoadExtensionMessages( 'RatingHistory' );
172174 if( $ok ) {
173175 return '<suc#>'.wfMsgExt( 'readerfeedback-success', array('parseinline'),
174 - $form->page->getPrefixedText(), $graphLink, $talk->getFullUrl( 'action=edit&section=new' ) );
 176+ $form->page->getPrefixedText(), $graphLink, $talk->getFullUrl( 'action=edit&section=new' ) ) .
 177+ '<h4>'.wfMsgHtml('ratinghistory-table')."</h4>\n".RatingHistory::getVoteAggregates( $form->page, 31 );
175178 } else {
176179 return '<err#>'.wfMsgExt( 'readerfeedback-voted', array('parseinline'),
177 - $form->page->getPrefixedText(), $graphLink, $talk->getFullUrl( 'action=edit&section=new' ) );
 180+ $form->page->getPrefixedText(), $graphLink, $talk->getFullUrl( 'action=edit&section=new' ) ) .
 181+ '<h4>'.wfMsgHtml('ratinghistory-table')."</h4>\n".RatingHistory::getVoteAggregates( $form->page, 31 );
178182 }
179183 }
180184

Status & tagging log