if ( 0 == $this->getID() ) {
wfProfileOut( __METHOD__ );
- $wgOut->setRobotpolicy( 'noindex,nofollow' );
+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
$wgMessageCache->loadAllMessages();
# We're looking at an old revision
if ( !empty( $oldid ) ) {
- $wgOut->setRobotpolicy( 'noindex,nofollow' );
+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
if( is_null( $this->mRevision ) ) {
// FIXME: This would be a nice place to load the 'no such page' text.
} else {
"</form>\n", $msg );
$wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
- $wgOut->setRobotpolicy( 'noindex,nofollow' );
+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
$wgOut->addHTML( $msg );
}
}
if( $this->doWatch() ) {
$wgOut->setPagetitle( wfMsg( 'addedwatch' ) );
- $wgOut->setRobotpolicy( 'noindex,nofollow' );
+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
$wgOut->addWikiMsg( 'addedwatchtext', $this->mTitle->getPrefixedText() );
}
if( $this->doUnwatch() ) {
$wgOut->setPagetitle( wfMsg( 'removedwatch' ) );
- $wgOut->setRobotpolicy( 'noindex,nofollow' );
+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
$wgOut->addWikiMsg( 'removedwatchtext', $this->mTitle->getPrefixedText() );
}
wfDebug( "Article::confirmDelete\n" );
$wgOut->setSubtitle( wfMsg( 'delete-backlink', $wgUser->getSkin()->makeKnownLinkObj( $this->mTitle ) ) );
- $wgOut->setRobotpolicy( 'noindex,nofollow' );
+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
$wgOut->addWikiMsg( 'confirmdeletetext' );
if( $wgUser->isAllowed( 'suppressrevision' ) ) {
$deleted = $this->mTitle->getPrefixedText();
$wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
- $wgOut->setRobotpolicy( 'noindex,nofollow' );
+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
$loglink = '[[Special:Log/delete|' . wfMsgNoTrans( 'deletionlog' ) . ']]';
$wgOut->setSubtitle( wfMsg( 'creditspage' ) );
$wgOut->setArticleFlag( false );
$wgOut->setArticleRelated( true );
- $wgOut->setRobotpolicy( 'noindex,nofollow' );
+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
if( $article->mTitle->getArticleID() == 0 ) {
$s = wfMsg( 'nocredits' );
$wgOut->setPageTitle( $oldTitle . ', ' . $newTitle );
}
$wgOut->setSubtitle( wfMsg( 'difference' ) );
- $wgOut->setRobotpolicy( 'noindex,nofollow' );
+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
if ( !( $this->mOldPage->userCanRead() && $this->mNewPage->userCanRead() ) ) {
$wgOut->loginToUse();
$wgOut->addHTML( $header );
$wgOut->setSubtitle( wfMsg( 'difference' ) );
- $wgOut->setRobotpolicy( 'noindex,nofollow' );
+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
wfProfileOut( __METHOD__ );
}
wfRunHooks( 'EditPage::showEditForm:initial', array( &$this ) ) ;
- $wgOut->setRobotpolicy( 'noindex,nofollow' );
+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
# Enabled article-related sidebar, toplinks, etc.
$wgOut->setArticleRelated( true );
global $wgOut;
if ( $this->useOutputPage() ) {
$wgOut->setPageTitle( $this->getPageTitle() );
- $wgOut->setRobotpolicy( "noindex,nofollow" );
+ $wgOut->setRobotPolicy( "noindex,nofollow" );
$wgOut->setArticleRelated( false );
$wgOut->enableClientCache( false );
$wgOut->redirect( '' );
} else {
# Just need to set the right headers
$wgOut->setArticleFlag( true );
- $wgOut->setRobotpolicy( 'noindex,nofollow' );
+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
$wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
$this->viewUpdates();
}
function showError( $description ) {
global $wgOut;
$wgOut->setPageTitle( wfMsg( "internalerror" ) );
- $wgOut->setRobotpolicy( "noindex,nofollow" );
+ $wgOut->setRobotPolicy( "noindex,nofollow" );
$wgOut->setArticleRelated( false );
$wgOut->enableClientCache( false );
$wgOut->addWikiText( $description );
class OutputPage {
var $mMetatags, $mKeywords;
var $mLinktags, $mPagetitle, $mBodytext, $mDebugtext;
- var $mHTMLtitle, $mRobotpolicy, $mIsarticle, $mPrintable;
+ var $mHTMLtitle, $mIsarticle, $mPrintable;
var $mSubtitle, $mRedirect, $mStatusCode;
var $mLastModified, $mETag, $mCategoryLinks;
var $mScripts, $mLinkColours, $mPageLinkTitle;
var $mPageTitleActionText = '';
var $mParseWarnings = array();
+ private $mIndexPolicy = 'index';
+ private $mFollowPolicy = 'follow';
+
/**
* Constructor
* Initialise private variables
$this->mAllowUserJs = $wgAllowUserJs;
$this->mMetatags = $this->mKeywords = $this->mLinktags = array();
$this->mHTMLtitle = $this->mPagetitle = $this->mBodytext =
- $this->mRedirect = $this->mLastModified =
- $this->mSubtitle = $this->mDebugtext = $this->mRobotpolicy =
- $this->mOnloadHandler = $this->mPageLinkTitle = '';
+ $this->mRedirect = $this->mLastModified = $this->mSubtitle =
+ $this->mDebugtext = $this->mOnloadHandler = $this->mPageLinkTitle = '';
$this->mIsArticleRelated = $this->mIsarticle = $this->mPrintable = true;
$this->mSuppressQuickbar = $this->mPrintable = false;
$this->mLanguageLinks = array();
}
}
- public function setRobotpolicy( $str ) { $this->mRobotpolicy = $str; }
+ /**
+ * Set the robot policy for the page: <http://www.robotstxt.org/meta.html>
+ *
+ * @param $policy string The literal string to output as the contents of
+ * the meta tag. Will be parsed according to the spec and output in
+ * standardized form.
+ * @return null
+ */
+ public function setRobotPolicy( $policy ) {
+ $policy = explode( ',', $policy );
+ $policy = array_map( 'trim', $policy );
+
+ # The default policy is follow, so if nothing is said explicitly, we
+ # do that.
+ if( in_array( 'nofollow', $policy ) ) {
+ $this->mFollowPolicy = 'nofollow';
+ } else {
+ $this->mFollowPolicy = 'follow';
+ }
+
+ if( in_array( 'noindex', $policy ) ) {
+ $this->mIndexPolicy = 'noindex';
+ } else {
+ $this->mIndexPolicy = 'index';
+ }
+ }
+
+ /**
+ * Set the index policy for the page, but leave the follow policy un-
+ * touched.
+ *
+ * @param $policy string Either 'index' or 'noindex'.
+ * @return null
+ */
+ public function setIndexPolicy( $policy ) {
+ $policy = trim( $policy );
+ if( in_array( $policy, array( 'index', 'noindex' ) ) ) {
+ $this->mIndexPolicy = $policy;
+ }
+ }
+
+ /**
+ * Set the follow policy for the page, but leave the index policy un-
+ * touched.
+ *
+ * @param $policy string Either 'follow' or 'nofollow'.
+ * @return null
+ */
+ public function setFollowPolicy( $policy ) {
+ $policy = trim( $policy );
+ if( in_array( $policy, array( 'follow', 'nofollow' ) ) ) {
+ $this->mFollowPolicy = $policy;
+ }
+ }
+
public function setHTMLTitle( $name ) {$this->mHTMLtitle = $name; }
public function setPageTitle( $name ) {
global $action, $wgContLang;
global $wgUser, $wgContLang, $wgTitle, $wgLang;
$this->setPageTitle( wfMsg( 'blockedtitle' ) );
- $this->setRobotpolicy( 'noindex,nofollow' );
+ $this->setRobotPolicy( 'noindex,nofollow' );
$this->setArticleRelated( false );
$name = User::whoIs( $wgUser->blockedBy() );
}
$this->setPageTitle( wfMsg( $title ) );
$this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
- $this->setRobotpolicy( 'noindex,nofollow' );
+ $this->setRobotPolicy( 'noindex,nofollow' );
$this->setArticleRelated( false );
$this->enableClientCache( false );
$this->mRedirect = '';
$wgTitle->getPrefixedText() . "\n";
$this->setPageTitle( wfMsg( 'permissionserrors' ) );
$this->setHTMLTitle( wfMsg( 'permissionserrors' ) );
- $this->setRobotpolicy( 'noindex,nofollow' );
+ $this->setRobotPolicy( 'noindex,nofollow' );
$this->setArticleRelated( false );
$this->enableClientCache( false );
$this->mRedirect = '';
public function versionRequired( $version ) {
$this->setPageTitle( wfMsg( 'versionrequired', $version ) );
$this->setHTMLTitle( wfMsg( 'versionrequired', $version ) );
- $this->setRobotpolicy( 'noindex,nofollow' );
+ $this->setRobotPolicy( 'noindex,nofollow' );
$this->setArticleRelated( false );
$this->mBodytext = '';
$this->setPageTitle( wfMsg( 'badaccess' ) );
$this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
- $this->setRobotpolicy( 'noindex,nofollow' );
+ $this->setRobotPolicy( 'noindex,nofollow' );
$this->setArticleRelated( false );
$this->mBodytext = '';
global $wgUser, $wgTitle;
$skin = $wgUser->getSkin();
- $this->setRobotpolicy( 'noindex,nofollow' );
+ $this->setRobotPolicy( 'noindex,nofollow' );
$this->setArticleRelated( false );
// If no reason is given, just supply a default "I can't let you do
public function showFatalError( $message ) {
$this->setPageTitle( wfMsg( "internalerror" ) );
- $this->setRobotpolicy( "noindex,nofollow" );
+ $this->setRobotPolicy( "noindex,nofollow" );
$this->setArticleRelated( false );
$this->enableClientCache( false );
$this->mRedirect = '';
global $wgVersion;
$this->addMeta( "generator", "MediaWiki $wgVersion" );
- $p = $this->mRobotpolicy;
- if( $p !== '' && $p != 'index,follow' ) {
+ $p = "{$this->mIndexPolicy},{$this->mFollowPolicy}";
+ if( $p !== 'index,follow' ) {
// http://www.robotstxt.org/wc/meta-user.html
// Only show if it's different from the default robots policy
$this->addMeta( 'robots', $p );
$wgOut->setPageTitleActionText( wfMsg( 'history_short' ) );
$wgOut->setArticleFlag( false );
$wgOut->setArticleRelated( true );
- $wgOut->setRobotpolicy( 'noindex,nofollow' );
+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
$wgOut->setSyndicated( true );
$wgOut->setFeedAppendQuery( 'action=history' );
$wgOut->addScriptFile( 'history.js' );
function show( $err = null ) {
global $wgOut, $wgUser;
- $wgOut->setRobotpolicy( 'noindex,nofollow' );
+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
if( is_null( $this->mTitle ) ||
$this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
if ( !$page ) {
if ( !$including ) {
$wgOut->setArticleRelated( false );
- $wgOut->setRobotpolicy( 'noindex,nofollow' );
+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
$wgOut->setStatusCode( 404 );
$wgOut->showErrorPage( 'nosuchspecialpage', 'nospecialpagetext' );
}
$wgOut->setPageTitle( wfMsg( 'preferences' ) );
$wgOut->setArticleRelated( false );
- $wgOut->setRobotpolicy( 'noindex,nofollow' );
+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
$wgOut->addScriptFile( 'prefs.js' );
$wgOut->disallowUserJs(); # Prevent hijacked user scripts from sniffing passwords etc.
$subtitlemsg = ( Title::newFromText( $term ) ? 'searchsubtitle' : 'searchsubtitleinvalid' );
$wgOut->setSubtitle( $wgOut->parse( wfMsg( $subtitlemsg, wfEscapeWikiText($term) ) ) );
$wgOut->setArticleRelated( false );
- $wgOut->setRobotpolicy( 'noindex,nofollow' );
+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
}
/**
$wgMessageCache->loadAllMessages();
- $wgOut->setRobotpolicy( 'noindex,nofollow' ); # Is this really needed?
+ $wgOut->setRobotPolicy( 'noindex,nofollow' ); # Is this really needed?
$sk = $wgUser->getSkin();
$pages = SpecialPage::getUsablePages();
function showError( $description ) {
global $wgOut;
$wgOut->setPageTitle( wfMsg( "internalerror" ) );
- $wgOut->setRobotpolicy( "noindex,nofollow" );
+ $wgOut->setRobotPolicy( "noindex,nofollow" );
$wgOut->setArticleRelated( false );
$wgOut->enableClientCache( false );
$wgOut->addWikiText( $description );
wfRunHooks( 'AddNewAccount', array( $u, true ) );
$wgOut->setPageTitle( wfMsg( 'accmailtitle' ) );
- $wgOut->setRobotpolicy( 'noindex,nofollow' );
+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
$wgOut->setArticleRelated( false );
if( WikiError::isError( $result ) ) {
wfRunHooks('UserLoginComplete', array(&$wgUser, &$injected_html));
$wgOut->setPageTitle( wfMsg( 'loginsuccesstitle' ) );
- $wgOut->setRobotpolicy( 'noindex,nofollow' );
+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
$wgOut->setArticleRelated( false );
$wgOut->addWikiMsgArray( $msg, $params );
$wgOut->addHtml( $injected_html );
global $wgOut;
$wgOut->setPageTitle( wfMsg( 'permissionserrors' ) );
- $wgOut->setRobotpolicy( 'noindex,nofollow' );
+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
$wgOut->setArticleRelated( false );
$wgOut->addWikitext( $wgOut->formatPermissionsErrorMessage( $errors, 'createaccount' ) );
# out.
$wgOut->setPageTitle( wfMsg( 'cantcreateaccounttitle' ) );
- $wgOut->setRobotpolicy( 'noindex,nofollow' );
+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
$wgOut->setArticleRelated( false );
$ip = wfGetIP();
}
$wgOut->setPageTitle( wfMsg( 'userlogin' ) );
- $wgOut->setRobotpolicy( 'noindex,nofollow' );
+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
$wgOut->setArticleRelated( false );
$wgOut->disallowUserJs(); // just in case...
$wgOut->addTemplate( $template );
$oldName = $wgUser->getName();
$wgUser->logout();
- $wgOut->setRobotpolicy( 'noindex,nofollow' );
+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
// Hook.
$injected_html = '';