MediaWiki r14559 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r14558‎ | r14559 (on ViewVC)‎ | r14560 >
Date:00:25, 4 June 2006
Author:tstarling
Status:old
Tags:
Comment:
Added $wgNamespaceRobotPolicies to allow customisation of robot policies on a per-namespace basis.
Modified paths:

Diff [purge]

Index: trunk/phase3/includes/Article.php
===================================================================
--- trunk/phase3/includes/Article.php	(revision 14558)
+++ trunk/phase3/includes/Article.php	(revision 14559)
@@ -736,12 +736,15 @@
 	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 @@
 		$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 @@
 			# 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 @@
 		}
 		
 		# 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: trunk/phase3/includes/DefaultSettings.php
===================================================================
--- trunk/phase3/includes/DefaultSettings.php	(revision 14558)
+++ trunk/phase3/includes/DefaultSettings.php	(revision 14559)
@@ -1844,6 +1844,12 @@
 $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.
  */
Index: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES	(revision 14558)
+++ trunk/phase3/RELEASE-NOTES	(revision 14559)
@@ -420,6 +420,8 @@
 * (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 ==
 

Status & tagging log

  • 01:58, 13 October 2010 ^demon (Talk | contribs) changed the status of r14559 [removed: new added: old]
Personal tools
Namespaces
Variants
Views
Actions
Site
Support
Download
Development
Communication
Toolbox