Esempio n. 1
0
    /**
     * The edit form is self-submitting, so that when things like
     * preview and edit conflicts occur, we get the same form back
     * with the extra stuff added.  Only when the final submission
     * is made and all is well do we actually save and redirect to
     * the newly-edited page.
     *
     * @param string $formtype Type of form either : save, initial, diff or preview
     * @param bool $firsttime True to load form data from db
     */
    function editForm($formtype, $firsttime = false)
    {
        global $wgOut, $wgUser;
        global $wgLang, $wgContLang, $wgParser, $wgTitle;
        global $wgAllowAnonymousMinor, $wgRequest;
        global $wgSpamRegex, $wgFilterCallback;
        $sk = $wgUser->getSkin();
        $isConflict = false;
        // css / js subpages of user pages get a special treatment
        $isCssJsSubpage = $wgTitle->isCssJsSubpage();
        if (!$this->mTitle->getArticleID()) {
            # new article
            $editintro = $wgRequest->getText('editintro');
            $addstandardintro = true;
            if ($editintro) {
                $introtitle = Title::newFromText($editintro);
                if (isset($introtitle) && $introtitle->userCanRead()) {
                    $rev = Revision::newFromTitle($introtitle);
                    if ($rev) {
                        $wgOut->addWikiText($rev->getText());
                        $addstandardintro = false;
                    }
                }
            }
            if ($addstandardintro) {
                $wgOut->addWikiText(wfmsg('newarticletext'));
            }
        }
        if ($this->mTitle->isTalkPage()) {
            $wgOut->addWikiText(wfmsg('talkpagetext'));
        }
        # Attempt submission here.  This will check for edit conflicts,
        # and redundantly check for locked database, blocked IPs, etc.
        # that edit() already checked just in case someone tries to sneak
        # in the back door with a hand-edited submission URL.
        if ('save' == $formtype) {
            # Reintegrate metadata
            if ($this->mMetaData != '') {
                $this->textbox1 .= "\n" . $this->mMetaData;
            }
            $this->mMetaData = '';
            # Check for spam
            if ($wgSpamRegex && preg_match($wgSpamRegex, $this->textbox1, $matches)) {
                $this->spamPage($matches[0]);
                return;
            }
            if ($wgFilterCallback && $wgFilterCallback($this->mTitle, $this->textbox1, $this->section)) {
                # Error messages or other handling should be performed by the filter function
                return;
            }
            if ($wgUser->isBlockedFrom($this->mTitle, false)) {
                # Check block state against master, thus 'false'.
                $this->blockedIPpage();
                return;
            }
            if (!$wgUser->isAllowed('edit')) {
                if ($wgUser->isAnon()) {
                    $this->userNotLoggedInPage();
                    return;
                } else {
                    $wgOut->readOnlyPage();
                    return;
                }
            }
            if (wfReadOnly()) {
                $wgOut->readOnlyPage();
                return;
            }
            if ($wgUser->pingLimiter()) {
                $wgOut->rateLimited();
                return;
            }
            # If article is new, insert it.
            $aid = $this->mTitle->getArticleID(GAID_FOR_UPDATE);
            if (0 == $aid) {
                # Don't save a new article if it's blank.
                if ('' == $this->textbox1 || wfMsg('newarticletext') == $this->textbox1) {
                    $wgOut->redirect($this->mTitle->getFullURL());
                    return;
                }
                if (wfRunHooks('ArticleSave', array(&$this->mArticle, &$wgUser, &$this->textbox1, &$this->summary, &$this->minoredit, &$this->watchthis, NULL))) {
                    $isComment = $this->section == 'new';
                    $this->mArticle->insertNewArticle($this->textbox1, $this->summary, $this->minoredit, $this->watchthis, false, $isComment);
                    wfRunHooks('ArticleSaveComplete', array(&$this->mArticle, &$wgUser, $this->textbox1, $this->summary, $this->minoredit, $this->watchthis, NULL));
                }
                return;
            }
            # Article exists. Check for edit conflict.
            $this->mArticle->clear();
            # Force reload of dates, etc.
            $this->mArticle->forUpdate(true);
            # Lock the article
            if ($this->section != 'new' && $this->mArticle->getTimestamp() != $this->edittime) {
                $isConflict = true;
            }
            $userid = $wgUser->getID();
            if ($isConflict) {
                wfDebug("EditPage::editForm conflict! getting section '{$this->section}' for time '{$this->edittime}' (article time '" . $this->mArticle->getTimestamp() . "'\n");
                $text = $this->mArticle->getTextOfLastEditWithSectionReplacedOrAdded($this->section, $this->textbox1, $this->summary, $this->edittime);
            } else {
                wfDebug("EditPage::editForm getting section '{$this->section}'\n");
                $text = $this->mArticle->getTextOfLastEditWithSectionReplacedOrAdded($this->section, $this->textbox1, $this->summary);
            }
            # Suppress edit conflict with self
            if (0 != $userid && $this->mArticle->getUser() == $userid) {
                wfDebug("Suppressing edit conflict, same user.\n");
                $isConflict = false;
            } else {
                # switch from section editing to normal editing in edit conflict
                if ($isConflict) {
                    # Attempt merge
                    if ($this->mergeChangesInto($text)) {
                        // Successful merge! Maybe we should tell the user the good news?
                        $isConflict = false;
                        wfDebug("Suppressing edit conflict, successful merge.\n");
                    } else {
                        $this->section = '';
                        $this->textbox1 = $text;
                        wfDebug("Keeping edit conflict, failed merge.\n");
                    }
                }
            }
            if (!$isConflict) {
                # All's well
                $sectionanchor = '';
                if ($this->section == 'new') {
                    if ($this->summary != '') {
                        $sectionanchor = $this->sectionAnchor($this->summary);
                    }
                } elseif ($this->section != '') {
                    # Try to get a section anchor from the section source, redirect to edited section if header found
                    # XXX: might be better to integrate this into Article::getTextOfLastEditWithSectionReplacedOrAdded
                    # for duplicate heading checking and maybe parsing
                    $hasmatch = preg_match("/^ *([=]{1,6})(.*?)(\\1) *\\n/i", $this->textbox1, $matches);
                    # we can't deal with anchors, includes, html etc in the header for now,
                    # headline would need to be parsed to improve this
                    #if($hasmatch and strlen($matches[2]) > 0 and !preg_match( "/[\\['{<>]/", $matches[2])) {
                    if ($hasmatch and strlen($matches[2]) > 0) {
                        $sectionanchor = $this->sectionAnchor($matches[2]);
                    }
                }
                // Save errors may fall down to the edit form, but we've now
                // merged the section into full text. Clear the section field
                // so that later submission of conflict forms won't try to
                // replace that into a duplicated mess.
                $this->textbox1 = $text;
                $this->section = '';
                if (wfRunHooks('ArticleSave', array(&$this->mArticle, &$wgUser, &$text, &$this->summary, &$this->minoredit, &$this->watchthis, &$sectionanchor))) {
                    # update the article here
                    if ($this->mArticle->updateArticle($text, $this->summary, $this->minoredit, $this->watchthis, '', $sectionanchor)) {
                        wfRunHooks('ArticleSaveComplete', array(&$this->mArticle, &$wgUser, $text, $this->summary, $this->minoredit, $this->watchthis, $sectionanchor));
                        return;
                    } else {
                        $isConflict = true;
                    }
                }
            }
        }
        # First time through: get contents, set time for conflict
        # checking, etc.
        if ('initial' == $formtype || $firsttime) {
            $this->edittime = $this->mArticle->getTimestamp();
            $this->textbox1 = $this->mArticle->getContent(true);
            $this->summary = '';
            $this->proxyCheck();
        }
        $wgOut->setRobotpolicy('noindex,nofollow');
        # Enabled article-related sidebar, toplinks, etc.
        $wgOut->setArticleRelated(true);
        if ($isConflict) {
            $s = wfMsg('editconflict', $this->mTitle->getPrefixedText());
            $wgOut->setPageTitle($s);
            $wgOut->addWikiText(wfMsg('explainconflict'));
            $this->textbox2 = $this->textbox1;
            $this->textbox1 = $this->mArticle->getContent(true);
            $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());
                    if (!$this->preview && !$this->diff) {
                        preg_match("/^(=+)(.+)\\1/mi", $this->textbox1, $matches);
                        if (!empty($matches[2])) {
                            $this->summary = "/* " . trim($matches[2]) . " */ ";
                        }
                    }
                }
            } else {
                $s = wfMsg('editing', $this->mTitle->getPrefixedText());
            }
            $wgOut->setPageTitle($s);
            if (!$this->checkUnicodeCompliantBrowser()) {
                $this->mArticle->setOldSubtitle();
                $wgOut->addWikiText(wfMsg('nonunicodebrowser'));
            }
            if (isset($this->mArticle) && isset($this->mArticle->mRevision) && !$this->mArticle->mRevision->isCurrent()) {
                $this->mArticle->setOldSubtitle();
                $wgOut->addWikiText(wfMsg('editingold'));
            }
        }
        if (wfReadOnly()) {
            $wgOut->addWikiText(wfMsg('readonlywarning'));
        } else {
            if ($isCssJsSubpage and 'preview' != $formtype) {
                $wgOut->addWikiText(wfMsg('usercssjsyoucanpreview'));
            }
        }
        if ($this->mTitle->isProtected('edit')) {
            $wgOut->addWikiText(wfMsg('protectedpagewarning'));
        }
        $kblength = (int) (strlen($this->textbox1) / 1024);
        if ($kblength > 29) {
            $wgOut->addWikiText(wfMsg('longpagewarning', $wgLang->formatNum($kblength)));
        }
        $rows = $wgUser->getOption('rows');
        $cols = $wgUser->getOption('cols');
        $ew = $wgUser->getOption('editwidth');
        if ($ew) {
            $ew = " style=\"width:100%\"";
        } else {
            $ew = '';
        }
        $q = 'action=submit';
        #if ( "no" == $redirect ) { $q .= "&redirect=no"; }
        $action = $this->mTitle->escapeLocalURL($q);
        $summary = wfMsg('summary');
        $subject = wfMsg('subject');
        $minor = wfMsg('minoredit');
        $watchthis = wfMsg('watchthis');
        $save = wfMsg('savearticle');
        $prev = wfMsg('showpreview');
        $diff = wfMsg('showdiff');
        $cancel = $sk->makeKnownLink($this->mTitle->getPrefixedText(), wfMsg('cancel'));
        $edithelpurl = $sk->makeInternalOrExternalUrl(wfMsg('edithelppage'));
        $edithelp = '<a target="helpwindow" href="' . $edithelpurl . '">' . htmlspecialchars(wfMsg('edithelp')) . '</a> ' . htmlspecialchars(wfMsg('newwindow'));
        global $wgRightsText;
        $copywarn = "<div id=\"editpage-copywarn\">\n" . wfMsg($wgRightsText ? 'copyrightwarning' : 'copyrightwarning2', '[[' . wfMsgForContent('copyrightpage') . ']]', $wgRightsText) . "\n</div>";
        # Patch for FCKeditor
        global $wgUseEditor, $wgEditorToken;
        if ($wgUseEditor || isset($wgEditorToken) && eregi($wgEditorToken, $this->textbox1, $eregi_result)) {
            $toolbar = '';
        } elseif ($wgUser->getOption('showtoolbar') and !$isCssJsSubpage) {
            # prepare toolbar for edit buttons
            $toolbar = $this->getEditToolbar();
        } else {
            $toolbar = '';
        }
        // activate checkboxes if user wants them to be always active
        if (!$this->preview && !$this->diff) {
            if ($wgUser->getOption('watchdefault')) {
                $this->watchthis = true;
            }
            if ($wgUser->getOption('minordefault')) {
                $this->minoredit = true;
            }
            // activate checkbox also if user is already watching the page,
            // require wpWatchthis to be unset so that second condition is not
            // checked unnecessarily
            if (!$this->watchthis && $this->mTitle->userIsWatching()) {
                $this->watchthis = true;
            }
        }
        $minoredithtml = '';
        if ($wgUser->isLoggedIn() || $wgAllowAnonymousMinor) {
            $minoredithtml = "<input tabindex='3' type='checkbox' value='1' name='wpMinoredit'" . ($this->minoredit ? " checked='checked'" : "") . " accesskey='" . wfMsg('accesskey-minoredit') . "' id='wpMinoredit' />" . "<label for='wpMinoredit' title='" . wfMsg('tooltip-minoredit') . "'>{$minor}</label>";
        }
        $watchhtml = '';
        if ($wgUser->isLoggedIn()) {
            $watchhtml = "<input tabindex='4' type='checkbox' name='wpWatchthis'" . ($this->watchthis ? " checked='checked'" : "") . " accesskey='" . wfMsg('accesskey-watch') . "' id='wpWatchthis'  />" . "<label for='wpWatchthis' title='" . wfMsg('tooltip-watch') . "'>{$watchthis}</label>";
        }
        $checkboxhtml = $minoredithtml . $watchhtml . '<br />';
        $wgOut->addHTML('<div id="wikiPreview">');
        if ('preview' == $formtype) {
            $previewOutput = $this->getPreviewText($isConflict, $isCssJsSubpage);
            if ($wgUser->getOption('previewontop')) {
                $wgOut->addHTML($previewOutput);
                if ($this->mTitle->getNamespace() == NS_CATEGORY) {
                    $this->mArticle->closeShowCategory();
                }
                $wgOut->addHTML("<br style=\"clear:both;\" />\n");
            }
        }
        $wgOut->addHTML('</div>');
        if ('diff' == $formtype) {
            if ($wgUser->getOption('previewontop')) {
                $wgOut->addHTML($this->getDiff());
            }
        }
        # 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 = "{$subject}: <input tabindex='1' type='text' value=\"{$summarytext}\" name=\"wpSummary\" maxlength='200' size='60' /><br />";
            $editsummary = '';
        } else {
            $commentsubject = '';
            $editsummary = "{$summary}: <input tabindex='2' type='text' value=\"{$summarytext}\" name=\"wpSummary\" maxlength='200' size='60' /><br />";
        }
        if (!$this->preview && !$this->diff) {
            # Don't select the edit box on preview; this interferes with seeing what's going on.
            $wgOut->setOnloadHandler('document.editform.wpTextbox1.focus()');
        }
        # Prepare a list of templates used by this page
        $templates = '';
        $articleTemplates = $this->mArticle->getUsedTemplates();
        if (count($articleTemplates) > 0) {
            $templates = '<br />' . wfMsg('templatesused') . '<ul>';
            foreach ($articleTemplates as $tpl) {
                if ($titleObj = Title::makeTitle(NS_TEMPLATE, $tpl)) {
                    $templates .= '<li>' . $sk->makeLinkObj($titleObj) . '</li>';
                }
            }
            $templates .= '</ul>';
        }
        global $wgLivePreview, $wgStylePath;
        /**
         * Live Preview lets us fetch rendered preview page content and
         * add it to the page without refreshing the whole page.
         * Set up the button for it; if not supported by the browser
         * it will fall through to the normal form submission method.
         */
        if ($wgLivePreview) {
            global $wgJsMimeType;
            $wgOut->addHTML('<script type="' . $wgJsMimeType . '" src="' . htmlspecialchars($wgStylePath . '/common/preview.js') . '"></script>' . "\n");
            $liveAction = $wgTitle->getLocalUrl('action=submit&wpPreview=true&live=true');
            $liveOnclick = 'onclick="return !livePreview(' . 'getElementById(\'wikiPreview\'),' . 'editform.wpTextbox1.value,' . htmlspecialchars('"' . $liveAction . '"') . ')"';
        } else {
            $liveOnclick = '';
        }
        global $wgUseMetadataEdit;
        if ($wgUseMetadataEdit) {
            $metadata = $this->mMetaData;
            $metadata = htmlspecialchars($wgContLang->recodeForEdit($metadata));
            $helppage = Title::newFromText(wfmsg("metadata_page"));
            $top = str_replace("\$1", $helppage->getInternalURL(), wfmsg("metadata"));
            $metadata = $top . "<textarea name='metadata' rows='3' cols='{$cols}'{$ew}>{$metadata}</textarea>";
        } else {
            $metadata = "";
        }
        $safemodehtml = $this->checkUnicodeCompliantBrowser() ? "" : "<input type='hidden' name=\"safemode\" value='1' />\n";
        # Patch for FCKeditor
        global $wgUseEditor, $wgEditorDir, $wgEditorToken, $wgScriptPath, $wgEditorToolbarSet, $wgEditorHeight;
        $tbox = $wgContLang->recodeForEdit($this->textbox1);
        if ($wgUseEditor || isset($wgEditorToken) && eregi($wgEditorToken, $tbox, $eregi_result)) {
            $wgUseEditor = true;
            $wgOut->addHTML("\n{$toolbar}\n<form id=\"editform\" name=\"editform\" method=\"post\" action=\"{$action}\"\nenctype=\"multipart/form-data\">\n{$commentsubject}");
            require_once "{$wgEditorDir}/fckeditor.php";
            $oFCKeditor = new FCKeditor('wpTextbox1');
            $oFCKeditor->BasePath = $wgScriptPath . "/" . $wgEditorDir . "/";
            $oFCKeditor->Value = $tbox;
            $oFCKeditor->ToolbarSet = $wgEditorToolbarSet;
            $oFCKeditor->Height = $wgEditorHeight;
            $oFCKeditor->Width = '100%';
            $wgOut->addHTML($oFCKeditor->CreateHtml());
            /*
            <textarea tabindex='1' accesskey="," name="wpTextbox1" rows='{$rows}'
            cols='{$cols}'{$ew}>
            END
            . htmlspecialchars( $wgContLang->recodeForEdit( $this->textbox1 ) ) .
            "
            </textarea>
            */
            $wgOut->addHTML("\n{$metadata}\n<br />{$editsummary}\n{$checkboxhtml}\n{$safemodehtml}\n<input tabindex='5' id='wpSave' type='submit' value=\"{$save}\" name=\"wpSave\" accesskey=\"" . wfMsg('accesskey-save') . "\"" . " title=\"" . wfMsg('tooltip-save') . "\"/>\n<input tabindex='6' id='wpPreview' type='submit' {$liveOnclick} value=\"{$prev}\" name=\"wpPreview\" accesskey=\"" . wfMsg('accesskey-preview') . "\"" . " title=\"" . wfMsg('tooltip-preview') . "\"/>\n<input tabindex='7' id='wpDiff' type='submit' value=\"{$diff}\" name=\"wpDiff\" accesskey=\"" . wfMsg('accesskey-diff') . "\"" . " title=\"" . wfMsg('tooltip-diff') . "\"/>\n<em>{$cancel}</em> | <em>{$edithelp}</em>{$templates}");
        } else {
            # end patch
            $wgOut->addHTML(<<<END
{$toolbar}
<form id="editform" name="editform" method="post" action="{$action}"
enctype="multipart/form-data">
{$commentsubject}
<textarea tabindex='1' accesskey="," name="wpTextbox1" rows='{$rows}'
cols='{$cols}'{$ew}>
END
 . htmlspecialchars($this->safeUnicodeOutput($this->textbox1)) . "\n</textarea>\n{$metadata}\n<br />{$editsummary}\n{$checkboxhtml}\n{$safemodehtml}\n<input tabindex='5' id='wpSave' type='submit' value=\"{$save}\" name=\"wpSave\" accesskey=\"" . wfMsg('accesskey-save') . "\"" . " title=\"" . wfMsg('tooltip-save') . "\"/>\n<input tabindex='6' id='wpPreview' type='submit' {$liveOnclick} value=\"{$prev}\" name=\"wpPreview\" accesskey=\"" . wfMsg('accesskey-preview') . "\"" . " title=\"" . wfMsg('tooltip-preview') . "\"/>\n<input tabindex='7' id='wpDiff' type='submit' value=\"{$diff}\" name=\"wpDiff\" accesskey=\"" . wfMsg('accesskey-diff') . "\"" . " title=\"" . wfMsg('tooltip-diff') . "\"/>\n<em>{$cancel}</em> | <em>{$edithelp}</em>{$templates}");
        }
        $wgOut->addWikiText($copywarn);
        $wgOut->addHTML("\n<input type='hidden' value=\"" . htmlspecialchars($this->section) . "\" name=\"wpSection\" />\n<input type='hidden' value=\"{$this->edittime}\" name=\"wpEdittime\" />\n");
        if ($wgUser->isLoggedIn()) {
            /**
             * 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.
             */
            $token = htmlspecialchars($wgUser->editToken());
            $wgOut->addHTML("\n<input type='hidden' value=\"{$token}\" name=\"wpEditToken\" />\n");
        }
        if ($isConflict) {
            require_once "DifferenceEngine.php";
            $wgOut->addWikiText('==' . wfMsg("yourdiff") . '==');
            DifferenceEngine::showDiff($this->textbox2, $this->textbox1, 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("</form>\n");
        if ($formtype == 'preview' && !$wgUser->getOption('previewontop')) {
            $wgOut->addHTML('<div id="wikiPreview">' . $previewOutput . '</div>');
        }
        if ($formtype == 'diff' && !$wgUser->getOption('previewontop')) {
            #$wgOut->addHTML( '<div id="wikiPreview">' . $difftext . '</div>' );
            $wgOut->addHTML($this->getDiff());
        }
    }
Esempio n. 2
0
 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'));
         $action = str_replace("&title=" . $main, "", $action);
     }
     $summary = wfMsg("summary");
     $subject = wfMsg("subject");
     $minor = wfMsg("minoredit");
     $watchthis = wfMsg("watchthis");
     $save = wfMsg("savearticle");
     $prev = wfMsg("showpreview");
     $cancel = $sk->makeKnownLink($this->mTitle->getPrefixedText(), wfMsg("cancel"));
     $edithelpurl = Skin::makeInternalOrExternalUrl(wfMsgForContent('edithelppage'));
     $edithelp = '<a target="helpwindow" href="' . $edithelpurl . '">' . htmlspecialchars(wfMsg('edithelp')) . '</a> ' . htmlspecialchars(wfMsg('newwindow'));
     $copywarn = wfMsg("copyrightwarning", $sk->makeKnownLink(wfMsg("copyrightpage")));
     $minoredithtml = '';
     if ($wgUser->isAllowed('minoredit')) {
         $minoredithtml = "<input tabindex='11' type='checkbox' value='1' name='wpMinoredit'" . ($this->minoredit ? " checked='checked'" : "") . " accesskey='" . wfMsg('accesskey-minoredit') . "' id='wpMinoredit' />\n" . "<label for='wpMinoredit' title='" . wfMsg('tooltip-minoredit') . "'>{$minor}</label>\n";
     }
     $watchhtml = '';
     if ($wgUser->isLoggedIn()) {
         $watchhtml = "<input tabindex='12' type='checkbox' name='wpWatchthis'" . ($this->watchthis ? " checked='checked'" : "") . " accesskey=\"" . htmlspecialchars(wfMsg('accesskey-watch')) . "\" id='wpWatchthis'  />\n" . "<label for='wpWatchthis' title=\"" . htmlspecialchars(wfMsg('tooltip-watch')) . "\">{$watchthis}</label>\n";
     }
     $checkboxhtml = $minoredithtml . $watchhtml;
     $tabindex = 14;
     $buttons = $this->getEditButtons($tabindex);
     $footerbuttons = "";
     $buttons['preview'] = "<span id='gatGuidedPreview'>{$buttons['preview']}</span>";
     if ($wgUser->getOption('hidepersistantsavebar', 0) == 0) {
         $footerbuttons .= "<span id='gatPSBSave'>{$buttons['save']}</span>";
         $footerbuttons .= "<span id='gatPSBPreview'>{$buttons['preview']}</span>";
     }
     $saveBtn = str_replace('accesskey="s"', "", $buttons['save']);
     $buttons['save'] = "<span id='gatGuidedSave'>{$saveBtn}</span>";
     $buttonshtml = implode($buttons, "\n");
     # 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($wgLang->recodeForEdit($this->summary));
     # FIXME
     $editsummary1 = "";
     if ($wgRequest->getVal('suggestion')) {
         $summarytext .= ($summarytext == "" ? "" : ", ") . wfMsg('suggestion_edit_summary');
     }
     if ($this->section == "new") {
         $commentsubject = "{$subject}: <input tabindex='1' type='text' value=\"{$summarytext}\" name=\"wpSummary\" id='wpSummary' maxlength='200' size='60' />";
         $editsummary = "";
     } else {
         $commentsubject = "";
         if ($wgTitle->getArticleID() == 0 && $wgTitle->getNamespace() == NS_MAIN && $summarytext == "") {
             $summarytext = wfMsg('creating_new_article');
         }
         $editsummary = "<input tabindex='10' type='text' value=\"{$summarytext}\" name=\"wpSummary\" id='wpSummary' maxlength='200' size='60' /><br />";
         $editsummary1 = "<input tabindex='10' type='text' value=\"{$summarytext}\" name=\"wpSummary1\" id='wpSummary1' maxlength='200' size='60' /><br />";
     }
     // create the wikiHow
     if ($conflictWikiHow == null) {
         if ($this->textbox1 != "") {
             $whow = WikihowArticleEditor::newFromText($this->textbox1);
         } else {
             $whow = WikihowArticleEditor::newFromArticle($this->mArticle);
         }
     } else {
         $whow = $conflictWikiHow;
     }
     //********** SETTING UP THE FORM
     //
     //
     //
     //
     $confirm = "window.onbeforeunload = confirmExit;";
     if ($wgUser->getOption('disablewarning') == '1') {
         $confirm = "";
     }
     $wgOut->addHTML("<script language=\"JavaScript\">\n\t\t\t\tvar isGuided = true;\n\t\t\t\tvar needToConfirm = false;\n\t\t\t\tvar checkMinLength = true;\n\t\t\t\t{$confirm}\n\t\t\t\tfunction confirmExit() {\n\t\t\t\t\tif (needToConfirm)\n\t\t\t\t\t\treturn \"" . wfMsg('all-changes-lost') . "\";\n\t\t\t\t}\n\t\t\t\tfunction addrows(element) {\n\t\t\t\t\tif (element.rows < 32)  {\n\t\t\t\t\t\telement.rows += 4;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfunction removerows(element) {\n\t\t\t\t\tif (element.rows > 4)  {\n\t\t\t\t\t\telement.rows -= 4;\n\t\t\t\t\t} else {\n\t\t\t\t\t\telement.rows = 4;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfunction saveandpublish() {\n\t\t\t\t\twindow.onbeforeunload = null;\n\t\t\t\t\tdocument.editform.submit();\n\t\t\t\t}\n\t\t\t\t(function (\$) {\n\t\t\t\t\t\$(document).ready(function() {\n\t\t\t\t\t\t\$('.button').click(function () {\n\t\t\t\t\t\t\tvar button = \$(this).not('.submit_button');\n\t\t\t\t\t\t\tif (button.length) {\n\t\t\t\t\t\t\t\tneedToConfirm = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\$('textarea').focus(function () {\n\t\t\t\t\t\t\tneedToConfirm = true;\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t\t\$('#ep_cat').live('click', function(e) {\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\tvar title = 'Categorize ' + wgTitle;\n\t\t\t\t\t\tif (title.length > 54) {\n\t\t\t\t\t\t\ttitle = title.substr(0, 54) + '...';\n\t\t\t\t\t\t}\n\t\t\t\t\t\tjQuery('#dialog-box').html('');\n\t\t\t\t\t\t\n\t\t\t\t\t\tjQuery('#dialog-box').load('/Special:Categorizer?a=editpage&id=' + wgArticleId, function() {\n\t\t\t\t\t\t\tjQuery('#dialog-box').dialog({\n\t\t\t\t\t\t\t\twidth: 673,\n\t\t\t\t\t\t\t\theight: 600,\n\t\t\t\t\t\t\t\tmodal: true,\n\t\t\t\t\t\t\t\ttitle: title,\n\t\t\t\t\t\t\t\tcloseText: 'Close',\t\n\t\t\t\t\t\t\t\tdialogClass: 'modal2',\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\treCenter = function() {\n\t\t\t\t\t\t\t\tjQuery('#dialog-box').dialog('option', 'position', 'center');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsetTimeout('reCenter()', 100);\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\$.getScript('/extensions/wikihow/cattool/categorizer.js');\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t})(jQuery);\n\t\t\t</script>\n\t\t\t<script type=\"text/javascript\" src=\"" . wfGetPad('/extensions/min/f/skins/common/clientscript.js,/skins/common/ac.js,/extensions/wikihow/video/importvideo.js&rev=') . WH_SITEREV . "\"></script>\n\n\t\t");
     if (!$this->preview) {
         # Don't select the edit box on preview; this interferes with seeing what's going on.
         $wgOut->setOnloadHandler("document.editform.title.focus(); load_cats();");
     }
     $title = "";
     //$wgOut->setOnloadHandler( "' onbeforeunload='return confirm(\"Are you sure you want to navigate away from this page? All changes will be lost!\");" );
     $suggested_title = "";
     if (isset($_GET["requested"])) {
         $t = Title::makeTitle(NS_MAIN, $_GET["requested"]);
         $suggested_title = $t->getText();
     }
     if ($wgRequest->getVal('title', null) == null || $conflictTitle || $suggested_title != "") {
         $title = "<div id='title'><h3>" . wfMsg('title') . "</h3><br/>" . wfMsg('howto', '') . " &nbsp;&nbsp;&nbsp;\n\t\t\t<input autocomplete=\"off\" size=60 type=\"text\" name=\"title\" id=category tabindex=\"1\" value=\"{$suggested_title}\"></div>";
     }
     $steps = htmlspecialchars($wgLang->recodeForEdit($whow->getSteps(true)), ENT_QUOTES);
     $video = htmlspecialchars($wgLang->recodeForEdit($whow->getSection(wfMsg('video'))));
     $tips = htmlspecialchars($wgLang->recodeForEdit($whow->getSection(wfMsg('tips'))));
     $warns = htmlspecialchars($wgLang->recodeForEdit($whow->getSection(wfMsg('warnings'))));
     $related_text = htmlspecialchars($wgLang->recodeForEdit($whow->getSection(wfMsg('relatedwikihows'))));
     $summary = htmlspecialchars($wgLang->recodeForEdit($whow->getSummary()));
     if ($newArticle || $whow->mIsNew) {
         if ($steps == "") {
             $steps = "#  ";
         }
         if ($tips == "") {
             $tips = "*  ";
         }
         if ($warns == "") {
             $warns = "*  ";
         }
         if ($ingredients == "") {
             $ingredients = "*  ";
         }
     }
     $cat = $whow->getCategoryString();
     $advanced = "";
     $cat_array = explode("|", $whow->getCategoryString());
     $i = 0;
     $cat_string = "";
     foreach ($cat_array as $cat) {
         if ($cat == "") {
             continue;
         }
         if ($i != 0) {
             $cat_string .= "," . $cat;
         } else {
             $cat_string = $cat;
         }
         $i++;
     }
     $removeButton = "";
     $cat_advisory = "";
     if ($cat_string != "") {
         $removeButton = "<input type=\"button\" name=\"change_cats\" onclick=\"removeCategories();\" value=\"" . wfMsg('remove-categories') . "\">";
     } else {
         $cat_advisory = wfMsg('categorization-optional');
     }
     //$cat_string = str_replace("|", ", ", $whow->getCategoryString());
     //$cat_string = implode(", ", $raa);
     if (!$newArticle && !$whow->mIsNew && !$conflictTitle) {
         $oldparameters = "";
         if ($wgRequest->getVal("oldid") != "") {
             $oldparameters = "&oldid=" . $wgRequest->getVal("oldid");
         }
         if (!$this->preview) {
             $advanced = "<a class='' href='{$wgScript}?title=" . $wgTitle->getPrefixedURL() . "&action=edit&advanced=true{$oldparameters}'>" . wfMsg('advanced-editing') . "</a>";
         }
     } elseif ($newArticle && $wgRequest->getVal('title', null) != null) {
         $t = Title::newFromText("CreatePage", NS_SPECIAL);
         //$advanced = str_replace("href=", "class='guided-button' href=", $sk->makeLinkObj($t, wfMsg('advanced-editing'))) . " |";
         //$advanced = "<a href='{$wgScript}?title=" . $wgTitle->getPrefixedURL() . "&action=edit&advanced=true$oldparameters';\">".wfMsg('advanced-editing')."</a>";
         $advanced = "<a class='button secondary' style='float:left;' href='{$wgScript}?title=" . $wgTitle->getPrefixedURL() . "&action=edit&advanced=true{$oldparameters}'>" . wfMsg('advanced-editing') . "</a>";
     }
     $section_class = 'minor_section';
     // MODIFIED FOR POPUP
     $categoryHTML = "";
     if ($wgUser->getID() > 0) {
         $ctitle = $this->mTitle->getText();
         $css = HtmlSnips::makeUrlTags('css', array('categoriespopup.css'), 'extensions/wikihow', false);
         if ($wgLanguageCode == 'en') {
             $editCatMore = "<a href=\"{$wgScriptPath}/Writer%27s-Guide?section=2#" . wfMsg('more-info-categorization') . "\" target=\"new\">" . wfMsg('moreinfo') . "</a>";
             $editCatHtml = "<a href='#' id='ep_cat'>[" . wfMsg('editcategory') . "]</a><strong>{$editCatLink}</strong>";
         }
         $categoryHTML = "\n\t\t\t\t{$css}\n\t\t\t\t<div id='categories'>\n\t\t\t\t\t<h5>" . wfMsg('add-optional-categories') . "{$editCatMore}</h5>\n\t\t\t\t\t<div id='option_cats'>\n\t\t\t\t\t{$editCatHtml}" . Categoryhelper::getCategoryOptionsForm2($cat_string, $whow->mCategories) . "\t</div>\n\t\t\t\t</div>";
     }
     $requested = "";
     if (isset($_GET['requested'])) {
         $requested = $_GET['requested'];
     }
     $related_vis = "hide";
     $related_checked = "";
     $relatedHTML = "";
     if ($whow->getSection(wfMsg('relatedwikihows')) != "") {
         $related_vis = "show";
         $relatedHTML = $whow->getSection(wfMsg('relatedwikihows'));
         $relatedHTML = str_replace("*", "", $relatedHTML);
         $relatedHTML = str_replace("[[", "", $relatedHTML);
         $relatedHTML = str_replace("]]", "", $relatedHTML);
         $lines = split("\n", $relatedHTML);
         $relatedHTML = "";
         foreach ($lines as $line) {
             $xx = strpos($line, "|");
             if ($xx !== false) {
                 $line = substr($line, 0, $xx);
             }
             // Google+ hack.  We don't normally allow + but will for the Goog
             if (false === stripos($line, 'Google+')) {
                 $line = trim(urldecode($line));
             }
             if ($line == "") {
                 continue;
             }
             $relatedHTML .= "<OPTION VALUE=\"" . htmlspecialchars($line) . "\">{$line}</OPTION>\n";
         }
         $related_checked = " CHECKED ";
     }
     $vidpreview_vis = "hide";
     $vidbtn_vis = "show";
     $vidpreview = "<img src='" . wfGetPad('/extensions/wikihow/rotate.gif') . "'/>";
     if ($whow->getSection(wfMsg('video')) != "") {
         $vidpreview_vis = "show";
         $vidbtn_vis = "hide";
         try {
             #$vt = Title::makeTitle(NS_VIDEO, $this->mTitle->getText());
             #$r = Revision::newFromTitle($vt);
             $vidtext = $whow->getSection(wfMsg('video'));
             $vidpreview = $wgOut->parse($vidtext);
         } catch (Exception $e) {
             $vidpreview = "Sorry, preview is currently not available.";
         }
     } else {
         $vidpreview = wfMsg('video_novideoyet');
     }
     $video_disabled = "";
     $vid_alt = "";
     $video_msg = "";
     $video_button = "<a id='gatVideoImportEdit' type='button' onclick=\"changeVideo('" . urlencode($wgTitle->getDBKey()) . "'); return false;\" href='#' id='show_preview_button' class='button secondary'  >" . wfMsg('video_change') . "</a>";
     if ($wgUser->getID() == 0) {
         $video_disabled = "disabled";
         $video_alt = "<input type='hidden' name='video' value=\"" . htmlspecialchars($video) . "\"/>";
         $video_msg = wfMsg('video_loggedin');
         $video_button = "";
     }
     $things_vis = "hide";
     $things = "*  ";
     $things_checked = "";
     $tyn = $whow->getSection(wfMsg("thingsyoullneed"));
     if ($tyn != '') {
         $things_vis = "show";
         $things = $tyn;
         $things_checked = " CHECKED ";
     }
     $ingredients_vis = "hide";
     $section = $whow->getSection(wfMsg("ingredients"));
     $ingredients_checked = "";
     if ($section != '') {
         $ingredients_vis = "show";
         $ingredients = $section;
         $ingredients_checked = " CHECKED ";
     }
     $sources_vis = "hide";
     $sources = "*  ";
     $sources_checked = "";
     $sources = $whow->getSection(wfMsg("sources"));
     $sources = str_replace('<div class="references-small"><references/></div>', '', $sources);
     $sources = str_replace('{{reflist}}', '', $sources);
     if ($sources != "") {
         $sources_vis = "show";
         $sources_checked = " CHECKED ";
     }
     $new_field = "";
     if ($newArticle || $new_article) {
         $new_field = "<input type=hidden name=new_article value=true>";
     }
     $lang_links = htmlspecialchars($whow->getLangLinks());
     $vt = Title::makeTitle(NS_VIDEO, $this->mTitle->getText());
     $vp = SpecialPage::getTitleFor("Previewvideo", $vt->getFullText());
     $newArticleWarn = '<script type="text/javascript" src="' . wfGetPad('/extensions/min/f/extensions/wikihow/winpop.js?') . WH_SITEREV . '"></script>';
     $popup = Title::newFromText("UploadPopup", NS_SPECIAL);
     if ($wgUser->isLoggedIn()) {
         $token = htmlspecialchars($wgUser->editToken());
     } else {
         $token = EDIT_TOKEN_SUFFIX;
     }
     if ('preview' == $this->formtype) {
         $previewOutput = $this->getPreviewText();
         $this->showPreview($previewOutput);
         $show_weave = true;
     } else {
         $wgOut->addHTML('<div id="wikiPreview"></div>');
     }
     if ('diff' == $this->formtype) {
         $this->showDiff();
         $show_weave = true;
     }
     if ($show_weave) {
         $relBtn = $wgLanguageCode == 'en' ? PopBox::getGuidedEditorButton() : '';
         $relHTML = PopBox::getPopBoxJSGuided() . PopBox::getPopBoxDiv() . PopBox::getPopBoxCSS();
         $weave_links = $relHTML . '<div class="wh_block editpage_sublinks">' . $relBtn . '</div>';
     }
     $undo = '';
     if ($wgRequest->getVal('undo', null) != null) {
         $undo_id = $wgRequest->getVal('undo', null);
         $undo = "\n<input type='hidden' value=\"{$undo_id}\" name=\"wpUndoEdit\" />\n";
     }
     $wgOut->addHTML(Easyimageupload::getUploadBoxJS());
     $wgOut->addHTML("\t\n{$newArticleWarn}\n\n<div id='editpage'>\n<form id=\"editform\" name=\"editform\" method=\"post\" action=\"{$action}\"\nenctype=\"application/x-www-form-urlencoded\"  onSubmit=\"return checkForm();\">\t\t");
     if (is_callable($formCallback)) {
         call_user_func_array($formCallback, array(&$wgOut));
     }
     $hidden_cats = "";
     if (!$wgUser->isLoggedIn()) {
         $hidden_cats = "<input type=\"hidden\" name=\"categories22\" value=\"{$cat_string}\">";
     }
     $token1 = md5($wgUser->getName() . $this->mTitle->getArticleID() . time());
     wfTrackEditToken($wgUser, $token1, $this->mTitle, $this instanceof EditPageWrapper);
     $wgOut->addHTML("\n\t\t{$new_field}\n\t\t{$hidden_cats}\n\t\t<input type='hidden' value=\"{$this->starttime}\" name=\"wpStarttime\" />\n\n\t\t<input type=\"hidden\" name=\"requested\" value=\"{$requested}\">\n\t\t<input type=\"hidden\" name=\"langlinks\" value=\"{$lang_links}\">\n\t\t<input type='hidden' value=\"{$this->edittime}\" name=\"wpEdittime\" />\n\n\n\t\t{$commentsubject}\n\t\t{$title}\n\t\t<br clear='all'/>\n<script language='javascript'>\n\tvar vp_URL = '{$vp->getLocalUrl()}';\n</script>\n<script language='javascript' src='" . wfGetPad('/extensions/min/f/extensions/wikihow/previewvideo.js?rev=') . "'></script>\n<style type='text/css' media='all'>/*<![CDATA[*/ @import '" . wfGetPad('/extensions/min/f/extensions/wikihow/editpagewrapper.css,/extensions/wikihow/winpop.css,/extensions/wikihow/video/importvideo.css,/extensions/wikihow/cattool/categorizer.css,/extensions/wikihow/cattool/categorizer_editpage.css&rev=') . WH_SITEREV . "'; /*]]>*/</style>\n\n\t{$weave_links}\n\n\t<div id='introduction' class='{$section_class}'>\n\t\t<h2>" . wfMsg('introduction') . "\n\t\t\t<div class='head_details'>" . wfMsg('summaryinfo') . "</div>\n\t\t\t<a href=\"{$wgScriptPath}/" . wfMsg('writers-guide-url') . "?section=2#" . wfMsg('introduction-url') . "\" target=\"new\">" . wfMsg('moreinfo') . "</a>\n\t\t</h2>\n\t\t<textarea rows='4' cols='100' name='summary' id='summary' tabindex=\"2\" wrap=virtual>{$summary}</textarea>\n\t\t<!--a href='#' class='button secondary add_image_button' onclick='easyImageUpload.doEIUModal(\"intro\"); return false;'>" . wfMsg('eiu-add-image-to-introduction') . "</a-->\n\t\t<div class='clearall'></div>\n\t</div>\n\n\n\t<div id='ingredients' class='{$ingredients_vis} {$section_class}'>\n\t\t<h2>" . wfMsg('ingredients') . "\n\t\t\t<div class='head_details'>" . wfMsg('ingredients_tooltip') . "</div>\n\t\t\t<a href=\"{$wgScriptPath}/" . wfMsg('writers-guide-url') . "?section=2#" . wfMsg('ingredients') . "\" target=\"new\">" . wfMsg('moreinfo') . "</a>\n\t\t</h2>\n\t\t<textarea name='ingredients' rows='4' cols='100' onKeyUp=\"addStars(event, document.editform.ingredients);\" tabindex='3' id='ingredients_text'>{$ingredients}</textarea>\n\t\t<a href='#' class='button secondary add_image_button'  onclick='easyImageUpload.doEIUModal(\"ingredients\"); return false;'>" . wfMsg('eiu-add-image-to-ingredients') . "</a>\n\t</div>\n\n\t<div id='steps' class='{$section_class}'>\n\t\t<h2>" . wfMsg('steps') . "\n\t\t\t<div class='head_details'>" . wfMsg('stepsinfo') . "</div>\n\t\t\t<a href=\"{$wgScriptPath}/" . wfMsg('writers-guide-url') . "?section=2#" . wfMsg('steps') . "\" target=\"new\">" . wfMsg('moreinfo') . "</a>\n\t\t</h2>\n\t\t<textarea name='steps' rows='{$wgRequest->getVal('txtarea_steps_text', 12)}' cols='100' wrap='virtual' onKeyUp=\"addNumToSteps(event);\" tabindex='4' id='steps_text'>{$steps}</textarea>\n\t\t<a href='#' class='button secondary add_image_button' onclick='easyImageUpload.doEIUModal(\"steps\", 0); return false;'>" . wfMsg('eiu-add-image-to-steps') . "</a>\n\t</div>");
     $wgOut->addHTML("<div id='video' class='{$section_class}'>\n\t\t<h2>" . wfMsg('video') . "\n\t\t\t<div class='head_details'>" . wfMsg('videoinfo') . "</div>\n\t\t\t<a href=\"{$wgScriptPath}/" . wfMsg('writers-guide-url') . "?section=2#" . wfMsg('video') . "\" target=\"new\">" . wfMsg('moreinfo') . "</a>\n\t\t</h2>\n\t\t{$video_alt}\n\t\t<input type='text' name='video{$video_disabled}' size='60' id='video_text' style='float:left;' value=\"{$video}\" {$video_disabled}/><br />\n\t\t{$video_button}\n\t\t<a href='javascript:showHideVideoPreview();' id='show_preview_button' class='button secondary {$vidbtn_vis}'>" . wfMsg('show_preview') . "</a>\n\t\t{$video_msg}\n\t</div>\n\t<div id='viewpreview' class='{$vidpreview_vis} {$section_class}' style='text-align: center; margin-top: 5px;'>\n\t\t<center><a onclick='showHideVideoPreview();'>" . wfMsg('ep_hide_preview') . "</a></center><br/>\n\t\t<div id='viewpreview_innards'>{$vidpreview}</div>\n\t</div>\n\n\t<div id='tips' class='{$section_class}'>\n\t\t<h2>" . wfMsg('tips') . "\n\t\t\t<div class='head_details'>" . wfMsg('listhints') . "</div>\n\t\t\t<a href=\"{$wgScriptPath}/" . wfMsg('writers-guide-url') . "?section=2#" . wfMsg('tips') . "\" target=\"new\">" . wfMsg('moreinfo') . "</a>\n\t\t</h2>\n\t\t<textarea name='tips' rows='{$wgRequest->getVal('txtarea_tips_text', 12)}' cols='100' wrap='virtual' onKeyUp='addStars(event, document.editform.tips);' tabindex='5' id='tips_text'>{$tips}</textarea>\n\t\t<a href='#' class='button secondary add_image_button' onclick='easyImageUpload.doEIUModal(\"tips\"); return false;'>" . wfMsg('eiu-add-image-to-tips') . "</a>\n\t</div>\n\n\t<div id='warnings' class='{$section_class}'>\n\t\t<h2>" . wfMsg('warnings') . "\n\t\t\t<div class='head_details'>" . wfMsg('optionallist') . "</div>\n\t\t\t<a href=\"{$wgScriptPath}/" . wfMsg('writers-guide-url') . "?section=3#" . wfMsg('warnings') . "\" target=\"new\">" . wfMsg('moreinfo') . "</a>\n\t\t</h2>\n\t\t<textarea name='warnings' rows='{$wgRequest->getVal('txtarea_warnings_text', 4)}' cols='100' wrap='virtual' onKeyUp='addStars(event, document.editform.warnings);' id='warnings_text' tabindex=\"6\" id='warnings_text'>{$warns}</textarea>\n\t\t<a href='#' class='button secondary add_image_button' onclick='easyImageUpload.doEIUModal(\"warnings\"); return false;'>" . wfMsg('eiu-add-image-to-warnings') . "</a>\n\t</div>\n\n\t<div id='thingsyoullneed' class='{$things_vis} {$section_class}'>\n\t\t<h2>" . wfMsg('thingsyoullneed') . "\n\t\t\t<div class='head_details'>" . wfMsg('items') . "</div>\n\t\t\t<a href=\"{$wgScriptPath}/" . wfMsg('writers-guide-url') . "?section=4#" . wfMsg('thingsyoullneed') . "\" target=\"new\">" . wfMsg('moreinfo') . "</a>\n\t\t</h2>\n\t\t<textarea name='thingsyoullneed' rows='4' cols='65' wrap='virtual' onKeyUp='addStars(event, document.editform.thingsyoullneed);' tabindex='7' id='thingsyoullneed_text'>{$things}</textarea>\n\t\t<a href='#' class='button secondary add_image_button' onclick='easyImageUpload.doEIUModal(\"thingsyoullneed\"); return false;'>" . wfMsg('eiu-add-image-to-thingsyoullneed') . "</a>\n\t</div>\n\n\t<div id='relatedwikihows' class='{$related_vis} {$section_class}'>\n\t\t<h2>" . wfMsg('relatedarticlestext') . "\n\t\t\t<div class='head_details'>" . wfMsg('relatedlist') . "</div>\n\t\t\t<a href=\"{$wgScriptPath}/" . wfMsg('writers-guide-url') . "?section=5#" . wfMsg('related-wikihows-url') . "\" target=\"new\">" . wfMsg('moreinfo') . "</a>\n\t\t</h2>\n\t\t<div id='related_buttons'>\n\t\t\t<a href='#'  class='button secondary' onclick='moveRelated(true);return false;' >" . wfMsg('epw_move_up') . "</a>\n\t\t\t<a href='#' class='button secondary' onclick='moveRelated(false);return false;'>" . wfMsg('epw_move_down') . "</a>\n\t\t\t<a href='#' class='button red' onclick='removeRelated(); return false;'>" . wfMsg('epw_remove') . "</a>\n\t\t\t<br />\n\t\t\t<br />\n\t\t</div>\n\t\t<input type=hidden value=\"\" name=\"related_list\">\n\t\t<select size='4' name='related' id='related_select' ondblclick='viewRelated();'>\n\t\t\t{$relatedHTML}\n\t\t</select>\n\t\t<br />\n\t\t<br />\n\t\t<br class='clearall'/>\n\t\t<div>\n\t\t\t<b>" . wfMsg('addtitle') . "</b><br />\n\t\t\t<input type='text' autocomplete=\"off\" maxLength='256' name='q' value='' onKeyPress=\"return keyxxx(event);\" tabindex='8'>\n\t\t</div>\n\t\t<a href='#' id='add_button' class='button secondary' onclick='add_related();return false;'>" . wfMsg('epw_add') . "</a>\n\t\t<br class='clearall'/>\n\t</div>\n\n<script language=\"JavaScript\">\n\tvar js_enabled = document.getElementById('related');\n\t\t if (js_enabled != null) {\n\t\t\t\t js_enabled.className = 'display';\n\t\t\t}\n\t</script>\n\t<noscript>\n\t\t<input type='hidden' name='no_js' value='true'>\n\t\t<div id='related'>\n\t\t\t<textarea name='related_no_js' rows='4' cols='65' wrap='virtual' onKeyUp='addStars(event, document.editform.related_no_js);' id='related_no_js' tabindex='8'>{$related_text}</textarea>\n\t\t</div>\n\t</noscript>\n\n\t<div id='sources' class='{$sources_vis} {$section_class}'>\n\t\t<h2>" . wfMsg('sources') . "\n\t\t\t<div class='head_details'>" . wfMsg('linkstosites') . "</div>\n\t\t\t<a href=\"{$wgScriptPath}/" . wfMsg('writers-guide-url') . "?section=2#" . wfMsg('sources-links-url') . "\" target=\"new\"> " . wfMsg('moreinfo') . "</a>\n\t\t</h2>\n\t\t<textarea name='sources' rows='3' cols='100' wrap='virtual' onKeyUp='addStars(event, document.editform.sources);' id='sources' tabindex='9'>{$sources}</textarea>\n\t</div>\n\n\t<div class='{$section_class}'>\n\t\t<h2>" . wfMsg('optional_options') . "</h2>\n\t\t{$categoryHTML}\n\n\t\t<div id='optional_sections'>\n\t\t\t<h5>" . wfMsg('optionalsections') . "</h5>\n\t\t\t<ul>\n\t\t\t\t<li><input type='checkbox' id='thingsyoullneed_checkbox' name='thingsyoullneed_checkbox' onclick='showhiderow(\"thingsyoullneed\", \"thingsyoullneed_checkbox\");' {$things_checked} /> <label for='thingsyoullneed_checkbox'>" . wfMsg('thingsyoullneed') . "</label></li>\n\t\t\t\t<li><input type='checkbox' id='related_checkbox' name='related_checkbox' onclick='showhiderow(\"relatedwikihows\", \"related_checkbox\");' {$related_checked} > <label for='related_checkbox'>" . wfMsg('relatedwikihows') . "</label></li>\n\t\t\t\t<li><input type='checkbox' id='sources_checkbox' name='sources_checkbox' onclick='showhiderow(\"sources\", \"sources_checkbox\");' {$sources_checked} > <label for='sources_checkbox'>" . wfMsg('sources') . "</label></li>\n\t\t\t\t<li><input type='checkbox' id='ingredients_checkbox' name='ingredients_checkbox' onclick='showhiderow(\"ingredients\", \"ingredients_checkbox\");' {$ingredients_checked} > <label for='ingredients_checkbox'>" . wfMsg('ingredients_checkbox') . "</label></li>\n\t\t\t</ul>\n\t\t</div>\n\t</div>\n\t\n\t<div class='{$section_class}'>\n\t\t<div class='editOptions'>\n\t\t\t<h2>" . wfMsg('editdetails') . "\n\t\t\t\t<div class='head_details'>" . wfMsg('summaryedit') . "</div>\n\t\t\t\t<a href=\"{$wgScriptPath}/" . wfMsg('writers-guide-url') . "?section=2#" . wfMsg('summary') . "\" target=\"new\"> " . wfMsg('moreinfo') . "</a>\n\t\t\t</h2>\n\t\t\t{$editsummary}\n\t\t\t{$checkboxhtml}\n\t\t\t{$undo}\n\t\t\t<input type='hidden' value=\"{$token}\" name=\"wpEditToken\" />\n\t\t\t<input type='hidden' value=\"{$token1}\" name=\"wpEditTokenTrack\" />\n\t\t\t<div class='editButtons'>\n\t\t\t\t<a href=\"javascript:history.back()\" id=\"wpCancel\" class=\"button secondary\">" . wfMsg('cancel') . "</a>\n\t\t\t\t{$buttonshtml}\n\t\t\t</div>\n\t\t\t{$copywarn}\n\t\t</div>\n\t</div>\n\t<input type='hidden' value=\"" . htmlspecialchars($this->section) . "\" name=\"wpSection\" />\n\t<input type='hidden' value=\"{$this->edittime}\" name=\"wpEdittime\" />\n");
     if ($this->isConflict) {
         require_once "DifferenceEngine.php";
         $wgOut->addHTML("<h2>" . wfMsg("yourdiff") . "</h2>\n");
         DifferenceEngine::showDiff($this->textbox2, $this->textbox1, wfMsg("yourtext"), wfMsg("storedversion"));
     }
     if ($wgUser->getOption('hidepersistantsavebar', 0) == 0) {
         $wgOut->addHTML(" <div id='edit_page_footer'>\n\t\t\t\t<table class='edit_footer'><tr><td class='summary'>\n\t\t\t\t" . wfMsg('editsummary') . ": &nbsp; {$editsummary1}</td>\n\t\t\t\t<td class='buttons'>{$footerbuttons}</td></tr></table>\n\t\t\t\t</div> ");
     }
     $wgOut->addHTML("</form></div>\n");
 }
    /**
     * Replace entire showEditForm, need to add our own textbox and stuff
     */
    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();
            # MeanEditor: too complicated for visual editing
            $this->noVisualEditor = false;
        } 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()));
            # MeanEditor: visual editing makes no sense here
            $this->noVisualEditor = true;
        } 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) {
            # MeanEditor: the length will probably be different in HTML
            $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') . ']]');
        }
        /* MeanEditor: always disable the toolbar */
        if ($wgUser->getOption('showtoolbar') and !$this->isCssJsSubpage) {
            # prepare toolbar for edit buttons
            $toolbar = '';
        } 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;
            }
            # MeanEditor: User preference
            if ($wgUser->getOption('prefer_traditional_editor')) {
                $this->userWantsTraditionalEditor = 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, 'want_traditional_editor' => $this->userWantsTraditionalEditor));
        $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
);
        if ($this->isConflict || $this->diff) {
            # MeanEditor: should be redundant, but let's be sure
            $this->noVisualEditor = true;
        }
        # MeanEditor: also apply htmlspecialchars? See $encodedtext
        $html_text = $this->safeUnicodeOutput($this->textbox1);
        if (!($this->noVisualEditor || $this->userWantsTraditionalEditor)) {
            $this->noVisualEditor = wfRunHooks('EditPage::wiki2html', array($this->mArticle, $wgUser, &$this, &$html_text));
        }
        if (!$this->noVisualEditor && !$this->userWantsTraditionalEditor) {
            $this->noVisualEditor = wfRunHooks('EditPage::showBox', array(&$this, $html_text, $rows, $cols, $ew));
        }
        if (!$this->noVisualEditor && !$this->userWantsTraditionalEditor) {
            $wgOut->addHTML("<input type='hidden' value=\"0\" name=\"wpNoVisualEditor\" />\n");
        } else {
            $wgOut->addHTML("<input type='hidden' value=\"1\" name=\"wpNoVisualEditor\" />\n");
            $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);
    }
