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


PHP ParserOptions::newFromUserAndLang方法代碼示例

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


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

示例1: setUp

 function setUp()
 {
     global $wgContLang, $wgUser, $wgLanguageCode;
     $wgContLang = Language::factory($wgLanguageCode);
     $this->popts = ParserOptions::newFromUserAndLang($wgUser, $wgContLang);
     $this->pcache = ParserCache::singleton();
 }
開發者ID:Tjorriemorrie,項目名稱:app,代碼行數:7,代碼來源:ParserOptionsTest.php

示例2: setUp

 protected function setUp()
 {
     global $wgParserConf, $wgContLang;
     parent::setUp();
     $this->mOptions = ParserOptions::newFromUserAndLang(new User(), $wgContLang);
     $name = isset($wgParserConf['preprocessorClass']) ? $wgParserConf['preprocessorClass'] : 'Preprocessor_DOM';
     $this->mPreprocessor = new $name($this);
 }
開發者ID:paladox,項目名稱:2,代碼行數:8,代碼來源:PreprocessorTest.php

示例3: testBadFunctionTagHooks

 /**
  * @dataProvider provideBadNames
  * @expectedException MWException
  * @covers Parser::setFunctionTagHook
  */
 public function testBadFunctionTagHooks($tag)
 {
     global $wgParserConf, $wgContLang;
     $parser = new Parser($wgParserConf);
     $parser->setFunctionTagHook($tag, array($this, 'functionTagCallback'), Parser::SFH_OBJECT_ARGS);
     $parser->parse("Foo<{$tag}>Bar</{$tag}>Baz", Title::newFromText('Test'), ParserOptions::newFromUserAndLang(new User(), $wgContLang));
     $this->fail('Exception not thrown.');
 }
開發者ID:D66Ha,項目名稱:mediawiki,代碼行數:13,代碼來源:TagHooksTest.php

示例4: testPreloadTransform

 /**
  * @dataProvider dataPreloadTransform
  */
 public function testPreloadTransform($text, $expected)
 {
     global $wgContLang;
     $options = ParserOptions::newFromUserAndLang($this->context->getUser(), $wgContLang);
     $content = $this->newContent($text);
     $content = $content->preloadTransform($this->context->getTitle(), $options);
     $this->assertEquals($expected, $content->getNativeData());
 }
開發者ID:mangowi,項目名稱:mediawiki,代碼行數:11,代碼來源:TextContentTest.php

示例5: setUp

 protected function setUp()
 {
     global $wgLanguageCode, $wgUser;
     parent::setUp();
     $langObj = Language::factory($wgLanguageCode);
     $this->setMwGlobals(array('wgContLang' => $langObj, 'wgUseDynamicDates' => true));
     $this->popts = ParserOptions::newFromUserAndLang($wgUser, $langObj);
     $this->pcache = ParserCache::singleton();
 }
開發者ID:nischayn22,項目名稱:mediawiki-core,代碼行數:9,代碼來源:ParserOptionsTest.php

示例6: setUp

 protected function setUp()
 {
     global $wgContLang;
     parent::setUp();
     $this->mOptions = ParserOptions::newFromUserAndLang(new User(), $wgContLang);
     $this->mPreprocessors = [];
     foreach (self::$classNames as $className) {
         $this->mPreprocessors[$className] = new $className($this);
     }
 }
開發者ID:paladox,項目名稱:mediawiki,代碼行數:10,代碼來源:PreprocessorTest.php

示例7: setUp

 protected function setUp()
 {
     parent::setUp();
     $contLang = Language::factory('en');
     $this->setMwGlobals(array('wgShowDBErrorBacktrace' => true, 'wgLanguageCode' => 'en', 'wgContLang' => $contLang, 'wgLang' => Language::factory('en'), 'wgMemc' => new EmptyBagOStuff(), 'wgAlwaysUseTidy' => false, 'wgCleanSignatures' => true));
     $this->options = ParserOptions::newFromUserAndLang(new User(), $contLang);
     $this->options->setTemplateCallback(array(__CLASS__, 'statelessFetchTemplate'));
     $this->parser = new Parser();
     MagicWord::clearCache();
 }
開發者ID:nischayn22,項目名稱:mediawiki-core,代碼行數:10,代碼來源:ExtraParserTest.php

示例8: setUp

 protected function setUp()
 {
     global $wgContLang;
     parent::setUp();
     $this->testParserOptions = ParserOptions::newFromUserAndLang(new User(), $wgContLang);
     $this->testParser = new Parser();
     $this->testParser->Options($this->testParserOptions);
     $this->testParser->clearState();
     $this->title = Title::newFromText('Preload Test');
 }
