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


PHP RequestContext类代码示例

本文整理汇总了PHP中RequestContext的典型用法代码示例。如果您正苦于以下问题:PHP RequestContext类的具体用法?PHP RequestContext怎么用?PHP RequestContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: encodeData

 /**
  * Get the formatter output for the given input data
  * @param array $params Query parameters
  * @param array $data Data to encode
  * @param string $class Printer class to use instead of the normal one
  * @return string
  * @throws Exception
  */
 protected function encodeData(array $params, array $data, $class = null)
 {
     $context = new RequestContext();
     $context->setRequest(new FauxRequest($params, true));
     $main = new ApiMain($context);
     if ($class !== null) {
         $main->getModuleManager()->addModule($this->printerName, 'format', $class);
     }
     $result = $main->getResult();
     $result->addArrayType(null, 'default');
     foreach ($data as $k => $v) {
         $result->addValue(null, $k, $v);
     }
     $printer = $main->createPrinterByName($this->printerName);
     $printer->initPrinter();
     $printer->execute();
     ob_start();
     try {
         $printer->closePrinter();
         return ob_get_clean();
     } catch (Exception $ex) {
         ob_end_clean();
         throw $ex;
     }
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:33,代码来源:ApiFormatTestBase.php

示例2: 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'));
     });
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:32,代码来源:SharedDependencyContainer.php

示例3: testPreferences

    function testPreferences()
    {
        global $wgUser, $wgOut, $wgTitle;
        // This test makes call to the parser which requires valids Outputpage
        // and Title objects. Set them up there, they will be released at the
        // end of the test.
        $old_wgOut = $wgOut;
        $old_wgTitle = $wgTitle;
        $wgTitle = Title::newFromText('Parser test for Gadgets extension');
        // Proceed with test setup:
        $prefs = array();
        $context = new RequestContext();
        $wgOut = $context->getOutput();
        $wgOut->setTitle(Title::newFromText('test'));
        Gadget::loadStructuredList('* foo | foo.js
==keep-section1==
* bar| bar.js
==remove-section==
* baz [rights=embezzle] |baz.js
==keep-section2==
* quux [rights=read] | quux.js');
        $this->assertTrue(GadgetHooks::getPreferences($wgUser, $prefs), 'GetPrefences hook should return true');
        $options = $prefs['gadgets']['options'];
        $this->assertFalse(isset($options['<gadget-section-remove-section>']), 'Must not show empty sections');
        $this->assertTrue(isset($options['<gadget-section-keep-section1>']));
        $this->assertTrue(isset($options['<gadget-section-keep-section2>']));
        // Restore globals
        $wgOut = $old_wgOut;
        $wgTitle = $old_wgTitle;
    }
开发者ID:Tarendai,项目名称:spring-website,代码行数:30,代码来源:GadgetTest.php

示例4: getTestContext

 public function getTestContext(User $user)
 {
     $context = new RequestContext();
     $context->setLanguage(Language::factory('en'));
     $context->setUser($user);
     return $context;
 }
开发者ID:Habatchii,项目名称:wikibase-for-mediawiki,代码行数:7,代码来源:TestRecentChangesHelper.php

示例5: 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);
 }
开发者ID:WolfgangFahl,项目名称:SemanticMediaWiki,代码行数:30,代码来源:BeforePageDisplayTest.php

示例6: testCrossDomainMangling

 public function testCrossDomainMangling()
 {
     $config = new HashConfig(array('MangleFlashPolicy' => false));
     $context = new RequestContext();
     $context->setConfig(new MultiConfig(array($config, $context->getConfig())));
     $main = new ApiMain($context);
     $main->getResult()->addValue(null, null, '< Cross-Domain-Policy >');
     if (!function_exists('wfOutputHandler')) {
         function wfOutputHandler($s)
         {
             return $s;
         }
     }
     $printer = $main->createPrinterByName('php');
     ob_start('wfOutputHandler');
     $printer->initPrinter();
     $printer->execute();
     $printer->closePrinter();
     $ret = ob_get_clean();
     $this->assertSame('a:1:{i:0;s:23:"< Cross-Domain-Policy >";}', $ret);
     $config->set('MangleFlashPolicy', true);
     $printer = $main->createPrinterByName('php');
     ob_start('wfOutputHandler');
     try {
         $printer->initPrinter();
         $printer->execute();
         $printer->closePrinter();
         ob_end_clean();
         $this->fail('Expected exception not thrown');
     } catch (UsageException $ex) {
         ob_end_clean();
         $this->assertSame('This response cannot be represented using format=php. See https://phabricator.wikimedia.org/T68776', $ex->getMessage(), 'Expected exception');
     }
 }
开发者ID:ngertrudiz,项目名称:mediawiki,代码行数:34,代码来源:ApiFormatPhpTest.php

