Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -147,6 +147,15 @@ |
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
| 151 | + /** |
| 152 | + * Should this be using a simple icon-based UI? |
| 153 | + */ |
| 154 | + static function useSimpleUI() { |
| 155 | + global $wgSimpleFlaggedRevsUI; |
| 156 | + |
| 157 | + return $wgSimpleFlaggedRevsUI; |
| 158 | + } |
| 159 | + |
151 | 160 | /** |
152 | 161 | * @param string $text |
153 | 162 | * @returns array( string, bool ) |
— | — | @@ -273,9 +282,11 @@ |
274 | 283 | } |
275 | 284 | |
276 | 285 | /** |
277 | | - * static counterpart for getOverridingRev() |
| 286 | + * Get latest quality rev, if not, the latest reviewed one |
| 287 | + * @param Title $title |
| 288 | + * @returns Row |
278 | 289 | */ |
279 | | - public static function getOverridingPageRev( $title=NULL ) { |
| 290 | + public function getOverridingRev( $title=NULL ) { |
280 | 291 | if( is_null($title) ) |
281 | 292 | return null; |
282 | 293 | |
— | — | @@ -304,13 +315,15 @@ |
305 | 316 | } |
306 | 317 | |
307 | 318 | /** |
308 | | - * static counterpart for getFlagsForRevision() |
| 319 | + * Get flags for a revision |
| 320 | + * @param int $rev_id |
| 321 | + * @returns Array |
309 | 322 | */ |
310 | | - public static function getFlagsForPageRev( $rev_id ) { |
| 323 | + public function getFlagsForRevision( $rev_id ) { |
311 | 324 | global $wgFlaggedRevTags; |
312 | 325 | // Set all flags to zero |
313 | 326 | $flags = array(); |
314 | | - foreach( array_keys($wgFlaggedRevTags) as $tag ) { |
| 327 | + foreach( array_keys($this->dimensions) as $tag ) { |
315 | 328 | $flags[$tag] = 0; |
316 | 329 | } |
317 | 330 | |
— | — | @@ -617,14 +630,14 @@ |
618 | 631 | return true; |
619 | 632 | } |
620 | 633 | |
621 | | - public static function extraLinksUpdate( &$linksUpdate ) { |
| 634 | + public function extraLinksUpdate( &$linksUpdate ) { |
622 | 635 | $fname = 'FlaggedRevs::extraLinksUpdate'; |
623 | 636 | wfProfileIn( $fname ); |
624 | 637 | |
625 | 638 | if( !$linksUpdate->mTitle->isContentPage() ) |
626 | 639 | return true; |
627 | 640 | # Check if this page has a stable version |
628 | | - $sv = self::getOverridingPageRev( $linksUpdate->mTitle ); |
| 641 | + $sv = $this->getOverridingRev( $linksUpdate->mTitle ); |
629 | 642 | if( !$sv ) |
630 | 643 | return true; |
631 | 644 | # Retrieve the text |
— | — | @@ -788,8 +801,31 @@ |
789 | 802 | |
790 | 803 | $user->addGroup('editor'); |
791 | 804 | } |
792 | | - return true; |
| 805 | + return true; |
793 | 806 | } |
| 807 | + |
| 808 | + static function pageOverride() { return false; } |
| 809 | + |
| 810 | + function setPageContent( &$article, &$outputDone, &$pcache ) {} |
| 811 | + |
| 812 | + function addToEditView( &$editform ) {} |
| 813 | + |
| 814 | + function addReviewForm( &$out ) {} |
| 815 | + |
| 816 | + function setPermaLink( &$sktmp, &$nav_urls, &$revid, &$revid ) {} |
| 817 | + |
| 818 | + function setCurrentTab( &$sktmp, &$content_actions ) {} |
| 819 | + |
| 820 | + function addToPageHist( &$article ) {} |
| 821 | + |
| 822 | + function addToHistLine( &$row, &$s ) {} |
| 823 | + |
| 824 | + function addQuickReview( $id=NULL, $out ) {} |
| 825 | + |
| 826 | + function getLatestQualityRev() {} |
| 827 | + |
| 828 | + function getLatestStableRev() {} |
| 829 | + |
794 | 830 | } |
795 | 831 | |
796 | 832 | class FlaggedArticle extends FlaggedRevs { |
— | — | @@ -815,14 +851,6 @@ |
816 | 852 | return !( $wgRequest->getIntOrNull('stable') !==1 ); |
817 | 853 | } |
818 | 854 | } |
819 | | - /** |
820 | | - * Should this be using a simple icon-based UI? |
821 | | - */ |
822 | | - static function useSimpleUI() { |
823 | | - global $wgSimpleFlaggedRevsUI; |
824 | | - |
825 | | - return $wgSimpleFlaggedRevsUI; |
826 | | - } |
827 | 855 | |
828 | 856 | /** |
829 | 857 | * Replaces a page with the last stable version if possible |
— | — | @@ -980,7 +1008,7 @@ |
981 | 1009 | $tag .= '<span id="mwrevisionratings" style="display:block;">' . |
982 | 1010 | wfMsg('revreview-oldrating') . parent::addTagRatings( $flags ) . |
983 | 1011 | '</span>'; |
984 | | - $wgOut->addHTML( '<div id="mwrevisiontag" class="flaggedrevs_notice plainlinks">' . $tag . '</div><br/>' ); |
| 1012 | + $wgOut->addHTML( '<div id="mwrevisiontag" class="flaggedrevs_notice plainlinks">' . $tag . '</div>' ); |
985 | 1013 | } |
986 | 1014 | return true; |
987 | 1015 | } |
— | — | @@ -1256,8 +1284,14 @@ |
1257 | 1285 | |
1258 | 1286 | /** |
1259 | 1287 | * Get latest quality rev, if not, the latest reviewed one |
| 1288 | + * @returns Row |
1260 | 1289 | */ |
1261 | | - function getOverridingRev() { |
| 1290 | + function getOverridingRev( $title = NULL ) { |
| 1291 | + global $wgTitle; |
| 1292 | + |
| 1293 | + if( !is_null($title) && $title->getArticleID() != $wgTitle->getArticleID() ) |
| 1294 | + return null; // wtf? |
| 1295 | + |
1262 | 1296 | if( !$row = $this->getLatestQualityRev() ) { |
1263 | 1297 | if( !$row = $this->getLatestStableRev() ) { |
1264 | 1298 | return null; |
— | — | @@ -1376,34 +1410,38 @@ |
1377 | 1411 | |
1378 | 1412 | } |
1379 | 1413 | |
1380 | | -// Our class instances |
1381 | | -$flaggedRevsModifier = new FlaggedArticle(); |
1382 | | -// Main hooks, overrides pages content, adds tags, sets tabs and permalink |
1383 | | -$wgHooks['SkinTemplateTabs'][] = array($flaggedRevsModifier, 'setCurrentTab'); |
1384 | | -// Update older, incomplete, page caches (ones that lack template Ids/image timestamps) |
1385 | | -$wgHooks['ArticleViewHeader'][] = array($flaggedRevsModifier, 'maybeUpdateMainCache'); |
1386 | | -$wgHooks['ArticleViewHeader'][] = array($flaggedRevsModifier, 'setPageContent'); |
1387 | | -$wgHooks['SkinTemplateBuildNavUrlsNav_urlsAfterPermalink'][] = array($flaggedRevsModifier, 'setPermaLink'); |
1388 | | -// Add tags do edit view |
1389 | | -$wgHooks['EditPage::showEditForm:initial'][] = array($flaggedRevsModifier, 'addToEditView'); |
1390 | | -// Add review form |
1391 | | -$wgHooks['BeforePageDisplay'][] = array($flaggedRevsModifier, 'addReviewForm'); |
1392 | | -// Mark of items in page history |
1393 | | -$wgHooks['PageHistoryBeforeList'][] = array($flaggedRevsModifier, 'addToPageHist'); |
1394 | | -$wgHooks['PageHistoryLineEnding'][] = array($flaggedRevsModifier, 'addToHistLine'); |
1395 | | -// Autopromote Editors |
1396 | | -$wgHooks['ArticleSaveComplete'][] = array($flaggedRevsModifier, 'autoPromoteUser'); |
1397 | | -// Adds table link references to include ones from the stable version |
1398 | | -$wgHooks['LinksUpdateConstructed'][] = array($flaggedRevsModifier, 'extraLinksUpdate'); |
1399 | | -// If a stable version is hidden, move to the next one if possible, and update things |
1400 | | -$wgHooks['ArticleRevisionVisiblityUpdates'][] = array($flaggedRevsModifier, 'articleLinksUpdate'); |
1401 | | -// Update our table NS/Titles when things are moved |
1402 | | -$wgHooks['SpecialMovepageAfterMove'][] = array($flaggedRevsModifier, 'updateFromMove'); |
1403 | | -// Parser hooks, selects the desired images/templates |
1404 | | -$wgHooks['BeforeParserrenderImageGallery'][] = array( $flaggedRevsModifier, 'parserMakeGalleryStable'); |
1405 | | -$wgHooks['BeforeGalleryFindFile'][] = array( $flaggedRevsModifier, 'galleryFindStableFileTime'); |
1406 | | -$wgHooks['BeforeParserFetchTemplateAndtitle'][] = array( $flaggedRevsModifier, 'parserFetchStableTemplate'); |
1407 | | -$wgHooks['BeforeParserMakeImageLinkObj'][] = array( $flaggedRevsModifier, 'parserMakeStableImageLink'); |
1408 | | -// Additional parser versioning |
1409 | | -$wgHooks['ParserAfterTidy'][] = array( $flaggedRevsModifier, 'parserInjectImageTimestamps'); |
1410 | | -$wgHooks['OutputPageParserOutput'][] = array( $flaggedRevsModifier, 'outputInjectImageTimestamps'); |
| 1414 | +// Our global class instances |
| 1415 | +$wgFlaggedRevs = new FlaggedRevs(); |
| 1416 | +$wgFlaggedArticle = new FlaggedArticle(); |
| 1417 | + |
| 1418 | +######### Hook attachments ######### |
| 1419 | +# Main hooks, overrides pages content, adds tags, sets tabs and permalink |
| 1420 | +$wgHooks['SkinTemplateTabs'][] = array($wgFlaggedArticle, 'setCurrentTab'); |
| 1421 | +# Update older, incomplete, page caches (ones that lack template Ids/image timestamps) |
| 1422 | +$wgHooks['ArticleViewHeader'][] = array($wgFlaggedArticle, 'maybeUpdateMainCache'); |
| 1423 | +$wgHooks['ArticleViewHeader'][] = array($wgFlaggedArticle, 'setPageContent'); |
| 1424 | +$wgHooks['SkinTemplateBuildNavUrlsNav_urlsAfterPermalink'][] = array($wgFlaggedArticle, 'setPermaLink'); |
| 1425 | +# Add tags do edit view |
| 1426 | +$wgHooks['EditPage::showEditForm:initial'][] = array($wgFlaggedArticle, 'addToEditView'); |
| 1427 | +# Add review form |
| 1428 | +$wgHooks['BeforePageDisplay'][] = array($wgFlaggedArticle, 'addReviewForm'); |
| 1429 | +# Mark of items in page history |
| 1430 | +$wgHooks['PageHistoryBeforeList'][] = array($wgFlaggedArticle, 'addToPageHist'); |
| 1431 | +$wgHooks['PageHistoryLineEnding'][] = array($wgFlaggedArticle, 'addToHistLine'); |
| 1432 | +# Autopromote Editors |
| 1433 | +$wgHooks['ArticleSaveComplete'][] = array($wgFlaggedArticle, 'autoPromoteUser'); |
| 1434 | +# Adds table link references to include ones from the stable version |
| 1435 | +$wgHooks['LinksUpdateConstructed'][] = array($wgFlaggedArticle, 'extraLinksUpdate'); |
| 1436 | +# If a stable version is hidden, move to the next one if possible, and update things |
| 1437 | +$wgHooks['ArticleRevisionVisiblityUpdates'][] = array($wgFlaggedArticle, 'articleLinksUpdate'); |
| 1438 | +# Update our table NS/Titles when things are moved |
| 1439 | +$wgHooks['SpecialMovepageAfterMove'][] = array($wgFlaggedArticle, 'updateFromMove'); |
| 1440 | +# Parser hooks, selects the desired images/templates |
| 1441 | +$wgHooks['BeforeParserrenderImageGallery'][] = array( $wgFlaggedArticle, 'parserMakeGalleryStable'); |
| 1442 | +$wgHooks['BeforeGalleryFindFile'][] = array( $wgFlaggedArticle, 'galleryFindStableFileTime'); |
| 1443 | +$wgHooks['BeforeParserFetchTemplateAndtitle'][] = array( $wgFlaggedArticle, 'parserFetchStableTemplate'); |
| 1444 | +$wgHooks['BeforeParserMakeImageLinkObj'][] = array( $wgFlaggedArticle, 'parserMakeStableImageLink'); |
| 1445 | +# Additional parser versioning |
| 1446 | +$wgHooks['ParserAfterTidy'][] = array( $wgFlaggedArticle, 'parserInjectImageTimestamps'); |
| 1447 | +$wgHooks['OutputPageParserOutput'][] = array( $wgFlaggedArticle, 'outputInjectImageTimestamps'); |
| 1448 | +######### |
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage_body.php |
— | — | @@ -14,7 +14,7 @@ |
15 | 15 | } |
16 | 16 | |
17 | 17 | function execute( $par ) { |
18 | | - global $wgRequest, $wgUser, $wgOut, $wgFlaggedRevComments, $wgFlaggedRevTags; |
| 18 | + global $wgRequest, $wgUser, $wgOut, $wgFlaggedRevComments, $wgFlaggedRevs; |
19 | 19 | |
20 | 20 | $confirm = $wgRequest->wasPosted() && |
21 | 21 | $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ); |
— | — | @@ -62,11 +62,11 @@ |
63 | 63 | // Additional notes |
64 | 64 | $this->notes = ($wgFlaggedRevComments) ? $wgRequest->getText('wpNotes') : ''; |
65 | 65 | // Get the revision's current flags, if any |
66 | | - $this->oflags = FlaggedRevs::getFlagsForPageRev( $this->oldid ); |
| 66 | + $this->oflags = $wgFlaggedRevs->getFlagsForRevision( $this->oldid ); |
67 | 67 | // Get our accuracy/quality dimensions |
68 | 68 | $this->dims = array(); |
69 | 69 | $this->upprovedTags = 0; |
70 | | - foreach ( array_keys($wgFlaggedRevTags) as $tag ) { |
| 70 | + foreach ( array_keys($wgFlaggedRevs->dimensions) as $tag ) { |
71 | 71 | $this->dims[$tag] = $wgRequest->getIntOrNull( "wp$tag" ); |
72 | 72 | // Must be greater than zero |
73 | 73 | if ( $this->dims[$tag] < 0 ) { |
— | — | @@ -549,7 +549,7 @@ |
550 | 550 | } |
551 | 551 | |
552 | 552 | function showStableRevision( $frev ) { |
553 | | - global $wgParser, $wgLang, $wgUser, $wgOut, $wgTitle; |
| 553 | + global $wgParser, $wgLang, $wgUser, $wgOut, $wgTitle, $wgFlaggedRevs; |
554 | 554 | |
555 | 555 | // Get the revision |
556 | 556 | $frev = FlaggedRevs::getFlaggedRev( $this->oldid ); |
— | — | @@ -561,11 +561,8 @@ |
562 | 562 | $page = Title::makeTitle( $frev->fr_namespace, $frev->fr_title ); |
563 | 563 | |
564 | 564 | $wgOut->setPagetitle( $page->getPrefixedText() ); |
565 | | - |
566 | | - // Modifier instance |
567 | | - $RevFlagging = new FlaggedRevs(); |
568 | 565 | // Get flags and date |
569 | | - $flags = FlaggedRevs::getFlagsForPageRev( $frev->fr_rev_id ); |
| 566 | + $flags = $wgFlaggedRevs->getFlagsForRevision( $frev->fr_rev_id ); |
570 | 567 | $time = $wgLang->timeanddate( wfTimestamp(TS_MW, $frev->fr_timestamp), true ); |
571 | 568 | // We will be looking at the reviewed revision... |
572 | 569 | $tag = wfMsgExt('revreview-static', array('parseinline'), urlencode($page->getPrefixedText()), $time, $page->getPrefixedText()); |