Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -104,7 +104,7 @@ |
105 | 105 | # Autopromote Editors |
106 | 106 | $wgHooks['ArticleSaveComplete'][] = array( $wgFlaggedRevs, 'autoPromoteUser' ); |
107 | 107 | # Adds table link references to include ones from the stable version |
108 | | - $wgHooks['LinksUpdateConstructed'][] = array( $wgFlaggedRevs, 'extraLinksUpdate' ); |
| 108 | + $wgHooks['LinksUpdateConstructed'][] = array( $wgFlaggedArticle, 'extraLinksUpdate' ); |
109 | 109 | # Empty flagged page settings row on delete |
110 | 110 | $wgHooks['ArticleDeleteComplete'][] = array( $wgFlaggedArticle, 'deleteVisiblitySettings' ); |
111 | 111 | # Check on undelete/merge/revisiondelete for changes to stable version |
— | — | @@ -124,7 +124,7 @@ |
125 | 125 | # Page review on edit |
126 | 126 | $wgHooks['ArticleUpdateBeforeRedirect'][] = array($wgFlaggedArticle, 'injectReviewDiffURLParams'); |
127 | 127 | $wgHooks['DiffViewHeader'][] = array($wgFlaggedArticle, 'addDiffNoticeAfterEdit' ); |
128 | | - $wgHooks['DiffViewHeader'][] = array($wgFlaggedRevs, 'addPatrolLink' ); |
| 128 | + $wgHooks['DiffViewHeader'][] = array($wgFlaggedArticle, 'addPatrolLink' ); |
129 | 129 | # Autoreview stuff |
130 | 130 | $wgHooks['ArticleInsertComplete'][] = array( $wgFlaggedArticle, 'maybeMakeNewPageReviewed' ); |
131 | 131 | $wgHooks['ArticleSaveComplete'][] = array( $wgFlaggedArticle, 'maybeMakeEditReviewed' ); |
— | — | @@ -373,7 +373,7 @@ |
374 | 374 | * @param int $rev_id |
375 | 375 | * @param bool $getText, fetch fr_text and fr_flags too? |
376 | 376 | * @return Revision |
377 | | - * Will not return if deleted |
| 377 | + * Will not return a revision if deleted |
378 | 378 | */ |
379 | 379 | public function getFlaggedRev( $title, $rev_id, $getText=false ) { |
380 | 380 | $selectColumns = array('fr_rev_id','fr_user','fr_timestamp','fr_comment','rev_timestamp'); |
— | — | @@ -413,17 +413,6 @@ |
414 | 414 | |
415 | 415 | return $count; |
416 | 416 | } |
417 | | - |
418 | | - /** |
419 | | - * Get latest quality rev, if not, the latest reviewed one. |
420 | | - * @param Title $title, page title |
421 | | - * @param bool $getText, fetch fr_text and fr_flags too? |
422 | | - * @param bool $forUpdate, use master DB and avoid using page_ext_stable? |
423 | | - * @return Row |
424 | | - */ |
425 | | - public function getStableRev( $title, $getText=false, $forUpdate=false ) { |
426 | | - return $this->getStablePageRev( $title, $getText, $forUpdate ); |
427 | | - } |
428 | 417 | |
429 | 418 | /** |
430 | 419 | * Get latest quality rev, if not, the latest reviewed one. |
— | — | @@ -457,7 +446,7 @@ |
458 | 447 | return null; |
459 | 448 | } else { |
460 | 449 | // Get visiblity settings... |
461 | | - $config = $this->getVisibilitySettings( $title, $forUpdate ); |
| 450 | + $config = $this->getPageVisibilitySettings( $title, $forUpdate ); |
462 | 451 | $dbw = wfGetDB( DB_MASTER ); |
463 | 452 | // Look for the latest quality revision |
464 | 453 | if( $config['select'] !== FLAGGED_VIS_LATEST ) { |
— | — | @@ -488,16 +477,6 @@ |
489 | 478 | } |
490 | 479 | return $row; |
491 | 480 | } |
492 | | - |
493 | | - /** |
494 | | - * Get visiblity restrictions on page |
495 | | - * @param Title $title, page title |
496 | | - * @param bool $forUpdate, use master DB? |
497 | | - * @returns Array |
498 | | - */ |
499 | | - public function getVisibilitySettings( $title, $forUpdate=false ) { |
500 | | - return $this->getPageVisibilitySettings( $title, $forUpdate ); |
501 | | - } |
502 | 481 | |
503 | 482 | /** |
504 | 483 | * Get visiblity restrictions on page |
— | — | @@ -525,15 +504,6 @@ |
526 | 505 | * @param int $rev_id |
527 | 506 | * @return Array |
528 | 507 | */ |
529 | | - public function getFlagsForRevision( $rev_id ) { |
530 | | - return $this->getRevisionTags( $rev_id ); |
531 | | - } |
532 | | - |
533 | | - /** |
534 | | - * Get flags for a revision |
535 | | - * @param int $rev_id |
536 | | - * @return Array |
537 | | - */ |
538 | 508 | public function getRevisionTags( $rev_id ) { |
539 | 509 | # Set all flags to zero |
540 | 510 | $flags = array(); |
— | — | @@ -604,7 +574,7 @@ |
605 | 575 | * @param Title, $title |
606 | 576 | * @return bool |
607 | 577 | */ |
608 | | - public function isReviewable( $title ) { |
| 578 | + public function isPageReviewable( $title ) { |
609 | 579 | global $wgFlaggedRevsNamespaces; |
610 | 580 | |
611 | 581 | return ( in_array($title->getNamespace(),$wgFlaggedRevsNamespaces) |
— | — | @@ -899,10 +869,10 @@ |
900 | 870 | public function extraLinksUpdate( $linksUpdate ) { |
901 | 871 | wfProfileIn( __METHOD__ ); |
902 | 872 | |
903 | | - if( !$this->isReviewable( $linksUpdate->mTitle ) ) |
| 873 | + if( !$this->isPageReviewable( $linksUpdate->mTitle ) ) |
904 | 874 | return true; |
905 | 875 | # Check if this page has a stable version |
906 | | - $sv = $this->getStableRev( $linksUpdate->mTitle, true, true ); |
| 876 | + $sv = $this->getStablePageRev( $linksUpdate->mTitle, true, true ); |
907 | 877 | if( !$sv ) |
908 | 878 | return true; |
909 | 879 | # Parse the revision |
— | — | @@ -1043,9 +1013,9 @@ |
1044 | 1014 | * Add a link to patrol non-reviewable pages |
1045 | 1015 | */ |
1046 | 1016 | public function addPatrolLink( $diff, $OldRev, $NewRev ) { |
1047 | | - global $wgUser, $wgOut, $wgFlaggedRevs; |
| 1017 | + global $wgUser, $wgOut; |
1048 | 1018 | |
1049 | | - if( $wgFlaggedRevs->isReviewable( $NewRev->getTitle() ) ) |
| 1019 | + if( $this->isPageReviewable( $NewRev->getTitle() ) ) |
1050 | 1020 | return true; |
1051 | 1021 | // Prepare a change patrol link, if applicable |
1052 | 1022 | if( $wgUser->isAllowed( 'patrolother' ) ) { |
— | — | @@ -1108,7 +1078,7 @@ |
1109 | 1079 | $prev_id = $article->mTitle->getPreviousRevisionID( $rev->getID() ); |
1110 | 1080 | if( !$prev_id ) |
1111 | 1081 | return true; |
1112 | | - $frev = $this->getStableRev( $article->mTitle ); |
| 1082 | + $frev = $this->getStablePageRev( $article->mTitle ); |
1113 | 1083 | # Is this an edit directly to the stable version? |
1114 | 1084 | if( is_null($frev) || $prev_id != $frev->fr_rev_id ) |
1115 | 1085 | return true; |
— | — | @@ -1135,7 +1105,7 @@ |
1136 | 1106 | if( $action != 'move' ) |
1137 | 1107 | return true; |
1138 | 1108 | # See if there is a stable version |
1139 | | - $frev = $this->getStableRev( $title ); |
| 1109 | + $frev = $this->getStablePageRev( $title ); |
1140 | 1110 | if( !$frev ) |
1141 | 1111 | return true; |
1142 | 1112 | # Allow for only editors/reviewers to move this |
— | — | @@ -1154,12 +1124,12 @@ |
1155 | 1125 | * are autopatrolled. |
1156 | 1126 | */ |
1157 | 1127 | public function autoMarkPatrolled( $article, $user, $text, $c, $m, $a, $b, $flags, $rev ) { |
1158 | | - global $wgUser, $wgFlaggedRevs; |
| 1128 | + global $wgUser; |
1159 | 1129 | |
1160 | 1130 | if( !$rev ) |
1161 | 1131 | return true; |
1162 | 1132 | |
1163 | | - if( !$wgFlaggedRevs->isReviewable( $article->getTitle() ) && $wgUser->isAllowed('patrolother') ) { |
| 1133 | + if( !$this->isPageReviewable( $article->getTitle() ) && $wgUser->isAllowed('patrolother') ) { |
1164 | 1134 | $dbw = wfGetDB( DB_MASTER ); |
1165 | 1135 | $dbw->update( 'recentchanges', |
1166 | 1136 | array( 'rc_patrolled' => 1 ), |
— | — | @@ -1292,7 +1262,7 @@ |
1293 | 1263 | # Only trigger on article view for content pages, not for protect/delete/hist |
1294 | 1264 | if( $action !='view' || !$wgUser->isAllowed( 'review' ) ) |
1295 | 1265 | return true; |
1296 | | - if( !$article || !$article->exists() || !$this->isReviewable( $article->mTitle ) ) |
| 1266 | + if( !$article || !$article->exists() || !$this->isPageReviewable( $article->mTitle ) ) |
1297 | 1267 | return true; |
1298 | 1268 | |
1299 | 1269 | $parserCache = ParserCache::singleton(); |
— | — | @@ -1307,11 +1277,29 @@ |
1308 | 1278 | } |
1309 | 1279 | |
1310 | 1280 | ######### Stub functions, overridden by subclass ######### |
| 1281 | + |
| 1282 | + public function pageOverride() { return false; } |
1311 | 1283 | |
1312 | | - function pageOverride() { return false; } |
| 1284 | + public function showStableByDefault() { return false; } |
1313 | 1285 | |
1314 | | - function showStableByDefault() { return false; } |
| 1286 | + public function addTagRatings( $flags, $prettyBox = false, $css='' ) {} |
1315 | 1287 | |
| 1288 | + public function prettyRatingBox( $tfrev, $flags, $revs_since, $stable=true ) {} |
| 1289 | + |
| 1290 | + public function ReviewNotes( $row ) {} |
| 1291 | + |
| 1292 | + public function injectReviewDiffURLParams( $article, &$sectionanchor, &$extraq ) {} |
| 1293 | + |
| 1294 | + public function addDiffNoticeAfterEdit( $diff, $OldRev, $NewRev ) {} |
| 1295 | + |
| 1296 | + public function getStableRev( $getText=false, $forUpdate=false ) {} |
| 1297 | + |
| 1298 | + public function getVisibilitySettings( $forUpdate=false ) {} |
| 1299 | + |
| 1300 | + public function getFlagsForRevision( $rev_id ) {} |
| 1301 | + |
| 1302 | + public function isReviewable() {} |
| 1303 | + |
1316 | 1304 | function setPageContent( $article, &$outputDone, &$pcache ) {} |
1317 | 1305 | |
1318 | 1306 | function addToEditView( $editform ) {} |
— | — | @@ -1328,16 +1316,6 @@ |
1329 | 1317 | |
1330 | 1318 | function addVisibilityLink( $out ) {} |
1331 | 1319 | |
1332 | | - public function addTagRatings( $flags, $prettyBox = false, $css='' ) {} |
1333 | | - |
1334 | | - public function prettyRatingBox( $tfrev, $flags, $revs_since, $stable=true ) {} |
1335 | | - |
1336 | | - public function ReviewNotes( $row ) {} |
1337 | | - |
1338 | | - public function injectReviewDiffURLParams( $article, &$sectionanchor, &$extraq ) {} |
1339 | | - |
1340 | | - public function addDiffNoticeAfterEdit( $diff, $OldRev, $NewRev ) {} |
1341 | | - |
1342 | 1320 | ######### |
1343 | 1321 | |
1344 | 1322 | } |
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php |
— | — | @@ -5,16 +5,16 @@ |
6 | 6 | * Does the config and current URL params allow |
7 | 7 | * for overriding by stable revisions? |
8 | 8 | */ |
9 | | - function pageOverride() { |
| 9 | + public function pageOverride() { |
10 | 10 | global $wgFlaggedRevs, $wgTitle, $wgUser, $wgRequest, $action; |
11 | 11 | # This only applies to viewing content pages |
12 | | - if( $action !='view' || !$this->isReviewable( $wgTitle ) ) |
| 12 | + if( $action !='view' || !$this->isReviewable() ) |
13 | 13 | return false; |
14 | 14 | # Does not apply to diffs/old revisions |
15 | 15 | if( $wgRequest->getVal('oldid') || $wgRequest->getVal('diff') ) |
16 | 16 | return false; |
17 | 17 | # Get page configuration |
18 | | - $config = $wgFlaggedRevs->getVisibilitySettings( $wgTitle ); |
| 18 | + $config = $wgFlaggedRevs->getVisibilitySettings(); |
19 | 19 | # Does the stable version override the current one? |
20 | 20 | if( $config['override'] ) { |
21 | 21 | global $wgFlaggedRevsExceptions; |
— | — | @@ -39,7 +39,7 @@ |
40 | 40 | /** |
41 | 41 | * Is this user shown the stable version by default for this page? |
42 | 42 | */ |
43 | | - function showStableByDefault() { |
| 43 | + public function showStableByDefault() { |
44 | 44 | global $wgFlaggedRevsOverride, $wgFlaggedRevsExceptions, $wgUser; |
45 | 45 | # Get page configuration |
46 | 46 | $config = $this->getVisibilitySettings(); |
— | — | @@ -56,6 +56,15 @@ |
57 | 57 | } |
58 | 58 | return true; |
59 | 59 | } |
| 60 | + |
| 61 | + /** |
| 62 | + * Is this article reviewable? |
| 63 | + */ |
| 64 | + public function isReviewable() { |
| 65 | + global $wgTitle; |
| 66 | + |
| 67 | + return $this->isPageReviewable( $wgTitle ); |
| 68 | + } |
60 | 69 | |
61 | 70 | /** |
62 | 71 | * Replaces a page with the last stable version if possible |
— | — | @@ -67,7 +76,7 @@ |
68 | 77 | |
69 | 78 | $skin = $wgUser->getSkin(); |
70 | 79 | # For unreviewable pages, allow for basic patrolling |
71 | | - if( !$this->isReviewable( $article->mTitle ) ) { |
| 80 | + if( !$this->isPageReviewable( $article->mTitle ) ) { |
72 | 81 | # If we have been passed an &rcid= parameter, we want to give the user a |
73 | 82 | # chance to mark this new article as patrolled. |
74 | 83 | $rcid = $wgRequest->getIntOrNull( 'rcid' ); |
— | — | @@ -96,7 +105,7 @@ |
97 | 106 | $vis_id = $revid; |
98 | 107 | $tag = $notes = ''; |
99 | 108 | # Check the newest stable version... |
100 | | - $tfrev = $this->getStableRev( null, true ); |
| 109 | + $tfrev = $this->getStableRev( true ); |
101 | 110 | $simpleTag = false; |
102 | 111 | if( $wgRequest->getVal('diff') || $wgRequest->getVal('oldid') ) { |
103 | 112 | // Do not clutter up diffs any further... |
— | — | @@ -209,7 +218,7 @@ |
210 | 219 | function addToEditView( $editform ) { |
211 | 220 | global $wgRequest, $wgTitle, $wgOut; |
212 | 221 | # Talk pages cannot be validated |
213 | | - if( !$editform->mArticle || !$this->isReviewable( $wgTitle ) ) |
| 222 | + if( !$editform->mArticle || !$this->isReviewable() ) |
214 | 223 | return false; |
215 | 224 | # Find out revision id |
216 | 225 | if( $editform->mArticle->mRevision ) { |
— | — | @@ -266,7 +275,7 @@ |
267 | 276 | function addReviewForm( $out ) { |
268 | 277 | global $wgArticle, $wgRequest, $action; |
269 | 278 | |
270 | | - if( !$wgArticle || !$wgArticle->exists() || !$this->isReviewable( $wgArticle->mTitle ) ) |
| 279 | + if( !$wgArticle || !$wgArticle->exists() || !$this->isReviewable() ) |
271 | 280 | return true; |
272 | 281 | # Check if page is protected |
273 | 282 | if( $action !='view' || !$wgArticle->mTitle->quickUserCan( 'edit' ) ) { |
— | — | @@ -293,7 +302,7 @@ |
294 | 303 | function addVisibilityLink( $out ) { |
295 | 304 | global $wgUser, $wgRequest, $wgTitle, $action; |
296 | 305 | |
297 | | - if( !$this->isReviewable( $wgTitle ) ) |
| 306 | + if( !$this->isReviewable() ) |
298 | 307 | return true; |
299 | 308 | |
300 | 309 | if( $action=='protect' || $action=='unprotect' ) { |
— | — | @@ -326,7 +335,7 @@ |
327 | 336 | # Are we using the popular cite extension? |
328 | 337 | global $wgHooks; |
329 | 338 | if( in_array('wfSpecialCiteNav',$wgHooks['SkinTemplateBuildNavUrlsNav_urlsAfterPermalink']) ) { |
330 | | - if( $this->isReviewable( $sktmp->mTitle ) && $revid !== 0 ) { |
| 339 | + if( $this->isPageReviewable( $sktmp->mTitle ) && $revid !== 0 ) { |
331 | 340 | $nav_urls['cite'] = array( |
332 | 341 | 'text' => wfMsg( 'cite_article_link' ), |
333 | 342 | 'href' => $sktmp->makeSpecialUrl( 'Cite', "page=" . wfUrlencode( "{$sktmp->thispage}" ) . "&id={$tfrev->fr_rev_id}" ) |
— | — | @@ -343,7 +352,7 @@ |
344 | 353 | return true; |
345 | 354 | $title = $sktmp->mTitle->getSubjectPage(); |
346 | 355 | # Non-content pages cannot be validated |
347 | | - if( !$this->isReviewable( $title ) || !$title->exists() ) |
| 356 | + if( !$this->isPageReviewable( $title ) || !$title->exists() ) |
348 | 357 | return true; |
349 | 358 | $article = new Article( $title ); |
350 | 359 | # If we are viewing a page normally, and it was overridden, |
— | — | @@ -459,7 +468,7 @@ |
460 | 469 | function addToHistLine( $row, &$s ) { |
461 | 470 | global $wgUser, $wgTitle; |
462 | 471 | # Non-content pages cannot be validated |
463 | | - if( !$this->isReviewable( $wgTitle ) ) |
| 472 | + if( !$this->isReviewable() ) |
464 | 473 | return true; |
465 | 474 | |
466 | 475 | if( !isset($this->dbw) ) { |
— | — | @@ -705,7 +714,7 @@ |
706 | 715 | if( !$wgUser->isAllowed( 'review') || !$wgRequest->getBool('editreview') || !$NewRev->isCurrent() ) |
707 | 716 | return true; |
708 | 717 | |
709 | | - $frev = $this->getStableRev( $diff->mTitle ); |
| 718 | + $frev = $this->getStableRev(); |
710 | 719 | if( !$frev || $frev->fr_rev_id != $OldRev->getID() ) |
711 | 720 | return true; |
712 | 721 | |
— | — | @@ -765,7 +774,7 @@ |
766 | 775 | public function injectReviewDiffURLParams( $article, &$sectionanchor, &$extraq ) { |
767 | 776 | global $wgUser, $wgReviewChangesAfterEdit; |
768 | 777 | |
769 | | - $frev = $this->getStableRev( $article->getTitle() ); |
| 778 | + $frev = $this->getStableRev(); |
770 | 779 | # Was this already autoreviewed, are we allowed? |
771 | 780 | if( $this->skipReviewDiff || !$wgReviewChangesAfterEdit || !$wgUser->isAllowed('review') ) { |
772 | 781 | if( $frev ) { |
— | — | @@ -784,7 +793,7 @@ |
785 | 794 | * Same params for the sake of inheritance |
786 | 795 | * @return Row |
787 | 796 | */ |
788 | | - function getStableRev( $t=null, $getText=false, $forUpdate=false ) { |
| 797 | + public function getStableRev( $getText=false, $forUpdate=false ) { |
789 | 798 | global $wgTitle, $wgFlaggedRevs; |
790 | 799 | # Cached results available? |
791 | 800 | if( $getText ) { |
— | — | @@ -814,7 +823,7 @@ |
815 | 824 | * Same params for the sake of inheritance |
816 | 825 | * @returns Array |
817 | 826 | */ |
818 | | - public function getVisibilitySettings( $t=null, $forUpdate=false ) { |
| 827 | + public function getVisibilitySettings( $forUpdate=false ) { |
819 | 828 | global $wgTitle; |
820 | 829 | # Cached results available? |
821 | 830 | if( isset($this->pageconfig) ) { |
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage.php |
— | — | @@ -48,7 +48,7 @@ |
49 | 49 | $this->page = Title::newFromUrl( $this->target ); |
50 | 50 | // Revision ID |
51 | 51 | $this->oldid = $wgRequest->getIntOrNull( 'oldid' ); |
52 | | - if( !$this->target || !$this->oldid || !$wgFlaggedRevs->isReviewable( $this->page ) ) { |
| 52 | + if( !$this->target || !$this->oldid || !$wgFlaggedRevs->isPageReviewable( $this->page ) ) { |
53 | 53 | $wgOut->addHTML( wfMsgExt('revreview-main',array('parse')) ); |
54 | 54 | return; |
55 | 55 | } |
— | — | @@ -572,7 +572,7 @@ |
573 | 573 | function showStableList() { |
574 | 574 | global $wgOut, $wgUser, $wgLang, $wgFlaggedRevs; |
575 | 575 | // Must be a content page |
576 | | - if( !$wgFlaggedRevs->isReviewable( $this->page ) ) { |
| 576 | + if( !$wgFlaggedRevs->isPageReviewable( $this->page ) ) { |
577 | 577 | $wgOut->addHTML( wfMsgExt('stableversions-none', array('parse'), |
578 | 578 | $this->page->getPrefixedText() ) ); |
579 | 579 | return; |
— | — | @@ -905,7 +905,7 @@ |
906 | 906 | $wgOut->addHTML( wfMsgExt( 'stabilization-notexists', array('parseinline'), |
907 | 907 | $this->page->getPrefixedText() ) ); |
908 | 908 | $isValid = false; |
909 | | - } else if( !$wgFlaggedRevs->isReviewable( $this->page ) ) { |
| 909 | + } else if( !$wgFlaggedRevs->isPageReviewable( $this->page ) ) { |
910 | 910 | $wgOut->addHTML( wfMsgExt( 'stabilization-notcontent', array('parseinline'), |
911 | 911 | $this->page->getPrefixedText() ) ); |
912 | 912 | $isValid = false; |
— | — | @@ -943,7 +943,7 @@ |
944 | 944 | function showSettings() { |
945 | 945 | global $wgOut, $wgScript, $wgTitle, $wgUser, $wgFlaggedRevs; |
946 | 946 | // Must be a content page |
947 | | - if( !$wgFlaggedRevs->isReviewable( $this->page ) ) { |
| 947 | + if( !$wgFlaggedRevs->isPageReviewable( $this->page ) ) { |
948 | 948 | $wgOut->addHTML( wfMsgExt('stableversions-none', array('parse'), |
949 | 949 | $this->page->getPrefixedText() ) ); |
950 | 950 | return; |