Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -495,10 +495,11 @@ |
496 | 496 | global $wgUser; |
497 | 497 | // Only trigger on article view for content pages, not for protect/delete/hist |
498 | 498 | if( !$article || !$article->exists() || !$article->mTitle->isContentPage() || $action !='view' ) |
499 | | - return; |
| 499 | + return true; |
500 | 500 | |
501 | | - // User must have review rights |
502 | | - if( !$wgUser->isAllowed( 'review' ) ) return; |
| 501 | + // User must have review rightss |
| 502 | + if( !$wgUser->isAllowed( 'review' ) ) |
| 503 | + return true; |
503 | 504 | |
504 | 505 | $parserOutput = $parserCache->get( $article, $wgUser ); |
505 | 506 | if( $parserOutput ) { |
— | — | @@ -539,7 +540,8 @@ |
540 | 541 | $fname = 'FlaggedRevs::extraLinksUpdate'; |
541 | 542 | wfProfileIn( $fname ); |
542 | 543 | |
543 | | - if( !$title->isContentPage() ) return; |
| 544 | + if( !$title->isContentPage() ) |
| 545 | + return true; |
544 | 546 | # Check if this page has a stable version |
545 | 547 | $sv = self::getOverridingPageRev( $title ); |
546 | 548 | if( !$sv ) return; |
— | — | @@ -608,7 +610,8 @@ |
609 | 611 | |
610 | 612 | static function parserFetchStableTemplate( &$parser, &$title, &$skip, &$id ) { |
611 | 613 | // Trigger for stable version parsing only |
612 | | - if( !isset($parser->isStable) || !$parser->isStable ) return; |
| 614 | + if( !isset($parser->isStable) || !$parser->isStable ) |
| 615 | + return true; |
613 | 616 | |
614 | 617 | $dbr = wfGetDB( DB_SLAVE ); |
615 | 618 | $id = $dbr->selectField('flaggedtemplates', 'ft_tmp_rev_id', |
— | — | @@ -631,7 +634,8 @@ |
632 | 635 | |
633 | 636 | static function parserMakeStableImageLink( &$parser, &$nt, &$skip, &$time ) { |
634 | 637 | // Trigger for stable version parsing only |
635 | | - if( !isset($parser->isStable) || !$parser->isStable ) return; |
| 638 | + if( !isset($parser->isStable) || !$parser->isStable ) |
| 639 | + return true; |
636 | 640 | |
637 | 641 | $dbr = wfGetDB( DB_SLAVE ); |
638 | 642 | $time = $dbr->selectField('flaggedimages', 'fi_img_timestamp', |
— | — | @@ -652,7 +656,8 @@ |
653 | 657 | |
654 | 658 | static function galleryFindStableFileTime( &$ig, &$nt, &$time ) { |
655 | 659 | // Trigger for stable version parsing only |
656 | | - if( !isset($ig->isStable) || !$ig->isStable ) return; |
| 660 | + if( !isset($ig->isStable) || !$ig->isStable ) |
| 661 | + return true; |
657 | 662 | |
658 | 663 | $dbr = wfGetDB( DB_SLAVE ); |
659 | 664 | $time = $dbr->selectField('flaggedimages', 'fi_img_timestamp', |
— | — | @@ -663,7 +668,8 @@ |
664 | 669 | |
665 | 670 | static function parserMakeGalleryStable( &$parser, &$ig ) { |
666 | 671 | // Trigger for stable version parsing only |
667 | | - if( !isset($parser->isStable) || !$parser->isStable ) return; |
| 672 | + if( !isset($parser->isStable) || !$parser->isStable ) |
| 673 | + return true; |
668 | 674 | |
669 | 675 | $ig->isStable = true; |
670 | 676 | } |
— | — | @@ -694,14 +700,16 @@ |
695 | 701 | public static function autoPromoteUser( &$article, &$user, &$text, &$summary, &$isminor, &$iswatch, &$section ) { |
696 | 702 | global $wgUser, $wgFlaggedRevsAutopromote; |
697 | 703 | |
698 | | - if( !$wgFlaggedRevsAutopromote ) return; |
699 | | - |
| 704 | + if( !$wgFlaggedRevsAutopromote ) |
| 705 | + return true; |
| 706 | + // Grab current groups |
700 | 707 | $groups = $user->getGroups(); |
701 | 708 | $now = time(); |
702 | 709 | $usercreation = wfTimestamp(TS_UNIX,$user->mRegistration); |
703 | 710 | $userage = floor(($now-$usercreation) / 86400); |
704 | 711 | // Do not give this to bots |
705 | | - if( in_array( 'bot', $groups ) ) return; |
| 712 | + if( in_array( 'bot', $groups ) ) |
| 713 | + return true; |
706 | 714 | // Check if we need to promote... |
707 | 715 | $vars = $wgFlaggedRevsAutopromote; |
708 | 716 | if( !in_array('editor',$groups) && $userage >= $vars['days'] && $user->getEditCount() >= $vars['edits'] |
— | — | @@ -729,7 +737,7 @@ |
730 | 738 | /** |
731 | 739 | * Do the current URL params allow for overriding by stable revisions? |
732 | 740 | */ |
733 | | - function pageOverride() { |
| 741 | + static function pageOverride() { |
734 | 742 | global $wgTitle, $wgFlaggedRevsAnonOnly, $wgFlaggedRevsOverride, $wgUser, $wgRequest, $action; |
735 | 743 | // This only applies to viewing content pages |
736 | 744 | if( $action !='view' || !$wgTitle->isContentPage() ) return; |
— | — | @@ -761,7 +769,8 @@ |
762 | 770 | // Grab page and rev ids |
763 | 771 | $pageid = $article->getId(); |
764 | 772 | $revid = $article->mRevision ? $article->mRevision->mId : $article->getLatest(); |
765 | | - if( !$revid ) return; |
| 773 | + if( !$revid ) |
| 774 | + return true; |
766 | 775 | |
767 | 776 | $vis_id = $revid; |
768 | 777 | $tag = ''; $notes = ''; |
— | — | @@ -864,7 +873,8 @@ |
865 | 874 | $revid = $editform->mArticle->getLatest(); |
866 | 875 | } |
867 | 876 | // Grab the ratings for this revision if any |
868 | | - if( !$revid ) return; |
| 877 | + if( !$revid ) |
| 878 | + return true; |
869 | 879 | // Set new body html text as that of now |
870 | 880 | $tag = ''; |
871 | 881 | // Check the newest stable version |
— | — | @@ -890,44 +900,48 @@ |
891 | 901 | global $wgArticle, $action; |
892 | 902 | |
893 | 903 | if( !$wgArticle || !$wgArticle->exists() || !$wgArticle->mTitle->isContentPage() || $action !='view' ) |
894 | | - return; |
| 904 | + return true; |
895 | 905 | // Check if page is protected |
896 | 906 | if( !$wgArticle->mTitle->quickUserCan( 'edit' ) ) { |
897 | | - return; |
| 907 | + return true; |
898 | 908 | } |
899 | 909 | // Get revision ID |
900 | 910 | $revId = ( $wgArticle->mRevision ) ? $wgArticle->mRevision->mId : $wgArticle->getLatest(); |
901 | 911 | // We cannot review deleted revisions |
902 | 912 | if( is_object($wgArticle->mRevision) && $wgArticle->mRevision->mDeleted ) |
903 | | - return; |
| 913 | + return true; |
904 | 914 | // Add quick review links IF we did not override, otherwise, they might |
905 | 915 | // review a revision that parses out newer templates/images than what they saw. |
906 | 916 | // Revisions are always reviewed based on current templates/images. |
907 | 917 | if( $this->pageOverride() ) { |
908 | 918 | $tfrev = $this->getOverridingRev(); |
909 | | - if( $tfrev ) return; |
| 919 | + if( $tfrev ) return true; |
910 | 920 | } |
911 | 921 | $this->addQuickReview( $revId, $out, false ); |
912 | 922 | } |
913 | 923 | |
914 | | - function setPermaLink( &$sktmp, &$nav_urls, &$oldid, &$revid ) { |
915 | | - global $wgTitle; |
| 924 | + function setPermaLink( &$sktmp, &$nav_urls, &$revid, &$revid ) { |
916 | 925 | // Non-content pages cannot be validated |
917 | | - if( !$wgTitle->isContentPage() || !$this->pageOverride() ) return; |
| 926 | + if( !$this->pageOverride() ) return true; |
918 | 927 | // Check for an overridabe revision |
919 | 928 | $tfrev = $this->getOverridingRev(); |
920 | | - if( !$tfrev ) return; |
| 929 | + if( !$tfrev ) |
| 930 | + return true; |
921 | 931 | // Replace "permalink" with an actual permanent link |
922 | 932 | $nav_urls['permalink'] = array( |
923 | 933 | 'text' => wfMsg( 'permalink' ), |
924 | 934 | 'href' => $sktmp->makeSpecialUrl( 'Stableversions', "oldid={$tfrev->fr_rev_id}" ) |
925 | 935 | ); |
| 936 | + |
| 937 | + global $wgHooks; |
926 | 938 | // Are we using the popular cite extension? |
927 | | - if( isset($nav_urls['cite']) ) { |
928 | | - $nav_urls['cite'] = array( |
929 | | - 'text' => wfMsg( 'cite_article_link' ), |
930 | | - 'href' => $sktmp->makeSpecialUrl( 'Cite', "page=" . wfUrlencode( "{$sktmp->thispage}" ) . "&id={$tfrev->fr_rev_id}" ) |
931 | | - ); |
| 939 | + if( in_array('wfSpecialCiteNav',$wgHooks['SkinTemplateBuildNavUrlsNav_urlsAfterPermalink']) ) { |
| 940 | + if( $sktmp->mTitle->getNamespace() === NS_MAIN && $revid !== 0 ) { |
| 941 | + $nav_urls['cite'] = array( |
| 942 | + 'text' => wfMsg( 'cite_article_link' ), |
| 943 | + 'href' => $sktmp->makeSpecialUrl( 'Cite', "page=" . wfUrlencode( "{$sktmp->thispage}" ) . "&id={$tfrev->fr_rev_id}" ) |
| 944 | + ); |
| 945 | + } |
932 | 946 | } |
933 | 947 | } |
934 | 948 | |
— | — | @@ -936,13 +950,15 @@ |
937 | 951 | // Get the subject page |
938 | 952 | $title = $sktmp->mTitle->getSubjectPage(); |
939 | 953 | // Non-content pages cannot be validated |
940 | | - if( !$title->isContentPage() || !$title->exists() ) return; |
| 954 | + if( !$title->isContentPage() || !$title->exists() ) |
| 955 | + return true; |
941 | 956 | $article = new Article( $title ); |
942 | 957 | // If we are viewing a page normally, and it was overridden, |
943 | 958 | // change the edit tab to a "current revision" tab |
944 | 959 | $tfrev = $this->getOverridingRev( $article ); |
945 | 960 | // No quality revs? Find the last reviewed one |
946 | | - if( !is_object($tfrev) ) return; |
| 961 | + if( !is_object($tfrev) ) |
| 962 | + return true; |
947 | 963 | // Note that revisions may not be set to override for users |
948 | 964 | if( $this->pageOverride() ) { |
949 | 965 | # Remove edit option altogether |
— | — | @@ -1032,7 +1048,37 @@ |
1033 | 1049 | $content_actions = $new_actions; |
1034 | 1050 | } |
1035 | 1051 | } |
1036 | | - |
| 1052 | + |
| 1053 | + function addToPageHist( &$article ) { |
| 1054 | + global $wgUser; |
| 1055 | + |
| 1056 | + $this->pageFlaggedRevs = array(); |
| 1057 | + $rows = $this->getReviewedRevs( $article->getTitle() ); |
| 1058 | + |
| 1059 | + // Try to keep the skin readily accesible, |
| 1060 | + // addToHistLine() will use it |
| 1061 | + $this->skin = $wgUser->getSkin(); |
| 1062 | + |
| 1063 | + if( !$rows ) |
| 1064 | + return true; |
| 1065 | + |
| 1066 | + foreach( $rows as $rev => $quality ) { |
| 1067 | + $this->pageFlaggedRevs[$rev] = $quality; |
| 1068 | + } |
| 1069 | + } |
| 1070 | + |
| 1071 | + function addToHistLine( &$row, &$s ) { |
| 1072 | + global $wgUser; |
| 1073 | + |
| 1074 | + if( isset($this->pageFlaggedRevs) && array_key_exists($row->rev_id,$this->pageFlaggedRevs) ) { |
| 1075 | + $msg = ($this->pageFlaggedRevs[$row->rev_id] >= 1) ? 'hist-quality' : 'hist-stable'; |
| 1076 | + $special = SpecialPage::getTitleFor( 'Stableversions' ); |
| 1077 | + $s .= ' <tt><small><strong>' . |
| 1078 | + $this->skin->makeLinkObj( $special, wfMsgHtml($msg), 'oldid='.$row->rev_id ) . |
| 1079 | + '</strong></small></tt>'; |
| 1080 | + } |
| 1081 | + } |
| 1082 | + |
1037 | 1083 | function addQuickReview( $id=NULL, $out ) { |
1038 | 1084 | global $wgOut, $wgTitle, $wgUser, $wgFlaggedRevsOverride, $wgFlaggedRevComments, $wgFlaggedRevsWatch; |
1039 | 1085 | // User must have review rights |
— | — | @@ -1112,41 +1158,13 @@ |
1113 | 1159 | |
1114 | 1160 | $wgOut->addHTML( '<hr style="clear:both"></hr>' . $form ); |
1115 | 1161 | } |
1116 | | - |
1117 | | - function addToPageHist( &$article ) { |
1118 | | - global $wgUser; |
1119 | | - |
1120 | | - $this->pageFlaggedRevs = array(); |
1121 | | - $rows = $this->getReviewedRevs( $article->getTitle() ); |
1122 | | - |
1123 | | - // Try to keep the skin readily accesible |
1124 | | - $this->skin = $wgUser->getSkin(); |
1125 | | - |
1126 | | - if( !$rows ) return; |
1127 | | - |
1128 | | - foreach( $rows as $rev => $quality ) { |
1129 | | - $this->pageFlaggedRevs[$rev] = $quality; |
1130 | | - } |
1131 | | - } |
1132 | | - |
1133 | | - function addToHistLine( &$row, &$s ) { |
1134 | | - global $wgUser; |
1135 | | - |
1136 | | - if( isset($this->pageFlaggedRevs) && array_key_exists($row->rev_id,$this->pageFlaggedRevs) ) { |
1137 | | - $msg = ($this->pageFlaggedRevs[$row->rev_id] >= 1) ? 'hist-quality' : 'hist-stable'; |
1138 | | - $special = SpecialPage::getTitleFor( 'Stableversions' ); |
1139 | | - $s .= ' <tt><small><strong>' . |
1140 | | - $this->skin->makeLinkObj( $special, wfMsgHtml($msg), 'oldid='.$row->rev_id ) . |
1141 | | - '</strong></small></tt>'; |
1142 | | - } |
1143 | | - } |
1144 | 1162 | |
1145 | 1163 | /** |
1146 | 1164 | * Get latest quality rev, if not, the latest reviewed one |
1147 | 1165 | */ |
1148 | | - function getOverridingRev( $article=NULL ) { |
1149 | | - if( !$row = $this->getLatestQualityRev( $article ) ) { |
1150 | | - if( !$row = $this->getLatestStableRev( $article ) ) { |
| 1166 | + function getOverridingRev() { |
| 1167 | + if( !$row = $this->getLatestQualityRev() ) { |
| 1168 | + if( !$row = $this->getLatestStableRev() ) { |
1151 | 1169 | return null; |
1152 | 1170 | } |
1153 | 1171 | } |
— | — | @@ -1158,16 +1176,10 @@ |
1159 | 1177 | * per the $wgFlaggedRevTags variable |
1160 | 1178 | * This passes rev_deleted revisions |
1161 | 1179 | * This is based on the current article and caches results |
1162 | | - * Accepts an argument because of the fact that the article |
1163 | | - * object for edit mode is part of the editform; insert only |
1164 | | - * the article object for the current page! |
1165 | 1180 | * @output array ( rev, flags ) |
1166 | 1181 | */ |
1167 | | - function getLatestQualityRev( $article=NULL ) { |
1168 | | - global $wgArticle; |
1169 | | - |
1170 | | - $article = $article ? $article : $wgArticle; |
1171 | | - $title = $article->getTitle(); |
| 1182 | + function getLatestQualityRev() { |
| 1183 | + global $wgTitle; |
1172 | 1184 | // Cached results available? |
1173 | 1185 | if( isset($this->stablefound) ) { |
1174 | 1186 | return ( $this->stablefound ) ? $this->stablerev : null; |
— | — | @@ -1179,8 +1191,8 @@ |
1180 | 1192 | $result = $dbr->select( |
1181 | 1193 | array('flaggedrevs', 'revision'), |
1182 | 1194 | array('fr_rev_id', 'fr_user', 'fr_timestamp', 'fr_comment', 'rev_timestamp'), |
1183 | | - array('fr_namespace' => $title->getNamespace(), 'fr_title' => $title->getDBkey(), 'fr_quality >= 1', |
1184 | | - 'fr_rev_id = rev_id', 'rev_page' => $article->getId(), 'rev_deleted = 0'), |
| 1195 | + array('fr_namespace' => $wgTitle->getNamespace(), 'fr_title' => $wgTitle->getDBkey(), 'fr_quality >= 1', |
| 1196 | + 'fr_rev_id = rev_id', 'rev_page' => $wgTitle->getArticleID(), 'rev_deleted = 0'), |
1185 | 1197 | __METHOD__, |
1186 | 1198 | array('ORDER BY' => 'fr_rev_id DESC', 'LIMIT' => 1 ) ); |
1187 | 1199 | wfProfileOut( __METHOD__ ); |
— | — | @@ -1199,17 +1211,12 @@ |
1200 | 1212 | * Get latest flagged revision |
1201 | 1213 | * This passes rev_deleted revisions |
1202 | 1214 | * This is based on the current article and caches results |
1203 | | - * Accepts an argument because of the fact that the article |
1204 | | - * object for edit mode is part of the editform; insert only |
1205 | | - * the article object for the current page! |
1206 | 1215 | * The cache here doesn't make sense for arbitrary articles |
1207 | 1216 | * @output array ( rev, flags ) |
1208 | 1217 | */ |
1209 | | - function getLatestStableRev( $article=NULL ) { |
1210 | | - global $wgArticle; |
| 1218 | + function getLatestStableRev() { |
| 1219 | + global $wgTitle; |
1211 | 1220 | |
1212 | | - $article = $article ? $article : $wgArticle; |
1213 | | - $title = $article->getTitle(); |
1214 | 1221 | // Cached results available? |
1215 | 1222 | if( isset($this->latestfound) ) { |
1216 | 1223 | return ( $this->latestfound ) ? $this->latestrev : NULL; |
— | — | @@ -1220,8 +1227,8 @@ |
1221 | 1228 | $result = $dbr->select( |
1222 | 1229 | array('flaggedrevs', 'revision'), |
1223 | 1230 | array('fr_rev_id', 'fr_user', 'fr_timestamp', 'fr_comment', 'rev_timestamp'), |
1224 | | - array('fr_namespace' => $title->getNamespace(), 'fr_title' => $title->getDBkey(), |
1225 | | - 'fr_rev_id = rev_id', 'rev_page' => $article->getId(), 'rev_deleted = 0'), |
| 1231 | + array('fr_namespace' => $wgTitle->getNamespace(), 'fr_title' => $wgTitle->getDBkey(), |
| 1232 | + 'fr_rev_id = rev_id', 'rev_page' => $wgTitle->getArticleID(), 'rev_deleted = 0'), |
1226 | 1233 | __METHOD__, |
1227 | 1234 | array('ORDER BY' => 'fr_rev_id DESC', 'LIMIT' => 1 ) ); |
1228 | 1235 | wfProfileOut( __METHOD__ ); |
— | — | @@ -1276,19 +1283,18 @@ |
1277 | 1284 | } |
1278 | 1285 | |
1279 | 1286 | // Our class instances |
1280 | | -$flaggedrevs = new FlaggedRevs(); |
1281 | | -$flaggedarticle = new FlaggedArticle(); |
| 1287 | +$flaggedrevs = new FlaggedArticle(); |
1282 | 1288 | // Main hooks, overrides pages content, adds tags, sets tabs and permalink |
1283 | | -$wgHooks['SkinTemplateTabs'][] = array($flaggedarticle, 'setCurrentTab'); |
1284 | | -$wgHooks['ArticleViewHeader'][] = array($flaggedarticle, 'setPageContent'); |
1285 | | -$wgHooks['SkinTemplateBuildNavUrlsNav_urlsAfterPermalink'][] = array($flaggedarticle, 'setPermaLink'); |
| 1289 | +$wgHooks['SkinTemplateTabs'][] = array($flaggedrevs, 'setCurrentTab'); |
| 1290 | +$wgHooks['ArticleViewHeader'][] = array($flaggedrevs, 'setPageContent'); |
| 1291 | +$wgHooks['SkinTemplateBuildNavUrlsNav_urlsAfterPermalink'][] = array($flaggedrevs, 'setPermaLink'); |
1286 | 1292 | // Add tags do edit view |
1287 | | -$wgHooks['EditPage::showEditForm:initial'][] = array($flaggedarticle, 'addToEditView'); |
| 1293 | +$wgHooks['EditPage::showEditForm:initial'][] = array($flaggedrevs, 'addToEditView'); |
1288 | 1294 | // Add review form |
1289 | | -$wgHooks['BeforePageDisplay'][] = array($flaggedarticle, 'addReviewForm'); |
| 1295 | +$wgHooks['BeforePageDisplay'][] = array($flaggedrevs, 'addReviewForm'); |
1290 | 1296 | // Mark of items in page history |
1291 | | -$wgHooks['PageHistoryBeforeList'][] = array($flaggedarticle, 'addToPageHist'); |
1292 | | -$wgHooks['PageHistoryLineEnding'][] = array($flaggedarticle, 'addToHistLine'); |
| 1297 | +$wgHooks['PageHistoryBeforeList'][] = array($flaggedrevs, 'addToPageHist'); |
| 1298 | +$wgHooks['PageHistoryLineEnding'][] = array($flaggedrevs, 'addToHistLine'); |
1293 | 1299 | // Autopromote Editors |
1294 | 1300 | $wgHooks['ArticleSaveComplete'][] = array($flaggedrevs, 'autoPromoteUser'); |
1295 | 1301 | // Update older, incomplete, page caches (ones that lack template Ids/image timestamps) |
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage.i18n.php |
— | — | @@ -33,7 +33,7 @@ |
34 | 34 | [{{fullurl:Special:Log|type=review&page={{FULLPAGENAMEE}}}} approved] on <i>$4</i>. The [{{fullurl:{{FULLPAGENAMEE}}|stable=0}} current revision] |
35 | 35 | is usually [{{fullurl:{{FULLPAGENAMEE}}|action=edit}} editable] and more up to date. There {{plural:$3|is $3 revision|are $3 revisions}} |
36 | 36 | ([{{fullurl:{{FULLPAGENAMEE}}|oldid=$1&diff=$2}} changes]) awaiting review.', |
37 | | - 'revreview-static' => 'This is a [[Help:Article validation|reviewed]] revision of the page \'\'\'[[:$3]]\'\'\', |
| 37 | + 'revreview-static' => 'This is a [[Help:Article validation|reviewed]] revision of \'\'\'[[:$3|this page]]\'\'\', |
38 | 38 | [{{fullurl:Special:Log/review|page=$1}} approved] on <i>$2</i>. The [{{fullurl:$3|stable=0}} current revision] |
39 | 39 | is usually editable and more up to date.', |
40 | 40 | 'revreview-toggle' => '(toggle details)', |