Added $wgNamespaceRobotPolicies to allow customisation of robot policies on a per...
authorTim Starling <tstarling@users.mediawiki.org>
Sun, 4 Jun 2006 00:25:53 +0000 (00:25 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sun, 4 Jun 2006 00:25:53 +0000 (00:25 +0000)
RELEASE-NOTES
includes/Article.php
includes/DefaultSettings.php

index 382b787..7d709a7 100644 (file)
@@ -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 ==
 
index d4a3cde..d6890a0 100644 (file)
@@ -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') );
                }
index acfceac..1b3e2d4 100644 (file)
@@ -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.