Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -14,7 +14,7 @@ |
15 | 15 | $wgExtensionCredits['specialpage'][] = array( |
16 | 16 | 'name' => 'Flagged Revisions', |
17 | 17 | 'author' => array( 'Aaron Schulz', 'Joerg Baach' ), |
18 | | - 'version' => '1.045', |
| 18 | + 'version' => '1.05', |
19 | 19 | 'url' => 'http://www.mediawiki.org/wiki/Extension:FlaggedRevs', |
20 | 20 | 'descriptionmsg' => 'flaggedrevs-desc', |
21 | 21 | ); |
— | — | @@ -461,7 +461,7 @@ |
462 | 462 | * @return ParserOutput |
463 | 463 | */ |
464 | 464 | public static function parseStableText( $article, $text='', $id, $reparsed = true ) { |
465 | | - global $wgParser; |
| 465 | + global $wgParser, $wgUseStableTemplates; |
466 | 466 | $title = $article->getTitle(); // avoid pass-by-reference error |
467 | 467 | # Make our hooks to trigger |
468 | 468 | $wgParser->fr_isStable = true; |
— | — | @@ -478,24 +478,32 @@ |
479 | 479 | # Do we need to set the template uses via DB? |
480 | 480 | if( $reparsed ) { |
481 | 481 | $dbr = wfGetDB( DB_SLAVE ); |
482 | | - $res = $dbr->select( array('flaggedtemplates', 'revision'), |
483 | | - array( 'ft_namespace', 'ft_title', 'ft_tmp_rev_id', 'rev_page' ), |
484 | | - array( 'ft_rev_id' => $id, 'rev_id = ft_rev_id' ), |
485 | | - __METHOD__ ); |
| 482 | + if( $wgUseStableTemplates ) { |
| 483 | + $res = $dbr->select( array('flaggedtemplates','page','flaggedpages'), |
| 484 | + array( 'ft_namespace', 'ft_title', 'fp_stable AS rev_id', 'page_id' ), |
| 485 | + array( 'ft_rev_id' => $id, 'page_namespace = ft_namespace', 'page_title = ft_title', |
| 486 | + 'fp_page_id = page_id' ), |
| 487 | + __METHOD__ ); |
| 488 | + } else { |
| 489 | + $res = $dbr->select( array('flaggedtemplates','revision'), |
| 490 | + array( 'ft_namespace', 'ft_title', 'ft_tmp_rev_id AS rev_id', 'rev_page AS page_id' ), |
| 491 | + array( 'ft_rev_id' => $id, 'rev_id = ft_rev_id' ), |
| 492 | + __METHOD__ ); |
| 493 | + } |
486 | 494 | # Add template metadata to output |
487 | 495 | $maxTempID = 0; |
488 | 496 | while( $row = $res->fetchObject() ) { |
489 | 497 | if( !isset($parserOut->mTemplates[$row->ft_namespace]) ) { |
490 | 498 | $parserOut->mTemplates[$row->ft_namespace] = array(); |
491 | 499 | } |
492 | | - $parserOut->mTemplates[$row->ft_namespace][$row->ft_title] = $row->rev_page; |
| 500 | + $parserOut->mTemplates[$row->ft_namespace][$row->ft_title] = $row->page_id; |
493 | 501 | |
494 | 502 | if( !isset($parserOut->mTemplateIds[$row->ft_namespace]) ) { |
495 | 503 | $parserOut->mTemplateIds[$row->ft_namespace] = array(); |
496 | 504 | } |
497 | | - $parserOut->mTemplateIds[$row->ft_namespace][$row->ft_title] = $row->ft_tmp_rev_id; |
498 | | - if( $row->ft_tmp_rev_id > $maxTempID ) { |
499 | | - $maxTempID = $row->ft_tmp_rev_id; |
| 505 | + $parserOut->mTemplateIds[$row->ft_namespace][$row->ft_title] = $row->rev_id; |
| 506 | + if( $row->rev_id > $maxTempID ) { |
| 507 | + $maxTempID = $row->rev_id; |
500 | 508 | } |
501 | 509 | } |
502 | 510 | $parserOut->fr_newestTemplateID = $maxTempID; |
— | — | @@ -666,7 +674,7 @@ |
667 | 675 | * Will not return a revision if deleted |
668 | 676 | */ |
669 | 677 | public static function getFlaggedRev( $title, $rev_id, $getText=false, $forUpdate=false, $page_id=false ) { |
670 | | - $columns = array('fr_rev_id','fr_page_id','fr_user','fr_timestamp','fr_comment','fr_quality','fr_tags'); |
| 678 | + $columns = FlaggedRevision::selectFields(); |
671 | 679 | if( $getText ) { |
672 | 680 | $columns[] = 'fr_text'; |
673 | 681 | $columns[] = 'fr_flags'; |
— | — | @@ -778,7 +786,7 @@ |
779 | 787 | * @returns mixed FlaggedRevision (null on failure) |
780 | 788 | */ |
781 | 789 | public static function getStablePageRev( $title, $getText=false, $forUpdate=false ) { |
782 | | - $columns = array('fr_rev_id','fr_page_id','fr_user','fr_timestamp','fr_comment','fr_quality','fr_tags'); |
| 790 | + $columns = FlaggedRevision::selectFields(); |
783 | 791 | if( $getText ) { |
784 | 792 | $columns[] = 'fr_text'; |
785 | 793 | $columns[] = 'fr_flags'; |
— | — | @@ -1250,8 +1258,8 @@ |
1251 | 1259 | $parserCache->save( $poutput, $article, $user ); |
1252 | 1260 | } |
1253 | 1261 | # NS:title -> rev ID mapping |
1254 | | - foreach( $poutput->mTemplateIds as $namespace => $title ) { |
1255 | | - foreach( $title as $dbkey => $id ) { |
| 1262 | + foreach( $poutput->mTemplateIds as $namespace => $titleAndID ) { |
| 1263 | + foreach( $titleAndID as $dbkey => $id ) { |
1256 | 1264 | $tmpset[] = array( |
1257 | 1265 | 'ft_rev_id' => $rev->getId(), |
1258 | 1266 | 'ft_namespace' => $namespace, |
— | — | @@ -1313,17 +1321,28 @@ |
1314 | 1322 | $textFlags .= 'external'; |
1315 | 1323 | } |
1316 | 1324 | |
| 1325 | + # If this is an image page, store corresponding file info |
| 1326 | + $fileData = array(); |
| 1327 | + if( $title->getNamespace() == NS_IMAGE && $file = wfFindFile($title) ) { |
| 1328 | + $fileData['name'] = $title->getDBkey(); |
| 1329 | + $fileData['timestamp'] = $file->getTimestamp(); |
| 1330 | + $fileData['sha1'] = $file->getSha1(); |
| 1331 | + } |
| 1332 | + |
1317 | 1333 | # Our review entry |
1318 | 1334 | $revisionset = array( |
1319 | | - 'fr_page_id' => $rev->getPage(), |
1320 | | - 'fr_rev_id' => $rev->getId(), |
1321 | | - 'fr_user' => $user->getId(), |
1322 | | - 'fr_timestamp' => $dbw->timestamp( wfTimestampNow() ), |
1323 | | - 'fr_comment' => "", |
1324 | | - 'fr_quality' => $quality, |
1325 | | - 'fr_tags' => self::flattenRevisionTags( $flags ), |
1326 | | - 'fr_text' => $fulltext, # Store expanded text for speed |
1327 | | - 'fr_flags' => $textFlags |
| 1335 | + 'fr_page_id' => $rev->getPage(), |
| 1336 | + 'fr_rev_id' => $rev->getId(), |
| 1337 | + 'fr_user' => $user->getId(), |
| 1338 | + 'fr_timestamp' => $dbw->timestamp( wfTimestampNow() ), |
| 1339 | + 'fr_comment' => "", |
| 1340 | + 'fr_quality' => $quality, |
| 1341 | + 'fr_tags' => self::flattenRevisionTags( $flags ), |
| 1342 | + 'fr_text' => $fulltext, # Store expanded text for speed |
| 1343 | + 'fr_flags' => $textFlags, |
| 1344 | + 'fr_img_name' => $fileData ? $fileData['name'] : null, |
| 1345 | + 'fr_img_timestamp' => $fileData ? $fileData['timestamp'] : null, |
| 1346 | + 'fr_img_sha1' => $fileData ? $fileData['sha1'] : null |
1328 | 1347 | ); |
1329 | 1348 | # Update flagged revisions table |
1330 | 1349 | $dbw->replace( 'flaggedrevs', |
— | — | @@ -1658,14 +1677,21 @@ |
1659 | 1678 | $sha1 = ""; |
1660 | 1679 | global $wgUseStableImages; |
1661 | 1680 | if( $wgUseStableImages && self::isPageReviewable( $nt ) ) { |
1662 | | - $row = $dbw->selectRow( array('flaggedpages', 'flaggedimages'), |
1663 | | - array( 'fi_img_timestamp', 'fi_img_sha1' ), |
1664 | | - array( 'fp_page_id' => $nt->getArticleId(), |
1665 | | - 'fp_stable = fi_rev_id', |
1666 | | - 'fi_name' => $nt->getDBkey() ), |
1667 | | - __METHOD__ ); |
1668 | | - $time = $row ? $row->fi_img_timestamp : $time; |
1669 | | - $sha1 = $row ? $row->fi_img_sha1 : $sha1; |
| 1681 | + $srev = self::getStablePageRev( $nt, false, true ); |
| 1682 | + if( $srev ) { |
| 1683 | + $time = $srev->getFileTimestamp(); |
| 1684 | + $sha1 = $srev->getFileSha1(); |
| 1685 | + // B/C, may be stored in associated image version metadata table |
| 1686 | + if( !$time || !$sha1 ) { |
| 1687 | + $row = $dbw->selectRow( 'flaggedimages', |
| 1688 | + array( 'fi_img_timestamp', 'fi_img_sha1' ), |
| 1689 | + array( 'fi_rev_id' => $srev->getRevId(), |
| 1690 | + 'fi_name' => $nt->getDBkey() ), |
| 1691 | + __METHOD__ ); |
| 1692 | + $time = $row ? $row->fi_img_timestamp : $time; |
| 1693 | + $sha1 = $row ? $row->fi_img_sha1 : $sha1; |
| 1694 | + } |
| 1695 | + } |
1670 | 1696 | } |
1671 | 1697 | # If there is no stable version (or that feature is not enabled), use |
1672 | 1698 | # the image revision during review time. |
— | — | @@ -1720,14 +1746,21 @@ |
1721 | 1747 | $sha1 = ""; |
1722 | 1748 | global $wgUseStableImages; |
1723 | 1749 | if( $wgUseStableImages && self::isPageReviewable( $nt ) ) { |
1724 | | - $row = $dbw->selectRow( array('flaggedpages', 'flaggedimages'), |
1725 | | - array( 'fi_img_timestamp', 'fi_img_sha1' ), |
1726 | | - array( 'fp_page_id' => $nt->getArticleId(), |
1727 | | - 'fp_stable = fi_rev_id', |
1728 | | - 'fi_name' => $nt->getDBkey() ), |
1729 | | - __METHOD__ ); |
1730 | | - $time = $row ? $row->fi_img_timestamp : $time; |
1731 | | - $sha1 = $row ? $row->fi_img_sha1 : $sha1; |
| 1750 | + $srev = self::getStablePageRev( $nt, false, true ); |
| 1751 | + if( $srev ) { |
| 1752 | + $time = $srev->getFileTimestamp(); |
| 1753 | + $sha1 = $srev->getFileSha1(); |
| 1754 | + // B/C, may be stored in associated image version metadata table |
| 1755 | + if( !$time || !$sha1 ) { |
| 1756 | + $row = $dbw->selectRow( 'flaggedimages', |
| 1757 | + array( 'fi_img_timestamp', 'fi_img_sha1' ), |
| 1758 | + array( 'fi_rev_id' => $srev->getRevId(), |
| 1759 | + 'fi_name' => $nt->getDBkey() ), |
| 1760 | + __METHOD__ ); |
| 1761 | + $time = $row ? $row->fi_img_timestamp : $time; |
| 1762 | + $sha1 = $row ? $row->fi_img_sha1 : $sha1; |
| 1763 | + } |
| 1764 | + } |
1732 | 1765 | } |
1733 | 1766 | # If there is no stable version (or that feature is not enabled), use |
1734 | 1767 | # the image revision during review time. |
— | — | @@ -2355,6 +2388,7 @@ |
2356 | 2389 | $wgExtNewIndexes[] = array('flaggedpage_config', 'fpc_expiry', "$base/archives/patch-expiry-index.sql" ); |
2357 | 2390 | $wgExtNewTables[] = array( 'flaggedrevs_promote', "$base/archives/patch-flaggedrevs_promote.sql" ); |
2358 | 2391 | $wgExtNewTables[] = array( 'flaggedpages', "$base/archives/patch-flaggedpages.sql" ); |
| 2392 | + $wgExtNewFields[] = array( 'flaggedrevs', 'fr_img_name', "$base/archives/patch-fr_img_name.sql" ); |
2359 | 2393 | } else if( $wgDBtype == 'postgres' ) { |
2360 | 2394 | $wgExtPGNewFields[] = array('flaggedpage_config', 'fpc_expiry', "TIMESTAMPTZ NULL" ); |
2361 | 2395 | $wgExtNewIndexes[] = array('flaggedpage_config', 'fpc_expiry', "$base/postgres/patch-expiry-index.sql" ); |
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php |
— | — | @@ -2,10 +2,11 @@ |
3 | 3 | |
4 | 4 | class FlaggedArticle extends Article { |
5 | 5 | public $isDiffFromStable = false; |
6 | | - public $stableRev = null; |
7 | | - public $pageconfig = null; |
8 | | - public $flags = null; |
| 6 | + protected $stableRev = null; |
| 7 | + protected $pageconfig = null; |
| 8 | + protected $flags = null; |
9 | 9 | protected $reviewNotice = ''; |
| 10 | + protected $file = NULL; |
10 | 11 | /** |
11 | 12 | * Does the config and current URL params allow |
12 | 13 | * for overriding by stable revisions? |
— | — | @@ -360,6 +361,10 @@ |
361 | 362 | * Set the image revision to display |
362 | 363 | */ |
363 | 364 | public function setImageVersion() { |
| 365 | + global $wgArticle; |
| 366 | + if( !$wgArticle instanceof ImagePage ) { |
| 367 | + return false; |
| 368 | + } |
364 | 369 | if( $this->getTitle()->getNamespace() == NS_IMAGE && $this->isReviewable() ) { |
365 | 370 | global $wgRequest; |
366 | 371 | # A reviewed version may have explicitly been requested... |
— | — | @@ -370,14 +375,20 @@ |
371 | 376 | $frev = $this->getStableRev( true ); |
372 | 377 | } |
373 | 378 | if( !is_null($frev) ) { |
374 | | - $dbr = wfGetDB( DB_SLAVE ); |
375 | | - $time = $dbr->selectField( 'flaggedimages', 'fi_img_timestamp', |
376 | | - array( 'fi_rev_id' => $frev->getRevId(), |
377 | | - 'fi_name' => $this->getTitle()->getDBkey() ), |
378 | | - __METHOD__ ); |
| 379 | + $timestamp = $frev->getFileTimestamp(); |
| 380 | + // B/C, may be stored in associated image version metadata table |
| 381 | + if( !$timestamp ) { |
| 382 | + $dbr = wfGetDB( DB_SLAVE ); |
| 383 | + $timestamp = $dbr->selectField( 'flaggedimages', |
| 384 | + 'fi_img_timestamp', |
| 385 | + array( 'fi_rev_id' => $frev->getRevId(), |
| 386 | + 'fi_name' => $this->getTitle()->getDBkey() ), |
| 387 | + __METHOD__ ); |
| 388 | + } |
379 | 389 | # NOTE: if not found, this will use the current |
380 | | - $article = new ImagePage( $this->getTitle(), $time ); |
| 390 | + $wgArticle = new ImagePage( $this->getTitle(), $timestamp ); |
381 | 391 | } |
| 392 | + $this->file = $wgArticle->getFile(); |
382 | 393 | } |
383 | 394 | return true; |
384 | 395 | } |
— | — | @@ -488,7 +499,7 @@ |
489 | 500 | return true; |
490 | 501 | } |
491 | 502 | # Add review form |
492 | | - $this->addQuickReview( $out, $wgRequest->getVal('diff') ); |
| 503 | + $this->addQuickReview( $out, (bool)$wgRequest->getVal('diff') ); |
493 | 504 | |
494 | 505 | return true; |
495 | 506 | } |
— | — | @@ -667,12 +678,14 @@ |
668 | 679 | # Use same DB object |
669 | 680 | $this->dbr = isset($this->dbr) ? $this->dbr : wfGetDB( DB_SLAVE ); |
670 | 681 | $skin = $wgUser->getSkin(); |
671 | | - # Get corresponding title |
672 | | - $rev = Revision::loadFromTimestamp( $this->dbr, $this->getTitle(), $file->getTimestamp() ); |
673 | | - if( !$rev ) { |
| 682 | + # See if this is reivewed |
| 683 | + $quality = $this->dbr->selectField( 'flaggedrevs', 'fr_quality', |
| 684 | + array( 'fr_img_sha1' => $file->getSha1(), 'fr_img_timestamp' => $file->getTimestamp() ), |
| 685 | + __METHOD__ ); |
| 686 | + if( $quality === false ) { |
674 | 687 | return true; |
675 | 688 | } |
676 | | - list($link,$css) = FlaggedRevs::makeStableVersionLink( $this->getTitle(), $rev->getId(), $skin, $this->dbr ); |
| 689 | + $css = FlaggedRevs::getQualityColor( $quality ); |
677 | 690 | return true; |
678 | 691 | } |
679 | 692 | |
— | — | @@ -709,45 +722,79 @@ |
710 | 723 | if( $frev && $frev->getRevId() == $OldRev->getID() ) { |
711 | 724 | $changeList = array(); |
712 | 725 | $skin = $wgUser->getSkin(); |
| 726 | + |
713 | 727 | # Make a list of each changed template... |
714 | 728 | $dbr = wfGetDB( DB_SLAVE ); |
715 | | - $ret = $dbr->select( array('flaggedtemplates','page'), |
716 | | - array( 'ft_namespace', 'ft_title', 'ft_tmp_rev_id' ), |
717 | | - array( 'ft_rev_id' => $frev->getRevId(), |
718 | | - 'ft_namespace = page_namespace', |
719 | | - 'ft_title = page_title', |
720 | | - 'ft_tmp_rev_id != page_latest' ), |
721 | | - __METHOD__ ); |
722 | | - |
| 729 | + global $wgUseStableTemplates; |
| 730 | + if( $wgUseStableTemplates ) { |
| 731 | + $ret = $dbr->select( array('flaggedtemplates','page','flaggedpages'), |
| 732 | + array( 'ft_namespace', 'ft_title', 'ft_tmp_rev_id' ), |
| 733 | + array( 'ft_rev_id' => $frev->getRevId(), |
| 734 | + 'page_namespace = ft_namespace', |
| 735 | + 'page_title = ft_title', |
| 736 | + 'fp_page_id = page_id', |
| 737 | + 'fp_stable != page_latest' ), |
| 738 | + __METHOD__ ); |
| 739 | + } else { |
| 740 | + $ret = $dbr->select( array('flaggedtemplates','page'), |
| 741 | + array( 'ft_namespace', 'ft_title', 'ft_tmp_rev_id' ), |
| 742 | + array( 'ft_rev_id' => $frev->getRevId(), |
| 743 | + 'page_namespace = ft_namespace', |
| 744 | + 'page_title = ft_title', |
| 745 | + 'ft_tmp_rev_id != page_latest' ), |
| 746 | + __METHOD__ ); |
| 747 | + } |
723 | 748 | while( $row = $dbr->fetchObject( $ret ) ) { |
724 | 749 | $title = Title::makeTitle( $row->ft_namespace, $row->ft_title ); |
725 | 750 | $changeList[] = $skin->makeKnownLinkObj( $title, $title->GetPrefixedText(), |
726 | 751 | "diff=cur&oldid=" . $row->ft_tmp_rev_id ); |
727 | 752 | } |
| 753 | + |
728 | 754 | # And images... |
729 | | - $ret = $dbr->select( array('flaggedimages','image'), |
730 | | - array( 'fi_name' ), |
731 | | - array( 'fi_rev_id' => $frev->getRevId(), |
732 | | - 'fi_name = img_name', |
733 | | - 'fi_img_sha1 != img_sha1' ), |
734 | | - __METHOD__ ); |
735 | | - |
| 755 | + global $wgUseStableImages; |
| 756 | + if( $wgUseStableImages ) { |
| 757 | + $ret = $dbr->select( array('flaggedimages','page','flaggedpages','flaggedrevs','image'), |
| 758 | + array( 'fi_name' ), |
| 759 | + array( 'fi_rev_id' => $frev->getRevId(), |
| 760 | + 'page_namespace' => NS_IMAGE, |
| 761 | + 'page_title = fi_name', |
| 762 | + 'fp_page_id = page_id', |
| 763 | + 'fr_page_id = page_id', |
| 764 | + 'fr_rev_id = fp_stable', |
| 765 | + 'img_name = fi_name', |
| 766 | + 'fr_img_sha1 != img_sha1' ), |
| 767 | + __METHOD__ ); |
| 768 | + } else { |
| 769 | + $ret = $dbr->select( array('flaggedimages','image'), |
| 770 | + array( 'fi_name' ), |
| 771 | + array( 'fi_rev_id' => $frev->getRevId(), |
| 772 | + 'fi_name = img_name', |
| 773 | + 'fi_img_sha1 != img_sha1' ), |
| 774 | + __METHOD__ ); |
| 775 | + } |
736 | 776 | while( $row = $dbr->fetchObject( $ret ) ) { |
737 | 777 | $title = Title::makeTitle( NS_IMAGE, $row->fi_name ); |
738 | 778 | $changeList[] = $skin->makeKnownLinkObj( $title ); |
739 | 779 | } |
| 780 | + |
| 781 | + # Some important information... |
| 782 | + if( ($wgUseStableTemplates || $wgUseStableImages) && !empty($changeList) ) { |
| 783 | + $notice = '<br/>'.wfMsgExt('revreview-update-use', array('parseinline')); |
| 784 | + } else { |
| 785 | + $notice = ""; |
| 786 | + } |
740 | 787 | # If the user is allowed to review, prompt them! |
741 | 788 | if( empty($changeList) && $wgUser->isAllowed('review') ) { |
742 | 789 | $wgOut->addHTML( "<div id='mw-difftostable' class='flaggedrevs_diffnotice plainlinks'>" . |
743 | | - wfMsgExt('revreview-update-none', array('parseinline')).'</div>' ); |
| 790 | + wfMsgExt('revreview-update-none', array('parseinline')).$notice.'</div>' ); |
744 | 791 | } else if( !empty($changeList) && $wgUser->isAllowed('review') ) { |
745 | 792 | $changeList = implode(', ',$changeList); |
746 | 793 | $wgOut->addHTML( "<div id='mw-difftostable' class='flaggedrevs_diffnotice plainlinks'>" . |
747 | | - wfMsgExt('revreview-update', array('parseinline')) . ' ' . $changeList . '</div>' ); |
| 794 | + wfMsgExt('revreview-update', array('parseinline')).' '.$changeList.$notice.'</div>' ); |
748 | 795 | } else if( !empty($changeList) ) { |
749 | 796 | $changeList = implode(', ',$changeList); |
750 | 797 | $wgOut->addHTML( "<div id='mw-difftostable' class='flaggedrevs_diffnotice plainlinks'>" . |
751 | | - wfMsgExt('revreview-update-includes', array('parseinline')) . ' ' . $changeList . '</div>' ); |
| 798 | + wfMsgExt('revreview-update-includes', array('parseinline')).' '.$changeList.$notice.'</div>' ); |
752 | 799 | } |
753 | 800 | # Set flag for review form to tell it to autoselect tag settings from the |
754 | 801 | # old revision unless the current one is tagged to. |
— | — | @@ -760,13 +807,15 @@ |
761 | 808 | $oldRevQ = $OldRev ? FlaggedRevs::getRevQuality( $NewRev->getTitle(), $OldRev->getId() ) : false; |
762 | 809 | # Diff between two revisions |
763 | 810 | if( $OldRev ) { |
| 811 | + $wgOut->addHTML( "<table class='fr-diff-ratings' width='100%'><tr>" ); |
| 812 | + |
764 | 813 | $css = FlaggedRevs::getQualityColor( $oldRevQ ); |
765 | 814 | if( $oldRevQ !== false ) { |
766 | 815 | $msg = $oldRevQ ? 'hist-quality' : 'hist-stable'; |
767 | 816 | } else { |
768 | 817 | $msg = 'hist-draft'; |
769 | 818 | } |
770 | | - $wgOut->addHTML( "<table class='fr-diff-ratings' width='100%'><tr><td class='fr-$msg' width='50%' align='center'>" ); |
| 819 | + $wgOut->addHTML( "<td width='50%' align='center'>" ); |
771 | 820 | $wgOut->addHTML( "<span class='$css'><b>[" . wfMsgHtml( $msg ) . "]</b></span>" ); |
772 | 821 | |
773 | 822 | $css = FlaggedRevs::getQualityColor( $newRevQ ); |
— | — | @@ -775,7 +824,7 @@ |
776 | 825 | } else { |
777 | 826 | $msg = 'hist-draft'; |
778 | 827 | } |
779 | | - $wgOut->addHTML( "</td><td class='fr-$msg' width='50%' align='center'>" ); |
| 828 | + $wgOut->addHTML( "</td><td width='50%' align='center'>" ); |
780 | 829 | $wgOut->addHTML( "<span class='$css'><b>[" . wfMsgHtml( $msg ) . "]</b></span>" ); |
781 | 830 | |
782 | 831 | $wgOut->addHTML( '</td></tr></table>' ); |
— | — | @@ -1110,11 +1159,8 @@ |
1111 | 1160 | } |
1112 | 1161 | } |
1113 | 1162 | # For image pages, note the current image version |
1114 | | - if( $this->getTitle()->getNamespace() == NS_IMAGE ) { |
1115 | | - $file = wfFindFile( $this->getTitle() ); |
1116 | | - if( $file ) { |
1117 | | - $imageParams .= $this->getTitle()->getDBkey() . "|" . $file->getTimestamp() . "|" . $file->getSha1() . "#"; |
1118 | | - } |
| 1163 | + if( $this->getTitle()->getNamespace() == NS_IMAGE && $this->file ) { |
| 1164 | + $imageParams .= $this->getTitle()->getDBkey() . "|" . $this->file->getTimestamp() . "|" . $this->file->getSha1() . "#"; |
1119 | 1165 | } |
1120 | 1166 | |
1121 | 1167 | # Hidden params |
Index: trunk/extensions/FlaggedRevs/archives/patch-fr_img_name.sql |
— | — | @@ -0,0 +1,9 @@ |
| 2 | +-- Add file metadata for flaggedrevs of image pages |
| 3 | +ALTER TABLE /*$wgDBprefix*/flaggedrevs |
| 4 | + -- Name of included image |
| 5 | + ADD fr_img_name varchar(255) binary NULL default NULL, |
| 6 | + -- Timestamp of file (when uploaded) |
| 7 | + ADD fr_img_timestamp char(14) NULL default NULL, |
| 8 | + -- Statistically unique SHA-1 key |
| 9 | + ADD fr_img_sha1 varbinary(32) NULL default NULL, |
| 10 | + ADD INDEX key_timestamp (fr_img_sha1,fr_img_timestamp); |
Property changes on: trunk/extensions/FlaggedRevs/archives/patch-fr_img_name.sql |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 11 | + native |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.sql |
— | — | @@ -19,8 +19,7 @@ |
20 | 20 | INDEX fp_quality_page (fp_quality,fp_page_id) |
21 | 21 | ) TYPE=InnoDB; |
22 | 22 | |
| 23 | +-- This stores all of our rev reviews |
23 | 24 | CREATE TABLE /*$wgDBprefix*/flaggedrevs ( |
24 | 25 | -- Foreign key to page.page_id |
25 | 26 | fr_page_id integer NOT NULL, |
— | — | @@ -43,8 +42,16 @@ |
44 | 43 | -- utf8: in UTF-8 |
45 | 44 | -- external: the fr_text column is a url to an external storage object |
46 | 45 | fr_flags tinyblob NOT NULL, |
| 46 | + -- Parameters for revisions of Image pages: |
| 47 | + -- Name of included image (NULL if n/a) |
| 48 | + fr_img_name varchar(255) binary NULL default NULL, |
| 49 | + -- Timestamp of file (when uploaded) (NULL if n/a) |
| 50 | + fr_img_timestamp char(14) NULL default NULL, |
| 51 | + -- Statistically unique SHA-1 key (NULL if n/a) |
| 52 | + fr_img_sha1 varbinary(32) NULL default NULL, |
47 | 53 | |
48 | 54 | PRIMARY KEY (fr_page_id,fr_rev_id), |
| 55 | + INDEX key_timestamp (fr_img_sha1,fr_img_timestamp), |
49 | 56 | INDEX page_qal_rev (fr_page_id,fr_quality,fr_rev_id) |
50 | 57 | ) TYPE=InnoDB; |
51 | 58 | |
— | — | @@ -82,7 +89,7 @@ |
83 | 90 | -- Name of included image |
84 | 91 | fi_name varchar(255) binary NOT NULL default '', |
85 | 92 | -- Timestamp of image used when reviewed |
86 | | - fi_img_timestamp char(14) NULL, |
| 93 | + fi_img_timestamp char(14) NOT NULL, |
87 | 94 | -- Statistically unique SHA-1 key |
88 | 95 | fi_img_sha1 varbinary(32) NOT NULL default '', |
89 | 96 | |
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage.i18n.php |
— | — | @@ -96,6 +96,8 @@ |
97 | 97 | '''Some templates/images were updated:'''", |
98 | 98 | 'revreview-update-none' => "Please [[{{MediaWiki:Validationpage}}|review]] any changes ''(shown below)'' made since the stable revision was [{{fullurl:Special:Log|type=review&page={{FULLPAGENAMEE}}}} approved].", |
99 | 99 | 'revreview-update-includes' => "'''Some templates/images were updated:'''", |
| 100 | + 'revreview-update-use' => "'''NOTE:''' If any of these templates/images have a stable version, then it is already used in the stable version of this page.", |
| 101 | + |
100 | 102 | 'revreview-auto' => '(automatic)', |
101 | 103 | 'revreview-auto-w' => "You are editing the stable revision; changes will '''automatically be reviewed'''.", |
102 | 104 | 'revreview-auto-w-old' => "You are editing a reviewed revision; changes will '''automatically be reviewed'''.", |
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage.php |
— | — | @@ -423,6 +423,8 @@ |
424 | 424 | # Our image version pointers |
425 | 425 | $imgset = array(); |
426 | 426 | $imageMap = explode('#',trim($this->imageParams) ); |
| 427 | + # If this is an image page, store corresponding file info |
| 428 | + $fileData = array(); |
427 | 429 | foreach( $imageMap as $image ) { |
428 | 430 | if( !$image ) |
429 | 431 | continue; |
— | — | @@ -437,6 +439,14 @@ |
438 | 440 | if( is_null($img_title) ) |
439 | 441 | continue; // Page must be valid! |
440 | 442 | |
| 443 | + # Is this parameter for THIS image itself? |
| 444 | + if( $title->equals($img_title) ) { |
| 445 | + $fileData['name'] = $img_title->getDBkey(); |
| 446 | + $fileData['timestamp'] = $timestamp; |
| 447 | + $fileData['sha1'] = $key; |
| 448 | + continue; |
| 449 | + } |
| 450 | + |
441 | 451 | if( $timestamp > $lastImgTime ) |
442 | 452 | $lastImgTime = $timestamp; |
443 | 453 | |
— | — | @@ -536,15 +546,18 @@ |
537 | 547 | |
538 | 548 | # Our review entry |
539 | 549 | $revset = array( |
540 | | - 'fr_rev_id' => $rev->getId(), |
541 | | - 'fr_page_id' => $title->getArticleID(), |
542 | | - 'fr_user' => $wgUser->getId(), |
543 | | - 'fr_timestamp' => $dbw->timestamp( wfTimestampNow() ), |
544 | | - 'fr_comment' => $this->notes, |
545 | | - 'fr_quality' => $quality, |
546 | | - 'fr_tags' => FlaggedRevs::flattenRevisionTags( $flags ), |
547 | | - 'fr_text' => $fulltext, # Store expanded text for speed |
548 | | - 'fr_flags' => $textFlags |
| 550 | + 'fr_rev_id' => $rev->getId(), |
| 551 | + 'fr_page_id' => $title->getArticleID(), |
| 552 | + 'fr_user' => $wgUser->getId(), |
| 553 | + 'fr_timestamp' => $dbw->timestamp( wfTimestampNow() ), |
| 554 | + 'fr_comment' => $this->notes, |
| 555 | + 'fr_quality' => $quality, |
| 556 | + 'fr_tags' => FlaggedRevs::flattenRevisionTags( $flags ), |
| 557 | + 'fr_text' => $fulltext, # Store expanded text for speed |
| 558 | + 'fr_flags' => $textFlags, |
| 559 | + 'fr_img_name' => $fileData ? $fileData['name'] : null, |
| 560 | + 'fr_img_timestamp' => $fileData ? $fileData['timestamp'] : null, |
| 561 | + 'fr_img_sha1' => $fileData ? $fileData['sha1'] : null |
549 | 562 | ); |
550 | 563 | |
551 | 564 | # Update flagged revisions table |
Index: trunk/extensions/FlaggedRevs/FlaggedRevision.php |
— | — | @@ -13,6 +13,9 @@ |
14 | 14 | private $mUser; |
15 | 15 | private $mTitle; |
16 | 16 | private $mRevision; |
| 17 | + private $mFileName; |
| 18 | + private $mFileSha1; |
| 19 | + private $mFileTimestamp; |
17 | 20 | |
18 | 21 | /** |
19 | 22 | * @param Title $title |
— | — | @@ -27,6 +30,9 @@ |
28 | 31 | $this->mComment = $row->fr_comment; |
29 | 32 | $this->mQuality = intval( $row->fr_quality ); |
30 | 33 | $this->mTags = FlaggedRevs::expandRevisionTags( strval($row->fr_tags) ); |
| 34 | + $this->mFileName = $row->fr_img_name ? $row->fr_img_name : null; |
| 35 | + $this->mFileSha1 = $row->fr_img_sha1 ? $row->fr_img_sha1 : null; |
| 36 | + $this->mFileTimestamp = $row->fr_img_timestamp ? $row->fr_img_timestamp : null; |
31 | 37 | # Optional fields |
32 | 38 | $this->mUser = isset($row->fr_user) ? $row->fr_user : 0; |
33 | 39 | $this->mFlags = isset($row->fr_flags) ? explode(',',$row->fr_flags) : null; |
— | — | @@ -34,6 +40,11 @@ |
35 | 41 | # Deal with as it comes |
36 | 42 | $this->mText = null; |
37 | 43 | } |
| 44 | + |
| 45 | + public static function selectFields() { |
| 46 | + return array('fr_rev_id','fr_page_id','fr_user','fr_timestamp','fr_comment','fr_quality','fr_tags', |
| 47 | + 'fr_img_name', 'fr_img_sha1', 'fr_img_timestamp'); |
| 48 | + } |
38 | 49 | |
39 | 50 | /** |
40 | 51 | * @returns Integer revision ID |
— | — | @@ -118,6 +129,30 @@ |
119 | 130 | } |
120 | 131 | |
121 | 132 | /** |
| 133 | + * @returns string, filename accosciated with this revision. |
| 134 | + * This returns NULL for non-image page revisions. |
| 135 | + */ |
| 136 | + public function getFileName() { |
| 137 | + return $this->mFileName; |
| 138 | + } |
| 139 | + |
| 140 | + /** |
| 141 | + * @returns string, sha1 key accosciated with this revision. |
| 142 | + * This returns NULL for non-image page revisions. |
| 143 | + */ |
| 144 | + public function getFileSha1() { |
| 145 | + return $this->mFileSha1; |
| 146 | + } |
| 147 | + |
| 148 | + /** |
| 149 | + * @returns string, timestamp accosciated with this revision. |
| 150 | + * This returns NULL for non-image page revisions. |
| 151 | + */ |
| 152 | + public function getFileTimestamp() { |
| 153 | + return $this->mFileTimestamp; |
| 154 | + } |
| 155 | + |
| 156 | + /** |
122 | 157 | * @returns bool |
123 | 158 | */ |
124 | 159 | public function userCanSetFlags() { |