r25129 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25128‎ | r25129 | r25130 >
Date:09:02, 25 August 2007
Author:aaron
Status:old
Tags:
Comment:
*Add $wgFlaggedRevsNamespaces
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
@@ -74,6 +74,9 @@
7575 # Add stable/current revision tabs. May be redundant due to the tags.
7676 $wgFlaggedRevTabs = false;
7777
 78+# Allowed namespaces of reviewable pages
 79+$wgFlaggedRevsNamespaces = array( NS_MAIN );
 80+
7881 # Revision tagging can slow development...
7982 # For example, the main user base may become complacent,
8083 # perhaps treat flagged pages as "done",
@@ -84,7 +87,8 @@
8588 $wgFlaggedRevsOverride = true;
8689 # Can users make comments that will show up below flagged revisions?
8790 $wgFlaggedRevComments = false;
88 -# Make user's watch pages when reviewed if they watch pages that they edit
 91+# Automatically checks the 'watch' box on the review form if they set
 92+# "watch pages I edit" as true at [[Special:Preferences]].
8993 $wgFlaggedRevsWatch = true;
9094 # Redirect users out to review changes since stable version on save?
9195 $wgReviewChangesAfterEdit = true;
@@ -536,6 +540,17 @@
537541 }
538542 return $min;
539543 }
 544+
 545+ /**
 546+ * Is this page in reviewable namespace?
 547+ * @param Title, $title
 548+ * @returns bool
 549+ */
 550+ public static function isReviewable( $title ) {
 551+ global $wgFlaggedRevsNamespaces;
 552+
 553+ return in_array($title->getNamespace(),$wgFlaggedRevsNamespaces);
 554+ }
540555
541556 ######### Hooked functions #########
542557
@@ -684,7 +699,7 @@
685700 $fname = 'FlaggedRevs::extraLinksUpdate';
686701 wfProfileIn( $fname );
687702
688 - if( !$linksUpdate->mTitle->isContentPage() )
 703+ if( !FlaggedRevs::isReviewable( $linksUpdate->mTitle ) )
