本文整理汇总了PHP中RequestContext::setLanguage方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestContext::setLanguage方法的具体用法?PHP RequestContext::setLanguage怎么用?PHP RequestContext::setLanguage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RequestContext
的用法示例。
在下文中一共展示了RequestContext::setLanguage方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
protected function setUp()
{
parent::setUp();
global $wgLang;
$this->setMwGlobals(array('wgLogTypes' => array('phpunit'), 'wgLogActionsHandlers' => array('phpunit/test' => 'LogFormatter', 'phpunit/param' => 'LogFormatter'), 'wgUser' => User::newFromName('Testuser'), 'wgExtensionMessagesFiles' => array('LogTests' => __DIR__ . '/LogTests.i18n.php')));
Language::getLocalisationCache()->recache($wgLang->getCode());
$this->user = User::newFromName('Testuser');
$this->title = Title::newMainPage();
$this->context = new RequestContext();
$this->context->setUser($this->user);
$this->context->setTitle($this->title);
$this->context->setLanguage($wgLang);
}
示例2: setUp
protected function setUp()
{
parent::setUp();
global $wgLang;
$this->setMwGlobals(['wgLogTypes' => ['phpunit'], 'wgLogActionsHandlers' => ['phpunit/test' => 'LogFormatter', 'phpunit/param' => 'LogFormatter'], 'wgUser' => User::newFromName('Testuser'), 'wgExtensionMessagesFiles' => ['LogTests' => __DIR__ . '/LogTests.i18n.php']]);
Language::getLocalisationCache()->recache($wgLang->getCode());
$this->user = User::newFromName('Testuser');
$this->title = Title::newFromText('SomeTitle');
$this->target = Title::newFromText('TestTarget');
$this->context = new RequestContext();
$this->context->setUser($this->user);
$this->context->setTitle($this->title);
$this->context->setLanguage($wgLang);
$this->user_comment = '<User comment about action>';
}
示例3: testProcess
/**
* @dataProvider titleDataProvider
*/
public function testProcess($setup, $expected)
{
$skin = $this->getMockBuilder('\\Skin')->disableOriginalConstructor()->getMock();
$context = new \RequestContext();
$context->setTitle($setup['title']);
$context->setLanguage(Language::factory('en'));
$outputPage = new OutputPage($context);
$instance = new BeforePageDisplay($outputPage, $skin);
$result = $instance->process();
$this->assertInternalType('boolean', $result);
$this->assertTrue($result);
$contains = false;
if (method_exists($outputPage, 'getHeadLinksArray')) {
foreach ($outputPage->getHeadLinksArray() as $key => $value) {
if (strpos($value, 'ExportRDF')) {
$contains = true;
break;
}
}
} else {
// MW 1.19
if (strpos($outputPage->getHeadLinks(), 'ExportRDF')) {
$contains = true;
}
}
$expected['result'] ? $this->assertTrue($contains) : $this->assertFalse($contains);
}
示例4: getDefinitions
/**
* @see BaseDependencyContainer::registerDefinitions
*
* @since 1.9
*
* @return array
*/
protected function getDefinitions()
{
return array('ParserData' => $this->getParserData(), 'NamespaceExaminer' => $this->getNamespaceExaminer(), 'JobFactory' => function (DependencyBuilder $builder) {
return new \SMW\MediaWiki\Jobs\JobFactory();
}, 'ContentParser' => function (DependencyBuilder $builder) {
return new ContentParser($builder->getArgument('Title'));
}, 'RequestContext' => function (DependencyBuilder $builder) {
$instance = new \RequestContext();
if ($builder->hasArgument('Title')) {
$instance->setTitle($builder->getArgument('Title'));
}
if ($builder->hasArgument('Language')) {
$instance->setLanguage($builder->getArgument('Language'));
}
return $instance;
}, 'WikiPage' => function (DependencyBuilder $builder) {
return \WikiPage::factory($builder->getArgument('Title'));
}, 'TitleCreator' => function (DependencyBuilder $builder) {
return new TitleCreator(new PageCreator());
}, 'PageCreator' => function (DependencyBuilder $builder) {
return new PageCreator();
}, 'MessageFormatter' => function (DependencyBuilder $builder) {
return new MessageFormatter($builder->getArgument('Language'));
});
}
示例5: getTestContext
public function getTestContext(User $user)
{
$context = new RequestContext();
$context->setLanguage(Language::factory('en'));
$context->setUser($user);
return $context;
}
示例6: getTestContext
public function getTestContext(User $user)
{
$context = new RequestContext();
$context->setLanguage('en');
$context->setUser($user);
$title = Title::newFromText('RecentChanges', NS_SPECIAL);
$context->setTitle($title);
return $context;
}
示例7: braceSubstitution
//.........这里部分代码省略.........
$found = true;
$text = '<span class="error">' . wfMessage('parser-template-recursion-depth-warning')->numParams($limit)->inContentLanguage()->text() . '</span>';
}
}
}
# Load from database
if (!$found && $title) {
if (!Profiler::instance()->isPersistent()) {
# Too many unique items can kill profiling DBs/collectors
$titleProfileIn = __METHOD__ . "-title-" . $title->getPrefixedDBkey();
wfProfileIn($titleProfileIn);
// template in
}
wfProfileIn(__METHOD__ . '-loadtpl');
if (!$title->isExternal()) {
if ($title->isSpecialPage() && $this->mOptions->getAllowSpecialInclusion() && $this->ot['html']) {
// Pass the template arguments as URL parameters.
// "uselang" will have no effect since the Language object
// is forced to the one defined in ParserOptions.
$pageArgs = array();
for ($i = 0; $i < $args->getLength(); $i++) {
$bits = $args->item($i)->splitArg();
if (strval($bits['index']) === '') {
$name = trim($frame->expand($bits['name'], PPFrame::STRIP_COMMENTS));
$value = trim($frame->expand($bits['value']));
$pageArgs[$name] = $value;
}
}
// Create a new context to execute the special page
$context = new RequestContext();
$context->setTitle($title);
$context->setRequest(new FauxRequest($pageArgs));
$context->setUser($this->getUser());
$context->setLanguage($this->mOptions->getUserLangObj());
$ret = SpecialPageFactory::capturePath($title, $context);
if ($ret) {
$text = $context->getOutput()->getHTML();
$this->mOutput->addOutputPageMetadata($context->getOutput());
$found = true;
$isHTML = true;
$this->disableCache();
}
} elseif (MWNamespace::isNonincludable($title->getNamespace())) {
$found = false;
# access denied
wfDebug(__METHOD__ . ": template inclusion denied for " . $title->getPrefixedDBkey() . "\n");
} else {
list($text, $title) = $this->getTemplateDom($title);
if ($text !== false) {
$found = true;
$isChildObj = true;
}
}
# If the title is valid but undisplayable, make a link to it
if (!$found && ($this->ot['html'] || $this->ot['pre'])) {
$text = "[[:{$titleText}]]";
$found = true;
}
} elseif ($title->isTrans()) {
# Interwiki transclusion
if ($this->ot['html'] && !$forceRawInterwiki) {
$text = $this->interwikiTransclude($title, 'render');
$isHTML = true;
} else {
$text = $this->interwikiTransclude($title, 'raw');
# Preprocess it like a template
示例8: testMakeResourceLoaderLink
/**
* @dataProvider provideMakeResourceLoaderLink
* @covers OutputPage::makeResourceLoaderLink
* @covers ResourceLoader::makeLoaderImplementScript
* @covers ResourceLoader::makeModuleResponse
* @covers ResourceLoader::makeInlineScript
* @covers ResourceLoader::makeLoaderStateScript
* @covers ResourceLoader::createLoaderURL
*/
public function testMakeResourceLoaderLink($args, $expectedHtml)
{
$this->setMwGlobals(array('wgResourceLoaderDebug' => false, 'wgLoadScript' => 'http://127.0.0.1:8080/w/load.php', 'wgWellFormedXml' => false));
$class = new ReflectionClass('OutputPage');
$method = $class->getMethod('makeResourceLoaderLink');
$method->setAccessible(true);
$ctx = new RequestContext();
$ctx->setSkin(SkinFactory::getDefaultInstance()->makeSkin('fallback'));
$ctx->setLanguage('en');
$out = new OutputPage($ctx);
$rl = $out->getResourceLoader();
$rl->setMessageBlobStore(new NullMessageBlobStore());
$rl->register(array('test.foo' => new ResourceLoaderTestModule(array('script' => 'mw.test.foo( { a: true } );', 'styles' => '.mw-test-foo { content: "style"; }')), 'test.bar' => new ResourceLoaderTestModule(array('script' => 'mw.test.bar( { a: true } );', 'styles' => '.mw-test-bar { content: "style"; }')), 'test.baz' => new ResourceLoaderTestModule(array('script' => 'mw.test.baz( { a: true } );', 'styles' => '.mw-test-baz { content: "style"; }')), 'test.quux' => new ResourceLoaderTestModule(array('script' => 'mw.test.baz( { token: 123 } );', 'styles' => '/* pref-animate=off */ .mw-icon { transition: none; }', 'group' => 'private')), 'test.raw' => new ResourceLoaderTestModule(array('script' => 'mw.test.baz( { token: 123 } );', 'isRaw' => true)), 'test.noscript' => new ResourceLoaderTestModule(array('styles' => '.mw-test-noscript { content: "style"; }', 'group' => 'noscript')), 'test.group.bar' => new ResourceLoaderTestModule(array('styles' => '.mw-group-bar { content: "style"; }', 'group' => 'bar')), 'test.group.foo' => new ResourceLoaderTestModule(array('styles' => '.mw-group-foo { content: "style"; }', 'group' => 'foo'))));
$links = $method->invokeArgs($out, $args);
$actualHtml = implode("\n", $links['html']);
$this->assertEquals($expectedHtml, $actualHtml);
}