本文整理汇总了PHP中RequestContext::setWikiPage方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestContext::setWikiPage方法的具体用法?PHP RequestContext::setWikiPage怎么用?PHP RequestContext::setWikiPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RequestContext
的用法示例。
在下文中一共展示了RequestContext::setWikiPage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testWikiPageTitle
/**
* Test the relationship between title and wikipage in RequestContext
* @covers RequestContext::getWikiPage
* @covers RequestContext::getTitle
*/
public function testWikiPageTitle()
{
$context = new RequestContext();
$curTitle = Title::newFromText("A");
$context->setTitle($curTitle);
$this->assertTrue($curTitle->equals($context->getWikiPage()->getTitle()), "When a title is first set WikiPage should be created on-demand for that title.");
$curTitle = Title::newFromText("B");
$context->setWikiPage(WikiPage::factory($curTitle));
$this->assertTrue($curTitle->equals($context->getTitle()), "Title must be updated when a new WikiPage is provided.");
$curTitle = Title::newFromText("C");
$context->setTitle($curTitle);
$this->assertTrue($curTitle->equals($context->getWikiPage()->getTitle()), "When a title is updated the WikiPage should be purged " . "and recreated on-demand with the new title.");
}
示例2: execute
//.........这里部分代码省略.........
} 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();
if (!Hooks::run('APIEditBeforeSave', array($ep, $content, &$r))) {
示例3: execute
//.........这里部分代码省略.........
}
if ($params['minor'] || !$params['notminor'] && $user->getOption('minordefault')) {
$requestArray['wpMinoredit'] = '';
}
if ($params['recreate']) {
$requestArray['wpRecreate'] = '';
}
if (!is_null($params['section'])) {
$section = intval($params['section']);
if ($section == 0 && $params['section'] != '0' && $params['section'] != 'new') {
$this->dieUsage("The section parameter must be set to an integer or 'new'", "invalidsection");
}
$requestArray['wpSection'] = $params['section'];
} else {
$requestArray['wpSection'] = '';
}
$watch = $this->getWatchlistValue($params['watchlist'], $titleObj);
// Deprecated parameters
if ($params['watch']) {
$watch = true;
} elseif ($params['unwatch']) {
$watch = false;
}
if ($watch) {
$requestArray['wpWatchthis'] = '';
}
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);
// allow editing of non-textual content.
$ep->allowNonTextContent = true;
$ep->setContextTitle($titleObj);
$ep->importFormData($req);
// Run hooks
// Handle APIEditBeforeSave parameters
$r = array();
if (!wfRunHooks('APIEditBeforeSave', array($ep, $ep->textbox1, &$r))) {
if (count($r)) {
$r['result'] = 'Failure';
$apiResult->addValue(null, $this->getModuleName(), $r);
return;
} else {
$this->dieUsageMsg('hookaborted');
}
}
// Do the actual save
$oldRevId = $articleObject->getRevIdFetched();
$result = null;
// Fake $wgRequest for some hooks inside EditPage
// @todo FIXME: This interface SUCKS
$oldRequest = $wgRequest;
$wgRequest = $req;
$status = $ep->internalAttemptSave($result, $user->isAllowed('bot') && $params['bot']);
$wgRequest = $oldRequest;
global $wgMaxArticleSize;
switch ($status->value) {
case EditPage::AS_HOOK_ERROR: