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


PHP ParserOptions::getUser方法代码示例

本文整理汇总了PHP中ParserOptions::getUser方法的典型用法代码示例。如果您正苦于以下问题:PHP ParserOptions::getUser方法的具体用法?PHP ParserOptions::getUser怎么用?PHP ParserOptions::getUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ParserOptions的用法示例。


在下文中一共展示了ParserOptions::getUser方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getUser

 /**
  * Get a User object either from $this->mUser, if set, or from the
  * ParserOptions object otherwise
  *
  * @return User object
  */
 function getUser()
 {
     if (!is_null($this->mUser)) {
         return $this->mUser;
     }
     return $this->mOptions->getUser();
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:13,代码来源:Parser.php

示例2: stashEditFromPreview

 /**
  * Attempt to cache PST content and corresponding parser output in passing
  *
  * This method can be called when the output was already generated for other
  * reasons. Parsing should not be done just to call this method, however.
  * $pstOpts must be that of the user doing the edit preview. If $pOpts does
  * not match the options of WikiPage::makeParserOptions( 'canonical' ), this
  * will do nothing. Provided the values are cacheable, they will be stored
  * in memcached so that final edit submission might make use of them.
  *
  * @param Article|WikiPage $page Page title
  * @param Content $content Proposed page content
  * @param Content $pstContent The result of preSaveTransform() on $content
  * @param ParserOutput $pOut The result of getParserOutput() on $pstContent
  * @param ParserOptions $pstOpts Options for $pstContent (MUST be for prospective author)
  * @param ParserOptions $pOpts Options for $pOut
  * @param string $timestamp TS_MW timestamp of parser output generation
  * @return bool Success
  */
 public static function stashEditFromPreview(Page $page, Content $content, Content $pstContent, ParserOutput $pOut, ParserOptions $pstOpts, ParserOptions $pOpts, $timestamp)
 {
     global $wgMemc;
     // getIsPreview() controls parser function behavior that references things
     // like user/revision that don't exists yet. The user/text should already
     // be set correctly by callers, just double check the preview flag.
     if (!$pOpts->getIsPreview()) {
         return false;
         // sanity
     } elseif ($pOpts->getIsSectionPreview()) {
         return false;
         // short-circuit (need the full content)
     }
     // PST parser options are for the user (handles signatures, etc...)
     $user = $pstOpts->getUser();
     // Get a key based on the source text, format, and user preferences
     $key = self::getStashKey($page->getTitle(), $content, $user);
     // Parser output options must match cannonical options.
     // Treat some options as matching that are different but don't matter.
     $canonicalPOpts = $page->makeParserOptions('canonical');
     $canonicalPOpts->setIsPreview(true);
     // force match
     $canonicalPOpts->setTimestamp($pOpts->getTimestamp());
     // force match
     if (!$pOpts->matches($canonicalPOpts)) {
         wfDebugLog('StashEdit', "Uncacheable preview output for key '{$key}' (options).");
         return false;
     }
     // Build a value to cache with a proper TTL
     list($stashInfo, $ttl) = self::buildStashValue($pstContent, $pOut, $timestamp);
     if (!$stashInfo) {
         wfDebugLog('StashEdit', "Uncacheable parser output for key '{$key}' (rev/TTL).");
         return false;
     }
     $ok = $wgMemc->set($key, $stashInfo, $ttl);
     if (!$ok) {
         wfDebugLog('StashEdit', "Failed to cache preview parser output for key '{$key}'.");
     } else {
         wfDebugLog('StashEdit', "Cached preview output for key '{$key}'.");
     }
     return $ok;
 }
开发者ID:natebrunette,项目名称:sphericalcow,代码行数:61,代码来源:ApiStashEdit.php


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