Esempio n. 4
0
 public function onView()
 {
     $details = null;
     $request = $this->getRequest();
     $result = $this->page->doRollback($request->getVal('from'), $request->getText('summary'), $request->getVal('token'), $request->getBool('bot'), $details, $this->getUser());
     if (in_array(array('actionthrottledtext'), $result)) {
         throw new ThrottledError();
     }
     if (isset($result[0][0]) && ($result[0][0] == 'alreadyrolled' || $result[0][0] == 'cantrollback')) {
         $this->getOutput()->setPageTitle($this->msg('rollbackfailed'));
         $errArray = $result[0];
         $errMsg = array_shift($errArray);
         $this->getOutput()->addWikiMsgArray($errMsg, $errArray);
         if (isset($details['current'])) {
             $current = $details['current'];
             if ($current->getComment() != '') {
                 $this->getOutput()->addHTML($this->msg('editcomment')->rawParams(Linker::formatComment($current->getComment()))->parse());
             }
         }
         return;
     }
     # Display permissions errors before read-only message -- there's no
     # point in misleading the user into thinking the inability to rollback
     # is only temporary.
     if (!empty($result) && $result !== array(array('readonlytext'))) {
         # array_diff is completely broken for arrays of arrays, sigh.
         # Remove any 'readonlytext' error manually.
         $out = array();
         foreach ($result as $error) {
             if ($error != array('readonlytext')) {
                 $out[] = $error;
             }
         }
         throw new PermissionsError('rollback', $out);
     }
     if ($result == array(array('readonlytext'))) {
         throw new ReadOnlyError();
     }
     $current = $details['current'];
     $target = $details['target'];
     $newId = $details['newid'];
     $this->getOutput()->setPageTitle($this->msg('actioncomplete'));
     $this->getOutput()->setRobotPolicy('noindex,nofollow');
     if ($current->getUserText() === '') {
         $old = $this->msg('rev-deleted-user')->escaped();
     } else {
         $old = Linker::userLink($current->getUser(), $current->getUserText()) . Linker::userToolLinks($current->getUser(), $current->getUserText());
     }
     $new = Linker::userLink($target->getUser(), $target->getUserText()) . Linker::userToolLinks($target->getUser(), $target->getUserText());
     $this->getOutput()->addHTML($this->msg('rollback-success')->rawParams($old, $new)->parseAsBlock());
     $this->getOutput()->returnToMain(false, $this->getTitle());
     if (!$request->getBool('hidediff', false) && !$this->getUser()->getBoolOption('norollbackdiff', false)) {
         $de = new DifferenceEngine($this->getContext(), $current->getId(), $newId, false, true);
         $de->showDiff('', '');
     }
 }
