Merge "Use WikiPage::makeParserOptions() where possible."
[lhc/web/wiklou.git] / includes / EditPage.php
index 528b4a6..2115eb0 100644 (file)
@@ -1295,7 +1295,7 @@ class EditPage {
                                                $this->isConflict = false;
                                                wfDebug( __METHOD__ . ": conflict suppressed; new section\n" );
                                        }
-                               } elseif ( $this->section == '' && $this->userWasLastToEdit( $wgUser->getId(), $this->edittime ) ) {
+                               } elseif ( $this->section == '' && Revision::userWasLastToEdit( DB_MASTER,  $this->mTitle->getArticleID(), $wgUser->getId(), $this->edittime ) ) {
                                        # Suppress edit conflict with self, except for section edits where merging is required.
                                        wfDebug( __METHOD__ . ": Suppressing edit conflict, same user.\n" );
                                        $this->isConflict = false;
@@ -1489,35 +1489,6 @@ class EditPage {
                }
        }
 
-       /**
-        * Check if no edits were made by other users since
-        * the time a user started editing the page. Limit to
-        * 50 revisions for the sake of performance.
-        *
-        * @param $id int
-        * @param $edittime string
-        *
-        * @return bool
-        */
-       protected function userWasLastToEdit( $id, $edittime ) {
-               if ( !$id ) return false;
-               $dbw = wfGetDB( DB_MASTER );
-               $res = $dbw->select( 'revision',
-                       'rev_user',
-                       array(
-                               'rev_page' => $this->mTitle->getArticleID(),
-                               'rev_timestamp > ' . $dbw->addQuotes( $dbw->timestamp( $edittime ) )
-                       ),
-                       __METHOD__,
-                       array( 'ORDER BY' => 'rev_timestamp ASC', 'LIMIT' => 50 ) );
-               foreach ( $res as $row ) {
-                       if ( $row->rev_user != $id ) {
-                               return false;
-                       }
-               }
-               return true;
-       }
-
        /**
         * @private
         * @todo document
@@ -1886,10 +1857,6 @@ class EditPage {
 
                $wgOut->addHTML( $this->editFormTextAfterContent );
 
-               $wgOut->addWikiText( $this->getCopywarn() );
-
-               $wgOut->addHTML( $this->editFormTextAfterWarn );
-
                $this->showStandardInputs();
 
                $this->showFormAfterText();
@@ -2102,8 +2069,11 @@ class EditPage {
                                );
                        }
                }
+               # Add header copyright warning
+               $this->showHeaderCopyrightWarning();
        }
 
+
        /**
         * Standard summary input and label (wgSummary), abstracted so EditPage
         * subclasses may reorganize the form.
@@ -2399,6 +2369,18 @@ HTML
                $wgOut->addHTML( '<div id="wikiDiff">' . $difftext . '</div>' );
        }
 
+       /**
+        * Show the header copyright warning.
+        */
+       protected function showHeaderCopyrightWarning() {
+               $msg = 'editpage-head-copy-warn';
+               if ( !wfMessage( $msg )->isDisabled() ) {
+                       global $wgOut;
+                       $wgOut->wrapWikiMsg( "<div class='editpage-head-copywarn'>\n$1\n</div>",
+                               'editpage-head-copy-warn' );
+               }
+       }
+
        /**
         * Give a chance for site and per-namespace customizations of
         * terms of service summary link that might exist separately
@@ -2448,7 +2430,7 @@ HTML
                wfRunHooks( 'EditPageCopyrightWarning', array( $title, &$copywarnMsg ) );
 
                return "<div id=\"editpage-copywarn\">\n" .
-                       call_user_func_array( "wfMsgNoTrans", $copywarnMsg ) . "\n</div>";
+                       call_user_func_array( 'wfMessage', $copywarnMsg )->plain() . "\n</div>";
        }
 
        protected function showStandardInputs( &$tabindex = 2 ) {
@@ -2463,6 +2445,11 @@ HTML
                $checkboxes = $this->getCheckboxes( $tabindex,
                        array( 'minor' => $this->minoredit, 'watch' => $this->watchthis ) );
                $wgOut->addHTML( "<div class='editCheckboxes'>" . implode( $checkboxes, "\n" ) . "</div>\n" );
+
+               // Show copyright warning.
+               $wgOut->addWikiText( $this->getCopywarn() );
+               $wgOut->addHTML( $this->editFormTextAfterWarn );
+
                $wgOut->addHTML( "<div class='editButtons'>\n" );
                $wgOut->addHTML( implode( $this->getEditButtons( $tabindex ), "\n" ) . "\n" );
 
@@ -2473,8 +2460,9 @@ HTML
                $edithelpurl = Skin::makeInternalOrExternalUrl( wfMessage( 'edithelppage' )->inContentLanguage()->text() );
                $edithelp = '<a target="helpwindow" href="' . $edithelpurl . '">' .
                        wfMessage( 'edithelp' )->escaped() . '</a> ' .
-                       wfMessage( 'newwindow' )->escaped();
-               $wgOut->addHTML( "      <span class='editHelp'>{$cancel}{$edithelp}</span>\n" );
+                       wfMessage( 'newwindow' )->parse();
+               $wgOut->addHTML( "      <span class='cancelLink'>{$cancel}</span>\n" );
+               $wgOut->addHTML( "      <span class='editHelp'>{$edithelp}</span>\n" );
                $wgOut->addHTML( "</div><!-- editButtons -->\n</div><!-- editOptions -->\n" );
        }
 
@@ -2614,20 +2602,20 @@ HTML
 
                if ( $this->mTriedSave && !$this->mTokenOk ) {
                        if ( $this->mTokenOkExceptSuffix ) {
-                               $note = wfMessage( 'token_suffix_mismatch' )->text();
+                               $note = wfMessage( 'token_suffix_mismatch' )->plain();
                        } else {
-                               $note = wfMessage( 'session_fail_preview' )->text();
+                               $note = wfMessage( 'session_fail_preview' )->plain();
                        }
                } elseif ( $this->incompleteForm ) {
-                       $note = wfMessage( 'edit_form_incomplete' )->text();
+                       $note = wfMessage( 'edit_form_incomplete' )->plain();
                } else {
                        $note = wfMessage( 'previewnote' )->plain() .
                                ' [[#' . self::EDITFORM_ID . '|' . $wgLang->getArrow() . ' ' . wfMessage( 'continue-editing' )->text() . ']]';
                }
 
-               $parserOptions = ParserOptions::newFromUser( $wgUser );
+               $parserOptions = $this->mArticle->makeParserOptions( $this->mArticle->getContext() );
+
                $parserOptions->setEditSection( false );
-               $parserOptions->setTidy( true );
                $parserOptions->setIsPreview( true );
                $parserOptions->setIsSectionPreview( !is_null( $this->section ) && $this->section !== '' );
 
@@ -2672,8 +2660,6 @@ HTML
 
                        wfRunHooks( 'EditPageGetPreviewText', array( $this, &$toparse ) );
 
-                       $parserOptions->enableLimitReport();
-
                        $toparse = $wgParser->preSaveTransform( $toparse, $this->mTitle, $wgUser, $parserOptions );
                        $parserOutput = $wgParser->parse( $toparse, $this->mTitle, $parserOptions );