/**
	 * Get the editor form for writing a new thread, a reply, etc.
	 *
	 * @param $type String: either 'addthread' or 'editthread', depending on
	 * what we are doing to a thread.
	 * @param $action Array: action parameter(s) to be passed to the WikiForum
	 * special page call (i.e. array( 'thread' => $threadId ))
	 * @param $input String: usually whatever WikiForumGui::getInput() returns
	 * @param $height String: height of the textarea, i.e. '10em'
	 * @param $text_prev
	 * @param $saveButton String: save button text
	 * @return String: HTML
	 */
	public static function getWriteForm( $type, $action, $input, $height, $text_prev, $saveButton ) {
		global $wgOut, $wgUser, $wgWikiForumAllowAnonymous;

		$output = '';

		if ( $wgWikiForumAllowAnonymous || $wgUser->isLoggedIn() ) {
			// Required for the edit buttons to display
			$wgOut->addModules( 'mediawiki.action.edit' );
			$toolbar = EditPage::getEditToolbar();
			$specialPage = SpecialPage::getTitleFor( 'WikiForum' );

			$output = '<form name="frmMain" method="post" action="' . $specialPage->escapeFullURL( $action ) . '" id="writereply">
			<table class="mw-wikiforum-frame" cellspacing="10">' . $input . '
				<tr>
					<td>' . $toolbar . '</td>
				</tr>
				<tr>
					<td><textarea name="frmText" id="wpTextbox1" style="height: ' . $height . ';">' . $text_prev . '</textarea></td>
				</tr>
				<tr>
					<td>
						<input name="butSave" type="submit" value="' . $saveButton . '" accesskey="s" title="' . $saveButton . ' [s]" />
						<input name="butPreview" type="submit" value="' . wfMsg( 'wikiforum-button-preview' ) . '" accesskey="p" title="' . wfMsg( 'wikiforum-button-preview' ) . ' [p]" />';
			if ( $type == 'addthread' ) {
				$output .= ' <input name="butCancel" type="button" value="' . wfMsg( 'cancel' ) . '" accesskey="c" onclick="javascript:history.back();" title="' . wfMsg( 'cancel' ) . ' [c]" />';
			}
			$output .= '</td>
					</td>
				</tr>
			</table>
			</form>' . "\n";
		}
		return $output;
	}
Beispiel #2
0
 /**
  * Send the edit form and related headers to $wgOut
  * @param $formCallback Callback that takes an OutputPage parameter; will be called
  *     during form output near the top, for captchas and the like.
  */
 function showEditForm($formCallback = null)
 {
     global $wgOut, $wgUser;
     wfProfileIn(__METHOD__);
     #need to parse the preview early so that we know which templates are used,
     #otherwise users with "show preview after edit box" will get a blank list
     #we parse this near the beginning so that setHeaders can do the title
     #setting work instead of leaving it in getPreviewText
     $previewOutput = '';
     if ($this->formtype == 'preview') {
         $previewOutput = $this->getPreviewText();
     }
     wfRunHooks('EditPage::showEditForm:initial', array(&$this));
     $this->setHeaders();
     if ($this->showHeader() === false) {
         wfProfileOut(__METHOD__);
         return;
     }
     $wgOut->addHTML($this->editFormPageTop);
     if ($wgUser->getOption('previewontop')) {
         $this->displayPreviewArea($previewOutput, true);
     }
     $wgOut->addHTML($this->editFormTextTop);
     $showToolbar = true;
     if ($this->wasDeletedSinceLastEdit()) {
         if ($this->formtype == 'save') {
             // Hide the toolbar and edit area, user can click preview to get it back
             // Add an confirmation checkbox and explanation.
             $showToolbar = false;
         } else {
             $wgOut->wrapWikiMsg("<div class='error mw-deleted-while-editing'>\n\$1\n</div>", 'deletedwhileediting');
         }
     }
     $wgOut->addHTML(Html::openElement('form', array('id' => 'editform', 'name' => 'editform', 'method' => 'post', 'action' => $this->getActionURL($this->getContextTitle()), 'enctype' => 'multipart/form-data')));
     if (is_callable($formCallback)) {
         call_user_func_array($formCallback, array(&$wgOut));
     }
     wfRunHooks('EditPage::showEditForm:fields', array(&$this, &$wgOut));
     // Put these up at the top to ensure they aren't lost on early form submission
     $this->showFormBeforeText();
     if ($this->wasDeletedSinceLastEdit() && 'save' == $this->formtype) {
         $username = $this->lastDelete->user_name;
         $comment = $this->lastDelete->log_comment;
         // It is better to not parse the comment at all than to have templates expanded in the middle
         // TODO: can the checkLabel be moved outside of the div so that wrapWikiMsg could be used?
         $key = $comment === '' ? 'confirmrecreate-noreason' : 'confirmrecreate';
         $wgOut->addHTML('<div class="mw-confirm-recreate">' . wfMsgExt($key, 'parseinline', $username, "<nowiki>{$comment}</nowiki>") . Xml::checkLabel(wfMsg('recreate'), 'wpRecreate', 'wpRecreate', false, array('title' => Linker::titleAttrib('recreate'), 'tabindex' => 1, 'id' => 'wpRecreate')) . '</div>');
     }
     # If a blank edit summary was previously provided, and the appropriate
     # user preference is active, pass a hidden tag as wpIgnoreBlankSummary. This will stop the
     # user being bounced back more than once in the event that a summary
     # is not required.
     #####
     # For a bit more sophisticated detection of blank summaries, hash the
     # automatic one and pass that in the hidden field wpAutoSummary.
     if ($this->missingSummary || $this->section == 'new' && $this->nosummary) {
         $wgOut->addHTML(Html::hidden('wpIgnoreBlankSummary', true));
     }
     $autosumm = $this->autoSumm ? $this->autoSumm : md5($this->summary);
     $wgOut->addHTML(Html::hidden('wpAutoSummary', $autosumm));
     $wgOut->addHTML(Html::hidden('oldid', $this->oldid));
     if ($this->section == 'new') {
         $this->showSummaryInput(true, $this->summary);
         $wgOut->addHTML($this->getSummaryPreview(true, $this->summary));
     }
     $wgOut->addHTML($this->editFormTextBeforeContent);
     if (!$this->isCssJsSubpage && $showToolbar && $wgUser->getOption('showtoolbar')) {
         $wgOut->addHTML(EditPage::getEditToolbar());
     }
     if ($this->isConflict) {
         // In an edit conflict bypass the overrideable content form method
         // and fallback to the raw wpTextbox1 since editconflicts can't be
         // resolved between page source edits and custom ui edits using the
         // custom edit ui.
         $this->textbox2 = $this->textbox1;
         $this->textbox1 = $this->getCurrentText();
         $this->showTextbox1();
     } else {
         $this->showContentForm();
     }
     $wgOut->addHTML($this->editFormTextAfterContent);
     $wgOut->addWikiText($this->getCopywarn());
     $wgOut->addHTML($this->editFormTextAfterWarn);
     $this->showStandardInputs();
     $this->showFormAfterText();
     $this->showTosSummary();
     $this->showEditTools();
     $wgOut->addHTML($this->editFormTextAfterTools . "\n");
     $wgOut->addHTML(Html::rawElement('div', array('class' => 'templatesUsed'), Linker::formatTemplates($this->getTemplates(), $this->preview, $this->section != '')));
     $wgOut->addHTML(Html::rawElement('div', array('class' => 'hiddencats'), Linker::formatHiddenCategories($this->mArticle->getHiddenCategories())));
     if ($this->isConflict) {
         $this->showConflict();
     }
     $wgOut->addHTML($this->editFormTextBottom . "\n</form>\n");
     if (!$wgUser->getOption('previewontop')) {
         $this->displayPreviewArea($previewOutput, false);
     }
     wfProfileOut(__METHOD__);
 }
