Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -428,7 +428,7 @@ |
429 | 429 | * @returns string |
430 | 430 | * Generates a review box using a table using addTagRatings() |
431 | 431 | */ |
432 | | - function prettyRatingBox( $tfrev, $flags, $revs_since, $simpleTag=false ) { |
| 432 | + public function prettyRatingBox( $tfrev, $flags, $revs_since, $simpleTag=false ) { |
433 | 433 | global $wgLang, $wgUser; |
434 | 434 | |
435 | 435 | $box = ''; |
— | — | @@ -620,7 +620,6 @@ |
621 | 621 | // Only trigger on article view for content pages, not for protect/delete/hist |
622 | 622 | if( !$article || !$article->exists() || !$article->mTitle->isContentPage() || $action !='view' ) |
623 | 623 | return true; |
624 | | - |
625 | 624 | // User must have review rights |
626 | 625 | if( !$wgUser->isAllowed( 'review' ) ) |
627 | 626 | return true; |
— | — | @@ -630,9 +629,8 @@ |
631 | 630 | if( $parserOutput ) { |
632 | 631 | // Clear older, incomplete, cached versions |
633 | 632 | // We need the IDs of templates and timestamps of images used |
634 | | - if( !isset($parserOutput->mTemplateIds) || !isset($parserOutput->mImageTimestamps) ) { |
| 633 | + if( !isset($parserOutput->mTemplateIds) || !isset($parserOutput->mImageSHA1Keys) ) |
635 | 634 | $article->mTitle->invalidateCache(); |
636 | | - } |
637 | 635 | } |
638 | 636 | return true; |
639 | 637 | } |
— | — | @@ -707,7 +705,10 @@ |
708 | 706 | wfProfileOut( $fname ); |
709 | 707 | return true; |
710 | 708 | } |
711 | | - |
| 709 | + |
| 710 | + /** |
| 711 | + * Select the desired templates based on the selected stable revision IDs |
| 712 | + */ |
712 | 713 | static function parserFetchStableTemplate( $parser, $title, &$skip, &$id ) { |
713 | 714 | // Trigger for stable version parsing only |
714 | 715 | if( !isset($parser->isStable) || !$parser->isStable ) |
— | — | @@ -719,7 +720,7 @@ |
720 | 721 | array('ft_rev_id' => $parser->mRevisionId, |
721 | 722 | 'ft_namespace' => $title->getNamespace(), 'ft_title' => $title->getDBkey() ), |
722 | 723 | __METHOD__ ); |
723 | | - |
| 724 | + |
724 | 725 | if( !$id ) { |
725 | 726 | if( $id === false ) |
726 | 727 | $parser->includesMatched = false; // May want to give an error |
— | — | @@ -728,12 +729,14 @@ |
729 | 730 | } |
730 | 731 | return true; |
731 | 732 | } |
732 | | - |
| 733 | + |
| 734 | + /** |
| 735 | + * Select the desired images based on the selected stable revision times/SHA-1s |
| 736 | + */ |
733 | 737 | static function parserMakeStableImageLink( $parser, $nt, &$skip, &$time ) { |
734 | 738 | // Trigger for stable version parsing only |
735 | 739 | if( !isset($parser->isStable) || !$parser->isStable ) |
736 | 740 | return true; |
737 | | - |
738 | 741 | // Only called to make fr_text, right after template/image specifiers |
739 | 742 | // are added to the DB. Slaves may not have it yet... |
740 | 743 | $dbw = wfGetDB( DB_MASTER ); |
— | — | @@ -749,7 +752,10 @@ |
750 | 753 | } |
751 | 754 | return true; |
752 | 755 | } |
753 | | - |
| 756 | + |
| 757 | + /** |
| 758 | + * Select the desired images based on the selected stable revision times/SHA-1s |
| 759 | + */ |
754 | 760 | static function galleryFindStableFileTime( $ig, $nt, &$time ) { |
755 | 761 | // Trigger for stable version parsing only |
756 | 762 | if( !isset($ig->isStable) || !$ig->isStable ) |
— | — | @@ -763,7 +769,10 @@ |
764 | 770 | |
765 | 771 | return true; |
766 | 772 | } |
767 | | - |
| 773 | + |
| 774 | + /** |
| 775 | + * Flag of an image galley as stable |
| 776 | + */ |
768 | 777 | static function parserMakeGalleryStable( $parser, $ig ) { |
769 | 778 | // Trigger for stable version parsing only |
770 | 779 | if( !isset($parser->isStable) || !$parser->isStable ) |
— | — | @@ -773,25 +782,32 @@ |
774 | 783 | |
775 | 784 | return true; |
776 | 785 | } |
777 | | - |
| 786 | + |
| 787 | + /** |
| 788 | + * Insert image timestamps/SHA-1 keys into parser output |
| 789 | + */ |
778 | 790 | static function parserInjectImageTimestamps( $parser, &$text ) { |
779 | | - $parser->mOutput->mImageTimestamps = array(); |
| 791 | + $parser->mOutput->mImageSHA1Keys = array(); |
780 | 792 | # Fetch the timestamps of the images |
781 | 793 | if( !empty($parser->mOutput->mImages) ) { |
782 | 794 | $dbr = wfGetDB( DB_SLAVE ); |
783 | | - $res = $dbr->select('image', array('img_name','img_timestamp'), |
| 795 | + $res = $dbr->select('image', array('img_name','img_timestamp','img_sha1'), |
784 | 796 | array('img_name IN(' . $dbr->makeList( array_keys($parser->mOutput->mImages) ) . ')'), |
785 | | - __METHOD__ ); |
| 797 | + __METHOD__ ); |
786 | 798 | |
787 | 799 | while( $row = $dbr->fetchObject($res) ) { |
788 | | - $parser->mOutput->mImageTimestamps[$row->img_name] = $row->img_timestamp; |
| 800 | + $parser->mOutput->mImageSHA1Keys[$row->img_name] = array(); |
| 801 | + $parser->mOutput->mImageSHA1Keys[$row->img_name][$row->img_timestamp] = $row->img_sha1; |
789 | 802 | } |
790 | 803 | } |
791 | 804 | return true; |
792 | 805 | } |
793 | | - |
| 806 | + |
| 807 | + /** |
| 808 | + * Insert image timestamps/SHA-1s into page output |
| 809 | + */ |
794 | 810 | static function outputInjectImageTimestamps( $out, $parserOutput ) { |
795 | | - $out->mImageTimestamps = $parserOutput->mImageTimestamps; |
| 811 | + $out->mImageSHA1Keys = $parserOutput->mImageSHA1Keys; |
796 | 812 | |
797 | 813 | return true; |
798 | 814 | } |
— | — | @@ -802,7 +818,6 @@ |
803 | 819 | */ |
804 | 820 | public static function injectReviewDiffURLParams( $article, &$sectionanchor, &$extraq ) { |
805 | 821 | global $wgReviewChangesAfterEdit, $wgFlaggedRevs, $wgUser; |
806 | | - |
807 | 822 | # Was this already autoreviewed? |
808 | 823 | if( $wgFlaggedRevs->skipReviewDiff ) |
809 | 824 | return true; |
— | — | @@ -932,12 +947,15 @@ |
933 | 948 | } |
934 | 949 | } |
935 | 950 | # Image -> timestamp mapping |
936 | | - foreach( $poutput->mImageTimestamps as $dbkey => $timestamp ) { |
937 | | - $imgset[] = array( |
938 | | - 'fi_rev_id' => $rev->getId(), |
939 | | - 'fi_name' => $dbkey, |
940 | | - 'fi_img_timestamp' => $timestamp |
941 | | - ); |
| 951 | + foreach( $poutput->mImageTimestamps as $dbkey => $timeAndSHA1 ) { |
| 952 | + foreach( $timeAndSHA1 as $time => $sha1 ) { |
| 953 | + $imgset[] = array( |
| 954 | + 'fi_rev_id' => $rev->getId(), |
| 955 | + 'fi_name' => $img_title->getDBKey(), |
| 956 | + 'fi_img_timestamp' => $timestamp, |
| 957 | + 'fr_img_sha1' => $sha1 |
| 958 | + ); |
| 959 | + } |
942 | 960 | } |
943 | 961 | |
944 | 962 | $dbw = wfGetDB( DB_MASTER ); |
— | — | @@ -1515,14 +1533,14 @@ |
1516 | 1534 | $form .= $options; |
1517 | 1535 | $form .= "</select>\n"; |
1518 | 1536 | } |
1519 | | - if( $wgFlaggedRevComments ) { |
| 1537 | + if( $wgFlaggedRevComments && $wgUser->isAllowed( 'validate' ) ) { |
1520 | 1538 | $form .= "<br/><p>" . wfMsgHtml( 'revreview-notes' ) . "</p>" . |
1521 | 1539 | "<p><textarea tabindex='1' name='wpNotes' id='wpNotes' rows='2' cols='80' style='width:100%'></textarea>" . |
1522 | 1540 | "</p>\n"; |
1523 | 1541 | } |
1524 | 1542 | |
1525 | 1543 | $imageParams = $templateParams = ''; |
1526 | | - if( !isset($out->mTemplateIds) || !isset($out->mImageTimestamps) ) { |
| 1544 | + if( !isset($out->mTemplateIds) || !isset($out->mImageSHA1Keys) ) { |
1527 | 1545 | return; // something went terribly wrong... |
1528 | 1546 | } |
1529 | 1547 | // Hack, add NS:title -> rev ID mapping |
— | — | @@ -1534,17 +1552,20 @@ |
1535 | 1553 | } |
1536 | 1554 | $form .= Xml::hidden( 'templateParams', $templateParams ) . "\n"; |
1537 | 1555 | // Hack, image -> timestamp mapping |
1538 | | - foreach( $out->mImageTimestamps as $dbkey => $timestamp ) { |
1539 | | - $imageParams .= $dbkey . "|" . $timestamp . "#"; |
| 1556 | + foreach( $out->mImageSHA1Keys as $dbkey => $timeAndSHA1 ) { |
| 1557 | + foreach( $timeAndSHA1 as $time => $sha1 ) { |
| 1558 | + $imageParams .= $dbkey . "|" . $time . "#" . $sha1 . "#"; |
| 1559 | + } |
1540 | 1560 | } |
1541 | | - $form .= Xml::hidden( 'imageParams', $imageParams ) . "\n"; |
| 1561 | + $form .= Xml::hidden( 'imageParams', $imageParams ) . "\n"; |
1542 | 1562 | |
1543 | 1563 | $watchLabel = wfMsgExt('watchthis', array('parseinline')); |
1544 | 1564 | $watchAttribs = array('accesskey' => wfMsg( 'accesskey-watch' ), 'id' => 'wpWatchthis'); |
1545 | 1565 | $watchChecked = ( $wgFlaggedRevsWatch && $wgUser->getOption( 'watchdefault' ) || $wgTitle->userIsWatching() ); |
| 1566 | + // Not much to say unless you are a validator |
| 1567 | + if( $wgUser->isAllowed( 'validate' ) ) |
| 1568 | + $form .= "<p>".wfInputLabel( wfMsgHtml( 'revreview-log' ), 'wpReason', 'wpReason', 60 )."</p>\n"; |
1546 | 1569 | |
1547 | | - $form .= "<p>".wfInputLabel( wfMsgHtml( 'revreview-log' ), 'wpReason', 'wpReason', 60 )."</p>\n"; |
1548 | | - |
1549 | 1570 | $form .= "<p> ".Xml::check( 'wpWatchthis', $watchChecked, $watchAttribs ); |
1550 | 1571 | $form .= " <label for='wpWatchthis'".$skin->tooltipAndAccesskey('watch').">{$watchLabel}</label>"; |
1551 | 1572 | |
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage_body.php |
— | — | @@ -58,9 +58,11 @@ |
59 | 59 | $this->templateParams = $wgRequest->getVal( 'templateParams' ); |
60 | 60 | $this->imageParams = $wgRequest->getVal( 'imageParams' ); |
61 | 61 | // Log comment |
62 | | - $this->comment = $wgRequest->getText( 'wpReason' ); |
63 | | - // Additional notes |
64 | | - $this->notes = $wgFlaggedRevs->allowComments() ? $wgRequest->getText('wpNotes') : ''; |
| 62 | + $this->comment = $wgUser->isAllowed('validate') ? |
| 63 | + $wgRequest->getText( 'wpReason' ) : ''; |
| 64 | + // Additional notes (displayed at bottom of page) |
| 65 | + $this->notes = ($wgFlaggedRevs->allowComments() && $wgUser->isAllowed('validate')) ? |
| 66 | + $wgRequest->getText('wpNotes') : ''; |
65 | 67 | // Get the revision's current flags, if any |
66 | 68 | $this->oflags = $wgFlaggedRevs->getFlagsForRevision( $this->oldid ); |
67 | 69 | // Get our accuracy/quality dimensions |
— | — | @@ -160,9 +162,6 @@ |
161 | 163 | $formradios[$tag][] = array( "revreview-$tag-$i", "wp$tag", $i ); |
162 | 164 | } |
163 | 165 | } |
164 | | - $items = array( |
165 | | - wfInputLabel( wfMsgHtml( 'revreview-log' ), 'wpReason', 'wpReason', 60 ), |
166 | | - wfSubmitButton( wfMsgHtml( 'revreview-submit' ) ) ); |
167 | 166 | $hidden = array( |
168 | 167 | wfHidden( 'wpEditToken', $wgUser->editToken() ), |
169 | 168 | wfHidden( 'target', $this->page->getPrefixedText() ), |
— | — | @@ -193,15 +192,17 @@ |
194 | 193 | } |
195 | 194 | $form .= '</tr></table></fieldset>'; |
196 | 195 | // Add box to add live notes to a flagged revision |
197 | | - if( $wgFlaggedRevComments ) { |
| 196 | + if( $wgFlaggedRevComments && $wgUser->isAllowed( 'validate' ) ) { |
198 | 197 | $form .= "<fieldset><legend>" . wfMsgHtml( 'revreview-notes' ) . "</legend>" . |
199 | 198 | "<textarea tabindex='1' name='wpNotes' id='wpNotes' rows='3' cols='80' style='width:100%'>$this->notes</textarea>" . |
200 | 199 | "</fieldset>"; |
201 | 200 | } |
| 201 | + // Not much to say unless you are a validator |
| 202 | + if( $wgUser->isAllowed( 'validate' ) ) |
| 203 | + $form .= '<p>'.wfInputLabel( wfMsgHtml( 'revreview-log' ), 'wpReason', 'wpReason', 60 ).'</p>'; |
202 | 204 | |
203 | | - foreach( $items as $item ) { |
204 | | - $form .= '<p>' . $item . '</p>'; |
205 | | - } |
| 205 | + $form .= '<p>'.wfSubmitButton( wfMsgHtml( 'revreview-submit' ) ).'</p>'; |
| 206 | + |
206 | 207 | foreach( $hidden as $item ) { |
207 | 208 | $form .= $item; |
208 | 209 | } |
— | — | @@ -328,22 +329,25 @@ |
329 | 330 | $imageMap = explode('#',trim($this->imageParams) ); |
330 | 331 | foreach( $imageMap as $image ) { |
331 | 332 | if( !$image ) continue; |
332 | | - $m = explode('|',$image,2); |
| 333 | + $m = explode('|',$image,3); |
| 334 | + # Expand our parameters ... <name>#<timestamp>#<key> |
| 335 | + if( !isset($m[0]) || !isset($m[1]) || !isset($m[2]) || !$m[0] ) |
| 336 | + continue; |
333 | 337 | |
334 | | - if( !isset($m[0]) || !isset($m[1]) || !$m[0] ) continue; |
| 338 | + list($dbkey,$timestamp,$key) = $m; |
335 | 339 | |
336 | | - list($dbkey,$timestamp) = $m; |
| 340 | + if( in_array($dbkey,$images) ) continue; // No dups! |
337 | 341 | |
338 | | - if( in_array($dbkey,$images) ) continue; // No dups! |
339 | 342 | $images[] = $dbkey; |
340 | 343 | |
341 | | - $img_title = Title::makeTitle( NS_IMAGE, $dbkey ); // Normalize this to be sure... |
| 344 | + $img_title = Title::makeTitle( NS_IMAGE, $dbkey ); // Normalize |
342 | 345 | if( is_null($img_title) ) continue; // Page must exist! |
343 | 346 | |
344 | 347 | $imgset[] = array( |
345 | 348 | 'fi_rev_id' => $rev->getId(), |
346 | 349 | 'fi_name' => $img_title->getDBKey(), |
347 | | - 'fi_img_timestamp' => $timestamp |
| 350 | + 'fi_img_timestamp' => $timestamp, |
| 351 | + 'fr_img_sha1' => $key |
348 | 352 | ); |
349 | 353 | } |
350 | 354 | |
— | — | @@ -813,4 +817,3 @@ |
814 | 818 | return( "{$link} {$stxt}" ); |
815 | 819 | } |
816 | 820 | } |
817 | | - |