開發者ID:nischayn22,項目名稱:mediawiki-core,代碼行數:10,代碼來源:ParserPreloadTest.php

示例9: runForTitleInternal

 public static function runForTitleInternal(Title $title, Revision $revision, $fname)
 {
     global $wgParser, $wgContLang;
     wfProfileIn($fname . '-parse');
     $options = ParserOptions::newFromUserAndLang(new User(), $wgContLang);
     $parserOutput = $wgParser->parse($revision->getText(), $title, $options, true, true, $revision->getId());
     wfProfileOut($fname . '-parse');
     wfProfileIn($fname . '-update');
     $updates = $parserOutput->getSecondaryDataUpdates($title, false);
     DataUpdate::runUpdates($updates);
     wfProfileOut($fname . '-update');
 }
開發者ID:Jobava,項目名稱:diacritice-meta-repo,代碼行數:12,代碼來源:RefreshLinksJob.php

示例10: setUp

 protected function setUp()
 {
     parent::setUp();
     $contLang = Language::factory('en');
     $this->setMwGlobals(['wgShowDBErrorBacktrace' => true, 'wgCleanSignatures' => true]);
     $this->setUserLang('en');
     $this->setContentLang($contLang);
     // FIXME: This test should pass without setting global content language
     $this->options = ParserOptions::newFromUserAndLang(new User(), $contLang);
     $this->options->setTemplateCallback([__CLASS__, 'statelessFetchTemplate']);
     $this->parser = new Parser();
     MagicWord::clearCache();
 }
開發者ID:claudinec,項目名稱:galan-wiki,代碼行數:13,代碼來源:ExtraParserTest.php

示例11: setUp

 /** setup a basic parser object */
 protected function setUp()
 {
     parent::setUp();
     $contLang = Language::factory('en');
     $this->setMwGlobals(array('wgLanguageCode' => 'en', 'wgContLang' => $contLang));
     $this->testParser = new Parser();
     $this->testParser->Options(ParserOptions::newFromUserAndLang(new User(), $contLang));
     # initialize parser output
     $this->testParser->clearState();
     # Needs a title to do magic word stuff
     $title = Title::newFromText('Tests');
     $title->mRedirect = false;
     # Else it needs a db connection just to check if it's a redirect (when deciding the page language)
     $this->testParser->setTitle($title);
 }
開發者ID:biribogos,項目名稱:wikihow-src,代碼行數:16,代碼來源:MagicVariableTest.php

示例12: makeParserOptions

 /**
  * Get parser options suitable for rendering and caching the article
  *
  * @param IContextSource|User|string $context One of the following:
  *        - IContextSource: Use the User and the Language of the provided
  *                                            context
  *        - User: Use the provided User object and $wgLang for the language,
  *                                            so use an IContextSource object if possible.
  *        - 'canonical': Canonical options (anonymous user with default
  *                                            preferences and content language).
  *
  * @throws MWException
  * @return ParserOptions
  */
 public function makeParserOptions($context)
 {
     global $wgContLang, $wgEnableParserLimitReporting;
     if ($context instanceof IContextSource) {
         $options = ParserOptions::newFromContext($context);
     } elseif ($context instanceof User) {
         // settings per user (even anons)
         $options = ParserOptions::newFromUser($context);
     } elseif ($context === 'canonical') {
         // canonical settings
         $options = ParserOptions::newFromUserAndLang(new User(), $wgContLang);
     } else {
         throw new MWException("Bad context for parser options: {$context}");
     }
     $options->enableLimitReport($wgEnableParserLimitReporting);
     // show inclusion/loop reports
     $options->setTidy(true);
     // fix bad HTML
     return $options;
 }
開發者ID:Tarendai,項目名稱:spring-website,代碼行數:34,代碼來源:ContentHandler.php

示例13: prepareTextForEdit

 /**
  * Prepare text which is about to be saved.
  * Returns a stdclass with source, pst and output members
  * @return bool|object
  */
 public function prepareTextForEdit($text, $revid = null, User $user = null)
 {
     global $wgParser, $wgContLang, $wgUser;
     $user = is_null($user) ? $wgUser : $user;
     // @TODO fixme: check $user->getId() here???
     if ($this->mPreparedEdit && $this->mPreparedEdit->newText == $text && $this->mPreparedEdit->revid == $revid) {
         // Already prepared
         return $this->mPreparedEdit;
     }
     $popts = ParserOptions::newFromUserAndLang($user, $wgContLang);
     wfRunHooks('ArticlePrepareTextForEdit', array($this, $popts));
     $edit = (object) array();
     $edit->revid = $revid;
     $edit->newText = $text;
     $edit->pst = $wgParser->preSaveTransform($text, $this->mTitle, $user, $popts);
     $edit->popts = $this->makeParserOptions('canonical');
     $edit->output = $wgParser->parse($edit->pst, $this->mTitle, $edit->popts, true, true, $revid);
     $edit->oldText = $this->getRawText();
     $this->mPreparedEdit = $edit;
     return $edit;
 }
