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


PHP RequestContext::setRequest方法代码示例

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


在下文中一共展示了RequestContext::setRequest方法的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: 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

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

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

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

示例6: testAppendDebugInfoToApiResultXmlFormat

 /**
  * @covers MWDebug::appendDebugInfoToApiResult
  */
 public function testAppendDebugInfoToApiResultXmlFormat()
 {
     $request = $this->newApiRequest(['action' => 'help', 'format' => 'xml'], '/api.php?action=help&format=xml');
     $context = new RequestContext();
     $context->setRequest($request);
     $apiMain = new ApiMain($context);
     $result = new ApiResult($apiMain);
     MWDebug::appendDebugInfoToApiResult($context, $result);
     $this->assertInstanceOf('ApiResult', $result);
     $data = $result->getResultData();
     $expectedKeys = ['mwVersion', 'phpEngine', 'phpVersion', 'gitRevision', 'gitBranch', 'gitViewUrl', 'time', 'log', 'debugLog', 'queries', 'request', 'memory', 'memoryPeak', 'includes', '_element'];
     foreach ($expectedKeys as $expectedKey) {
         $this->assertArrayHasKey($expectedKey, $data['debuginfo'], "debuginfo has {$expectedKey}");
     }
     $xml = ApiFormatXml::recXmlPrint('help', $data);
     // exception not thrown
     $this->assertInternalType('string', $xml);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:21,代码来源:MWDebugTest.php

示例7: createPageSetWithRedirect

 protected function createPageSetWithRedirect()
 {
     $target = Title::makeTitle(NS_MAIN, 'UTRedirectTarget');
     $sourceA = Title::makeTitle(NS_MAIN, 'UTRedirectSourceA');
     $sourceB = Title::makeTitle(NS_MAIN, 'UTRedirectSourceB');
     self::editPage('UTRedirectTarget', 'api page set test');
     self::editPage('UTRedirectSourceA', '#REDIRECT [[UTRedirectTarget]]');
     self::editPage('UTRedirectSourceB', '#REDIRECT [[UTRedirectTarget]]');
     $request = new FauxRequest(array('redirects' => 1));
     $context = new RequestContext();
     $context->setRequest($request);
     $main = new ApiMain($context);
     $pageSet = new ApiPageSet($main);
     $pageSet->setGeneratorData($sourceA, array('index' => 1));
     $pageSet->setGeneratorData($sourceB, array('index' => 3));
     $pageSet->populateFromTitles(array($sourceA, $sourceB));
     return array($target, $pageSet);
 }
开发者ID:Acidburn0zzz,项目名称:mediawiki,代码行数:18,代码来源:ApiPageSetTest.php

示例8: testBug41337

 /**
  * Make sure a nickname which is longer than $wgMaxSigChars
  * is not throwing a fatal error.
  *
  * Test specifications by Alexandre "ialex" Emsenhuber.
  * @todo give this test a real name explaining what is being tested here
  */
 public function testBug41337()
 {
     // Set a low limit
     $this->setMwGlobals('wgMaxSigChars', 2);
     $user = $this->getMock('User');
     $user->expects($this->any())->method('isAnon')->will($this->returnValue(false));
     # Yeah foreach requires an array, not NULL =(
     $user->expects($this->any())->method('getEffectiveGroups')->will($this->returnValue([]));
     # The mocked user has a long nickname
     $user->expects($this->any())->method('getOption')->will($this->returnValueMap([['nickname', null, false, 'superlongnickname']]));
     # Forge a request to call the special page
     $context = new RequestContext();
     $context->setRequest(new FauxRequest());
     $context->setUser($user);
     $context->setTitle(Title::newFromText('Test'));
     # Do the call, should not spurt a fatal error.
     $special = new SpecialPreferences();
     $special->setContext($context);
     $this->assertNull($special->execute([]));
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:27,代码来源:SpecialPreferencesTest.php

示例9: testProfileAndNamespaceLoading

 /**
  * @covers SpecialSearch::load
  * @dataProvider provideSearchOptionsTests
  * @param $requested Array Request parameters. For example array( 'ns5' => true, 'ns6' => true). NULL to use default options.
  * @param $userOptions Array User options to test with. For example array('searchNs5' => 1 );. NULL to use default options.
  * @param $expectedProfile An expected search profile name
  * @param $expectedNs Array Expected namespaces
  */
 function testProfileAndNamespaceLoading($requested, $userOptions, $expectedProfile, $expectedNS, $message = 'Profile name and namespaces mismatches!')
 {
     $context = new RequestContext();
     $context->setUser($this->newUserWithSearchNS($userOptions));
     /*
     		$context->setRequest( new FauxRequest( array(
     			'ns5'=>true,
     			'ns6'=>true,
     		) ));
     */
     $context->setRequest(new FauxRequest($requested));
     $search = new SpecialSearch();
     $search->setContext($context);
     $search->load();
     /**
      * Verify profile name and namespace in the same assertion to make
      * sure we will be able to fully compare the above code. PHPUnit stop
      * after an assertion fail.
      */
     $this->assertEquals(array('ProfileName' => $expectedProfile, 'Namespaces' => $expectedNS), array('ProfileName' => $search->getProfile(), 'Namespaces' => $search->getNamespaces()), $message);
 }
开发者ID:laiello,项目名称:media-wiki-law,代码行数:29,代码来源:SpecialSearchTest.php

示例10: testPrependHtmlForViewActionOnly

 public function testPrependHtmlForViewActionOnly()
 {
     $context = new \RequestContext();
     $context->setRequest(new \FauxRequest(array('action' => 'view'), true));
     $htmlBreadcrumbLinksBuilder = $this->getMockBuilder('\\SBL\\HtmlBreadcrumbLinksBuilder')->disableOriginalConstructor()->getMock();
     $htmlBreadcrumbLinksBuilder->expects($this->once())->method('buildBreadcrumbs')->will($this->returnSelf());
     $language = $this->getMockBuilder('\\Language')->disableOriginalConstructor()->getMock();
     $title = $this->getMockBuilder('\\Title')->disableOriginalConstructor()->getMock();
     $title->expects($this->once())->method('isKnown')->will($this->returnValue(true));
     $title->expects($this->once())->method('isSpecialPage')->will($this->returnValue(false));
     $title->expects($this->once())->method('getPageLanguage')->will($this->returnValue($language));
     $output = $this->getMockBuilder('\\OutputPage')->disableOriginalConstructor()->getMock();
     $output->expects($this->once())->method('prependHTML');
     $output->expects($this->once())->method('getContext')->will($this->returnValue($context));
     $output->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title));
     $instance = new SkinTemplateOutputModifier($htmlBreadcrumbLinksBuilder);
     $this->assertTrue($instance->modifyOutput($output));
     $template = new \stdClass();
     $template->data = array();
     $instance->modifyTemplate($template);
     $this->assertEmpty($template->data['subtitle']);
 }