689704 return true;
690705 # Check if this page has a stable version
691706 $sv = $wgFlaggedRevs->getOverridingRev( $linksUpdate->mTitle, true, true );
@@ -1089,11 +1104,10 @@
10901105 */
10911106 public static function maybeUpdateMainCache( $article, &$outputDone, &$pcache ) {
10921107 global $wgUser, $action;
1093 - // Only trigger on article view for content pages, not for protect/delete/hist
1094 - if( !$article || !$article->exists() || !$article->mTitle->isContentPage() || $action !='view' )
 1108+ // Only trigger on article view for content pages, not for protect/delete/hist
 1109+ if( $action !='view' || !$wgUser->isAllowed( 'review' ) )
10951110 return true;
1096 - // User must have review rights
1097 - if( !$wgUser->isAllowed( 'review' ) )
 1111+ if( !$article || !$article->exists() || !FlaggedRevs::isReviewable( $article->mTitle ) )
10981112 return true;
10991113
11001114 $parserCache =& ParserCache::singleton();
@@ -1145,9 +1159,11 @@
11461160 static function pageOverride() {
11471161 global $wgTitle, $wgFlaggedRevsAnonOnly, $wgFlaggedRevsOverride, $wgUser, $wgRequest, $action;
11481162 # This only applies to viewing content pages
1149 - if( $action !='view' || !$wgTitle->isContentPage() ) return;
 1163+ if( $action !='view' || !FlaggedRevs::isReviewable( $wgTitle ) )
 1164+ return;
11501165 # Does not apply to diffs/old revisions
1151 - if( $wgRequest->getVal('oldid') || $wgRequest->getVal('diff') ) return;
 1166+ if( $wgRequest->getVal('oldid') || $wgRequest->getVal('diff') )
 1167+ return;
11521168 # Does the stable version override the current one?
11531169 if( $wgFlaggedRevsOverride ) {
11541170 # If $wgFlaggedRevsAnonOnly is set to false, stable version are only requested explicitly
@@ -1169,7 +1185,7 @@
11701186 function setPageContent( $article, &$outputDone, &$pcache ) {
11711187 global $wgRequest, $wgTitle, $wgOut, $action, $wgUser;
11721188 // Only trigger on article view for content pages, not for protect/delete/hist
1173 - if( !$article || !$article->exists() || !$article->mTitle->isContentPage() || $action !='view' )
 1189+ if( $action !='view' || !$article || !$article->exists() || !FlaggedRevs::isReviewable( $article->mTitle ) )
11741190 return true;
11751191 // Grab page and rev ids
11761192 $pageid = $article->getId();
@@ -1289,7 +1305,7 @@
12901306 function addToEditView( $editform ) {
12911307 global $wgRequest, $wgTitle, $wgOut;
12921308 // Talk pages cannot be validated
1293 - if( !$editform->mArticle || !$wgTitle->isContentPage() )
 1309+ if( !$editform->mArticle || !FlaggedRevs::isReviewable( $wgTitle ) )
12941310 return false;
12951311 // Find out revision id
12961312 if( $editform->mArticle->mRevision ) {
@@ -1343,10 +1359,10 @@
13441360 function addReviewForm( $out ) {
13451361 global $wgArticle, $wgRequest, $action;
13461362
1347 - if( !$wgArticle || !$wgArticle->exists() || !$wgArticle->mTitle->isContentPage() || $action !='view' )
 1363+ if( !$wgArticle || !$wgArticle->exists() || !FlaggedRevs::isReviewable( $wgArticle->mTitle ) )
13481364 return true;
13491365 // Check if page is protected
1350 - if( !$wgArticle->mTitle->quickUserCan( 'edit' ) ) {
 1366+ if( $action !='view' || !$wgArticle->mTitle->quickUserCan( 'edit' ) ) {
13511367 return true;
13521368 }
13531369 // Get revision ID
@@ -1384,7 +1400,7 @@
13851401 global $wgHooks;
13861402 // Are we using the popular cite extension?
13871403 if( in_array('wfSpecialCiteNav',$wgHooks['SkinTemplateBuildNavUrlsNav_urlsAfterPermalink']) ) {
1388 - if( $sktmp->mTitle->isContentPage() && $revid !== 0 ) {
 1404+ if( FlaggedRevs::isReviewable( $sktmp->mTitle ) && $revid !== 0 ) {
13891405 $nav_urls['cite'] = array(
13901406 'text' => wfMsg( 'cite_article_link' ),
13911407 'href' => $sktmp->makeSpecialUrl( 'Cite', "page=" . wfUrlencode( "{$sktmp->thispage}" ) . "&id={$tfrev->fr_rev_id}" )
@@ -1402,7 +1418,7 @@
14031419 return true;
14041420 $title = $sktmp->mTitle->getSubjectPage();
14051421 // Non-content pages cannot be validated
1406 - if( !$title->isContentPage() || !$title->exists() )
 1422+ if( !FlaggedRevs::isReviewable( $title ) || !$title->exists() )
14071423 return true;
14081424 $article = new Article( $title );
14091425 // If we are viewing a page normally, and it was overridden,
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage_body.php
@@ -41,7 +41,7 @@
4242 $this->oldid = $wgRequest->getIntOrNull( 'oldid' );
4343 // Must be a valid content page
4444 $this->page = Title::newFromUrl( $this->target );
45 - if( !$this->target || !$this->oldid || !$this->page->isContentPage() ) {
 45+ if( !$this->target || !$this->oldid || !FlaggedRevs::isReviewable( $this->page ) ) {
4646 $wgOut->addHTML( wfMsgExt('revreview-main',array('parse')) );
4747 return;
4848 }
@@ -593,7 +593,7 @@
594594
595595 // Must be a valid page/Id
596596 $page = Title::newFromUrl( $this->page );
597 - if( is_null($page) || !$page->isContentPage() ) {
 597+ if( is_null($page) || !FlaggedRevs::isReviewable( $page ) ) {
598598 $wgOut->showErrorPage('notargettitle', 'allpagesbadtitle' );
599599 return;
600600 }
@@ -710,7 +710,7 @@
711711 }
712712
713713 function getNamespaceMenu( $selected=NULL, $allnamespaces = null, $includehidden=false ) {
714 - global $wgContLang, $wgContentNamespaces;
 714+ global $wgContLang, $wgFlaggedRevsNamespaces;
715715
716716 $selector = "<label for='namespace'>" . wfMsgHtml('namespace') . "</label>";
717717 if( $selected !== '' ) {
@@ -727,7 +727,7 @@
728728
729729 foreach($arr as $index => $name) {
730730 # Content only
731 - if($index < NS_MAIN || !in_array($index, $wgContentNamespaces) )
 731+ if($index < NS_MAIN || !in_array($index, $wgFlaggedRevsNamespaces) )
732732 continue;
733733
734734 $name = $index !== 0 ? $name : wfMsg('blanknamespace');
@@ -768,12 +768,12 @@
769769 }
770770
771771 function getSQLText( &$dbr, $namespace, $showOutdated, $category ) {
772 - global $wgContentNamespaces;
 772+ global $wgFlaggedRevsNamespaces;
773773
774774 list($page,$flaggedrevs,$categorylinks) = $dbr->tableNamesN('page','flaggedrevs','categorylinks');
775775 # Must be a content page...
776 - if( is_null($namespace) || !in_array($namespace,$wgContentNamespaces) ) {
777 - $where = 'page_namespace IN(' . implode(',',$wgContentNamespaces) . ') ';
 776+ if( is_null($namespace) || !in_array($namespace,$wgFlaggedRevsNamespaces) ) {
 777+ $where = 'page_namespace IN(' . implode(',',$wgFlaggedRevsNamespaces) . ') ';
778778 } else {
779779 $where = "page_namespace={$namespace} ";
780780 }

Status & tagging log