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


PHP ParserOptions::setTemplateCallback方法代码示例

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


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

示例1: 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:D66Ha,项目名称:mediawiki,代码行数:10,代码来源:ExtraParserTest.php

示例2: 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

示例3: setUp

 function setUp()
 {
     parent::setUp();
     $parser = new Parser();
     $options = new ParserOptions();
     $options->setTemplateCallback(array($this, 'templateCallback'));
     $parser->startExternalParse(Title::newMainPage(), $options, Parser::OT_HTML, true);
     try {
         $engine = new Scribunto_LuaSandboxEngine(array('parser' => $parser) + $this->sandboxOpts);
         $engine->setTitle($parser->getTitle());
         $engine->getInterpreter();
         $this->engines['LuaSandbox'] = $engine;
     } catch (Scribunto_LuaInterpreterNotFoundError $e) {
         $this->markTestSkipped("LuaSandbox interpreter not available");
         return;
     }
     try {
         $engine = new Scribunto_LuaStandaloneEngine(array('parser' => $parser) + $this->standaloneOpts);
         $engine->setTitle($parser->getTitle());
         $engine->getInterpreter();
         $this->engines['LuaStandalone'] = $engine;
     } catch (Scribunto_LuaInterpreterNotFoundError $e) {
         $this->markTestSkipped("LuaStandalone interpreter not available");
         return;
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:26,代码来源:LuaEnvironmentComparisonTest.php

示例4: runTemplateTransclusion

 /**
  * Helper method for processing a template transclusion by simulating template
  * expensions using a callback to avoid having to integrate DB read/write
  * process in order to access a Template
  *
  * @note Part of the routine has been taken from MW's ExtraParserTest
  *
  * @return text
  */
 private function runTemplateTransclusion(Title $title, $text, $return)
 {
     $parser = new \Parser();
     $options = new \ParserOptions();
     $options->setTemplateCallback(function ($title, $parser = false) use($return) {
         $text = $return;
         $deps = array();
         return array('text' => $text, 'finalTitle' => $title, 'deps' => $deps);
     });
     return $parser->preprocess($text, $title, $options);
 }
开发者ID:WolfgangFahl,项目名称:SemanticMediaWiki,代码行数:20,代码来源:InTextAnnotationParserTemplateTransclusionTest.php

示例5: makeEngine

 private function makeEngine($class, $opts)
 {
     $parser = new Parser();
     $options = new ParserOptions();
     $options->setTemplateCallback(array($this, 'templateCallback'));
     $parser->startExternalParse(Title::newMainPage(), $options, Parser::OT_HTML, true);
     $engine = new $class(array('parser' => $parser) + $opts);
     $parser->scribunto_engine = $engine;
     $engine->setTitle($parser->getTitle());
     $engine->getInterpreter();
     return $engine;
 }
开发者ID:sammykumar,项目名称:TheVRForums,代码行数:12,代码来源:LuaEnvironmentComparisonTest.php

示例6: getEngine

 function getEngine()
 {
     if (!$this->engine) {
         $parser = new Parser();
         $options = new ParserOptions();
         $options->setTemplateCallback(array($this, 'templateCallback'));
         $parser->startExternalParse(Title::newMainPage(), $options, Parser::OT_HTML, true);
         $class = "Scribunto_{$this->engineName}Engine";
         $this->engine = new $class(self::$engineConfigurations[$this->engineName] + array('parser' => $parser));
         $this->engine->setTitle($parser->getTitle());
     }
     return $this->engine;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:13,代码来源:LuaEngineTestBase.php

示例7: execute

 function execute()
 {
     global $wgParser, $wgUser;
     $wgUser = new PPFuzzUser();
     $wgUser->mName = 'Fuzz';
     $wgUser->mFrom = 'name';
     $wgUser->ppfz_test = $this;
     $options = new ParserOptions();
     $options->setTemplateCallback(array($this, 'templateHook'));
     $options->setTimestamp(wfTimestampNow());
     $this->output = call_user_func(array($wgParser, $this->entryPoint), $this->mainText, $this->title->getPrefixedText(), $options);
     return $this->output;
 }
开发者ID:rocLv,项目名称:conference,代码行数:13,代码来源:preprocessorFuzzTest.php

示例8: wfSetParserOptions

function wfSetParserOptions()
{
    global $wgParserOptions, $wgParser;
    $wgParserOptions = new ParserOptions(null);
    $wgParserOptions->setEditSection(false);
    $wgParserOptions->setTemplateCallback(array('ParserOffline', 'fetchTemplate'));
    $wgParser->Options($wgParserOptions);
    #$wgParser->disableCache();
    return $wgParserOptions;
}
开发者ID:josephdye,项目名称:wikireader,代码行数:10,代码来源:wr_parser.php

示例9: testHandleRecordTag

 function testHandleRecordTag()
 {
     global $wgDataTransclusionSources;
     $data[] = array("name" => "foo", "id" => "3", "info" => '<test>&[[X]]\'', "url" => 'http://test.org/', "evil" => 'javascript:alert("evil")');
     $spec = array('class' => 'FakeDataTransclusionSource', 'data' => $data, 'keyFields' => 'name,id', 'fieldNames' => 'id,name,info,url,evil', 'defaultKey' => 'id');
     $wgDataTransclusionSources['FOO'] = $spec;
     global $wgParser;
     $title = Title::newFromText("Dummy");
     $options = new ParserOptions();
     $options->setTemplateCallback('DataTransclusionTest::getTemplate');
     $text = 'xx <record source="FOO" id=3 extra="Hallo">Test</record> xx';
     $wgParser->parse($text, $title, $options);
     $html = $wgParser->getOutput()->getText();
     $this->assertEquals('<p>xx FOO:<b>3</b>|foo|Hallo|&lt;test&gt;&amp;&#91;&#91;X&#93;&#93;&#39;|<a href="http://test.org/" class="external text" rel="nofollow">link</a>|[javascript:alert("evil") click me] xx' . "\n" . '</p>', $html);
     // XXX: should be more lenient wrt whitespace
     $templates = $wgParser->getOutput()->getTemplates();
     $this->assertTrue(isset($templates[NS_TEMPLATE]['Test']));
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:18,代码来源:DataTransclusionTest.php


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