Beispiel #3
0
 /**
  * Send the edit form and related headers to $wgOut
  * @param callable|null $formCallback That takes an OutputPage parameter; will be called
  *     during form output near the top, for captchas and the like.
  */
 function showEditForm($formCallback = null)
 {
     global $wgOut, $wgUser;
     wfProfileIn(__METHOD__);
     # need to parse the preview early so that we know which templates are used,
     # otherwise users with "show preview after edit box" will get a blank list
     # we parse this near the beginning so that setHeaders can do the title
     # setting work instead of leaving it in getPreviewText
     $previewOutput = '';
     if ($this->formtype == 'preview') {
         $previewOutput = $this->getPreviewText();
     }
     wfRunHooks('EditPage::showEditForm:initial', array(&$this, &$wgOut));
     $this->setHeaders();
     if ($this->showHeader() === false) {
         wfProfileOut(__METHOD__);
         return;
     }
     $wgOut->addHTML($this->editFormPageTop);
     if ($wgUser->getOption('previewontop')) {
         $this->displayPreviewArea($previewOutput, true);
     }
     $wgOut->addHTML($this->editFormTextTop);
     $showToolbar = true;
     if ($this->wasDeletedSinceLastEdit()) {
         if ($this->formtype == 'save') {
             // Hide the toolbar and edit area, user can click preview to get it back
             // Add an confirmation checkbox and explanation.
             $showToolbar = false;
         } else {
             $wgOut->wrapWikiMsg("<div class='error mw-deleted-while-editing'>\n\$1\n</div>", 'deletedwhileediting');
         }
     }
     // @todo add EditForm plugin interface and use it here!
     //       search for textarea1 and textares2, and allow EditForm to override all uses.
     $wgOut->addHTML(Html::openElement('form', array('id' => self::EDITFORM_ID, 'name' => self::EDITFORM_ID, 'method' => 'post', 'action' => $this->getActionURL($this->getContextTitle()), 'enctype' => 'multipart/form-data')));
     if (is_callable($formCallback)) {
         call_user_func_array($formCallback, array(&$wgOut));
     }
     // Add an empty field to trip up spambots
     $wgOut->addHTML(Xml::openElement('div', array('id' => 'antispam-container', 'style' => 'display: none;')) . Html::rawElement('label', array('for' => 'wpAntiSpam'), wfMessage('simpleantispam-label')->parse()) . Xml::element('input', array('type' => 'text', 'name' => 'wpAntispam', 'id' => 'wpAntispam', 'value' => '')) . Xml::closeElement('div'));
     wfRunHooks('EditPage::showEditForm:fields', array(&$this, &$wgOut));
     // Put these up at the top to ensure they aren't lost on early form submission
     $this->showFormBeforeText();
     if ($this->wasDeletedSinceLastEdit() && 'save' == $this->formtype) {
         $username = $this->lastDelete->user_name;
         $comment = $this->lastDelete->log_comment;
         // It is better to not parse the comment at all than to have templates expanded in the middle
         // TODO: can the checkLabel be moved outside of the div so that wrapWikiMsg could be used?
         $key = $comment === '' ? 'confirmrecreate-noreason' : 'confirmrecreate';
         $wgOut->addHTML('<div class="mw-confirm-recreate">' . wfMessage($key, $username, "<nowiki>{$comment}</nowiki>")->parse() . Xml::checkLabel(wfMessage('recreate')->text(), 'wpRecreate', 'wpRecreate', false, array('title' => Linker::titleAttrib('recreate'), 'tabindex' => 1, 'id' => 'wpRecreate')) . '</div>');
     }
     # When the summary is hidden, also hide them on preview/show changes
     if ($this->nosummary) {
         $wgOut->addHTML(Html::hidden('nosummary', true));
     }
     # If a blank edit summary was previously provided, and the appropriate
     # user preference is active, pass a hidden tag as wpIgnoreBlankSummary. This will stop the
     # user being bounced back more than once in the event that a summary
     # is not required.
     #####
     # For a bit more sophisticated detection of blank summaries, hash the
     # automatic one and pass that in the hidden field wpAutoSummary.
     if ($this->missingSummary || $this->section == 'new' && $this->nosummary) {
         $wgOut->addHTML(Html::hidden('wpIgnoreBlankSummary', true));
     }
     if ($this->undidRev) {
         $wgOut->addHTML(Html::hidden('wpUndidRevision', $this->undidRev));
     }
     if ($this->hasPresetSummary) {
         // If a summary has been preset using &summary= we don't want to prompt for
         // a different summary. Only prompt for a summary if the summary is blanked.
         // (Bug 17416)
         $this->autoSumm = md5('');
     }
     $autosumm = $this->autoSumm ? $this->autoSumm : md5($this->summary);
     $wgOut->addHTML(Html::hidden('wpAutoSummary', $autosumm));
     $wgOut->addHTML(Html::hidden('oldid', $this->oldid));
     $wgOut->addHTML(Html::hidden('format', $this->contentFormat));
     $wgOut->addHTML(Html::hidden('model', $this->contentModel));
     if ($this->section == 'new') {
         $this->showSummaryInput(true, $this->summary);
         $wgOut->addHTML($this->getSummaryPreview(true, $this->summary));
     }
     $wgOut->addHTML($this->editFormTextBeforeContent);
     if (!$this->isCssJsSubpage && $showToolbar && $wgUser->getOption('showtoolbar')) {
         $wgOut->addHTML(EditPage::getEditToolbar());
     }
     if ($this->blankArticle) {
         $wgOut->addHTML(Html::hidden('wpIgnoreBlankArticle', true));
     }
     if ($this->isConflict) {
         // In an edit conflict bypass the overridable content form method
         // and fallback to the raw wpTextbox1 since editconflicts can't be
         // resolved between page source edits and custom ui edits using the
         // custom edit ui.
         $this->textbox2 = $this->textbox1;
         $content = $this->getCurrentContent();
         $this->textbox1 = $this->toEditText($content);
         $this->showTextbox1();
     } else {
         $this->showContentForm();
     }
     $wgOut->addHTML($this->editFormTextAfterContent);
     $this->showStandardInputs();
     $this->showFormAfterText();
     $this->showTosSummary();
     $this->showEditTools();
     $wgOut->addHTML($this->editFormTextAfterTools . "\n");
     $wgOut->addHTML(Html::rawElement('div', array('class' => 'templatesUsed'), Linker::formatTemplates($this->getTemplates(), $this->preview, $this->section != '')));
     $wgOut->addHTML(Html::rawElement('div', array('class' => 'hiddencats'), Linker::formatHiddenCategories($this->mArticle->getHiddenCategories())));
     $wgOut->addHTML(Html::rawElement('div', array('class' => 'limitreport'), self::getPreviewLimitReport($this->mParserOutput)));
     $wgOut->addModules('mediawiki.action.edit.collapsibleFooter');
     if ($this->isConflict) {
         try {
             $this->showConflict();
         } catch (MWContentSerializationException $ex) {
             // this can't really happen, but be nice if it does.
             $msg = wfMessage('content-failed-to-parse', $this->contentModel, $this->contentFormat, $ex->getMessage());
             $wgOut->addWikiText('<div class="error">' . $msg->text() . '</div>');
         }
     }
     // Marker for detecting truncated form data.  This must be the last
     // parameter sent in order to be of use, so do not move me.
     $wgOut->addHTML(Html::hidden('wpUltimateParam', true));
     $wgOut->addHTML($this->editFormTextBottom . "\n</form>\n");
     if (!$wgUser->getOption('previewontop')) {
         $this->displayPreviewArea($previewOutput, false);
     }
     wfProfileOut(__METHOD__);
 }
