当前位置: 首页>>代码示例>>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;未经允许,请勿转载。