r24303 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24302‎ | r24303 | r24304 >
Date:03:54, 21 July 2007
Author:aaron
Status:old
Tags:
Comment:
*OOP stuff
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevsPage_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -147,6 +147,15 @@
148148 }
149149 }
150150
 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+
151160 /**
152161 * @param string $text
153162 * @returns array( string, bool )
@@ -273,9 +282,11 @@
274283 }
275284
276285 /**
277 - * static counterpart for getOverridingRev()
 286+ * Get latest quality rev, if not, the latest reviewed one
 287+ * @param Title $title
 288+ * @returns Row
278289 */
279 - public static function getOverridingPageRev( $title=NULL ) {
 290+ public function getOverridingRev( $title=NULL ) {
280291 if( is_null($title) )
281292 return null;
282293
@@ -304,13 +315,15 @@
305316 }
306317
307318 /**
308 - * static counterpart for getFlagsForRevision()
 319+ * Get flags for a revision
 320+ * @param int $rev_id
 321+ * @returns Array
309322 */
310 - public static function getFlagsForPageRev( $rev_id ) {
 323+ public function getFlagsForRevision( $rev_id ) {
311324 global $wgFlaggedRevTags;
312325 // Set all flags to zero
313326 $flags = array();
314 - foreach( array_keys($wgFlaggedRevTags) as $tag ) {
 327+ foreach( array_keys($this->dimensions) as $tag ) {
315328 $flags[$tag] = 0;
316329 }
317330
@@ -617,14 +630,14 @@
618631 return true;
619632 }
620633
621 - public static function extraLinksUpdate( &$linksUpdate ) {
 634+ public function extraLinksUpdate( &$linksUpdate ) {
622635 $fname = 'FlaggedRevs::extraLinksUpdate';
623636 wfProfileIn( $fname );
624637
625638 if( !$linksUpdate->mTitle->isContentPage() )
626639 return true;
627640 # Check if this page has a stable version
628 - $sv = self::getOverridingPageRev( $linksUpdate->mTitle );
 641+ $sv = $this->getOverridingRev( $linksUpdate->mTitle );
629642 if( !$sv )
630643 return true;
631644 # Retrieve the text
@@ -788,8 +801,31 @@
789802
790803 $user->addGroup('editor');
791804 }
792 - return true;
 805+ return true;
793806 }
 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+
794830 }
795831
796832 class FlaggedArticle extends FlaggedRevs {
@@ -815,14 +851,6 @@
816852 return !( $wgRequest->getIntOrNull('stable') !==1 );
817853 }
818854 }
819 - /**
820 - * Should this be using a simple icon-based UI?
821 - */
822 - static function useSimpleUI() {
823 - global $wgSimpleFlaggedRevsUI;
824 -
825 - return $wgSimpleFlaggedRevsUI;
826 - }
827855
828856 /**
829857 * Replaces a page with the last stable version if possible
@@ -980,7 +1008,7 @@
9811009 $tag .= '<span id="mwrevisionratings" style="display:block;">' .
9821010 wfMsg('revreview-oldrating') . parent::addTagRatings( $flags ) .
9831011 '</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>' );
9851013 }
9861014 return true;
9871015 }
@@ -1256,8 +1284,14 @@
12571285
12581286 /**
12591287 * Get latest quality rev, if not, the latest reviewed one
 1288+ * @returns Row
12601289 */
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+
12621296 if( !$row = $this->getLatestQualityRev() ) {
12631297 if( !$row = $this->getLatestStableRev() ) {
12641298 return null;
@@ -1376,34 +1410,38 @@
13771411
13781412 }
13791413
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 @@
1515 }
1616
1717 function execute( $par ) {
18 - global $wgRequest, $wgUser, $wgOut, $wgFlaggedRevComments, $wgFlaggedRevTags;
 18+ global $wgRequest, $wgUser, $wgOut, $wgFlaggedRevComments, $wgFlaggedRevs;
1919
2020 $confirm = $wgRequest->wasPosted() &&
2121 $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) );
@@ -62,11 +62,11 @@
6363 // Additional notes
6464 $this->notes = ($wgFlaggedRevComments) ? $wgRequest->getText('wpNotes') : '';
6565 // Get the revision's current flags, if any
66 - $this->oflags = FlaggedRevs::getFlagsForPageRev( $this->oldid );
 66+ $this->oflags = $wgFlaggedRevs->getFlagsForRevision( $this->oldid );
6767 // Get our accuracy/quality dimensions
6868 $this->dims = array();
6969 $this->upprovedTags = 0;
70 - foreach ( array_keys($wgFlaggedRevTags) as $tag ) {
 70+ foreach ( array_keys($wgFlaggedRevs->dimensions) as $tag ) {
7171 $this->dims[$tag] = $wgRequest->getIntOrNull( "wp$tag" );
7272 // Must be greater than zero
7373 if ( $this->dims[$tag] < 0 ) {
@@ -549,7 +549,7 @@
550550 }
551551
552552 function showStableRevision( $frev ) {
553 - global $wgParser, $wgLang, $wgUser, $wgOut, $wgTitle;
 553+ global $wgParser, $wgLang, $wgUser, $wgOut, $wgTitle, $wgFlaggedRevs;
554554
555555 // Get the revision
556556 $frev = FlaggedRevs::getFlaggedRev( $this->oldid );
@@ -561,11 +561,8 @@
562562 $page = Title::makeTitle( $frev->fr_namespace, $frev->fr_title );
563563
564564 $wgOut->setPagetitle( $page->getPrefixedText() );
565 -
566 - // Modifier instance
567 - $RevFlagging = new FlaggedRevs();
568565 // Get flags and date
569 - $flags = FlaggedRevs::getFlagsForPageRev( $frev->fr_rev_id );
 566+ $flags = $wgFlaggedRevs->getFlagsForRevision( $frev->fr_rev_id );
570567 $time = $wgLang->timeanddate( wfTimestamp(TS_MW, $frev->fr_timestamp), true );
571568 // We will be looking at the reviewed revision...
572569 $tag = wfMsgExt('revreview-static', array('parseinline'), urlencode($page->getPrefixedText()), $time, $page->getPrefixedText());

Status & tagging log