Esempio n. 5
0
 /**
  * Show "your edit contains spam" page with your diff and text
  *
  * @param $match Text which triggered one or more filters
  */
 public function spamPageWithContent($match = false)
 {
     global $wgOut;
     $this->textbox2 = $this->textbox1;
     $wgOut->prepareErrorPage(wfMessage('spamprotectiontitle'));
     $wgOut->addHTML('<div id="spamprotected">');
     $wgOut->addWikiMsg('spamprotectiontext');
     if ($match) {
         $wgOut->addWikiMsg('spamprotectionmatch', wfEscapeWikiText($match));
     }
     $wgOut->addHTML('</div>');
     $wgOut->wrapWikiMsg('<h2>$1</h2>', "yourdiff");
     $de = new DifferenceEngine($this->mArticle->getContext());
     $de->setText($this->getCurrentText(), $this->textbox2);
     $de->showDiff(wfMsg("storedversion"), wfMsgExt('yourtext', 'parseinline'));
     $wgOut->wrapWikiMsg('<h2>$1</h2>', "yourtext");
     $this->showTextbox2();
     $wgOut->addReturnTo($this->getContextTitle(), array('action' => 'edit'));
 }
Esempio n. 6
0
 /**
  * User interface for rollback operations
  */
 public function rollback()
 {
     global $wgUser, $wgOut, $wgRequest;
     $details = null;
     $result = $this->doRollback($wgRequest->getVal('from'), $wgRequest->getText('summary'), $wgRequest->getVal('token'), $wgRequest->getBool('bot'), $details);
     if (in_array(array('actionthrottledtext'), $result)) {
         $wgOut->rateLimited();
         return;
     }
     if (isset($result[0][0]) && ($result[0][0] == 'alreadyrolled' || $result[0][0] == 'cantrollback')) {
         $wgOut->setPageTitle(wfMsg('rollbackfailed'));
         $errArray = $result[0];
         $errMsg = array_shift($errArray);
         $wgOut->addWikiMsgArray($errMsg, $errArray);
         if (isset($details['current'])) {
             $current = $details['current'];
             if ($current->getComment() != '') {
                 $wgOut->addWikiMsgArray('editcomment', array($wgUser->getSkin()->formatComment($current->getComment())), array('replaceafter'));
             }
         }
         return;
     }
     # Display permissions errors before read-only message -- there's no
     # point in misleading the user into thinking the inability to rollback
     # is only temporary.
     if (!empty($result) && $result !== array(array('readonlytext'))) {
         # array_diff is completely broken for arrays of arrays, sigh.
         # Remove any 'readonlytext' error manually.
         $out = array();
         foreach ($result as $error) {
             if ($error != array('readonlytext')) {
                 $out[] = $error;
             }
         }
         $wgOut->showPermissionsErrorPage($out);
         return;
     }
     if ($result == array(array('readonlytext'))) {
         $wgOut->readOnlyPage();
         return;
     }
     $current = $details['current'];
     $target = $details['target'];
     $newId = $details['newid'];
     $wgOut->setPageTitle(wfMsg('actioncomplete'));
     $wgOut->setRobotPolicy('noindex,nofollow');
     if ($current->getUserText() === '') {
         $old = wfMsg('rev-deleted-user');
     } else {
         $old = $wgUser->getSkin()->userLink($current->getUser(), $current->getUserText()) . $wgUser->getSkin()->userToolLinks($current->getUser(), $current->getUserText());
     }
     $new = $wgUser->getSkin()->userLink($target->getUser(), $target->getUserText()) . $wgUser->getSkin()->userToolLinks($target->getUser(), $target->getUserText());
     $wgOut->addHTML(wfMsgExt('rollback-success', array('parse', 'replaceafter'), $old, $new));
     $wgOut->returnToMain(false, $this->mTitle);
     if (!$wgRequest->getBool('hidediff', false) && !$wgUser->getBoolOption('norollbackdiff', false)) {
         $de = new DifferenceEngine($this->mTitle, $current->getId(), $newId, false, true);
         $de->showDiff('', '');
     }
 }
	/**
	 * Output a trimmed down diff view corresponding to a particular change
	 *
	 * @param $edit Recent change to produce a diff. for
	 */
	private function showDiff( &$edit ) {
		$diff = new DifferenceEngine( $edit->getTitle(), $edit->mAttribs['rc_last_oldid'], $edit->mAttribs['rc_this_oldid'] );
		$diff->showDiff( '', '' );
	}
