本文整理汇总了PHP中EditPage::showEditForm方法的典型用法代码示例。如果您正苦于以下问题:PHP EditPage::showEditForm方法的具体用法?PHP EditPage::showEditForm怎么用?PHP EditPage::showEditForm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EditPage
的用法示例。
在下文中一共展示了EditPage::showEditForm方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例2: showEditForm
function showEditForm($formCallback = null)
{
global $wgOut, $wgLanguageCode, $wgRequest, $wgTitle, $wgUser, $wgLang;
$whow = null;
// conflict resolution
if (!$wgRequest->wasPosted()) {
EditPage::showEditForm();
}
$wgOut->clearHTML();
//echo $this->textbox1; exit;
wfRunHooks('EditPage::showEditForm:initial', array(&$this));
// are we called with just action=edit and no title?
$newArticle = false;
if (($wgRequest->getVal("title") == "" || $wgTitle->getArticleID() == 0) && !$this->preview) {
$newArticle = true;
}
$sk = $wgUser->getSkin();
if (!$this->mTitle->getArticleID() && !$this->preview) {
# new article
$wgOut->addHTML(wfMsg("newarticletext"));
}
// do we have a new article? if so, format the title if it's English
$wgRequest->getVal("new_article");
if ($new_article && $wgLanguageCode == "en") {
$title = $this->mTitle->getText();
$old_title = $title;
$title = $this->formatTitle($title);
$titleObj = Title::newFromText($title);
$this->mTitle = $titleObj;
$this->mArticle = new Article($titleObj);
}
$conflictWikiHow = null;
$conflictTitle = false;
if ($this->isConflict) {
$s = wfMsg("editconflict", $this->mTitle->getPrefixedText());
$wgOut->setPageTitle($s);
if ($new_article) {
$wgOut->addHTML("<b><font color=red>" . wfMsg('page-name-exists') . "</b></font><br/><br/>");
$conflictTitle = true;
} else {
$this->edittime = $this->mArticle->getTimestamp();
$wgOut->addHTML(wfMsg("explainconflict"));
// let the advanced editor handle the situation
if ($this->isConflict) {
EditPage::showEditForm();
return;
}
}
$this->textbox2 = $this->textbox1;
$conflictWikiHow = WikihowArticleEditor::newFromText($this->textbox1);
$this->textbox1 = $this->mArticle->getContent(true, true);
$this->edittime = $this->mArticle->getTimestamp();
} else {
if ($this->mTitle->getArticleID() == 0) {
$s = wfMsg('creating', "\"" . wfMsg('howto', $this->mTitle->getPrefixedText()) . "\"");
} else {
$s = wfMsg('editing', "\"" . wfMsg('howto', $this->mTitle->getPrefixedText()) . "\"");
}
if ($this->section != "") {
if ($this->section == "new") {
$s .= wfMsg("commentedit");
} else {
$s .= wfMsg("sectionedit");
}
if (!$this->preview) {
$sectitle = preg_match("/^=+(.*?)=+/mi", $this->textbox1, $matches);
if (!empty($matches[1])) {
$this->summary = "/* " . trim($matches[1]) . " */ ";
}
}
}
$wgOut->setPageTitle($s);
if ($this->oldid) {
$this->mArticle->setOldSubtitle($this->oldid);
$wgOut->addHTML(wfMsg("editingold"));
}
}
if (wfReadOnly()) {
$wgOut->addHTML("<strong>" . wfMsg("readonlywarning") . "</strong>");
} elseif ($isCssJsSubpage and "preview" != $formtype) {
$wgOut->addHTML(wfMsg("usercssjsyoucanpreview"));
}
if (!$newArticle && $this->mTitle->isProtected('edit')) {
if ($this->mTitle->isSemiProtected()) {
$notice = wfMsg('semiprotectedpagewarning');
if (wfEmptyMsg('semiprotectedpagewarning', $notice) || $notice == '-') {
$notice = '';
}
} else {
$notice = wfMsg('protectedpagewarning');
}
$wgOut->addHTML("<div class='article_inner'>\n ");
$wgOut->addWikiText($notice);
$wgOut->addHTML("</div>\n");
}
$q = "action=submit2&override=yes";
#if ( "no" == $redirect ) { $q .= "&redirect=no"; }
$action = $this->mTitle->escapeLocalURL($q);
if ($newArticle) {
$main = str_replace(' ', '-', wfMsg('mainpage'));
//.........这里部分代码省略.........
示例3: 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
//.........这里部分代码省略.........
示例4: showEditForm
/**
* Send the edit form and related headers to $wgOut
* @param $formCallback Optional callable that takes an OutputPage
* parameter; will be called during form output
* near the top, for captchas and the like.
*/
function showEditForm($formCallback = null)
{
$this->app->wf->ProfileIn(__METHOD__);
// get HTML from form callback
if (is_callable($formCallback)) {
wfDebug(__METHOD__ . ": has form callback\n");
$out = new OutputPage();
call_user_func_array($formCallback, array(&$out));
$this->mCallbackNotices = $out->getHTML();
$formCallback = null;
}
if ($this->preloadedText !== false) {
$this->textbox1 = $this->preloadedText;
}
// show diff only (handle edit reverts)
if ($this->formtype == 'diff') {
$this->out->addHtml('<div id="diff">');
$this->showDiff();
$this->out->addHtml('</div>');
}
parent::showEditForm($formCallback);
$this->app->wf->ProfileOut(__METHOD__);
}