当前位置: 首页>>代码示例>>PHP>>正文


PHP ParserOutput::getIndexPolicy方法代码示例

本文整理汇总了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;
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:46,代码来源:Article.php


注:本文中的ParserOutput::getIndexPolicy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。