Esempio n. 8
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;
        $fname = 'EditPage::showEditForm';
        wfProfileIn($fname);
        $sk =& $wgUser->getSkin();
        wfRunHooks('EditPage::showEditForm:initial', array(&$this));
        $wgOut->setRobotpolicy('noindex,nofollow');
        # Enabled article-related sidebar, toplinks, 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->getContent();
            $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());
                    if (!$this->summary && !$this->preview && !$this->diff) {
                        preg_match("/^(=+)(.+)\\1/mi", $this->textbox1, $matches);
                        if (!empty($matches[2])) {
                            $this->summary = "/* " . trim($matches[2]) . " */ ";
                        }
                    }
                }
            } else {
                $s = wfMsg('editing', $this->mTitle->getPrefixedText());
            }
            $wgOut->setPageTitle($s);
            if ($this->missingComment) {
                $wgOut->addWikiText(wfMsg('missingcommenttext'));
            }
            if ($this->missingSummary) {
                $wgOut->addWikiText(wfMsg('missingsummary'));
            }
            if (!$this->hookError == '') {
                $wgOut->addWikiText($this->hookError);
            }
            if (!$this->checkUnicodeCompliantBrowser()) {
                $wgOut->addWikiText(wfMsg('nonunicodebrowser'));
            }
            if (isset($this->mArticle) && isset($this->mArticle->mRevision) && !$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->isValidCssJsSubpage) {
                    $wgOut->addWikiText(wfMsg('usercssjsyoucanpreview'));
                } else {
                    $wgOut->addWikiText(wfMsg('userinvalidcssjstitle', $this->mTitle->getSkinFromCssJsSubpage()));
                }
            }
        }
        if ($this->mTitle->isProtected('edit')) {
            # Is the protection due to the namespace, e.g. interface text?
            if ($this->mTitle->getNamespace() == NS_MEDIAWIKI) {
                # Yes; remind the user
                $notice = wfMsg('editinginterface');
            } elseif ($this->mTitle->isSemiProtected()) {
                # No; semi protected
                $notice = wfMsg('semiprotectedpagewarning');
                if (wfEmptyMsg('semiprotectedpagewarning', $notice) || $notice == '-') {
                    $notice = '';
                }
            } else {
                # No; regular protection
                $notice = wfMsg('protectedpagewarning');
            }
            $wgOut->addWikiText($notice);
        }
        if ($this->kblength === false) {
            $this->kblength = (int) (strlen($this->textbox1) / 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)));
        }
        $rows = $wgUser->getIntOption('rows');
        $cols = $wgUser->getIntOption('cols');
        $ew = $wgUser->getOption('editwidth');
        if ($ew) {
            $ew = " style=\"width:100%\"";
        } else {
            $ew = '';
        }
        $q = 'action=submit';
        #if ( "no" == $redirect ) { $q .= "&redirect=no"; }
        $action = $this->mTitle->escapeLocalURL($q);
        $summary = wfMsg('summary');
        $subject = wfMsg('subject');
        $minor = wfMsgExt('minoredit', array('parseinline'));
        $watchthis = wfMsgExt('watchthis', array('parseinline'));
        $cancel = $sk->makeKnownLink($this->mTitle->getPrefixedText(), wfMsgExt('cancel', array('parseinline')));
        $edithelpurl = Skin::makeInternalOrExternalUrl(wfMsgForContent('edithelppage'));
        $edithelp = '<a target="helpwindow" href="' . $edithelpurl . '">' . htmlspecialchars(wfMsg('edithelp')) . '</a> ' . htmlspecialchars(wfMsg('newwindow'));
        global $wgRightsText;
        $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 = $this->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;
            }
        }
        $minoredithtml = '';
        if ($wgUser->isAllowed('minoredit')) {
            $minoredithtml = "<input tabindex='3' type='checkbox' value='1' name='wpMinoredit'" . ($this->minoredit ? " checked='checked'" : "") . " accesskey='" . wfMsg('accesskey-minoredit') . "' id='wpMinoredit' />\n" . "<label for='wpMinoredit' title='" . wfMsg('tooltip-minoredit') . "'>{$minor}</label>\n";
        }
        $watchhtml = '';
        if ($wgUser->isLoggedIn()) {
            $watchhtml = "<input tabindex='4' type='checkbox' name='wpWatchthis'" . ($this->watchthis ? " checked='checked'" : "") . " accesskey=\"" . htmlspecialchars(wfMsg('accesskey-watch')) . "\" id='wpWatchthis'  />\n" . "<label for='wpWatchthis' title=\"" . htmlspecialchars(wfMsg('tooltip-watch')) . "\">{$watchthis}</label>\n";
        }
        $checkboxhtml = $minoredithtml . $watchhtml;
        if ($wgUser->getOption('previewontop')) {
            if ('preview' == $this->formtype) {
                $this->showPreview();
            } else {
                $wgOut->addHTML('<div id="wikiPreview"></div>');
            }
            if ('diff' == $this->formtype) {
                $wgOut->addHTML($this->getDiff());
            }
        }
        # 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 = "<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='60' /><br />";
            $editsummary = '';
        } else {
            $commentsubject = '';
            $editsummary = "<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='60' /><br />";
        }
        # 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->formatTemplates();
        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>";
            }
        }
        $temp = array('id' => 'wpSave', 'name' => 'wpSave', 'type' => 'submit', 'tabindex' => '5', 'value' => wfMsg('savearticle'), 'accesskey' => wfMsg('accesskey-save'), 'title' => wfMsg('tooltip-save'));
        $buttons['save'] = wfElement('input', $temp, '');
        $temp = array('id' => 'wpDiff', 'name' => 'wpDiff', 'type' => 'submit', 'tabindex' => '7', 'value' => wfMsg('showdiff'), 'accesskey' => wfMsg('accesskey-diff'), 'title' => wfMsg('tooltip-diff'));
        $buttons['diff'] = wfElement('input', $temp, '');
        global $wgLivePreview;
        if ($wgLivePreview && $wgUser->getOption('uselivepreview')) {
            $temp = array('id' => 'wpPreview', 'name' => 'wpPreview', 'type' => 'submit', 'tabindex' => '6', 'value' => wfMsg('showpreview'), 'accesskey' => '', 'title' => wfMsg('tooltip-preview'), 'style' => 'display: none;');
            $buttons['preview'] = wfElement('input', $temp, '');
            $temp = array('id' => 'wpLivePreview', 'name' => 'wpLivePreview', 'type' => 'submit', 'tabindex' => '6', 'value' => wfMsg('showlivepreview'), 'accesskey' => wfMsg('accesskey-preview'), 'title' => '', 'onclick' => $this->doLivePreviewScript());
            $buttons['live'] = wfElement('input', $temp, '');
        } else {
            $temp = array('id' => 'wpPreview', 'name' => 'wpPreview', 'type' => 'submit', 'tabindex' => '6', 'value' => wfMsg('showpreview'), 'accesskey' => wfMsg('accesskey-preview'), 'title' => wfMsg('tooltip-preview'));
            $buttons['preview'] = wfElement('input', $temp, '');
            $buttons['live'] = '';
        }
        $safemodehtml = $this->checkUnicodeCompliantBrowser() ? "" : "<input type='hidden' name=\"safemode\" value='1' />\n";
        $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));
        }
        // 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}