開發者ID:seedbank,項目名稱:old-repo,代碼行數:26,代碼來源:WikiPage.php

示例14: showDiff

 /**
  * Get a diff between the current contents of the edit box and the
  * version of the page we're editing from.
  *
  * If this is a section edit, we'll replace the section as for final
  * save and then make a comparison.
  */
 function showDiff()
 {
     global $wgUser, $wgContLang, $wgParser, $wgOut;
     $oldtext = $this->mArticle->getRawText();
     $newtext = $this->mArticle->replaceSection($this->section, $this->textbox1, $this->summary, $this->edittime);
     wfRunHooks('EditPageGetDiffText', array($this, &$newtext));
     $popts = ParserOptions::newFromUserAndLang($wgUser, $wgContLang);
     $newtext = $wgParser->preSaveTransform($newtext, $this->mTitle, $wgUser, $popts);
     if ($oldtext !== false || $newtext != '') {
         $oldtitle = wfMsgExt('currentrev', array('parseinline'));
         $newtitle = wfMsgExt('yourtext', array('parseinline'));
         $de = new DifferenceEngine($this->mArticle->getContext());
         $de->setText($oldtext, $newtext);
         $difftext = $de->getDiff($oldtitle, $newtitle);
         $de->showDiffStyle();
     } else {
         $difftext = '';
     }
     $wgOut->addHTML('<div id="wikiDiff">' . $difftext . '</div>');
 }
開發者ID:slackfaith,項目名稱:deadbrain_site,代碼行數:27,代碼來源:EditPage.php

示例15: showDiff

 /**
  * Get a diff between the current contents of the edit box and the
  * version of the page we're editing from.
  *
  * If this is a section edit, we'll replace the section as for final
  * save and then make a comparison.
  */
 function showDiff()
 {
     global $wgUser, $wgContLang, $wgOut;
     $oldtitlemsg = 'currentrev';
     # if message does not exist, show diff against the preloaded default
     if ($this->mTitle->getNamespace() == NS_MEDIAWIKI && !$this->mTitle->exists()) {
         $oldtext = $this->mTitle->getDefaultMessageText();
         if ($oldtext !== false) {
             $oldtitlemsg = 'defaultmessagetext';
             $oldContent = $this->toEditContent($oldtext);
         } else {
             $oldContent = null;
         }
     } else {
         $oldContent = $this->getCurrentContent();
     }
     $textboxContent = $this->toEditContent($this->textbox1);
     $newContent = $this->mArticle->replaceSectionContent($this->section, $textboxContent, $this->summary, $this->edittime);
     if ($newContent) {
         ContentHandler::runLegacyHooks('EditPageGetDiffText', array($this, &$newContent));
         wfRunHooks('EditPageGetDiffContent', array($this, &$newContent));
         $popts = ParserOptions::newFromUserAndLang($wgUser, $wgContLang);
         $newContent = $newContent->preSaveTransform($this->mTitle, $wgUser, $popts);
     }
     if ($oldContent && !$oldContent->isEmpty() || $newContent && !$newContent->isEmpty()) {
         $oldtitle = wfMessage($oldtitlemsg)->parse();
         $newtitle = wfMessage('yourtext')->parse();
         if (!$oldContent) {
             $oldContent = $newContent->getContentHandler()->makeEmptyContent();
         }
         if (!$newContent) {
             $newContent = $oldContent->getContentHandler()->makeEmptyContent();
         }
         $de = $oldContent->getContentHandler()->createDifferenceEngine($this->mArticle->getContext());
         $de->setContent($oldContent, $newContent);
         $difftext = $de->getDiff($oldtitle, $newtitle);
         $de->showDiffStyle();
     } else {
         $difftext = '';
     }
     $wgOut->addHTML('<div id="wikiDiff">' . $difftext . '</div>');
 }
開發者ID:whysasse,項目名稱:kmwiki,代碼行數:49,代碼來源:EditPage.php


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