示例7: setUp

 function setUp()
 {
     global $wgParser, $wgParserConf, $IP, $messageMemc, $wgMemc, $wgDeferredUpdateList, $wgUser, $wgLang, $wgOut, $wgRequest, $wgStyleDirectory, $wgEnableParserCache, $wgNamespaceAliases, $wgNamespaceProtection, $wgLocalFileRepo, $parserMemc, $wgThumbnailScriptPath, $wgScriptPath, $wgArticlePath, $wgStyleSheetPath, $wgScript, $wgStylePath;
     $wgScript = '/index.php';
     $wgScriptPath = '/';
     $wgArticlePath = '/wiki/$1';
     $wgStyleSheetPath = '/skins';
     $wgStylePath = '/skins';
     $wgThumbnailScriptPath = false;
     $wgLocalFileRepo = array('class' => 'LocalRepo', 'name' => 'local', 'directory' => wfTempDir() . '/test-repo', 'url' => 'http://example.com/images', 'deletedDir' => wfTempDir() . '/test-repo/delete', 'hashLevels' => 2, 'transformVia404' => false);
     $wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface';
     $wgNamespaceAliases['Image'] = NS_FILE;
     $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK;
     $wgEnableParserCache = false;
     $wgDeferredUpdateList = array();
     $wgMemc = wfGetMainCache();
     $messageMemc = wfGetMessageCacheStorage();
     $parserMemc = wfGetParserCacheStorage();
     // $wgContLang = new StubContLang;
     $wgUser = new User();
     $context = new RequestContext();
     $wgLang = $context->getLang();
     $wgOut = $context->getOutput();
     $wgParser = new StubObject('wgParser', $wgParserConf['class'], array($wgParserConf));
     $wgRequest = new WebRequest();
     if ($wgStyleDirectory === false) {
         $wgStyleDirectory = "{$IP}/skins";
     }
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:29,代码来源:UploadFromUrlTestSuite.php

示例8: testGetDesktopUrl

 /**
  * @dataProvider provideGetDesktopUrl
  * @param string $class
  * @param string $subPage
  * @param array $params
  * @param string|null $expected
  */
 public function testGetDesktopUrl($class, $subPage, array $params, $expected)
 {
     $context = new RequestContext();
     $context->setRequest(new FauxRequest($params));
     $page = new $class();
     $page->setContext($context);
     $this->assertEquals($expected, $page->getDesktopUrl($subPage));
 }
开发者ID:micha6554,项目名称:mediawiki-extensions-MobileFrontend,代码行数:15,代码来源:MobileSpecialPageTest.php

示例9: fromRequestContext

 /**
  * Updates the RequestContext information based on a HttpFoundation Request.
  *
  * @param RequestContext $requestContext
  *
  * @return $this The current instance, implementing a fluent interface
  *
  */
 public static function fromRequestContext(RequestContext $requestContext)
 {
     $Url = new static();
     $Url->setScheme($requestContext->getScheme());
     $Url->setHost($requestContext->getHost());
     $Url->setPath($requestContext->getPath());
     $Url->setParameters($requestContext->getParameters());
     return $Url;
 }
开发者ID:shakhraj,项目名称:reroute,代码行数:17,代码来源:Url.php

示例10: setUp

 function setUp()
 {
     $this->page = new MIMESearchPage();
     $context = new RequestContext();
     $context->setTitle(Title::makeTitle(NS_SPECIAL, 'MIMESearch'));
     $context->setRequest(new FauxRequest());
     $this->page->setContext($context);
     parent::setUp();
 }
开发者ID:rploaiza,项目名称:dbpedia-latinoamerica,代码行数:9,代码来源:SpecialMIMESearchTest.php

示例11: 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;
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:9,代码来源:TestRecentChangesHelper.php

示例12: testHandleNormalization

 public function testHandleNormalization()
 {
     $context = new RequestContext();
     $context->setRequest(new FauxRequest(['titles' => "a|B|å"]));
     $main = new ApiMain($context);
     $pageSet = new ApiPageSet($main);
     $pageSet->execute();
     $this->assertSame([0 => ['A' => -1, 'B' => -2, 'Å' => -3]], $pageSet->getAllTitlesByNamespace());
     $this->assertSame([['fromencoded' => true, 'from' => 'a%CC%8A', 'to' => 'å'], ['fromencoded' => false, 'from' => 'a', 'to' => 'A'], ['fromencoded' => false, 'from' => 'å', 'to' => 'Å']], $pageSet->getNormalizedTitlesAsResult());
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:10,代码来源:ApiPageSetTest.php

示例13: __construct

 public function __construct()
 {
     parent::__construct();
     $this->prefUsers['noemail'] = new User();
     $this->prefUsers['notauth'] = new User();
     $this->prefUsers['notauth']->setEmail('noauth@example.org');
     $this->prefUsers['auth'] = new User();
     $this->prefUsers['auth']->setEmail('noauth@example.org');
     $this->prefUsers['auth']->setEmailAuthenticationTimestamp(1330946623);
     $this->context = new RequestContext();
     $this->context->setTitle(Title::newFromText('PreferencesTest'));
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:12,代码来源:PreferencesTest.php

示例14: 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);
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:13,代码来源:LogFormatterTest.php

示例15: assertConditions

 /** helper to test SpecialRecentchanges::buildMainQueryConds() */
 private function assertConditions($expected, $requestOptions = null, $message = '')
 {
     $context = new RequestContext();
     $context->setRequest(new FauxRequest($requestOptions));
     # setup the rc object
     $this->rc = new SpecialRecentChanges();
     $this->rc->setContext($context);
     $formOptions = $this->rc->setup(null);
     #  Filter out rc_timestamp conditions which depends on the test runtime
     # This condition is not needed as of march 2, 2011 -- hashar
     # @todo FIXME: Find a way to generate the correct rc_timestamp
     $queryConditions = array_filter($this->rc->buildMainQueryConds($formOptions), 'SpecialRecentchangesTest::filterOutRcTimestampCondition');
     $this->assertEquals($expected, $queryConditions, $message);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:15,代码来源:SpecialRecentchangesTest.php


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