<textarea tabindex='1' accesskey="," name="wpTextbox1" id="wpTextbox1" rows='{$rows}'
cols='{$cols}'{$ew} {$hidden}>
END
 . htmlspecialchars($this->safeUnicodeOutput($this->textbox1)) . "\n</textarea>\n\t\t");
        $wgOut->addWikiText($copywarn);
        $wgOut->addHTML("\n{$metadata}\n{$editsummary}\n{$checkboxhtml}\n{$safemodehtml}\n");
        $wgOut->addHTML("<div class='editButtons'>\n\t{$buttons['save']}\n\t{$buttons['preview']}\n\t{$buttons['live']}\n\t{$buttons['diff']}\n\t<span class='editHelp'>{$cancel} | {$edithelp}</span>\n</div><!-- editButtons -->\n</div><!-- editOptions -->");
        $wgOut->addWikiText(wfMsgForContent('edittools'));
        $wgOut->addHTML("\n<div class='templatesUsed'>\n{$templates}\n</div>\n");
        if ($wgUser->isLoggedIn()) {
            /**
             * 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.
             */
            $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(wfHidden('wpAutoSummary', $autosumm));
        if ($this->isConflict) {
            $wgOut->addWikiText('==' . wfMsg("yourdiff") . '==');
            $de = new DifferenceEngine($this->mTitle);
            $de->setText($this->textbox2, $this->textbox1);
            $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("</form>\n");
        if (!$wgUser->getOption('previewontop')) {
            if ($this->formtype == 'preview') {
                $this->showPreview();
            } else {
                $wgOut->addHTML('<div id="wikiPreview"></div>');
            }
            if ($this->formtype == 'diff') {
                $wgOut->addHTML($this->getDiff());
            }
        }
        wfProfileOut($fname);
    }
 /**
  * Show "your edit contains spam" page with your diff and text
  *
  * @param $match Text which triggered one or more filters
  */
 public function spamPageWithContent($match = false)
 {
     global $wgOut;
     $this->textbox2 = $this->textbox1;
     $wgOut->setPageTitle(wfMsg('spamprotectiontitle'));
     $wgOut->setRobotPolicy('noindex,nofollow');
     $wgOut->setArticleRelated(false);
     $wgOut->addHTML('<div id="spamprotected">');
     $wgOut->addWikiMsg('spamprotectiontext');
     if ($match) {
         $wgOut->addWikiMsg('spamprotectionmatch', wfEscapeWikiText($match));
     }
     $wgOut->addHTML('</div>');
     $wgOut->wrapWikiMsg('<h2>$1</h2>', "yourdiff");
     $de = new DifferenceEngine($this->mTitle);
     $de->setText($this->getContent(), $this->textbox2);
     $de->showDiff(wfMsg("storedversion"), wfMsg("yourtext"));
     $wgOut->wrapWikiMsg('<h2>$1</h2>', "yourtext");
     $this->showTextbox2();
     $wgOut->addReturnTo($this->getContextTitle(), array('action' => 'edit'));
 }
Esempio n. 10
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;
        $fname = 'EditPage::showEditForm';
        wfProfileIn($fname);
        $sk = $wgUser->getSkin();
        wfRunHooks('EditPage::showEditForm:initial', array(&$this));
        $wgOut->setRobotpolicy('noindex,nofollow');
        # Enabled article-related sidebar, toplinks, etc.
        $wgOut->setArticleRelated(true);
        if ($this->formtype == 'preview') {
            $wgOut->setPageTitleActionText(wfMsg('preview'));
        }
        if ($this->isConflict) {
            $s = wfMsg('editconflict', $wgTitle->getPrefixedText());
            $wgOut->setPageTitle($s);
            $wgOut->addWikiMsg('explainconflict');
            $this->textbox2 = $this->textbox1;
            $this->textbox1 = $this->getContent();
            $this->edittime = $this->mArticle->getTimestamp();
        } else {
            if ($this->section != '') {
                if ($this->section == 'new') {
                    $s = wfMsg('editingcomment', $wgTitle->getPrefixedText());
                } else {
                    $s = wfMsg('editingsection', $wgTitle->getPrefixedText());
                    $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])) . " */ ";
                        }
                    }
                }
            } else {
                $s = wfMsg('editing', $wgTitle->getPrefixedText());
            }
            $wgOut->setPageTitle($s);
            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->addWikiMsg('rev-deleted-text-permission');
                } else {
                    if ($this->mArticle->mRevision->isDeleted(Revision::DELETED_TEXT)) {
                        $wgOut->addWikiMsg('rev-deleted-text-view');
                    }
                }
                if (!$this->mArticle->mRevision->isCurrent()) {
                    $this->mArticle->setOldSubtitle($this->mArticle->mRevision->getId());
                    $wgOut->addWikiMsg('editingold');
                }
            }
        }
        if (wfReadOnly()) {
            $wgOut->addHTML('<div id="mw-read-only-warning">' . wfMsgWikiHTML('readonlywarning') . '</div>');
        } elseif ($wgUser->isAnon() && $this->formtype != 'preview') {
            $wgOut->addHTML('<div id="mw-anon-edit-warning">' . wfMsgWikiHTML('anoneditwarning') . '</div>');
        } else {
            if ($this->isCssJsSubpage && $this->formtype != 'preview') {
                # Check the skin exists
                if ($this->isValidCssJsSubpage) {
                    $wgOut->addWikiMsg('usercssjsyoucanpreview');
                } else {
                    $wgOut->addWikiMsg('userinvalidcssjstitle', $wgTitle->getSkinFromCssJsSubpage());
                }
            }
        }
        if ($this->mTitle->getNamespace() == NS_MEDIAWIKI) {
            # Show a warning if editing an interface message
            $wgOut->addWikiMsg('editinginterface');
        } elseif ($this->mTitle->isProtected('edit')) {
            # Is the title semi-protected?
            if ($this->mTitle->isSemiProtected()) {
                $noticeMsg = 'semiprotectedpagewarning';
            } else {
                # Then it must be protected based on static groups (regular)
                $noticeMsg = 'protectedpagewarning';
            }
            $wgOut->addWikiMsg($noticeMsg);
        }
        if ($this->mTitle->isCascadeProtected()) {
            # Is this page under cascading protection from some source pages?
            list($cascadeSources, ) = $this->mTitle->getCascadeProtectionSources();
            $notice = "\$1\n";
            if (count($cascadeSources) > 0) {
                # Explain, and list the titles responsible
                foreach ($cascadeSources as $page) {
                    $notice .= '* [[:' . $page->getPrefixedText() . "]]\n";
                }
            }
            $wgOut->wrapWikiMsg($notice, array('cascadeprotectedwarning', count($cascadeSources)));
        }
        if (!$this->mTitle->exists() && $this->mTitle->getRestrictions('create') != array()) {
            $wgOut->addWikiMsg('titleprotectedwarning');
        }
        if ($this->kblength === false) {
            $this->kblength = (int) (strlen($this->textbox1) / 1024);
        }
        if ($this->tooBig || $this->kblength > $wgMaxArticleSize) {
            $wgOut->addWikiMsg('longpageerror', $wgLang->formatNum($this->kblength), $wgMaxArticleSize);
        } elseif ($this->kblength > 29) {
            $wgOut->addWikiMsg('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();
        }
        $rows = $wgUser->getIntOption('rows');
        $cols = $wgUser->getIntOption('cols');
        $ew = $wgUser->getOption('editwidth');
        if ($ew) {
            $ew = " style=\"width:100%\"";
        } else {
            $ew = '';
        }
        $q = 'action=submit';
        #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')));
        $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 = $this->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);
        if ($wgUser->getOption('previewontop')) {
            if ('preview' == $this->formtype) {
                $this->showPreview($previewOutput);
            } else {
                $wgOut->addHTML('<div id="wikiPreview"></div>');
            }
            if ('diff' == $this->formtype) {
                $this->showDiff();
            }
        }
        $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 = "<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='60' /><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 = "<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='60' /><br />";
            $summarypreview = $summarytext && $this->preview ? "<div class=\"mw-summary-preview\">" . wfMsg('summary-preview') . ':' . $sk->commentBlock($this->summary, $this->mTitle) . "</div>\n" : '';
            $subjectpreview = '';
        }
        # 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->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->addWikiMsg('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");
        $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
        $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}
{$this->editFormTextBeforeContent}
<textarea tabindex='1' accesskey="," name="wpTextbox1" id="wpTextbox1" rows='{$rows}'
cols='{$cols}'{$ew} {$hidden}>
END
 . htmlspecialchars($this->safeUnicodeOutput($this->textbox1)) . "\n</textarea>\n\t\t");
        $wgOut->wrapWikiMsg("<div id=\"editpage-copywarn\">\n\$1\n</div>", $copywarnMsg);
        $wgOut->addHTML($this->editFormTextAfterWarn);
        $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} | {$edithelp}</span>\n</div><!-- editButtons -->\n</div><!-- editOptions -->");
        $wgOut->addHtml('<div class="mw-editTools">');
        $wgOut->addWikiMsgArray('edittools', array(), array('content'));
        $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(wfHidden('wpAutoSummary', $autosumm));
        if ($this->isConflict) {
            $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");
            $wgOut->addHTML("<textarea tabindex='6' id='wpTextbox2' name=\"wpTextbox2\" rows='{$rows}' cols='{$cols}'>" . 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();
            }
        }
        wfProfileOut($fname);
    }
