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


PHP EditPage::setContextTitle方法代码示例

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


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

示例1: execute

 public function execute()
 {
     global $wgHooks;
     $out = $this->mSpecial->getOutput();
     if (!ModerationCanSkip::canSkip($this->moderator)) {
         // In order to merge, moderator must also be automoderated
         throw new ModerationError('moderation-merge-not-automoderated');
     }
     $dbw = wfGetDB(DB_MASTER);
     $row = $dbw->selectRow('moderation', array('mod_namespace AS namespace', 'mod_title AS title', 'mod_user_text AS user_text', 'mod_text AS text', 'mod_conflict AS conflict'), array('mod_id' => $this->id), __METHOD__);
     if (!$row) {
         throw new ModerationError('moderation-edit-not-found');
     }
     if (!$row->conflict) {
         throw new ModerationError('moderation-merge-not-needed');
     }
     $title = Title::makeTitle($row->namespace, $row->title);
     $article = new Article($title);
     ModerationEditHooks::$NewMergeID = $this->id;
     $editPage = new EditPage($article);
     $editPage->isConflict = true;
     $editPage->setContextTitle($title);
     $editPage->textbox1 = $row->text;
     $editPage->summary = wfMessage("moderation-merge-comment", $row->user_text)->inContentLanguage()->plain();
     $editPage->showEditForm();
 }
开发者ID:ATCARES,项目名称:mediawiki-moderation,代码行数:26,代码来源:ModerationActionMerge.php

示例2: execute