开发者ID:brandonphuong,项目名称:mediawiki,代码行数:22,代码来源:SkinTemplateOutputModifierTest.php

示例11: capturePath

 /**
  * Just like executePath() except it returns the HTML instead of outputting it
  * Returns false if there was no such special page, or a title object if it was
  * a redirect.
  *
  * Also saves the current $wgTitle, $wgOut, and $wgRequest variables so that
  * the special page will get the context it'd expect on a normal request,
  * and then restores them to their previous values after.
  *
  * @param $title Title
  *
  * @return String: HTML fragment
  */
 static function capturePath(&$title)
 {
     global $wgOut, $wgTitle, $wgRequest;
     $oldTitle = $wgTitle;
     $oldOut = $wgOut;
     $oldRequest = $wgRequest;
     // Don't want special pages interpreting ?feed=atom parameters.
     $wgRequest = new FauxRequest(array());
     $context = new RequestContext();
     $context->setTitle($title);
     $context->setRequest($wgRequest);
     $wgOut = $context->getOutput();
     $ret = self::executePath($title, $context, true);
     if ($ret === true) {
         $ret = $wgOut->getHTML();
     }
     $wgTitle = $oldTitle;
     $wgOut = $oldOut;
     $wgRequest = $oldRequest;
     return $ret;
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:34,代码来源:SpecialPageFactory.php

示例12: outputDataProvider

 public function outputDataProvider()
 {
     $language = Language::factory('en');
     $title = MockTitle::buildMockForMainNamespace(__METHOD__ . 'mock-subject');
     $title->expects($this->atLeastOnce())->method('exists')->will($this->returnValue(true));
     $subject = DIWikiPage::newFromTitle($title);
     $semanticData = $this->getMockBuilder('\\SMW\\SemanticData')->disableOriginalConstructor()->getMock();
     $semanticData->expects($this->atLeastOnce())->method('getSubject')->will($this->returnValue($subject));
     $semanticData->expects($this->atLeastOnce())->method('hasVisibleProperties')->will($this->returnValue(true));
     $semanticData->expects($this->atLeastOnce())->method('getPropertyValues')->will($this->returnValue(array(DIWikiPage::newFromTitle($title))));
     $semanticData->expects($this->atLeastOnce())->method('getProperties')->will($this->returnValue(array(new DIProperty(__METHOD__ . 'property'))));
     $store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass();
     #0 Factbox build, being visible
     $title = MockTitle::buildMock(__METHOD__ . 'title-being-visible');
     $title->expects($this->atLeastOnce())->method('exists')->will($this->returnValue(true));
     $title->expects($this->atLeastOnce())->method('getNamespace')->will($this->returnValue(NS_MAIN));
     $title->expects($this->atLeastOnce())->method('getPageLanguage')->will($this->returnValue($language));
     $title->expects($this->atLeastOnce())->method('getArticleID')->will($this->returnValue(10001));
     $title->expects($this->atLeastOnce())->method('getLatestRevID')->will($this->returnValue(10001));
     $outputPage = $this->getMockBuilder('\\OutputPage')->disableOriginalConstructor()->getMock();
     $outputPage->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title));
     $outputPage->expects($this->atLeastOnce())->method('getContext')->will($this->returnValue(new \RequestContext()));
     $provider[] = array(array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => true), 'smwgShowFactbox' => SMW_FACTBOX_NONEMPTY, 'outputPage' => $outputPage, 'store' => $store, 'parserOutput' => $this->makeParserOutput($semanticData)), array('text' => $subject->getDBKey()));
     #1 Factbox build, being visible, using WebRequest oldid
     $title = MockTitle::buildMock(__METHOD__ . 'title-with-oldid');
     $title->expects($this->atLeastOnce())->method('exists')->will($this->returnValue(true));
     $title->expects($this->atLeastOnce())->method('getNamespace')->will($this->returnValue(NS_MAIN));
     $title->expects($this->atLeastOnce())->method('getPageLanguage')->will($this->returnValue($language));
     $title->expects($this->atLeastOnce())->method('getArticleID')->will($this->returnValue(10002));
     $title->expects($this->atLeastOnce())->method('getLatestRevID')->will($this->returnValue(10002));
     $outputPage = $this->getMockBuilder('\\OutputPage')->disableOriginalConstructor()->getMock();
     $outputPage->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title));
     $context = new \RequestContext();
     $context->setRequest(new \FauxRequest(array('oldid' => 9001), true));
     $outputPage->expects($this->atLeastOnce())->method('getContext')->will($this->returnValue($context));
     $provider[] = array(array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => true), 'smwgShowFactbox' => SMW_FACTBOX_NONEMPTY, 'outputPage' => $outputPage, 'store' => $store, 'parserOutput' => $this->makeParserOutput($semanticData)), array('text' => $subject->getDBKey()));
     #2 Factbox is expected not to be visible
     $title = MockTitle::buildMock(__METHOD__ . 'title-ns-disabled');
     $title->expects($this->atLeastOnce())->method('getNamespace')->will($this->returnValue(NS_MAIN));
     $title->expects($this->atLeastOnce())->method('getPageLanguage')->will($this->returnValue($language));
     $title->expects($this->atLeastOnce())->method('getArticleID')->will($this->returnValue(10003));
     $title->expects($this->atLeastOnce())->method('getLatestRevID')->will($this->returnValue(10003));
     $outputPage = $this->getMockBuilder('\\OutputPage')->disableOriginalConstructor()->getMock();
     $outputPage->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title));
     $outputPage->expects($this->atLeastOnce())->method('getContext')->will($this->returnValue(new \RequestContext()));
     $provider[] = array(array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => false), 'smwgShowFactbox' => SMW_FACTBOX_HIDDEN, 'outputPage' => $outputPage, 'store' => $store, 'parserOutput' => $this->makeParserOutput($semanticData)), array('text' => null));
     #3 No semantic data
     $title = MockTitle::buildMock(__METHOD__ . 'title-empty-semanticdata');
     $title->expects($this->atLeastOnce())->method('getNamespace')->will($this->returnValue(NS_MAIN));
     $title->expects($this->atLeastOnce())->method('getPageLanguage')->will($this->returnValue($language));
     $title->expects($this->atLeastOnce())->method('getArticleID')->will($this->returnValue(10004));
     $title->expects($this->atLeastOnce())->method('getLatestRevID')->will($this->returnValue(10004));
     $outputPage = $this->getMockBuilder('\\OutputPage')->disableOriginalConstructor()->getMock();
     $outputPage->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title));
     $outputPage->expects($this->atLeastOnce())->method('getContext')->will($this->returnValue(new \RequestContext()));
     $semanticData = $this->getMockBuilder('\\SMW\\SemanticData')->disableOriginalConstructor()->getMock();
     $semanticData->expects($this->atLeastOnce())->method('isEmpty')->will($this->returnValue(true));
     $store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass();
     $store->expects($this->atLeastOnce())->method('getSemanticData')->will($this->returnValue($semanticData));
     $provider[] = array(array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => true), 'smwgShowFactbox' => SMW_FACTBOX_NONEMPTY, 'outputPage' => $outputPage, 'store' => $store, 'parserOutput' => $this->makeParserOutput(null)), array('text' => null));
     // #4 SpecialPage
     $title = MockTitle::buildMock(__METHOD__ . 'title-specialpage');
     $title->expects($this->atLeastOnce())->method('getNamespace')->will($this->returnValue(NS_MAIN));
     $title->expects($this->atLeastOnce())->method('isSpecialPage')->will($this->returnValue(true));
     $outputPage = $this->getMockBuilder('\\OutputPage')->disableOriginalConstructor()->getMock();
     $outputPage->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title));
     $outputPage->expects($this->atLeastOnce())->method('getContext')->will($this->returnValue(new \RequestContext()));
     $store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass();
     $store->expects($this->atLeastOnce())->method('getSemanticData')->will($this->returnValue($semanticData));
     $provider[] = array(array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => true), 'smwgShowFactbox' => SMW_FACTBOX_NONEMPTY, 'outputPage' => $outputPage, 'store' => $store, 'parserOutput' => $this->makeParserOutput(null)), array('text' => ''));
     // #5 does not exist
     $title = MockTitle::buildMock(__METHOD__ . 'title-not-exists');
     $title->expects($this->atLeastOnce())->method('getNamespace')->will($this->returnValue(NS_MAIN));
     $title->expects($this->atLeastOnce())->method('exists')->will($this->returnValue(false));
     $outputPage = $this->getMockBuilder('\\OutputPage')->disableOriginalConstructor()->getMock();
     $outputPage->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title));
     $outputPage->expects($this->atLeastOnce())->method('getContext')->will($this->returnValue(new \RequestContext()));
     $store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass();
     $store->expects($this->atLeastOnce())->method('getSemanticData')->will($this->returnValue($semanticData));
     $provider[] = array(array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => true), 'smwgShowFactbox' => SMW_FACTBOX_NONEMPTY, 'outputPage' => $outputPage, 'store' => $store, 'parserOutput' => $this->makeParserOutput(null)), array('text' => ''));
     return $provider;
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:82,代码来源:CachedFactboxTest.php