Esempio n. 11
0
 protected function showConflict()
 {
     if (wfRunHooks('EditPageBeforeConflictDiff', array(&$this, &$this->out))) {
         // diff
         $this->out->addHtml('<div id="diff">');
         $this->out->wrapWikiMsg('<h2>$1</h2>', 'editpagelayout-diff-header');
         $de = new DifferenceEngine($this->mTitle);
         $de->setText($this->textbox2, $this->textbox1);
         $de->showDiff(wfMsg("yourtext"), wfMsg("storedversion"));
         $this->out->addHtml('</div>');
         // user's edit
         $this->out->addHtml('<div id="myedit">');
         $this->out->wrapWikiMsg('<h2>$1</h2>', 'editpagelayout-myedit-header');
         $this->showTextbox2();
         $this->out->addHtml('</div>');
     }
 }
    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);
    }
Esempio n. 13
0
 protected function showConflict()
 {
     global $wgOut;
     $this->textbox2 = $this->textbox1;
     $this->textbox1 = $this->getContent();
     if (wfRunHooks('EditPageBeforeConflictDiff', array(&$this, &$wgOut))) {
         $wgOut->wrapWikiMsg('<h2>$1</h2>', "yourdiff");
         $de = new DifferenceEngine($this->mTitle);
         $de->setText($this->textbox2, $this->textbox1);
         $de->showDiff(wfMsg("yourtext"), wfMsg("storedversion"));
         $wgOut->wrapWikiMsg('<h2>$1</h2>', "yourtext");
         $this->showTextbox2();
     }
 }
