http://www.mediawiki.org/wiki/Special:Code/MediaWiki/61689

Revision: 61689
Author:   aaron
Date:     2010-01-29 21:13:06 +0000 (Fri, 29 Jan 2010)

Log Message:
-----------
* Fixed robot policy handling (broken by core changes)
* Doc and style tweaks

Modified Paths:
--------------
    trunk/extensions/FlaggedRevs/FlaggedArticleView.php
    trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php
    trunk/extensions/FlaggedRevs/FlaggedRevs.php

Modified: trunk/extensions/FlaggedRevs/FlaggedArticleView.php
===================================================================
--- trunk/extensions/FlaggedRevs/FlaggedArticleView.php 2010-01-29 21:00:20 UTC 
(rev 61688)
+++ trunk/extensions/FlaggedRevs/FlaggedArticleView.php 2010-01-29 21:13:06 UTC 
(rev 61689)
@@ -49,8 +49,9 @@
        }
 
        /**
-        * Does the config and current URL params allow
-        * for overriding by stable revisions?
+        * Do the config and current URL params allow
+        * for content overriding by the stable version?
+        * @returns bool
         */
        public function pageOverride() {
                global $wgUser, $wgRequest;
@@ -273,9 +274,21 @@
                                "$tag</div>";
                        $this->reviewNotice .= $tag;
                }
-
                return true;
        }
+       
+       // For pages that have a stable version, index only that version
+       public function setRobotPolicy() {
+               global $wgOut;
+               if ( !$this->article->isReviewable() || 
!$this->article->getStableRev() ) {
+                       return true; // page has no stable version
+               }
+               if ( !$this->pageOverride() && 
$this->article->isStableShownByDefault() ) {
+                       # Index the stable version only if it is the default
+                       $wgOut->setRobotPolicy( 'noindex,nofollow' );
+               }
+               return true;
+       }
 
        /**
        * @param $tag review box/bar info
@@ -400,10 +413,6 @@
                                $tag .= $prot . $icon . $msgHTML;
                        }
                }
-               # Index the stable version only if it is the default
-               if ( $this->article->isStableShownByDefault() ) {
-                       $wgOut->setRobotPolicy( 'noindex,nofollow' );
-               }
        }
        
        /**
@@ -477,8 +486,6 @@
                } else {
                        $wgOut->addParserOutput( $parserOut );
                }
-               # Index the stable version only
-               $wgOut->setRobotPolicy( 'noindex,nofollow' );
        }
 
        /**

Modified: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php
===================================================================
--- trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php  2010-01-29 21:00:20 UTC 
(rev 61688)
+++ trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php  2010-01-29 21:13:06 UTC 
(rev 61689)
@@ -97,11 +97,15 @@
                return true;
        }
        
+       /*
+       * Add tag notice, CSS/JS, and set robots policy
+       */
        public static function onBeforePageDisplay() {
                global $wgOut;
                if ( $wgOut->isArticleRelated() ) {
                        $view = FlaggedArticleView::singleton();
                        $view->displayTag(); // show notice bar/icon in subtitle
+                       $view->setRobotPolicy(); // set indexing policy
                        self::injectStyleAndJS(); // full CSS/JS
                } else {
                        self::InjectStyleForSpecial(); // try special page CSS

Modified: trunk/extensions/FlaggedRevs/FlaggedRevs.php
===================================================================
--- trunk/extensions/FlaggedRevs/FlaggedRevs.php        2010-01-29 21:00:20 UTC 
(rev 61688)
+++ trunk/extensions/FlaggedRevs/FlaggedRevs.php        2010-01-29 21:13:06 UTC 
(rev 61689)
@@ -457,8 +457,9 @@
 # Review/stability log links
 $wgHooks['LogLine'][] = 'FlaggedRevsHooks::logLineLinks';
 
-# Add CSS/JS as needed
+# Add CSS/JS and review notice
 $wgHooks['BeforePageDisplay'][] = 'FlaggedRevsHooks::onBeforePageDisplay';
+# Add global JS vars
 $wgHooks['MakeGlobalVariablesScript'][] = 
'FlaggedRevsHooks::injectGlobalJSVars';
 
 # Add flagging data to ApiQueryRevisions
@@ -483,13 +484,13 @@
 # Auto-reviewing
 $wgHooks['RecentChange_save'][] = 'FlaggedRevsHooks::autoMarkPatrolled';
 $wgHooks['NewRevisionFromEditComplete'][] = 
'FlaggedRevsHooks::maybeMakeEditReviewed';
+# Null edit review via checkbox
+$wgHooks['ArticleSaveComplete'][] = 'FlaggedRevsHooks::maybeNullEditReview';
 # Disable auto-promotion for demoted users
 $wgHooks['UserRights'][] = 'FlaggedRevsHooks::recordDemote';
 # User edit tallies
 $wgHooks['ArticleRollbackComplete'][] = 'FlaggedRevsHooks::incrementRollbacks';
 $wgHooks['NewRevisionFromEditComplete'][] = 
'FlaggedRevsHooks::incrementReverts';
-# Null edit review via checkbox
-$wgHooks['ArticleSaveComplete'][] = 'FlaggedRevsHooks::maybeNullEditReview';
 # Save stability settings
 $wgHooks['ProtectionForm::save'][] = 'FlaggedRevsHooks::onProtectionSave';
 # Extra cache updates for stable versions
@@ -516,6 +517,7 @@
 
 # Actually register special pages
 $wgHooks['SpecialPage_initList'][] = 'efLoadFlaggedRevsSpecialPages';
+
 # Stable dump hook
 $wgHooks['WikiExporter::dumpStableQuery'][] = 
'FlaggedRevsHooks::stableDumpQuery';
 



_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to