本文整理汇总了PHP中ParserOutput::getIndexPolicy方法的典型用法代码示例。如果您正苦于以下问题:PHP ParserOutput::getIndexPolicy方法的具体用法?PHP ParserOutput::getIndexPolicy怎么用?PHP ParserOutput::getIndexPolicy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParserOutput
的用法示例。
在下文中一共展示了ParserOutput::getIndexPolicy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRobotPolicy
/**
* Get the robot policy to be used for the current view
* @param $action String the action= GET parameter
* @return Array the policy that should be set
* TODO: actions other than 'view'
*/
public function getRobotPolicy($action)
{
global $wgOut, $wgArticleRobotPolicies, $wgNamespaceRobotPolicies;
global $wgDefaultRobotPolicy, $wgRequest;
$ns = $this->getTitle()->getNamespace();
if ($ns == NS_USER || $ns == NS_USER_TALK) {
# Don't index user and user talk pages for blocked users (bug 11443)
if (!$this->getTitle()->isSubpage()) {
if (Block::newFromTarget(null, $this->getTitle()->getText()) instanceof Block) {
return array('index' => 'noindex', 'follow' => 'nofollow');
}
}
}
if ($this->mPage->getID() === 0 || $this->getOldID()) {
# Non-articles (special pages etc), and old revisions
return array('index' => 'noindex', 'follow' => 'nofollow');
} elseif ($wgOut->isPrintable()) {
# Discourage indexing of printable versions, but encourage following
return array('index' => 'noindex', 'follow' => 'follow');
} elseif ($wgRequest->getInt('curid')) {
# For ?curid=x urls, disallow indexing
return array('index' => 'noindex', 'follow' => 'follow');
}
# Otherwise, construct the policy based on the various config variables.
$policy = self::formatRobotPolicy($wgDefaultRobotPolicy);
if (isset($wgNamespaceRobotPolicies[$ns])) {
# Honour customised robot policies for this namespace
$policy = array_merge($policy, self::formatRobotPolicy($wgNamespaceRobotPolicies[$ns]));
}
if ($this->getTitle()->canUseNoindex() && is_object($this->mParserOutput) && $this->mParserOutput->getIndexPolicy()) {
# __INDEX__ and __NOINDEX__ magic words, if allowed. Incorporates
# a final sanity check that we have really got the parser output.
$policy = array_merge($policy, array('index' => $this->mParserOutput->getIndexPolicy()));
}
if (isset($wgArticleRobotPolicies[$this->getTitle()->getPrefixedText()])) {
# (bug 14900) site config can override user-defined __INDEX__ or __NOINDEX__
$policy = array_merge($policy, self::formatRobotPolicy($wgArticleRobotPolicies[$this->getTitle()->getPrefixedText()]));
}
return $policy;
}