Esempio n. 14
0
 /**
  * Show an edit conflict. textbox1 is already shown in showEditForm().
  * If you want to use another entry point to this function, be careful.
  */
 protected function showConflict()
 {
     global $wgOut;
     if (wfRunHooks('EditPageBeforeConflictDiff', array(&$this, &$wgOut))) {
         $wgOut->wrapWikiMsg('<h2>$1</h2>', "yourdiff");
         $de = new DifferenceEngine($this->mArticle->getContext());
         $de->setText($this->textbox2, $this->textbox1);
         $de->showDiff(wfMessage('yourtext')->parse(), wfMessage('storedversion')->text());
         $wgOut->wrapWikiMsg('<h2>$1</h2>', "yourtext");
         $this->showTextbox2();
     }
 }
    function showDiffPage()
    {
        global $wgUser, $wgTitle, $wgOut, $wgContLang, $wgOnlySysopsCanPatrol, $wgUseExternalEditor, $wgUseRCPatrol;
        $fname = 'DifferenceEngine::showDiffPage';
        wfProfileIn($fname);
        # If external diffs are enabled both globally and for the user,
        # we'll use the application/x-external-editor interface to call
        # an external diff tool like kompare, kdiff3, etc.
        if ($wgUseExternalEditor && $wgUser->getOption('externaldiff')) {
            global $wgInputEncoding, $wgServer, $wgScript, $wgLang;
            $wgOut->disable();
            header("Content-type: application/x-external-editor; charset=" . $wgInputEncoding);
            $url1 = $wgTitle->getFullURL("action=raw&oldid=" . $this->mOldid);
            $url2 = $wgTitle->getFullURL("action=raw&oldid=" . $this->mNewid);
            $special = $wgLang->getNsText(NS_SPECIAL);
            $control = <<<CONTROL
[Process]
Type=Diff text
Engine=MediaWiki
Script={$wgServer}{$wgScript}
Special namespace={$special}

[File]
Extension=wiki
URL={$url1}

[File 2]
Extension=wiki
URL={$url2}
CONTROL;
            echo $control;
            return;
        }
        # mOldid is false if the difference engine is called with a "vague" query for
        # a diff between a version V and its previous version V' AND the version V
        # is the first version of that article. In that case, V' does not exist.
        if ($this->mOldid === false) {
            $this->showFirstRevision();
            wfProfileOut($fname);
            return;
        }
        $t = $wgTitle->getPrefixedText() . " (Diff: {$this->mOldid}, " . "{$this->mNewid})";
        $mtext = wfMsg('missingarticle', $t);
        $wgOut->setArticleFlag(false);
        if (!$this->loadText()) {
            $wgOut->setPagetitle(wfMsg('errorpagetitle'));
            $wgOut->addHTML($mtext);
            wfProfileOut($fname);
            return;
        }
        $wgOut->suppressQuickbar();
        $oldTitle = $this->mOldPage->getPrefixedText();
        $newTitle = $this->mNewPage->getPrefixedText();
        if ($oldTitle == $newTitle) {
            $wgOut->setPageTitle($newTitle);
        } else {
            $wgOut->setPageTitle($oldTitle . ', ' . $newTitle);
        }
        $wgOut->setSubtitle(wfMsg('difference'));
        $wgOut->setRobotpolicy('noindex,follow');
        if (!($this->mOldPage->userCanRead() && $this->mNewPage->userCanRead())) {
            $wgOut->loginToUse();
            $wgOut->output();
            wfProfileOut($fname);
            exit;
        }
        $sk = $wgUser->getSkin();
        $talk = $wgContLang->getNsText(NS_TALK);
        $contribs = wfMsg('contribslink');
        $this->mOldComment = $sk->formatComment($this->mOldComment);
        $this->mNewComment = $sk->formatComment($this->mNewComment);
        $oldUserLink = $sk->makeLinkObj(Title::makeTitleSafe(NS_USER, $this->mOldUser), $this->mOldUser);
        $newUserLink = $sk->makeLinkObj(Title::makeTitleSafe(NS_USER, $this->mNewUser), $this->mNewUser);
        $oldUTLink = $sk->makeLinkObj(Title::makeTitleSafe(NS_USER_TALK, $this->mOldUser), $talk);
        $newUTLink = $sk->makeLinkObj(Title::makeTitleSafe(NS_USER_TALK, $this->mNewUser), $talk);
        $oldContribs = $sk->makeKnownLinkObj(Title::makeTitle(NS_SPECIAL, 'Contributions'), $contribs, 'target=' . urlencode($this->mOldUser));
        $newContribs = $sk->makeKnownLinkObj(Title::makeTitle(NS_SPECIAL, 'Contributions'), $contribs, 'target=' . urlencode($this->mNewUser));
        if ($this->newRev->isCurrent() && $wgUser->isAllowed('rollback')) {
            $rollback = '&nbsp;&nbsp;&nbsp;<strong>[' . $sk->makeKnownLinkObj($wgTitle, wfMsg('rollbacklink'), 'action=rollback&from=' . urlencode($this->mNewUser) . '&token=' . urlencode($wgUser->editToken(array($wgTitle->getPrefixedText(), $this->mNewUser)))) . ']</strong>';
        } else {
            $rollback = '';
        }
        if ($wgUseRCPatrol && $this->mRcidMarkPatrolled != 0 && $wgUser->isLoggedIn() && ($wgUser->isAllowed('rollback') || !$wgOnlySysopsCanPatrol)) {
            $patrol = ' [' . $sk->makeKnownLinkObj($wgTitle, wfMsg('markaspatrolleddiff'), "action=markpatrolled&rcid={$this->mRcidMarkPatrolled}") . ']';
        } else {
            $patrol = '';
        }
        $prevlink = $sk->makeKnownLinkObj($wgTitle, wfMsg('previousdiff'), 'diff=prev&oldid=' . $this->mOldid);
        if ($this->newRev->isCurrent()) {
            $nextlink = '';
        } else {
            $nextlink = $sk->makeKnownLinkObj($wgTitle, wfMsg('nextdiff'), 'diff=next&oldid=' . $this->mNewid);
        }
        $oldHeader = "<strong>{$this->mOldtitle}</strong><br />{$oldUserLink} " . "({$oldUTLink} | {$oldContribs})<br />" . $this->mOldComment . '<br />' . $prevlink;
        $newHeader = "<strong>{$this->mNewtitle}</strong><br />{$newUserLink} " . "({$newUTLink} | {$newContribs}) {$rollback}<br />" . $this->mNewComment . '<br />' . $nextlink . $patrol;
        DifferenceEngine::showDiff($this->mOldtext, $this->mNewtext, $oldHeader, $newHeader);
        $wgOut->addHTML("<hr /><h2>{$this->mPagetitle}</h2>\n");
        if (!$this->newRev->isCurrent()) {
            $oldEditSectionSetting = $wgOut->mParserOptions->setEditSection(false);
        }
        $wgOut->addWikiText($this->mNewtext);
        if (!$this->newRev->isCurrent()) {
            $wgOut->mParserOptions->setEditSection($oldEditSectionSetting);
        }
        wfProfileOut($fname);
    }