//.........这里部分代码省略.........
         $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))) {
         if (count($r)) {
             $r['result'] = 'Failure';
             $apiResult->addValue(null, $this->getModuleName(), $r);
             return;
         }
         $this->dieUsageMsg('hookaborted');
开发者ID:D66Ha,项目名称:mediawiki,代码行数:67,代码来源:ApiEditPage.php

示例3: testCheckDirectEditingDisallowed_forNonTextContent

 /**
  * @depends testAutoMerge
  */
 public function testCheckDirectEditingDisallowed_forNonTextContent()
 {
     $title = Title::newFromText('Dummy:NonTextPageForEditPage');
     $page = WikiPage::factory($title);
     $article = new Article($title);
     $article->getContext()->setTitle($title);
     $ep = new EditPage($article);
     $ep->setContextTitle($title);
     $user = $GLOBALS['wgUser'];
     $edit = ['wpTextbox1' => serialize('non-text content'), 'wpEditToken' => $user->getEditToken(), 'wpEdittime' => '', 'wpStarttime' => wfTimestampNow()];
     $req = new FauxRequest($edit, true);
     $ep->importFormData($req);
     $this->setExpectedException('MWException', 'This content model is not supported: testing');
     $ep->internalAttemptSave($result, false);
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:18,代码来源:EditPageTest.php

示例4: execute


//.........这里部分代码省略.........
         // Fake wpStartime
     }
     if ($params['minor'] || !$params['notminor'] && $user->getGlobalPreference('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;
     $ep = new EditPage($articleObj);
     $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 = $articleObj->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:
         case EditPage::AS_HOOK_ERROR_EXPECTED:
             $this->dieUsageMsg('hookaborted');
         case EditPage::AS_IMAGE_REDIRECT_ANON:
             $this->dieUsageMsg('noimageredirect-anon');
         case EditPage::AS_IMAGE_REDIRECT_LOGGED:
             $this->dieUsageMsg('noimageredirect-logged');
         case EditPage::AS_SPAM_ERROR:
开发者ID:Tjorriemorrie,项目名称:app,代码行数:67,代码来源:ApiEditPage.php

示例5: assertEdit

 /**
  * Performs an edit and checks the result.
  *
  * @param string|Title $title The title of the page to edit
  * @param string|null $baseText Some text to create the page with before attempting the edit.
  * @param User|string|null $user The user to perform the edit as.
  * @param array $edit An array of request parameters used to define the edit to perform.
  *              Some well known fields are:
  *              * wpTextbox1: the text to submit
  *              * wpSummary: the edit summary
  *              * wpEditToken: the edit token (will be inserted if not provided)
  *              * wpEdittime: timestamp of the edit's base revision (will be inserted
  *                if not provided)
  *              * wpStarttime: timestamp when the edit started (will be inserted if not provided)
  *              * wpSectionTitle: the section to edit
  *              * wpMinorEdit: mark as minor edit
  *              * wpWatchthis: whether to watch the page
  * @param int|null $expectedCode The expected result code (EditPage::AS_XXX constants).
  *                  Set to null to skip the check.
  * @param string|null $expectedText The text expected to be on the page after the edit.
  *                  Set to null to skip the check.
  * @param string|null $message An optional message to show along with any error message.
  *
  * @return WikiPage The page that was just edited, useful for getting the edit's rev_id, etc.
  */
 protected function assertEdit($title, $baseText, $user = null, array $edit, $expectedCode = null, $expectedText = null, $message = null)
 {
     if (is_string($title)) {
         $ns = $this->getDefaultWikitextNS();
         $title = Title::newFromText($title, $ns);
     }
     $this->assertNotNull($title);
     if (is_string($user)) {
         $user = User::newFromName($user);
         if ($user->getId() === 0) {
             $user->addToDatabase();
         }
     }
     $page = WikiPage::factory($title);
     if ($baseText !== null) {
         $content = ContentHandler::makeContent($baseText, $title);
         $page->doEditContent($content, "base text for test");
         $this->forceRevisionDate($page, '20120101000000');
         //sanity check
         $page->clear();
         $currentText = ContentHandler::getContentText($page->getContent());
         # EditPage rtrim() the user input, so we alter our expected text
         # to reflect that.
         $this->assertEditedTextEquals($baseText, $currentText);
     }
     if ($user == null) {
         $user = $GLOBALS['wgUser'];
     } else {
         $this->setMwGlobals('wgUser', $user);
     }
     if (!isset($edit['wpEditToken'])) {
         $edit['wpEditToken'] = $user->getEditToken();
     }
     if (!isset($edit['wpEdittime'])) {
         $edit['wpEdittime'] = $page->exists() ? $page->getTimestamp() : '';
     }
     if (!isset($edit['wpStarttime'])) {
         $edit['wpStarttime'] = wfTimestampNow();
     }
     $req = new FauxRequest($edit, true);
     // session ??
     $article = new Article($title);
     $article->getContext()->setTitle($title);
     $ep = new EditPage($article);
     $ep->setContextTitle($title);
     $ep->importFormData($req);
     $bot = isset($edit['bot']) ? (bool) $edit['bot'] : false;
     // this is where the edit happens!
     // Note: don't want to use EditPage::AttemptSave, because it messes with $wgOut
     // and throws exceptions like PermissionsError
     $status = $ep->internalAttemptSave($result, $bot);
     if ($expectedCode !== null) {
         // check edit code
         $this->assertEquals($expectedCode, $status->value, "Expected result code mismatch. {$message}");
     }
     $page = WikiPage::factory($title);
     if ($expectedText !== null) {
         // check resulting page text
         $content = $page->getContent();
         $text = ContentHandler::getContentText($content);
         # EditPage rtrim() the user input, so we alter our expected text
         # to reflect that.
         $this->assertEditedTextEquals($expectedText, $text, "Expected article text mismatch. {$message}");
     }
     return $page;
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:91,代码来源:EditPageTest.php

示例6: execute


//.........这里部分代码省略.........
     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:
         case EditPage::AS_HOOK_ERROR_EXPECTED:
             $this->dieUsageMsg('hookaborted');
         case EditPage::AS_PARSE_ERROR:
             $this->dieUsage($status->getMessage(), 'parseerror');
         case EditPage::AS_IMAGE_REDIRECT_ANON:
             $this->dieUsageMsg('noimageredirect-anon');
         case EditPage::AS_IMAGE_REDIRECT_LOGGED:
开发者ID:mangowi,项目名称:mediawiki,代码行数:67,代码来源:ApiEditPage.php

示例7: doStore

 protected function doStore(EditPage $editor)
 {
     $title = $editor->getTitle();
     // If they used redlink=1 and the page exists, redirect to the main article and send notice
     if ($this->getRequest()->getBool('redlink') && $title->exists()) {
         $this->logMessage(wfMessage('sf_autoedit_redlinkexists')->parse(), self::WARNING);
     }
     $permErrors = $title->getUserPermissionsErrors('edit', $this->getUser());
     // if this title needs to be created, user needs create rights
     if (!$title->exists()) {
         $permErrors = array_merge($permErrors, wfArrayDiff2($title->getUserPermissionsErrors('create', $this->getUser()), $permErrors));
     }
     if ($permErrors) {
         // Auto-block user's IP if the account was "hard" blocked
         $this->getUser()->spreadAnyEditBlock();
         foreach ($permErrors as $error) {
             $this->logMessage(call_user_func_array('wfMessage', $error)->parse());
         }
         return;
     }
     $resultDetails = false;
     # Allow bots to exempt some edits from bot flagging
     $bot = $this->getUser()->isAllowed('bot') && $editor->bot;
     $request = $editor->sfFauxRequest;
     if ($editor->tokenOk($request)) {
         $ctx = RequestContext::getMain();
         $tempTitle = $ctx->getTitle();
         $ctx->setTitle($title);
         $status = $editor->internalAttemptSave($resultDetails, $bot);
         $ctx->setTitle($tempTitle);
     } else {
         throw new MWException(wfMessage('session_fail_preview')->parse());
     }
     switch ($status->value) {
         case EditPage::AS_HOOK_ERROR_EXPECTED:
             // A hook function returned an error
             // show normal Edit page
             // remove Preview and Diff standard buttons from editor page
             Hooks::register('EditPageBeforeEditButtons', function (&$editor, &$buttons, &$tabindex) {
                 foreach (array_keys($buttons) as $key) {
                     if ($key !== 'save') {
                         unset($buttons[$key]);
                     }
                 }
             });
             // Context title needed for correct Cancel link
             $editor->setContextTitle($title);
             $editor->showEditForm();
             return false;
             // success
         // success
         case EditPage::AS_CONTENT_TOO_BIG:
             // Content too big (> $wgMaxArticleSize)
         // Content too big (> $wgMaxArticleSize)
         case EditPage::AS_ARTICLE_WAS_DELETED:
             // article was deleted while editting and param wpRecreate == false or form was not posted
         // article was deleted while editting and param wpRecreate == false or form was not posted
         case EditPage::AS_CONFLICT_DETECTED:
             // (non-resolvable) edit conflict
         // (non-resolvable) edit conflict
         case EditPage::AS_SUMMARY_NEEDED:
             // no edit summary given and the user has forceeditsummary set and the user is not editting in his own userspace or talkspace and wpIgnoreBlankSummary == false
         // no edit summary given and the user has forceeditsummary set and the user is not editting in his own userspace or talkspace and wpIgnoreBlankSummary == false
         case EditPage::AS_TEXTBOX_EMPTY:
             // user tried to create a new section without content
         // user tried to create a new section without content
         case EditPage::AS_MAX_ARTICLE_SIZE_EXCEEDED:
             // article is too big (> $wgMaxArticleSize), after merging in the new section
         // article is too big (> $wgMaxArticleSize), after merging in the new section
         case EditPage::AS_END:
             // WikiPage::doEdit() was unsuccessfull
             throw new MWException(wfMessage('sf_autoedit_fail', $this->mOptions['target'])->parse());
         case EditPage::AS_HOOK_ERROR:
             // Article update aborted by a hook function
             $this->logMessage('Article update aborted by a hook function', self::DEBUG);
             return false;
             // success
             // TODO: This error code only exists from 1.21 onwards. It is
             // suitably handled by the default branch, but really should get its
             // own branch. Uncomment once compatibility to pre1.21 is dropped.
             //			case EditPage::AS_PARSE_ERROR: // can't parse content
             //
             //				throw new MWException( $status->getHTML() );
             //				return true; // fail
         // success
         // TODO: This error code only exists from 1.21 onwards. It is
         // suitably handled by the default branch, but really should get its
         // own branch. Uncomment once compatibility to pre1.21 is dropped.
         //			case EditPage::AS_PARSE_ERROR: // can't parse content
         //
         //				throw new MWException( $status->getHTML() );
         //				return true; // fail
         case EditPage::AS_SUCCESS_NEW_ARTICLE:
             // Article successfully created
             $query = $resultDetails['redirect'] ? 'redirect=no' : '';
             $anchor = isset($resultDetails['sectionanchor']) ? $resultDetails['sectionanchor'] : '';
             $this->getOutput()->redirect($title->getFullURL($query) . $anchor);
             $this->getResult()->addValue(NULL, 'redirect', $title->getFullURL($query) . $anchor);
             return false;
             // success
//.........这里部分代码省略.........
开发者ID:paladox,项目名称:mediawiki-extensions-SemanticForms,代码行数:101,代码来源:SF_AutoeditAPI.php

示例8: execute

 public function execute($par)
 {
     global $wgUser, $wgRequest, $wgOut, $wgCommentboxNamespaces;
     if (!$wgRequest->wasPosted()) {
         $wgOut->redirect(Title::newMainPage()->getFullURL());
         return;
     }
     $this->setHeaders();
     $Pagename = $wgRequest->getText('wpPageName');
     $Author = $wgRequest->getText('wpAuthor', '');
     $Comment = $wgRequest->getText('wpComment', '');
     $title = Title::newFromText($Pagename);
     if ($title == NULL || !$title->exists()) {
         $this->fail('commentbox-error-page-nonexistent');
         return;
     }
     if (!array_key_exists($title->getNamespace(), $wgCommentboxNamespaces) || !$wgCommentboxNamespaces[$title->getNamespace()]) {
         $this->fail('commentbox-error-namespace', $title);
         return;
     }
     if ($Comment == '' || $Comment == wfMsgNoTrans('commentbox-prefill')) {
         $this->fail('commentbox-error-empty-comment', $title);
         return;
     }
     if (!$title->userCan('edit')) {
         $this->displayRestrictionError();
         return;
     }
     // TODO: Integrate with SpamBlacklist etc.
     // Currently, no http/https-links are allowed at all
     $matches = array();
     if (preg_match('@https?://[-.\\w]+@', $Comment, $matches) || preg_match('@https?://[-.\\w]+@', $Author, $matches)) {
         $wgOut->setPageTitle(wfMsg('spamprotectiontitle'));
         $wgOut->setRobotPolicy('noindex,nofollow');
         $wgOut->setArticleRelated(false);
         $wgOut->addWikiMsg('spamprotectiontext');
         $wgOut->addWikiMsg('spamprotectionmatch', "<nowiki>{$matches[0]}</nowiki>");
         $wgOut->returnToMain(false, $title);
         return;
     }
     $article = new Article($title);
     $text = $article->getContent();
     $subject = '';
     if (!preg_match(wfMsgForContentNoTrans('commentbox-regex'), $text)) {
         $subject = wfMsgForContent('commentbox-first-comment-heading') . "\n";
     }
     $sig = $wgUser->isLoggedIn() ? "-- ~~~~" : "-- {$Author} ~~~~~";
     // Append <br /> after each newline, except if the user started a new paragraph
     $Comment = preg_replace('/(?<!\\n)\\n(?!\\n)/', "<br />\n", $Comment);
     $text .= "\n\n" . $subject . $Comment . "\n<br />" . $sig;
     $reqArr = array('wpTextbox1' => $text, 'wpSummary' => wfMsgForContent('commentbox-log'), 'wpEditToken' => $wgUser->editToken(), 'wpIgnoreBlankSummary' => '', 'wpStarttime' => wfTimestampNow(), 'wpEdittime' => $article->getTimestamp());
     $request = new FauxRequest($reqArr, true);
     $ep = new EditPage($article);
     $ep->setContextTitle($title);
     $ep->importFormData($request);
     $details = array();
     // Passed by ref
     $status = $ep->internalAttemptSave($details);
     $retval = $status->value;
     switch ($retval) {
         case EditPage::AS_SUCCESS_UPDATE:
             $wgOut->redirect($title->getFullURL());
             break;
         case EditPage::AS_SPAM_ERROR:
             $ep->spamPageWithContent($details['spam']);
             break;
         case EditPage::AS_BLOCKED_PAGE_FOR_USER:
             $wgOut->blockedPage();
             break;
         case EditPage::AS_READ_ONLY_PAGE_ANON:
         case EditPage::AS_READ_ONLY_PAGE_LOGGED:
             $wgOut->permissionRequired('edit');
             break;
         case EditPage::AS_READ_ONLY_PAGE:
             $wgOut->readOnlyPage();
     }
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:77,代码来源:SpecialAddComment_body.php


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