Index: trunk/extensions/ApprovedRevs/ApprovedRevs.php |
— | — | @@ -43,6 +43,7 @@ |
44 | 44 | // hooks |
45 | 45 | $wgHooks['ParserBeforeInternalParse'][] = 'ApprovedRevsHooks::setApprovedRevForParsing'; |
46 | 46 | $wgHooks['ArticleSaveComplete'][] = 'ApprovedRevsHooks::setLatestAsApproved'; |
| 47 | +$wgHooks['PersonalUrls'][] = 'ApprovedRevsHooks::removeRobotsTag'; |
47 | 48 | $wgHooks['ArticleFromTitle'][] = 'ApprovedRevsHooks::showApprovedRevision'; |
48 | 49 | $wgHooks['ArticleAfterFetchContent'][] = 'ApprovedRevsHooks::showBlankIfUnapproved'; |
49 | 50 | $wgHooks['DisplayOldSubtitle'][] = 'ApprovedRevsHooks::setSubtitle'; |
Index: trunk/extensions/ApprovedRevs/ApprovedRevs.hooks.php |
— | — | @@ -19,6 +19,26 @@ |
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
| 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 | + /** |
23 | 43 | * If the page is being saved, set the text of the approved revision |
24 | 44 | * as the text to be parsed, for correct saving of categories, |
25 | 45 | * Semantic MediaWiki properties, etc. |