Beispiel #4
0
    /**
     * 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)
    {
        global $wgOut, $wgUser, $wgLang, $wgContLang, $wgMaxArticleSize, $wgTitle, $wgRequest;
        # If $wgTitle is null, that means we're in API mode.
        # Some hook probably called this function  without checking
        # for is_null($wgTitle) first. Bail out right here so we don't
        # do lots of work just to discard it right after.
        if (is_null($wgTitle)) {
            return;
        }
        $fname = 'EditPage::showEditForm';
        wfProfileIn($fname);
        $sk = $wgUser->getSkin();
        wfRunHooks('EditPage::showEditForm:initial', array(&$this));
        #need to parse the preview early so that we know which templates are used,
        #otherwise users with "show preview after edit box" will get a blank list
        #we parse this near the beginning so that setHeaders can do the title
        #setting work instead of leaving it in getPreviewText
        $previewOutput = '';
        if ($this->formtype == 'preview') {
            $previewOutput = $this->getPreviewText();
        }
        $this->setHeaders();
        # Enabled article-related sidebar, toplinks, etc.
        $wgOut->setArticleRelated(true);
        if ($this->isConflict) {
            $wgOut->wrapWikiMsg("<div class='mw-explainconflict'>\n\$1</div>", 'explainconflict');
            $this->textbox2 = $this->textbox1;
            $this->textbox1 = $this->getContent();
            $this->edittime = $this->mArticle->getTimestamp();
        } else {
            if ($this->section != '' && $this->section != 'new') {
                $matches = array();
                if (!$this->summary && !$this->preview && !$this->diff) {
                    preg_match("/^(=+)(.+)\\1/mi", $this->textbox1, $matches);
                    if (!empty($matches[2])) {
                        global $wgParser;
                        $this->summary = "/* " . $wgParser->stripSectionName(trim($matches[2])) . " */ ";
                    }
                }
            }
            if ($this->missingComment) {
                $wgOut->wrapWikiMsg('<div id="mw-missingcommenttext">$1</div>', 'missingcommenttext');
            }
            if ($this->missingSummary && $this->section != 'new') {
                $wgOut->wrapWikiMsg('<div id="mw-missingsummary">$1</div>', 'missingsummary');
            }
            if ($this->missingSummary && $this->section == 'new') {
                $wgOut->wrapWikiMsg('<div id="mw-missingcommentheader">$1</div>', 'missingcommentheader');
            }
            if ($this->hookError !== '') {
                $wgOut->addWikiText($this->hookError);
            }
            if (!$this->checkUnicodeCompliantBrowser()) {
                $wgOut->addWikiMsg('nonunicodebrowser');
            }
            if (isset($this->mArticle) && isset($this->mArticle->mRevision)) {
                // Let sysop know that this will make private content public if saved
                if (!$this->mArticle->mRevision->userCan(Revision::DELETED_TEXT)) {
                    $wgOut->wrapWikiMsg("<div class='mw-warning plainlinks'>\n\$1</div>\n", 'rev-deleted-text-permission');
                } else {
                    if ($this->mArticle->mRevision->isDeleted(Revision::DELETED_TEXT)) {
                        $wgOut->wrapWikiMsg("<div class='mw-warning plainlinks'>\n\$1</div>\n", 'rev-deleted-text-view');
                    }
                }
                if (!$this->mArticle->mRevision->isCurrent()) {
                    $this->mArticle->setOldSubtitle($this->mArticle->mRevision->getId());
                    $wgOut->addWikiMsg('editingold');
                }
            }
        }
        if (wfReadOnly()) {
            $wgOut->wrapWikiMsg("<div id=\"mw-read-only-warning\">\n\$1\n</div>", array('readonlywarning', wfReadOnlyReason()));
        } elseif ($wgUser->isAnon() && $this->formtype != 'preview') {
            $wgOut->wrapWikiMsg('<div id="mw-anon-edit-warning">$1</div>', 'anoneditwarning');
        } else {
            if ($this->isCssJsSubpage) {
                # Check the skin exists
                if ($this->isValidCssJsSubpage) {
                    if ($this->formtype !== 'preview') {
                        $wgOut->addWikiMsg('usercssjsyoucanpreview');
                    }
                } else {
                    $wgOut->addWikiMsg('userinvalidcssjstitle', $wgTitle->getSkinFromCssJsSubpage());
                }
            }
        }
        $classes = array();
        // Textarea CSS
        if ($this->mTitle->getNamespace() == NS_MEDIAWIKI) {
        } elseif ($this->mTitle->isProtected('edit')) {
            # Is the title semi-protected?
            if ($this->mTitle->isSemiProtected()) {
                $noticeMsg = 'semiprotectedpagewarning';
                $classes[] = 'mw-textarea-sprotected';
            } else {
                # Then it must be protected based on static groups (regular)
                $noticeMsg = 'protectedpagewarning';
                $classes[] = 'mw-textarea-protected';
            }
            $wgOut->addHTML("<div class='mw-warning-with-logexcerpt'>\n");
            $wgOut->addWikiMsg($noticeMsg);
            LogEventsList::showLogExtract($wgOut, 'protect', $this->mTitle->getPrefixedText(), '', 1);
            $wgOut->addHTML("</div>\n");
        }
        if ($this->mTitle->isCascadeProtected()) {
            # Is this page under cascading protection from some source pages?
            list($cascadeSources, ) = $this->mTitle->getCascadeProtectionSources();
            $notice = "<div class='mw-cascadeprotectedwarning'>\$1\n";
            $cascadeSourcesCount = count($cascadeSources);
            if ($cascadeSourcesCount > 0) {
                # Explain, and list the titles responsible
                foreach ($cascadeSources as $page) {
                    $notice .= '* [[:' . $page->getPrefixedText() . "]]\n";
                }
            }
            $notice .= '</div>';
            $wgOut->wrapWikiMsg($notice, array('cascadeprotectedwarning', $cascadeSourcesCount));
        }
        if (!$this->mTitle->exists() && $this->mTitle->getRestrictions('create')) {
            $wgOut->wrapWikiMsg('<div class="mw-titleprotectedwarning">$1</div>', 'titleprotectedwarning');
        }
        if ($this->kblength === false) {
            $this->kblength = (int) (strlen($this->textbox1) / 1024);
        }
        if ($this->tooBig || $this->kblength > $wgMaxArticleSize) {
            $wgOut->addHTML("<div class='error' id='mw-edit-longpageerror'>\n");
            $wgOut->addWikiMsg('longpageerror', $wgLang->formatNum($this->kblength), $wgLang->formatNum($wgMaxArticleSize));
            $wgOut->addHTML("</div>\n");
        } elseif ($this->kblength > 29) {
            $wgOut->addHTML("<div id='mw-edit-longpagewarning'>\n");
            $wgOut->addWikiMsg('longpagewarning', $wgLang->formatNum($this->kblength));
            $wgOut->addHTML("</div>\n");
        }
        $q = 'action=' . $this->action;
        #if ( "no" == $redirect ) { $q .= "&redirect=no"; }
        $action = $wgTitle->escapeLocalURL($q);
        $summary = wfMsg('summary');
        $subject = wfMsg('subject');
        $cancel = $sk->makeKnownLink($wgTitle->getPrefixedText(), wfMsgExt('cancel', array('parseinline')));
        $separator = wfMsgExt('pipe-separator', 'escapenoentities');
        $edithelpurl = Skin::makeInternalOrExternalUrl(wfMsgForContent('edithelppage'));
        $edithelp = '<a target="helpwindow" href="' . $edithelpurl . '">' . htmlspecialchars(wfMsg('edithelp')) . '</a> ' . htmlspecialchars(wfMsg('newwindow'));
        global $wgRightsText;
        if ($wgRightsText) {
            $copywarnMsg = array('copyrightwarning', '[[' . wfMsgForContent('copyrightpage') . ']]', $wgRightsText);
        } else {
            $copywarnMsg = array('copyrightwarning2', '[[' . wfMsgForContent('copyrightpage') . ']]');
        }
        if ($wgUser->getOption('showtoolbar') and !$this->isCssJsSubpage) {
            # prepare toolbar for edit buttons
            $toolbar = EditPage::getEditToolbar();
        } else {
            $toolbar = '';
        }
        // activate checkboxes if user wants them to be always active
        if (!$this->preview && !$this->diff) {
            # Sort out the "watch" checkbox
            if ($wgUser->getOption('watchdefault')) {
                # Watch all edits
                $this->watchthis = true;
            } elseif ($wgUser->getOption('watchcreations') && !$this->mTitle->exists()) {
                # Watch creations
                $this->watchthis = true;
            } elseif ($this->mTitle->userIsWatching()) {
                # Already watched
                $this->watchthis = true;
            }
            # May be overriden by request parameters
            if ($wgRequest->getBool('watchthis')) {
                $this->watchthis = true;
            }
            if ($wgUser->getOption('minordefault')) {
                $this->minoredit = true;
            }
        }
        $wgOut->addHTML($this->editFormPageTop);
        if ($wgUser->getOption('previewontop')) {
            $this->displayPreviewArea($previewOutput, true);
        }
        $wgOut->addHTML($this->editFormTextTop);
        # if this is a comment, show a subject line at the top, which is also the edit summary.
        # Otherwise, show a summary field at the bottom
        $summarytext = $wgContLang->recodeForEdit($this->summary);
        # If a blank edit summary was previously provided, and the appropriate
        # user preference is active, pass a hidden tag as wpIgnoreBlankSummary. This will stop the
        # user being bounced back more than once in the event that a summary
        # is not required.
        #####
        # For a bit more sophisticated detection of blank summaries, hash the
        # automatic one and pass that in the hidden field wpAutoSummary.
        $summaryhiddens = '';
        if ($this->missingSummary) {
            $summaryhiddens .= Xml::hidden('wpIgnoreBlankSummary', true);
        }
        $autosumm = $this->autoSumm ? $this->autoSumm : md5($this->summary);
        $summaryhiddens .= Xml::hidden('wpAutoSummary', $autosumm);
        if ($this->section == 'new') {
            $commentsubject = '';
            if (!$wgRequest->getBool('nosummary')) {
                # Add a class if 'missingsummary' is triggered to allow styling of the summary line
                $summaryClass = $this->missingSummary ? 'mw-summarymissed' : 'mw-summary';
                $commentsubject = Xml::tags('label', array('for' => 'wpSummary'), $subject);
                $commentsubject = Xml::tags('span', array('class' => $summaryClass, 'id' => "wpSummaryLabel"), $commentsubject);
                $commentsubject .= '&nbsp;';
                $commentsubject .= Xml::input('wpSummary', 60, $summarytext, array('id' => 'wpSummary', 'maxlength' => '200', 'tabindex' => '1'));
            }
            $editsummary = "<div class='editOptions'>\n";
            global $wgParser;
            $formattedSummary = wfMsgForContent('newsectionsummary', $wgParser->stripSectionName($this->summary));
            $subjectpreview = $summarytext && $this->preview ? "<div class=\"mw-summary-preview\">" . wfMsg('subject-preview') . $sk->commentBlock($formattedSummary, $this->mTitle, true) . "</div>\n" : '';
            $summarypreview = '';
        } else {
            $commentsubject = '';
            # Add a class if 'missingsummary' is triggered to allow styling of the summary line
            $summaryClass = $this->missingSummary ? 'mw-summarymissed' : 'mw-summary';
            $editsummary = Xml::tags('label', array('for' => 'wpSummary'), $summary);
            $editsummary = Xml::tags('span', array('class' => $summaryClass, 'id' => "wpSummaryLabel"), $editsummary) . ' ';
            $editsummary .= Xml::input('wpSummary', 60, $summarytext, array('id' => 'wpSummary', 'maxlength' => '200', 'tabindex' => '1'));
            // No idea where this is closed.
            $editsummary = Xml::openElement('div', array('class' => 'editOptions')) . $editsummary . '<br/>';
            $summarypreview = '';
            if ($summarytext && $this->preview) {
                $summarypreview = Xml::tags('div', array('class' => 'mw-summary-preview'), wfMsg('summary-preview') . $sk->commentBlock($this->summary, $this->mTitle));
            }
            $subjectpreview = '';
        }
        $commentsubject .= $summaryhiddens;
        # Set focus to the edit box on load, except on preview or diff, where it would interfere with the display
        if (!$this->preview && !$this->diff) {
            $wgOut->setOnloadHandler('document.editform.wpTextbox1.focus()');
        }
        $templates = $this->getTemplates();
        $formattedtemplates = $sk->formatTemplates($templates, $this->preview, $this->section != '');
        $hiddencats = $this->mArticle->getHiddenCategories();
        $formattedhiddencats = $sk->formatHiddenCategories($hiddencats);
        global $wgUseMetadataEdit;
        if ($wgUseMetadataEdit) {
            $metadata = $this->mMetaData;
            $metadata = htmlspecialchars($wgContLang->recodeForEdit($metadata));
            $top = wfMsgWikiHtml('metadata_help');
            /* ToDo: Replace with clean code */
            $ew = $wgUser->getOption('editwidth');
            if ($ew) {
                $ew = " style=\"width:100%\"";
            } else {
                $ew = '';
            }
            $cols = $wgUser->getIntOption('cols');
            /* /ToDo */
            $metadata = $top . "<textarea name='metadata' rows='3' cols='{$cols}'{$ew}>{$metadata}</textarea>";
        } else {
            $metadata = "";
        }
        $recreate = '';
        if ($this->wasDeletedSinceLastEdit()) {
            if ('save' != $this->formtype) {
                $wgOut->wrapWikiMsg("<div class='error mw-deleted-while-editing'>\n\$1</div>", 'deletedwhileediting');
            } else {
                // Hide the toolbar and edit area, user can click preview to get it back
                // Add an confirmation checkbox and explanation.
                $toolbar = '';
                $recreate = '<div class="mw-confirm-recreate">' . $wgOut->parse(wfMsg('confirmrecreate', $this->lastDelete->user_name, $this->lastDelete->log_comment)) . Xml::checkLabel(wfMsg('recreate'), 'wpRecreate', 'wpRecreate', false, array('title' => $sk->titleAttrib('recreate'), 'tabindex' => 1, 'id' => 'wpRecreate')) . '</div>';
            }
        }
        $tabindex = 2;
        $checkboxes = $this->getCheckboxes($tabindex, $sk, array('minor' => $this->minoredit, 'watch' => $this->watchthis));
        $checkboxhtml = implode($checkboxes, "\n");
        $buttons = $this->getEditButtons($tabindex);
        $buttonshtml = implode($buttons, "\n");
        $safemodehtml = $this->checkUnicodeCompliantBrowser() ? '' : Xml::hidden('safemode', '1');
        $wgOut->addHTML(<<<END
{$toolbar}
<form id="editform" name="editform" method="post" action="{$action}" enctype="multipart/form-data">
END
);
        if (is_callable($formCallback)) {
            call_user_func_array($formCallback, array(&$wgOut));
        }
        wfRunHooks('EditPage::showEditForm:fields', array(&$this, &$wgOut));
        // Put these up at the top to ensure they aren't lost on early form submission
        $this->showFormBeforeText();
        $wgOut->addHTML(<<<END
{$recreate}
{$commentsubject}
{$subjectpreview}
{$this->editFormTextBeforeContent}
END
);
        $this->showTextbox1($classes);
        $wgOut->wrapWikiMsg("<div id=\"editpage-copywarn\">\n\$1\n</div>", $copywarnMsg);
        $wgOut->addHTML(<<<END
{$this->editFormTextAfterWarn}
{$metadata}
{$editsummary}
{$summarypreview}
{$checkboxhtml}
{$safemodehtml}
END
);
        $wgOut->addHTML("<div class='editButtons'>\n{$buttonshtml}\n\t<span class='editHelp'>{$cancel}{$separator}{$edithelp}</span>\n</div><!-- editButtons -->\n</div><!-- editOptions -->");
        /**
         * To make it harder for someone to slip a user a page
         * which submits an edit form to the wiki without their
         * knowledge, a random token is associated with the login
         * session. If it's not passed back with the submission,
         * we won't save the page, or render user JavaScript and
         * CSS previews.
         *
         * For anon editors, who may not have a session, we just
         * include the constant suffix to prevent editing from
         * broken text-mangling proxies.
         */
        $token = htmlspecialchars($wgUser->editToken());
        $wgOut->addHTML("\n<input type='hidden' value=\"{$token}\" name=\"wpEditToken\" />\n");
        $this->showEditTools();
        $wgOut->addHTML(<<<END
{$this->editFormTextAfterTools}
<div class='templatesUsed'>
{$formattedtemplates}
</div>
<div class='hiddencats'>
{$formattedhiddencats}
</div>
END
);
        if ($this->isConflict && wfRunHooks('EditPageBeforeConflictDiff', array(&$this, &$wgOut))) {
            $wgOut->wrapWikiMsg('==$1==', "yourdiff");
            $de = new DifferenceEngine($this->mTitle);
            $de->setText($this->textbox2, $this->textbox1);
            $de->showDiff(wfMsg("yourtext"), wfMsg("storedversion"));
            $wgOut->wrapWikiMsg('==$1==', "yourtext");
            $this->showTextbox2();
        }
        $wgOut->addHTML($this->editFormTextBottom);
        $wgOut->addHTML("</form>\n");
        if (!$wgUser->getOption('previewontop')) {
            $this->displayPreviewArea($previewOutput, false);
        }
        wfProfileOut($fname);
    }
    function showEditForm($formCallback = null)
    {
        global $wgOut, $wgUser, $wgLang, $wgContLang, $wgMaxArticleSize;
        // print "call SHOW EDIT FORM";
        if (!isset($this->stripped_edit_text)) {
            $this->stripped_edit_text = '';
        }
        $fname = 'EditPageAjax::showEditForm';
        wfProfileIn($fname);
        $closeFormHtml = '';
        // check if we are in the MVD namespace (and need to use templates for edits:)
        if ($this->mTitle->getNamespace() == MV_NS_MVD) {
            // get display type get mvTitle if not set
            if (!isset($this->article->mvTitle)) {
                $this->mvTitle = new MV_Title($this->mTitle->getDBkey());
            }
            $editFormType = strtolower($this->mvTitle->getMvdTypeKey());
        } else {
            // check if its seq type:
            if ($this->mvd_id == 'seq') {
                $editFormType = 'seq';
            } else {
                $editFormType = 'default';
            }
        }
        switch ($editFormType) {
            case 'ht_en':
                $this->do_pre_htEdit();
                $closeFormHtml = $this->do_post_HtEdit();
                break;
            case 'anno_en':
                $this->loadEditText();
                // set the default action so save page:
                $wgOut->addHTML($this->getAjaxForm());
                // add in adjust html if present:
                $wgOut->addHTML($this->adj_html);
                break;
            case 'seq':
                $wgOut->addHTML(wfMsg('mv_edit_sequence_desc_help'));
                if ($this->mArticle->mTitle->exists()) {
                    $this->stripped_edit_text = $this->mArticle->getPageContent();
                } else {
                    $this->stripped_edit_text = '';
                }
                $wgOut->addHTML($this->getAjaxForm());
                break;
            default:
                $this->loadEditText();
                // set the default action so save page:
                $wgOut->addHTML($this->getAjaxForm());
                break;
        }
        $sk = $wgUser->getSkin();
        // wfRunHooks( 'EditPage::showEditForm:initial', array( &$this ) ) ;
        // $wgOut->setRobotpolicy( 'noindex,nofollow' );
        # Enabled article-related sidebar, top links, etc.
        $wgOut->setArticleRelated(true);
        if ($this->isConflict) {
            $s = wfMsg('editconflict', $this->mTitle->getPrefixedText());
            $wgOut->setPageTitle($s);
            $wgOut->addWikiText(wfMsg('explainconflict'));
            $this->textbox2 = $this->textbox1;
            $this->textbox1 = $this->stripped_edit_text;
            $this->edittime = $this->mArticle->getTimestamp();
        } else {
            if ($this->section != '') {
                if ($this->section == 'new') {
                    $s = wfMsg('editingcomment', $this->mTitle->getPrefixedText());
                } else {
                    $s = wfMsg('editingsection', $this->mTitle->getPrefixedText());
                    $matches = array();
                    if (!$this->summary && !$this->preview && !$this->diff) {
                        preg_match("/^(=+)(.+)\\1/mi", $this->stripped_edit_text, $matches);
                        if (!empty($matches[2])) {
                            $this->summary = "/* " . trim($matches[2]) . " */ ";
                        }
                    }
                }
            } else {
                $s = wfMsg('editing', $this->mTitle->getPrefixedText());
            }
            // $wgOut->addHTML($s);
            // $wgOut->setPageTitle( $s );
            if ($this->missingComment) {
                $wgOut->addWikiText(wfMsg('missingcommenttext'));
            }
            if ($this->missingSummary && $this->section != 'new') {
                $wgOut->addWikiText(wfMsg('missingsummary'));
            }
            if ($this->missingSummary && $this->section == 'new') {
                $wgOut->addWikiText(wfMsg('missingcommentheader'));
            }
            if (!$this->hookError == '') {
                $wgOut->addWikiText($this->hookError);
            }
            if (!$this->checkUnicodeCompliantBrowser()) {
                $wgOut->addWikiText(wfMsg('nonunicodebrowser'));
            }
            if (isset($this->mArticle) && isset($this->mArticle->mRevision)) {
                // Let sysop know that this will make private content public if saved
                if ($this->mArticle->mRevision->isDeleted(Revision::DELETED_TEXT)) {
                    $wgOut->wrapWikiMsg("<div class='mw-warning plainlinks'>\n\$1</div>\n", 'rev-deleted-text-view');
                }
                if (!$this->mArticle->mRevision->isCurrent()) {
                    $this->mArticle->setOldSubtitle($this->mArticle->mRevision->getId());
                    $wgOut->addWikiText(wfMsg('editingold'));
                }
            }
        }
        if (wfReadOnly()) {
            $wgOut->addWikiText(wfMsg('readonlywarning'));
        } elseif ($wgUser->isAnon() && $this->formtype != 'preview') {
            $wgOut->addWikiText(wfMsg('anoneditwarning'));
        } else {
            if ($this->isCssJsSubpage && $this->formtype != 'preview') {
                # Check the skin exists
                if (!$this->isWrongCaseCssJsPage) {
                    $wgOut->addWikiText(wfMsg('usercssjsyoucanpreview'));
                } else {
                    $wgOut->addWikiText(wfMsg('userinvalidcssjstitle', $this->mTitle->getSkinFromCssJsSubpage()));
                }
            }
        }
        if ($this->mTitle->getNamespace() == NS_MEDIAWIKI) {
            # Show a warning if editing an interface message
            $wgOut->addWikiText(wfMsg('editinginterface'));
        } elseif ($this->mTitle->isProtected('edit')) {
            # Is the title semi-protected?
            if ($this->mTitle->isSemiProtected()) {
                $notice = wfMsg('semiprotectedpagewarning');
                if (wfEmptyMsg('semiprotectedpagewarning', $notice) || $notice == '-') {
                    $notice = '';
                }
            } else {
                # Then it must be protected based on static groups (regular)
                $notice = wfMsg('protectedpagewarning');
            }
            $wgOut->addWikiText($notice);
        }
        if ($this->mTitle->isCascadeProtected()) {
            # Is this page under cascading protection from some source pages?
            list($cascadeSources, ) = $this->mTitle->getCascadeProtectionSources();
            if (count($cascadeSources) > 0) {
                # Explain, and list the titles responsible
                $notice = wfMsgExt('cascadeprotectedwarning', array('parsemag'), count($cascadeSources)) . "\n";
                foreach ($cascadeSources as $id => $page) {
                    $notice .= '* [[:' . $page->getPrefixedText() . "]]\n";
                }
            }
            $wgOut->addWikiText($notice);
        }
        if ($this->kblength === false) {
            $this->kblength = (int) (strlen($this->stripped_edit_text) / 1024);
        }
        if ($this->tooBig || $this->kblength > $wgMaxArticleSize) {
            $wgOut->addWikiText(wfMsg('longpageerror', $wgLang->formatNum($this->kblength), $wgMaxArticleSize));
        } elseif ($this->kblength > 29) {
            $wgOut->addWikiText(wfMsg('longpagewarning', $wgLang->formatNum($this->kblength)));
        }
        # need to parse the preview early so that we know which templates are used,
        # otherwise users with "show preview after edit box" will get a blank list
        if ($this->formtype == 'preview') {
            $previewOutput = $this->getPreviewText();
        }
        if ($wgUser->getOption('previewontop')) {
            if ('preview' == $this->formtype) {
                $this->showPreview($previewOutput);
            } else {
                $wgOut->addHTML('<div id="wikiPreview_' . htmlspecialchars($this->mvd_id) . '"></div>');
            }
            if ('diff' == $this->formtype) {
                $this->showDiff();
            }
        }
        $wgOut->addHTML($this->basic_html);
        $wgOut->addHTML('<div style="display:inline" class="mv_advanced_edit"><br>');
        // $rows = $wgUser->getIntOption( 'rows' );
        // $cols = $wgUser->getIntOption( 'cols' );
        // for ajax short edit area:
        $rows = 3;
        $cols = 40;
        $ew = $wgUser->getOption('editwidth');
        if ($ew) {
            $ew = " style=\"width:100%\"";
        } else {
            $ew = '';
        }
        // do ajax action:
        // $q = 'action=ajax';
        # if ( "no" == $redirect ) { $q .= "&redirect=no"; }
        // $action = $this->mTitle->escapeLocalURL( $q );
        if ($editFormType == 'seq') {
            $summary = wfMsg('mv_seq_summary');
        } else {
            $summary = wfMsg('summary');
        }
        $subject = wfMsg('subject');
        if ($this->mvd_id == 'seq') {
            $cancel = $sk->makeKnownLinkObj($this->mTitle, wfMsgExt('cancel', array('parseinline')));
            $edithelpurl = Skin::makeInternalOrExternalUrl(wfMsgForContent('mv_edithelpsequence'));
        } else {
            $cancel = '<a href="javascript:mv_disp_mvd(\'' . $this->mTitle->getDBkey() . '\',\'' . $this->mvd_id . '\');">' . wfMsgExt('cancel', array('parseinline')) . '</a>';
            $edithelpurl = Skin::makeInternalOrExternalUrl(wfMsgForContent('edithelppage'));
        }
        $edithelp = '<a target="helpwindow" href="' . $edithelpurl . '">' . htmlspecialchars(wfMsg('edithelp')) . '</a> ' . htmlspecialchars(wfMsg('newwindow'));
        global $wgRightsText;
        // copy right here is too verbose for a ajax window
        /*$copywarn = "<div id=\"editpage-copywarn\">\n" .
        			wfMsg( $wgRightsText ? 'copyrightwarning' : 'copyrightwarning2',
        				'[[' . wfMsgForContent( 'copyrightpage' ) . ']]',
        				$wgRightsText ) . "\n</div>";
        		*/
        if ($wgUser->getOption('showtoolbar') and !$this->isCssJsSubpage) {
            # prepare toolbar for edit buttons
            $toolbar = EditPage::getEditToolbar();
        } else {
            $toolbar = '';
        }
        // activate checkboxes if user wants them to be always active
        if (!$this->preview && !$this->diff) {
            # Sort out the "watch" checkbox
            if ($wgUser->getOption('watchdefault')) {
                # Watch all edits
                $this->watchthis = true;
            } elseif ($wgUser->getOption('watchcreations') && !$this->mTitle->exists()) {
                # Watch creations
                $this->watchthis = true;
            } elseif ($this->mTitle->userIsWatching()) {
                # Already watched
                $this->watchthis = true;
            }
            if ($wgUser->getOption('minordefault')) {
                $this->minoredit = true;
            }
        }
        $wgOut->addHTML($this->editFormPageTop);
        $wgOut->addHTML($this->editFormTextTop);
        # if this is a comment, show a subject line at the top, which is also the edit summary.
        # Otherwise, show a summary field at the bottom
        $summarytext = htmlspecialchars($wgContLang->recodeForEdit($this->summary));
        # FIXME
        if ($this->section == 'new') {
            $commentsubject = "<br /><span id='wpSummaryLabel'><label for='wpSummary'>{$subject}:</label></span>\n<div class='editOptions'>\n<input tabindex='1' type='text' value=\"{$summarytext}\" name='wpSummary' id='wpSummary' maxlength='200' size='40' /><br />";
            $editsummary = '';
            $subjectpreview = $summarytext && $this->preview ? "<div class=\"mw-summary-preview\">" . wfMsg('subject-preview') . ':' . $sk->commentBlock($this->summary, $this->mTitle) . "</div>\n" : '';
            $summarypreview = '';
        } else {
            $commentsubject = '';
            $editsummary = "<br /><span id='wpSummaryLabel'><label for='wpSummary'>{$summary}:</label></span>\n<div class='editOptions'>\n<input tabindex='2' type='text' value=\"{$summarytext}\" name='wpSummary' id='wpSummary' maxlength='200' size='40' /><br />";
            $summarypreview = $summarytext && $this->preview ? "<div class=\"mw-summary-preview\">" . wfMsg('summary-preview') . ':' . $sk->commentBlock($this->summary, $this->mTitle) . "</div>\n" : '';
            $subjectpreview = '';
        }
        $templates = $this->preview || $this->section != '' ? $this->mPreviewTemplates : $this->mArticle->getUsedTemplates();
        $formattedtemplates = $sk->formatTemplates($templates, $this->preview, $this->section != '');
        global $wgUseMetadataEdit;
        if ($wgUseMetadataEdit) {
            $metadata = $this->mMetaData;
            $metadata = htmlspecialchars($wgContLang->recodeForEdit($metadata));
            $top = wfMsgWikiHtml('metadata_help');
            $metadata = $top . "<textarea name='metadata' rows='3' cols='{$cols}'{$ew}>{$metadata}</textarea>";
        } else {
            $metadata = "";
        }
        $hidden = '';
        $recreate = '';
        if ($this->deletedSinceEdit) {
            if ('save' != $this->formtype) {
                $wgOut->addWikiText(wfMsg('deletedwhileediting'));
            } else {
                // Hide the toolbar and edit area, use can click preview to get it back
                // Add an confirmation checkbox and explanation.
                $toolbar = '';
                $hidden = 'type="hidden" style="display:none;"';
                $recreate = $wgOut->parse(wfMsg('confirmrecreate', $this->lastDelete->user_name, $this->lastDelete->log_comment));
                $recreate .= "<br /><input tabindex='1' type='checkbox' value='1' name='wpRecreate' id='wpRecreate' />" . "<label for='wpRecreate' title='" . wfMsg('tooltip-recreate') . "'>" . wfMsg('recreate') . "</label>";
            }
        }
        $tabindex = 2;
        $checkboxes = self::getCheckboxes($tabindex, $sk, array('minor' => $this->minoredit, 'watch' => $this->watchthis));
        $checkboxhtml = implode($checkboxes, "\n");
        $button_action = 'mv_do_ajax_form_submit(\'' . $this->mvd_id . '\', \'%s\');';
        $buttons = $this->getEditButtons($tabindex, $button_action);
        $buttonshtml = implode($buttons, "\n");
        $safemodehtml = $this->checkUnicodeCompliantBrowser() ? '' : Html::Hidden('safemode', '1');
        $wgOut->addHTML(<<<END
{$toolbar}
END
);
        // remove form because set earlier
        // <form id="editform" name="editform" method="post" action="$action" enctype="multipart/form-data">
        if (is_callable($formCallback)) {
            call_user_func_array($formCallback, array(&$wgOut));
        }
        wfRunHooks('EditPage::showEditForm:fields', array(&$this, &$wgOut));
        // Put these up at the top to ensure they aren't lost on early form submission
        $wgOut->addHTML("\n<input type='hidden' value=\"" . htmlspecialchars($this->section) . "\" name=\"wpSection\" />\n<input type='hidden' value=\"{$this->starttime}\" name=\"wpStarttime\" />\n\n<input type='hidden' value=\"{$this->edittime}\" name=\"wpEdittime\" />\n\n<input type='hidden' value=\"{$this->scrolltop}\" name=\"wpScrolltop\" id=\"wpScrolltop\" />\n");
        $wgOut->addHTML(<<<END
{$recreate}
{$commentsubject}
{$subjectpreview}
<textarea class="mv_ajax_textarea" tabindex='1' accesskey="," name="wpTextbox1" id="wpTextbox1" rows='{$rows}'
cols='{$cols}' {$ew} {$hidden}>
END
 . htmlspecialchars($this->safeUnicodeOutput($this->stripped_edit_text)) . "\n</textarea>\n\t\t");
        // close advanced display_edit div
        $wgOut->addHTML("</div>");
        // $wgOut->addWikiText( $copywarn );
        $wgOut->addHTML($this->editFormTextAfterWarn);
        $separator = wfMsgExt('pipe-separator', 'escapenoentities');
        $wgOut->addHTML("\n{$metadata}\n{$editsummary}\n{$summarypreview}\n{$checkboxhtml}\n{$safemodehtml}\n");
        $wgOut->addHTML("<div class='editButtons'>\n{$buttonshtml}\n\t<span class='editHelp'>{$cancel}{$separator}{$edithelp}</span>\n</div><!-- editButtons -->\n</div><!-- editOptions -->");
        $wgOut->addHTML('<div class="mw-editTools">');
        $wgOut->addWikiText(wfMsgForContent('edittools'));
        $wgOut->addHTML('</div>');
        $wgOut->addHTML($this->editFormTextAfterTools);
        $wgOut->addHTML("\n<div class='templatesUsed'>\n{$formattedtemplates}\n</div>\n");
        /**
         * To make it harder for someone to slip a user a page
         * which submits an edit form to the wiki without their
         * knowledge, a random token is associated with the login
         * session. If it's not passed back with the submission,
         * we won't save the page, or render user JavaScript and
         * CSS previews.
         *
         * For anon editors, who may not have a session, we just
         * include the constant suffix to prevent editing from
         * broken text-mangling proxies.
         */
        $token = htmlspecialchars($wgUser->editToken());
        $wgOut->addHTML("\n<input type='hidden' value=\"{$token}\" name=\"wpEditToken\" />\n");
        # If a blank edit summary was previously provided, and the appropriate
        # user preference is active, pass a hidden tag here. This will stop the
        # user being bounced back more than once in the event that a summary
        # is not required.
        if ($this->missingSummary) {
            $wgOut->addHTML("<input type=\"hidden\" name=\"wpIgnoreBlankSummary\" value=\"1\" />\n");
        }
        # For a bit more sophisticated detection of blank summaries, hash the
        # automatic one and pass that in a hidden field.
        $autosumm = $this->autoSumm ? $this->autoSumm : md5($this->summary);
        $wgOut->addHTML(Html::Hidden('wpAutoSummary', $autosumm));
        if ($this->isConflict) {
            $wgOut->addWikiText('==' . wfMsg("yourdiff") . '==');
            $de = new DifferenceEngine($this->mTitle);
            $de->setText($this->textbox2, $this->stripped_edit_text);
            $de->showDiff(wfMsg("yourtext"), wfMsg("storedversion"));
            $wgOut->addWikiText('==' . wfMsg("yourtext") . '==');
            $wgOut->addHTML("<textarea tabindex=6 id='wpTextbox2' name=\"wpTextbox2\" rows='{$rows}' cols='{$cols}' wrap='virtual'>" . htmlspecialchars($this->safeUnicodeOutput($this->textbox2)) . "\n</textarea>");
        }
        $wgOut->addHTML($this->editFormTextBottom);
        $wgOut->addHTML("</form>\n");
        if (!$wgUser->getOption('previewontop')) {
            if ($this->formtype == 'preview') {
                $this->showPreview($previewOutput);
            } else {
                $wgOut->addHTML('<div id="wikiPreview"></div>');
            }
            if ($this->formtype == 'diff') {
                $this->showDiff();
            }
        }
        $wgOut->addHTML($closeFormHtml);
        wfProfileOut($fname);
    }
