r34745 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r34744‎ | r34745 | r34746 >
Date:18:17, 13 May 2008
Author:aaron
Status:old
Tags:
Comment:
* Show user in hist (bug 14109)
* Show age at oldreviewedpages (bug 14110)
* Some UI color tweaks
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedArticle.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevsPage.i18n.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevsPage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -683,6 +683,34 @@
684684 );
685685 return $quality;
686686 }
 687+
 688+ /**
 689+ * Make stable version link and return the css
 690+ * @param Title $title
 691+ * @param int $rev_id
 692+ * @param Database $db, optional
 693+ * @returns array (string,string)
 694+ */
 695+ public static function makeStableVersionLink( $title, $rev_id, $skin, $db = NULL ) {
 696+ $db = $db ? $db : wfGetDB( DB_SLAVE );
 697+ $row = $db->selectRow( 'flaggedrevs',
 698+ array( 'fr_quality', 'fr_user' ),
 699+ array( 'fr_page_id' => $title->getArticleID(),
 700+ 'fr_rev_id' => $rev_id ),
 701+ __METHOD__,
 702+ array( 'FORCE INDEX' => 'PRIMARY' )
 703+ );
 704+ if( $row ) {
 705+ $css = self::getQualityColor( $row->fr_quality );
 706+ $user = User::whois( $row->fr_user );
 707+ $msg = ($row->fr_quality >= 1) ? 'hist-quality-user' : 'hist-stable-user';
 708+ $st = $title->getPrefixedDBkey();
 709+ $link = "<span class='plainlinks'>".wfMsgExt($msg,array('parseinline'),$st,$rev_id,$user)."</span>";
 710+ } else {
 711+ return array("","");
 712+ }
 713+ return array($link,$css);
 714+ }
687715
688716 /**
689717 * Get the "prime" flagged revision of a page
@@ -931,6 +959,25 @@
932960
933961 return true;
934962 }
 963+
 964+ /**
 965+ * @param int $quality
 966+ * @return string, css color for this quality
 967+ */
 968+ public static function getQualityColor( $quality ) {
 969+ switch( $quality ) {
 970+ case 2:
 971+ $css = 'flaggedrevs-color-3';
 972+ break;
 973+ case 1:
 974+ $css = 'flaggedrevs-color-2';
 975+ break;
 976+ default:
 977+ $css = 'flaggedrevs-color-1';
 978+ break;
 979+ }
 980+ return $css;
 981+ }
