Merge "Removed redundant begin/commit calls"
[lhc/web/wiklou.git] / includes / EditPage.php
index ca11f16..4642320 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * Page edition user interface.
+ * User interface for page editing.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -797,9 +797,13 @@ class EditPage {
                                // suhosin.request.max_value_length (d'oh)
                                $this->incompleteForm = true;
                        } else {
-                               // edittime should be one of our last fields; if it's missing,
-                               // the submission probably broke somewhere in the middle.
-                               $this->incompleteForm = is_null( $this->edittime );
+                               // If we receive the last parameter of the request, we can fairly
+                               // claim the POST request has not been truncated.
+
+                               // TODO: softened the check for cutover.  Once we determine
+                               // that it is safe, we should complete the transition by
+                               // removing the "edittime" clause.
+                               $this->incompleteForm = ( !$request->getVal( 'wpUltimateParam' ) && is_null( $this->edittime ) );
                        }
                        if ( $this->incompleteForm ) {
                                # If the form is incomplete, force to preview.
@@ -2302,7 +2306,7 @@ class EditPage {
                        if ( $title instanceof Title && $title->exists() && $title->userCan( 'read' ) ) {
                                global $wgOut;
                                // Added using template syntax, to take <noinclude>'s into account.
-                               $wgOut->addWikiTextTitleTidy( '{{:' . $title->getFullText() . '}}', $this->mTitle );
+                               $wgOut->addWikiTextTitleTidy( '<div class="mw-editintro">{{:' . $title->getFullText() . '}}</div>', $this->mTitle );
                                return true;
                        }
                }
@@ -2584,6 +2588,9 @@ class EditPage {
                        }
                }
 
+               // Marker for detecting truncated form data.  This must be the last
+               // parameter sent in order to be of use, so do not move me.
+               $wgOut->addHTML( Html::hidden( 'wpUltimateParam', true ) );
                $wgOut->addHTML( $this->editFormTextBottom . "\n</form>\n" );
 
                if ( !$wgUser->getOption( 'previewontop' ) ) {
@@ -2614,6 +2621,7 @@ class EditPage {
         */
        protected function showHeader() {
                global $wgOut, $wgUser, $wgMaxArticleSize, $wgLang;
+               global $wgAllowUserCss, $wgAllowUserJs;
 
                if ( $this->mTitle->isTalkPage() ) {
                        $wgOut->addWikiMsg( 'talkpagetext' );
@@ -2714,14 +2722,14 @@ class EditPage {
                                        );
                                }
                                if ( $this->formtype !== 'preview' ) {
-                                       if ( $this->isCssSubpage ) {
+                                       if ( $this->isCssSubpage && $wgAllowUserCss ) {
                                                $wgOut->wrapWikiMsg(
                                                        "<div id='mw-usercssyoucanpreview'>\n$1\n</div>",
                                                        array( 'usercssyoucanpreview' )
                                                );
                                        }
 
-                                       if ( $this->isJsSubpage ) {
+                                       if ( $this->isJsSubpage && $wgAllowUserJs ) {
                                                $wgOut->wrapWikiMsg(
                                                        "<div id='mw-userjsyoucanpreview'>\n$1\n</div>",
                                                        array( 'userjsyoucanpreview' )
@@ -3444,6 +3452,7 @@ HTML
         */
        function getPreviewText() {
                global $wgOut, $wgUser, $wgRawHtml, $wgLang;
+               global $wgAllowUserCss, $wgAllowUserJs;
 
                wfProfileIn( __METHOD__ );
 
@@ -3509,8 +3518,14 @@ HTML
 
                                if ( $content->getModel() == CONTENT_MODEL_CSS ) {
                                        $format = 'css';
+                                       if ( $level === 'user' && !$wgAllowUserCss ) {
+                                               $format = false;
+                                       }
                                } elseif ( $content->getModel() == CONTENT_MODEL_JAVASCRIPT ) {
                                        $format = 'js';
+                                       if ( $level === 'user' && !$wgAllowUserJs ) {
+                                               $format = false;
+                                       }
                                } else {
                                        $format = false;
                                }
@@ -3548,7 +3563,7 @@ HTML
 
                        $previewHTML = $parserOutput->getText();
                        $this->mParserOutput = $parserOutput;
-                       $wgOut->addParserOutputNoText( $parserOutput );
+                       $wgOut->addParserOutputMetadata( $parserOutput );
 
                        if ( count( $parserOutput->getWarnings() ) ) {
                                $note .= "\n\n" . implode( "\n\n", $parserOutput->getWarnings() );