當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ParserOptions::getIsPreview方法代碼示例

本文整理匯總了PHP中ParserOptions::getIsPreview方法的典型用法代碼示例。如果您正苦於以下問題:PHP ParserOptions::getIsPreview方法的具體用法?PHP ParserOptions::getIsPreview怎麽用?PHP ParserOptions::getIsPreview使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ParserOptions的用法示例。


在下文中一共展示了ParserOptions::getIsPreview方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getRevisionUser

 /**
  * Get the name of the user that edited the last revision
  *
  * @return String: user name
  */
 function getRevisionUser()
 {
     if (is_null($this->mRevisionUser)) {
         $revObject = $this->getRevisionObject();
         # if this template is subst: the revision id will be blank,
         # so just use the current user's name
         if ($revObject) {
             $this->mRevisionUser = $revObject->getUserText();
         } elseif ($this->ot['wiki'] || $this->mOptions->getIsPreview()) {
             $this->mRevisionUser = $this->getUser()->getName();
         }
     }
     return $this->mRevisionUser;
 }
開發者ID:h4ck3rm1k3,項目名稱:mediawiki,代碼行數:19,代碼來源:Parser.php

示例2: getRevisionSize

 /**
  * Get the size of the revision
  *
  * @return int|null revision size
  */
 function getRevisionSize()
 {
     if (is_null($this->mRevisionSize)) {
         $revObject = $this->getRevisionObject();
         # if this variable is subst: the revision id will be blank,
         # so just use the parser input size, because the own substituation
         # will change the size.
         if ($revObject) {
             $this->mRevisionSize = $revObject->getSize();
         } elseif ($this->ot['wiki'] || $this->mOptions->getIsPreview()) {
             $this->mRevisionSize = $this->mInputSize;
         }
     }
     return $this->mRevisionSize;
 }
開發者ID:Tarendai,項目名稱:spring-website,代碼行數:20,代碼來源:Parser.php

示例3: 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::getIsPreview方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。