935982
936983 /**
937984 * Is this page in reviewable namespace?
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php
@@ -650,25 +650,10 @@
651651 if( !$this->dbr ) {
652652 $this->dbr = wfGetDB( DB_SLAVE );
653653 }
654 - $quality = FlaggedRevs::getRevQuality( $this->getTitle(), $row->rev_id, $this->dbr );
655 - if( $quality !== false ) {
656 - $skin = $wgUser->getSkin();
657 - $quality = intval($quality);
658 - switch( $quality ) {
659 - case 2:
660 - $css = 'flaggedrevs-color-3';
661 - break;
662 - case 1:
663 - $css = 'flaggedrevs-color-2';
664 - break;
665 - default:
666 - $css = 'flaggedrevs-color-1';
667 - break;
668 - }
669 - $msg = ($quality >= 1) ? 'hist-quality' : 'hist-stable';
670 - $s = "<span class='$css'>{$s}</span> <small><strong>[" .
671 - $skin->makeLinkObj( $this->getTitle(), wfMsgHtml( $msg ),'stableid=' . $row->rev_id ) .
672 - "]</strong></small>";
 654+ $skin = $wgUser->getSkin();
 655+ list($link,$css) = FlaggedRevs::makeStableVersionLink( $this->getTitle(), $row->rev_id, $skin, $this->dbr );
 656+ if( $link ) {
 657+ $s = "<span class='$css'>$s</span> <small><strong>[$link]</strong></small>";
673658 }
674659 return true;
675660 }
@@ -757,29 +742,31 @@
758743 $oldRevQ = $OldRev ? FlaggedRevs::getRevQuality( $NewRev->getTitle(), $OldRev->getId() ) : false;
759744 # Diff between two revisions
760745 if( $OldRev ) {
 746+ $css = FlaggedRevs::getQualityColor( $oldRevQ );
761747 if( $oldRevQ !== false ) {
762 - $msg = $oldRevQ ? 'revreview-quality-title' : 'revreview-stable-title';
 748+ $msg = $oldRevQ ? 'hist-quality' : 'hist-stable';
763749 } else {
764 - $msg = 'revreview-draft-title';
 750+ $msg = 'hist-draft';
765751 }
766752 $wgOut->addHTML( "<table class='fr-diff-ratings' width='100%'><tr><td class='fr-$msg' width='50%' align='center'>" );
767 - $wgOut->addHTML( "<b>[" . wfMsgHtml( $msg ) . "]</b>" );
 753+ $wgOut->addHTML( "<span class='$css'><b>[" . wfMsgHtml( $msg ) . "]</b></span>" );
768754
 755+ $css = FlaggedRevs::getQualityColor( $newRevQ );
769756 if( $newRevQ !== false ) {
770 - $msg = $newRevQ ? 'revreview-quality-title' : 'revreview-stable-title';
 757+ $msg = $newRevQ ? 'hist-quality' : 'hist-stable';
771758 } else {
772 - $msg = 'revreview-draft-title';
 759+ $msg = 'hist-draft';
773760 }
774761 $wgOut->addHTML( "</td><td class='fr-$msg' width='50%' align='center'>" );
775 - $wgOut->addHTML( "<b>[" . wfMsgHtml( $msg ) . "]</b>" );
 762+ $wgOut->addHTML( "<span class='$css'><b>[" . wfMsgHtml( $msg ) . "]</b></span>" );
776763
777764 $wgOut->addHTML( '</td></tr></table>' );
778765 # New page "diffs" - just one rev
779766 } else {
780767 if( $newRevQ !== false ) {
781 - $msg = $newRevQ ? 'revreview-quality-title' : 'revreview-stable-title';
 768+ $msg = $newRevQ ? 'hist-quality' : 'hist-stable';
782769 } else {
783 - $msg = 'revreview-draft-title';
 770+ $msg = 'hist-draft';
784771 }
785772 $wgOut->addHTML( "<table class='fr-diff-ratings' width='100%'><tr><td class='fr-$msg' align='center'>" );
786773 $wgOut->addHTML( "<b>[" . wfMsgHtml( $msg ) . "]</b>" );
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage.i18n.php
@@ -96,8 +96,11 @@
9797 'revreview-auto-w-old' => "You are editing a reviewed revision; changes will '''automatically be reviewed'''.",
9898 'revreview-patrolled' => 'The selected revision of [[:$1|$1]] has been marked as patrolled.',
9999
100 - 'hist-stable' => 'sighted revision',
101 - 'hist-quality' => 'quality revision',
 100+ 'hist-draft' => 'draft revision',
 101+ 'hist-stable' => 'sighted revision',
 102+ 'hist-quality' => 'quality revision',
 103+ 'hist-stable-user' => '[{{fullurl:$1|stableid=$2}} sighted] by [[User:$3|$3]]',
 104+ 'hist-quality-user' => '[{{fullurl:$1|stableid=$2}} validated] by [[User:$3|$3]]',
102105
103106 'flaggedrevs' => 'Flagged Revisions',
104107 'review-logpage' => 'Review log',
@@ -169,7 +172,7 @@
170173 'unreviewedpages' => 'Unreviewed pages',
171174 'unreviewed-legend' => 'List unreviewed content pages',
172175 'unreviewed-category' => 'Category:',
173 - 'unreviewed-diff' => 'review changes',
 176+ 'unreviewed-diff' => 'review',
174177 'unreviewed-unwatched' => '(unwatched)',
175178 'unreviewed-watched' => '($2 {{PLURAL:$1|user|users}} watching)',
176179 'unreviewed-list' => 'This page lists articles that have not been reviewed.',
@@ -181,6 +184,9 @@
182185 'oldreviewedpages-none' => 'There are currently no pages meeting these criteria',
183186 'oldreviewedpages-stable' => 'sighted',
184187 'oldreviewedpages-quality' => 'quality',
 188+ 'oldreviewedpages-hours' => '($1 {{PLURAL:$1|hour|hours}})',
 189+ 'oldreviewedpages-days' => '($1 {{PLURAL:$1|day|days}})',
 190+ 'oldreviewedpages-recent' => '(less than 1 hour)',
185191
186192 'revreview-visibility' => "'''This page has a [[{{MediaWiki:Validationpage}}|stable version]]; settings for it can be [{{fullurl:Special:Stabilization|page={{FULLPAGENAMEE}}}} configured].'''",
187193
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage.php
@@ -8,7 +8,6 @@
99
1010 class RevisionReview extends UnlistedSpecialPage
1111 {
12 -
1312 function __construct() {
1413 UnlistedSpecialPage::UnlistedSpecialPage( 'RevisionReview', 'review' );
1514 }
@@ -750,7 +749,6 @@
751750
752751 class StableVersions extends UnlistedSpecialPage
753752 {
754 -
755753 function __construct() {
756754 UnlistedSpecialPage::UnlistedSpecialPage( 'StableVersions' );
757755 }
@@ -862,7 +860,6 @@
863861 */
864862 class UnreviewedPages extends SpecialPage
865863 {
866 -
867864 function __construct() {
868865 SpecialPage::SpecialPage( 'UnreviewedPages', 'unreviewedpages' );
869866 }
@@ -1038,7 +1035,6 @@
10391036 */
10401037 class OldReviewedPages extends SpecialPage
10411038 {
1042 -
10431039 function __construct() {
10441040 SpecialPage::SpecialPage( 'OldReviewedPages', 'unreviewedpages' );
10451041 }
@@ -1099,15 +1095,32 @@
11001096 }
11011097 $review = $this->skin->makeKnownLinkObj( $title, wfMsg('unreviewed-diff'),
11021098 "diff=cur&oldid={$result->fp_stable}" );
1103 - $hist = $this->skin->makeKnownLinkObj( $title, wfMsg('hist'),
1104 - "action=history" );
11051099 $quality = $result->fp_quality ? wfMsgHtml('oldreviewedpages-quality') : wfMsgHtml('oldreviewedpages-stable');
1106 -
 1100+ # Get how old the reviewed revision is from the current
 1101+ if( $stableTS = Revision::getTimestampFromID( $result->fp_stable ) ) {
 1102+ $latestTS = wfTimestamp( TS_UNIX, $result->rev_timestamp );
 1103+ $stableTS = wfTimestamp( TS_UNIX, $stableTS );
 1104+ $hours = ($latestTS - $stableTS)/3600;
 1105+ // After three days, just use days
 1106+ if( $hours > (3*24) ) {
 1107+ $days = round($hours/24,0);
 1108+ $age = wfMsgExt('oldreviewedpages-days',array('parsemag'),$days);
 1109+ // If one or more hours, use hours
 1110+ } else if( $hours >= 1 ) {
 1111+ $hours = round($hours,0);
 1112+ $age = wfMsgExt('oldreviewedpages-hours',array('parsemag'),$hours);
 1113+ } else {
 1114+ $age = wfMsg('oldreviewedpages-recent'); // hot of the press :)
 1115+ }
 1116+ } else {
 1117+ $age = ""; // wtf?
 1118+ }
 1119+ # Is anybody watching?
11071120 $uw = UnreviewedPages::usersWatching( $title );
11081121 $uwPar = $uw >= 5 ? '5+' : $uw;
11091122 $watching = $uw ? wfMsgExt("unreviewed-watched",array('parsemag'),$uw,$uwPar) : wfMsgHtml("unreviewed-unwatched");
11101123
1111 - return( "<li>{$link} {$stxt} ({$review}) ({$hist}) <strong>[{$quality}]</strong> {$watching}</li>" );
 1124+ return( "<li>{$link} {$stxt} ({$review}) <i>{$age}</i> <strong>[{$quality}]</strong> {$watching}</li>" );
11121125 }
11131126 }
11141127
@@ -1133,10 +1146,13 @@
11341147
11351148 function getQueryInfo() {
11361149 $conds = $this->mConds;
1137 - $tables = array( 'flaggedpages', 'page' );
1138 - $fields = array('page_namespace','page_title','page_len','fp_stable','fp_quality');
 1150+ $tables = array( 'flaggedpages', 'page', 'revision' );
 1151+ $fields = array('page_namespace','page_title','page_len','fp_stable','fp_quality',
 1152+ 'rev_timestamp');
11391153 $conds['fp_reviewed'] = 0;
1140 - $conds[] = 'fp_page_id = page_id';
 1154+ $conds[] = 'page_id = fp_page_id';
 1155+ $conds[] = 'rev_page = page_id';
 1156+ $conds[] = 'rev_id = page_latest';
11411157 # Reviewable pages only (moves can make oddities, so check here)
11421158 global $wgFlaggedRevsNamespaces;
11431159 $conds['page_namespace'] = $wgFlaggedRevsNamespaces;
@@ -1168,7 +1184,6 @@
11691185
11701186 class ReviewedPages extends SpecialPage
11711187 {
1172 -
11731188 function __construct() {
11741189 SpecialPage::SpecialPage( 'ReviewedPages' );
11751190 }
@@ -1290,7 +1305,6 @@
12911306
12921307 class StablePages extends SpecialPage
12931308 {
1294 -
12951309 function __construct() {
12961310 SpecialPage::SpecialPage( 'StablePages' );
12971311 }
@@ -1375,7 +1389,6 @@
13761390
13771391 class Stabilization extends UnlistedSpecialPage
13781392 {
1379 -
13801393 function __construct() {
13811394 UnlistedSpecialPage::UnlistedSpecialPage( 'Stabilization', 'stablesettings' );
13821395 }
@@ -1640,7 +1653,6 @@
16411654
16421655 class QualityOversight extends SpecialPage
16431656 {
1644 -
16451657 function __construct() {
16461658 SpecialPage::SpecialPage( 'QualityOversight' );
16471659 }

Status & tagging log