Beispiel #6
0
    /**
     * 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)
    {
        global $wgOut, $wgUser, $wgTitle;
        # If $wgTitle is null, that means we're in API mode.
        # Some hook probably called this function  without checking
        # for is_null($wgTitle) first. Bail out right here so we don't
        # do lots of work just to discard it right after.
        if (is_null($wgTitle)) {
            return;
        }
        wfProfileIn(__METHOD__);
        $sk = $wgUser->getSkin();
        #need to parse the preview early so that we know which templates are used,
        #otherwise users with "show preview after edit box" will get a blank list
        #we parse this near the beginning so that setHeaders can do the title
        #setting work instead of leaving it in getPreviewText
        $previewOutput = '';
        if ($this->formtype == 'preview') {
            $previewOutput = $this->getPreviewText();
        }
        wfRunHooks('EditPage::showEditForm:initial', array(&$this));
        $this->setHeaders();
        # Enabled article-related sidebar, toplinks, etc.
        $wgOut->setArticleRelated(true);
        if ($this->showHeader() === false) {
            return;
        }
        $action = htmlspecialchars($this->getActionURL($wgTitle));
        if ($wgUser->getOption('showtoolbar') and !$this->isCssJsSubpage) {
            # prepare toolbar for edit buttons
            $toolbar = EditPage::getEditToolbar();
        } else {
            $toolbar = '';
        }
        $wgOut->addHTML($this->editFormPageTop);
        if ($wgUser->getOption('previewontop')) {
            $this->displayPreviewArea($previewOutput, true);
        }
        $wgOut->addHTML($this->editFormTextTop);
        $templates = $this->getTemplates();
        $formattedtemplates = $sk->formatTemplates($templates, $this->preview, $this->section != '');
        $hiddencats = $this->mArticle->getHiddenCategories();
        $formattedhiddencats = $sk->formatHiddenCategories($hiddencats);
        if ($this->wasDeletedSinceLastEdit() && 'save' != $this->formtype) {
            $wgOut->wrapWikiMsg("<div class='error mw-deleted-while-editing'>\n\$1</div>", 'deletedwhileediting');
        } elseif ($this->wasDeletedSinceLastEdit()) {
            // Hide the toolbar and edit area, user can click preview to get it back
            // Add an confirmation checkbox and explanation.
            $toolbar = '';
            // @todo move this to a cleaner conditional instead of blanking a variable
        }
        $wgOut->addHTML(<<<HTML
{$toolbar}
<form id="editform" name="editform" method="post" action="{$action}" enctype="multipart/form-data">
HTML
);
        if (is_callable($formCallback)) {
            call_user_func_array($formCallback, array(&$wgOut));
        }
        wfRunHooks('EditPage::showEditForm:fields', array(&$this, &$wgOut));
        // Put these up at the top to ensure they aren't lost on early form submission
        $this->showFormBeforeText();
        if ($this->wasDeletedSinceLastEdit() && 'save' == $this->formtype) {
            $wgOut->addHTML('<div class="mw-confirm-recreate">' . $wgOut->parse(wfMsg('confirmrecreate', $this->lastDelete->user_name, $this->lastDelete->log_comment)) . Xml::checkLabel(wfMsg('recreate'), 'wpRecreate', 'wpRecreate', false, array('title' => $sk->titleAttrib('recreate'), 'tabindex' => 1, 'id' => 'wpRecreate')) . '</div>');
        }
        # If a blank edit summary was previously provided, and the appropriate
        # user preference is active, pass a hidden tag as wpIgnoreBlankSummary. This will stop the
        # user being bounced back more than once in the event that a summary
        # is not required.
        #####
        # For a bit more sophisticated detection of blank summaries, hash the
        # automatic one and pass that in the hidden field wpAutoSummary.
        if ($this->missingSummary || $this->section == 'new' && $this->nosummary) {
            $wgOut->addHTML(Xml::hidden('wpIgnoreBlankSummary', true));
        }
        $autosumm = $this->autoSumm ? $this->autoSumm : md5($this->summary);
        $wgOut->addHTML(Xml::hidden('wpAutoSummary', $autosumm));
        $wgOut->addHTML(Xml::hidden('oldid', $this->mArticle->getOldID()));
        if ($this->section == 'new') {
            $this->showSummaryInput(true, $this->summary);
            $wgOut->addHTML($this->getSummaryPreview(true, $this->summary));
        }
        $wgOut->addHTML($this->editFormTextBeforeContent);
        if ($this->isConflict) {
            // In an edit conflict bypass the overrideable content form method
            // and fallback to the raw wpTextbox1 since editconflicts can't be
            // resolved between page source edits and custom ui edits using the
            // custom edit ui.
            $this->showTextbox1(null, $this->getContent());
        } else {
            $this->showContentForm();
        }
        $wgOut->addHTML($this->editFormTextAfterContent);
        $wgOut->addWikiText($this->getCopywarn());
        if (isset($this->editFormTextAfterWarn) && $this->editFormTextAfterWarn !== '') {
            $wgOut->addHTML($this->editFormTextAfterWarn);
        }
        $this->showStandardInputs();
        $this->showFormAfterText();
        $this->showTosSummary();
        $this->showEditTools();
        $wgOut->addHTML(<<<HTML
{$this->editFormTextAfterTools}
<div class='templatesUsed'>
{$formattedtemplates}
</div>
<div class='hiddencats'>
{$formattedhiddencats}
</div>
HTML
);
        if ($this->isConflict) {
            $this->showConflict();
        }
        $wgOut->addHTML($this->editFormTextBottom);
        $wgOut->addHTML("</form>\n");
        if (!$wgUser->getOption('previewontop')) {
            $this->displayPreviewArea($previewOutput, false);
        }
        wfProfileOut(__METHOD__);
    }
function GetWiki_ToolBar()
{
    global $wgVersion;
    /*
            if ( !file_exists($IP . '/includes/AutoLoader.php')){
                require_once($IP . '/includes/EditPage.php');
            }
    */
    if (version_compare($wgVersion, '1.13.0', '>=')) {
        global $wgOut;
        $wgOut->addScriptFile('edit.js');
    }
    $toolbar = EditPage::getEditToolbar();
    return $toolbar;
}