本文整理匯總了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;
}