示例13: braceSubstitution


//.........这里部分代码省略.........
             $limit = $this->mOptions->getMaxTemplateDepth();
             if ($frame->depth >= $limit) {
                 $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 {
开发者ID:Tarendai,项目名称:spring-website,代码行数:67,代码来源:Parser.php

示例14: execute


//.........这里部分代码省略.........
         $requestArray['wpSection'] = $params['section'];
     } else {
         $requestArray['wpSection'] = '';
     }
     $watch = $this->getWatchlistValue($params['watchlist'], $titleObj);
     // Deprecated parameters
     if ($params['watch']) {
         $this->logFeatureUsage('action=edit&watch');
         $watch = true;
     } elseif ($params['unwatch']) {
         $this->logFeatureUsage('action=edit&unwatch');
         $watch = false;
     }
     if ($watch) {
         $requestArray['wpWatchthis'] = '';
     }
     // Apply change tags
     if (count($params['tags'])) {
         if ($user->isAllowed('applychangetags')) {
             $requestArray['wpChangeTags'] = implode(',', $params['tags']);
         } else {
             $this->dieUsage('You don\'t have permission to set change tags.', 'taggingnotallowed');
         }
     }
     // Pass through anything else we might have been given, to support extensions
     // This is kind of a hack but it's the best we can do to make extensions work
     $requestArray += $this->getRequest()->getValues();
     global $wgTitle, $wgRequest;
     $req = new DerivativeRequest($this->getRequest(), $requestArray, true);
     // Some functions depend on $wgTitle == $ep->mTitle
     // TODO: Make them not or check if they still do
     $wgTitle = $titleObj;
     $articleContext = new RequestContext();
     $articleContext->setRequest($req);
     $articleContext->setWikiPage($pageObj);
     $articleContext->setUser($this->getUser());
     /** @var $articleObject Article */
     $articleObject = Article::newFromWikiPage($pageObj, $articleContext);
     $ep = new EditPage($articleObject);
     $ep->setApiEditOverride(true);
     $ep->setContextTitle($titleObj);
     $ep->importFormData($req);
     $content = $ep->textbox1;
     // The following is needed to give the hook the full content of the
     // new revision rather than just the current section. (Bug 52077)
     if (!is_null($params['section']) && $contentHandler->supportsSections() && $titleObj->exists()) {
         // If sectiontitle is set, use it, otherwise use the summary as the section title (for
         // backwards compatibility with old forms/bots).
         if ($ep->sectiontitle !== '') {
             $sectionTitle = $ep->sectiontitle;
         } else {
             $sectionTitle = $ep->summary;
         }
         $contentObj = $contentHandler->unserializeContent($content, $contentFormat);
         $fullContentObj = $articleObject->replaceSectionContent($params['section'], $contentObj, $sectionTitle);
         if ($fullContentObj) {
             $content = $fullContentObj->serialize($contentFormat);
         } else {
             // This most likely means we have an edit conflict which means that the edit
             // wont succeed anyway.
             $this->dieUsageMsg('editconflict');
         }
     }
     // Run hooks
     // Handle APIEditBeforeSave parameters
     $r = array();
开发者ID:D66Ha,项目名称:mediawiki,代码行数:67,代码来源:ApiEditPage.php

示例15: outputDataProvider

 public function outputDataProvider()
 {
     $text = __METHOD__ . 'text-0';
     #0 Retrive content from outputPage property
     $title = MockTitle::buildMock(__METHOD__ . 'from-property');
     $title->expects($this->atLeastOnce())->method('exists')->will($this->returnValue(true));
     $title->expects($this->atLeastOnce())->method('getArticleID')->will($this->returnValue(10001));
     $outputPage = $this->getMockBuilder('\\OutputPage')->disableOriginalConstructor()->getMock();
     $outputPage->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title));
     $outputPage->mSMWFactboxText = $text;
     $skin = $this->getMockBuilder('\\Skin')->disableOriginalConstructor()->getMock();
     $skin->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue(null));
     $skin->expects($this->atLeastOnce())->method('getOutput')->will($this->returnValue($outputPage));
     $skin->expects($this->atLeastOnce())->method('getContext')->will($this->returnValue(new \RequestContext()));
     $provider[] = array(array('skin' => $skin), array('text' => $text));
     #1 Retrive content from cache
     $title = MockTitle::buildMock(__METHOD__ . 'from-cache');
     $title->expects($this->atLeastOnce())->method('exists')->will($this->returnValue(true));
     $title->expects($this->atLeastOnce())->method('getArticleID')->will($this->returnValue(10002));
     $outputPage = $this->getMockBuilder('\\OutputPage')->disableOriginalConstructor()->getMock();
     $outputPage->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title));
     $text = __METHOD__ . 'text-1';
     $skin = $this->getMockBuilder('\\Skin')->disableOriginalConstructor()->getMock();
     $skin->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title));
     $skin->expects($this->atLeastOnce())->method('getOutput')->will($this->returnValue($outputPage));
     $skin->expects($this->atLeastOnce())->method('getContext')->will($this->returnValue(new \RequestContext()));
     $provider[] = array(array('skin' => $skin, 'text' => $text, 'title' => $outputPage->getTitle()), array('text' => $text));
     // #2 Special page
     $text = __METHOD__ . 'text-2';
     $title = MockTitle::buildMock(__METHOD__ . 'specialpage');
     $title->expects($this->atLeastOnce())->method('isSpecialPage')->will($this->returnValue(true));
     $outputPage = $this->getMockBuilder('\\OutputPage')->disableOriginalConstructor()->getMock();
     $outputPage->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title));
     $outputPage->mSMWFactboxText = $text;
     $skin = $this->getMockBuilder('\\Skin')->disableOriginalConstructor()->getMock();
     $skin->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title));
     $skin->expects($this->atLeastOnce())->method('getOutput')->will($this->returnValue($outputPage));
     $skin->expects($this->atLeastOnce())->method('getContext')->will($this->returnValue(new \RequestContext()));
     $provider[] = array(array('skin' => $skin, 'text' => $text), array('text' => ''));
     // #3 "edit" request
     $text = __METHOD__ . 'text-3';
     $title = MockTitle::buildMock(__METHOD__ . 'edit-request');
     $title->expects($this->atLeastOnce())->method('exists')->will($this->returnValue(true));
     $title->expects($this->atLeastOnce())->method('getArticleID')->will($this->returnValue(10003));
     $outputPage = $this->getMockBuilder('\\OutputPage')->disableOriginalConstructor()->getMock();
     $outputPage->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title));
     $outputPage->mSMWFactboxText = $text;
     $skin = $this->getMockBuilder('\\Skin')->disableOriginalConstructor()->getMock();
     $skin->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title));
     $skin->expects($this->atLeastOnce())->method('getOutput')->will($this->returnValue($outputPage));
     $context = new \RequestContext();
     $context->setRequest(new \FauxRequest(array('action' => 'edit'), true));
     $skin->expects($this->atLeastOnce())->method('getContext')->will($this->returnValue($context));
     $provider[] = array(array('skin' => $skin, 'text' => $text), array('text' => $text));
     // #4 "delete" request
     $text = __METHOD__ . 'text-4';
     $title = MockTitle::buildMock(__METHOD__ . 'delete-request');
     $outputPage = $this->getMockBuilder('\\OutputPage')->disableOriginalConstructor()->getMock();
     $outputPage->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title));
     $skin = $this->getMockBuilder('\\Skin')->disableOriginalConstructor()->getMock();
     $skin->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title));
     $skin->expects($this->atLeastOnce())->method('getOutput')->will($this->returnValue($outputPage));
     $context = new \RequestContext();
     $context->setRequest(new \FauxRequest(array('action' => 'delete'), true));
     $skin->expects($this->atLeastOnce())->method('getContext')->will($this->returnValue($context));
     $provider[] = array(array('skin' => $skin, 'text' => $text), array('text' => ''));
     return $provider;
 }
开发者ID:WolfgangFahl,项目名称:SemanticMediaWiki,代码行数:68,代码来源:SkinAfterContentTest.php


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