From c5acd3db4bb2fba2aa6c865536900bbdea946c68 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Sun, 4 Jun 2006 00:25:53 +0000 Subject: [PATCH] Added $wgNamespaceRobotPolicies to allow customisation of robot policies on a per-namespace basis. --- RELEASE-NOTES | 2 ++ includes/Article.php | 17 +++++++++++++---- includes/DefaultSettings.php | 6 ++++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 382b7878a7..7d709a731b 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -420,6 +420,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 6170) Update for Kashubian translation (csb) * (bug 6191) Update to Indonesian translation (id) #18 * (bug 6114) Update to Walloon localization (wa) +* Added $wgNamespaceRobotPolicies to allow customisation of robot policies on a + per-namespace basis. == Compatibility == diff --git a/includes/Article.php b/includes/Article.php index d4a3cdef44..d6890a0d18 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -736,12 +736,15 @@ class Article { function view() { global $wgUser, $wgOut, $wgRequest, $wgContLang; global $wgEnableParserCache, $wgStylePath, $wgUseRCPatrol, $wgParser; - global $wgUseTrackbacks; + global $wgUseTrackbacks, $wgNamespaceRobotPolicies; $sk = $wgUser->getSkin(); $fname = 'Article::view'; wfProfileIn( $fname ); + $parserCache =& ParserCache::singleton(); + $ns = $this->mTitle->getNamespace(); # shortcut + # Get variables from query string $oldid = $this->getOldID(); @@ -757,7 +760,13 @@ class Article { $rdfrom = $wgRequest->getVal( 'rdfrom' ); $wgOut->setArticleFlag( true ); - $wgOut->setRobotpolicy( 'index,follow' ); + if ( isset( $wgNamespaceRobotPolicies[$ns] ) ) { + $policy = $wgNamespaceRobotPolicies[$ns]; + } else { + $policy = 'index,follow'; + } + $wgOut->setRobotpolicy( $policy ); + # If we got diff and oldid in the query, we want to see a # diff page instead of the article. @@ -884,7 +893,7 @@ class Article { # wrap user css and user js in pre and don't parse # XXX: use $this->mTitle->usCssJsSubpage() when php is fixed/ a workaround is found if ( - $this->mTitle->getNamespace() == NS_USER && + $ns == NS_USER && preg_match('/\\/[\\w]+\\.(css|js)$/', $this->mTitle->getDBkey()) ) { $wgOut->addWikiText( wfMsg('clearyourcache')); @@ -932,7 +941,7 @@ class Article { } # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page - if( $this->mTitle->getNamespace() == NS_USER_TALK && + if( $ns == NS_USER_TALK && User::isIP( $this->mTitle->getText() ) ) { $wgOut->addWikiText( wfMsg('anontalkpagetext') ); } diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index acfceac2bf..1b3e2d41ba 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1843,6 +1843,12 @@ $wgNoFollowLinks = true; */ $wgNoFollowNsExceptions = array(); +/** + * Robot policies for namespaces + * e.g. $wgNamespaceRobotPolicies = array( NS_TALK => 'noindex' ); + */ +$wgNamespaceRobotPolicies = array(); + /** * Specifies the minimal length of a user password. If set to * 0, empty passwords are allowed. -- 2.20.1