r22004 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22003‎ | r22004 | r22005 >
Date:19:13, 8 May 2007
Author:aaron
Status:old
Tags:
Comment:
*Split up some review form functions
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -649,15 +649,9 @@
650650 $vis_id = $revid;
651651 $tag = ''; $notes = '';
652652 // Check the newest stable version...
653 - $quality = false; $featured = false;
 653+ $quality = false; $pristine = false;
654654 if ( $this->pageOverride() ) {
655 - // getLatestQualityRev() is slower, don't use it if we won't need to
656 - $tfrev = $this->getLatestQualityRev( $article );
657 - if ( is_null($tfrev) ) {
658 - $tfrev = $this->getLatestStableRev( $article );
659 - } else {
660 - $quality = true;
661 - }
 655+ $tfrev = $this->getOverridingRev( $article );
662656 } else {
663657 $tfrev = $this->getLatestStableRev( $article );
664658 }
@@ -694,8 +688,9 @@
695689 global $wgUser;
696690
697691 $skin = $wgUser->getSkin();
698 - // See if this page is featured
699 - $featured = parent::isPristine( $flags );
 692+ # See if this page is featured
 693+ $quality = $this->isQuality( $flags );
 694+ $pristine = $this->isPristine( $flags );
700695 # We will be looking at the reviewed revision...
701696 $vis_id = $tfrev->fr_rev_id;
702697 $revs_since = parent::getRevCountSince( $pageid, $vis_id );
@@ -713,7 +708,7 @@
714709 # Update the general cache
715710 parent::updatePageCache( $article, $parserOutput );
716711 }
717 - $wgOut->addHTML( $parserOutput->getText() );
 712+ $wgOut->mBodytext = $parserOutput->getText();
718713 # Show stable categories and interwiki links only
719714 $wgOut->mCategoryLinks = array();
720715 $wgOut->addCategoryLinks( $parserOutput->getCategories() );
@@ -727,7 +722,7 @@
728723 // Construct some tagging
729724 $tag .= parent::addTagRatings( $flags );
730725 // Some checks for which tag CSS to use
731 - if ( $featured )
 726+ if ( $pristine )
732727 $tag = '<div class="flaggedrevs_tag3 plainlinks">'.$tag.'</div>';
733728 else if ( $quality )
734729 $tag = '<div class="flaggedrevs_tag2 plainlinks">'.$tag.'</div>';
@@ -739,15 +734,6 @@
740735 $tag = '<div class="mw-warning plainlinks">'.wfMsgExt('revreview-noflagged', array('parse')).'</div>';
741736 $wgOut->addHTML( $tag );
742737 }
743 - // Show review links for the VISIBLE revision
744 - // We cannot review deleted revisions
745 - if( is_object($article->mRevision) && $article->mRevision->mDeleted ) return;
746 - // Add quick review links IF we did not override, otherwise, they might
747 - // review a revision that parses out newer templates/images than what they say
748 - // Note: overrides are never done when viewing with "oldid="
749 - if( $vis_id==$revid || !$this->pageOverride() ) {
750 - $this->addQuickReview( $vis_id, false, $out );
751 - }
752738 }
753739
754740 function addToEditView( &$editform ) {
@@ -802,13 +788,27 @@
803789 $wgOut->addHTML( '<div class="flaggedrevs_tag1 plainlinks">' . $tag . '</div><br/>' );
804790 }
805791 }
 792+
 793+ function addReviewForm( &$out ) {
 794+ global $wgArticle;
 795+
 796+ if ( !is_object($wgArticle) ) return;
 797+ $revId = ( $wgArticle->mRevision ) ? $wgArticle->mRevision->mId : $wgArticle->getLatest();
 798+ // Show review links for the VISIBLE revision
 799+ // We cannot review deleted revisions
 800+ if( is_object($wgArticle->mRevision) && $wgArticle->mRevision->mDeleted ) return;
 801+ // Add quick review links IF we did not override, otherwise, they might
 802+ // review a revision that parses out newer templates/images than what they say
 803+ // Note: overrides are never done when viewing with "oldid="
 804+ $this->addQuickReview( $revId, false );
 805+ }
806806
807807 /**
808808 * Get latest quality rev, if not, the latest reviewed one
809809 */
810810 function getOverridingRev( $article=NULL ) {
811 - if( !$row = $this->getLatestQualityRev() ) {
812 - if( !$row = $this->getLatestStableRev() ) {
 811+ if( !$row = $this->getLatestQualityRev( $article ) ) {
 812+ if( !$row = $this->getLatestStableRev( $article ) ) {
813813 return null;
814814 }
815815 }
@@ -959,7 +959,7 @@
960960 }
961961 }
962962
963 - function addQuickReview( $id, $ontop=false, &$out=false ) {
 963+ function addQuickReview( $id, $ontop=false ) {
964964 global $wgOut, $wgTitle, $wgUser, $wgScript, $wgFlaggedRevComments, $wgArticle, $wgRequest;
965965 // Hack, we don't want two forms!
966966 if( isset($this->formCount) && $this->formCount > 0 ) return;
@@ -1005,9 +1005,9 @@
10061006 $form .= "<p>".wfInputLabel( wfMsgHtml( 'revreview-log' ), 'wpReason', 'wpReason', 60 )." ";
10071007 $form .= Xml::submitButton( wfMsgHtml( 'revreview-submit' ) ) . "</p></fieldset>";
10081008 $form .= Xml::closeElement( 'form' );
1009 - // Hacks, to fiddle around with location a bit
1010 - if( $ontop && $out ) {
1011 - $out->mBodytext = $form . '<hr/>' . $out->mBodytext;
 1009+
 1010+ if( $ontop ) {
 1011+ $wgOut->mBodytext = $form . '<hr/>' . $wgOut->mBodytext;
10121012 } else {
10131013 $wgOut->addHTML( $form );
10141014 }
@@ -1054,6 +1054,7 @@
10551055 $flaggedrevs = new FlaggedRevs();
10561056 $flaggedarticle = new FlaggedArticle();
10571057 $wgHooks['ArticleViewHeader'][] = array($flaggedarticle, 'setPageContent');
 1058+$wgHooks['BeforePageDisplay'][] = array($flaggedarticle, 'addReviewForm');
10581059 $wgHooks['DiffViewHeader'][] = array($flaggedarticle, 'addToDiff');
10591060 $wgHooks['EditPage::showEditForm:initial'][] = array($flaggedarticle, 'addToEditView');
10601061 $wgHooks['SkinTemplateTabs'][] = array($flaggedarticle, 'setCurrentTab');