r85970 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85969‎ | r85970 | r85971 >
Date:18:15, 13 April 2011
Author:yaron
Status:deferred
Tags:
Comment:
Added removeRobotsTag() function
Modified paths:
  • /trunk/extensions/ApprovedRevs/ApprovedRevs.hooks.php (modified) (history)
  • /trunk/extensions/ApprovedRevs/ApprovedRevs.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ApprovedRevs/ApprovedRevs.php
@@ -43,6 +43,7 @@
4444 // hooks
4545 $wgHooks['ParserBeforeInternalParse'][] = 'ApprovedRevsHooks::setApprovedRevForParsing';
4646 $wgHooks['ArticleSaveComplete'][] = 'ApprovedRevsHooks::setLatestAsApproved';
 47+$wgHooks['PersonalUrls'][] = 'ApprovedRevsHooks::removeRobotsTag';
4748 $wgHooks['ArticleFromTitle'][] = 'ApprovedRevsHooks::showApprovedRevision';
4849 $wgHooks['ArticleAfterFetchContent'][] = 'ApprovedRevsHooks::showBlankIfUnapproved';
4950 $wgHooks['DisplayOldSubtitle'][] = 'ApprovedRevsHooks::setSubtitle';
Index: trunk/extensions/ApprovedRevs/ApprovedRevs.hooks.php
@@ -19,6 +19,26 @@
2020 }
2121
2222 /**
 23+ * "noindex" and "nofollow" meta-tags are added to every revision page,
 24+ * so that search engines won't index them - remove those if this is
 25+ * the approved revision.
 26+ * There doesn't seem to be an ideal MediaWiki hook to use for this
 27+ * function - it currently uses 'PersonalUrls', which works.
 28+ */
 29+ static public function removeRobotsTag( &$personal_urls, &$title ) {
 30+ if ( ! ApprovedRevs::isDefaultPageRequest() ) {
 31+ return true;
 32+ }
 33+
 34+ $revisionID = ApprovedRevs::getApprovedRevID( $title );
 35+ if ( ! empty( $revisionID ) ) {
 36+ global $wgOut;
 37+ $wgOut->setRobotPolicy( 'index,follow' );
 38+ }
 39+ return true;
 40+ }
 41+
 42+ /**
2343 * If the page is being saved, set the text of the approved revision
2444 * as the text to be parsed, for correct saving of categories,
2545 * Semantic MediaWiki properties, etc.

Status & tagging log