Merge "PLURAL support for list lengths in default-skin-not-found"
[lhc/web/wiklou.git] / includes / EditPage.php
index 6789259..e113426 100644 (file)
@@ -377,9 +377,6 @@ class EditPage {
        /** @var bool */
        protected $edit;
 
-       /** @var bool */
-       public $live;
-
        /**
         * @param Article $article
         */
@@ -478,11 +475,6 @@ class EditPage {
                $this->importFormData( $wgRequest );
                $this->firsttime = false;
 
-               if ( $this->live ) {
-                       $this->livePreview();
-                       return;
-               }
-
                if ( wfReadOnly() && $this->save ) {
                        // Force preview
                        $this->save = false;
@@ -801,8 +793,7 @@ class EditPage {
                                wfDebug( "POST DATA: " . var_export( $_POST, true ) . "\n" );
                                $this->preview = true;
                        } else {
-                               /* Fallback for live preview */
-                               $this->preview = $request->getCheck( 'wpPreview' ) || $request->getCheck( 'wpLivePreview' );
+                               $this->preview = $request->getCheck( 'wpPreview' );
                                $this->diff = $request->getCheck( 'wpDiff' );
 
                                // Remember whether a save was requested, so we can indicate
@@ -915,7 +906,6 @@ class EditPage {
                 *   allowed.
                 */
 
-               $this->live = $request->getCheck( 'live' );
                $this->editintro = $request->getText( 'editintro',
                        // Custom edit intro for new sections
                        $this->section === 'new' ? 'MediaWiki:addsection-editintro' : '' );
@@ -2098,6 +2088,9 @@ class EditPage {
                        $displayTitle = $contextTitle->getPrefixedText();
                }
                $wgOut->setPageTitle( wfMessage( $msg, $displayTitle ) );
+               # Transmit the name of the message to JavaScript for live preview
+               # Keep Resources.php/mediawiki.action.edit.preview in sync with the possible keys
+               $wgOut->addJsConfigVars( 'wgEditMessage', $msg );
        }
 
        /**
@@ -2555,7 +2548,19 @@ class EditPage {
                }
 
                // Add edit notices
-               $wgOut->addHTML( implode( "\n", $this->mTitle->getEditNotices( $this->oldid ) ) );
+               $editNotices = $this->mTitle->getEditNotices( $this->oldid );
+               if ( count( $editNotices ) ) {
+                       $wgOut->addHTML( implode( "\n", $editNotices ) );
+               } else {
+                       $msg = wfMessage( 'editnotice-notext' );
+                       if ( !$msg->isDisabled() ) {
+                               $wgOut->addHTML(
+                                       '<div class="mw-editnotice-notext">'
+                                       . $msg->parseAsBlock()
+                                       . '</div>'
+                               );
+                       }
+               }
 
                if ( $this->isConflict ) {
                        $wgOut->wrapWikiMsg( "<div class='mw-explainconflict'>\n$1\n</div>", 'explainconflict' );
@@ -2665,19 +2670,21 @@ class EditPage {
                                                array( 'userinvalidcssjstitle', $this->mTitle->getSkinFromCssJsSubpage() )
                                        );
                                }
-                               if ( $this->formtype !== 'preview' ) {
-                                       if ( $this->isCssSubpage && $wgAllowUserCss ) {
-                                               $wgOut->wrapWikiMsg(
-                                                       "<div id='mw-usercssyoucanpreview'>\n$1\n</div>",
-                                                       array( 'usercssyoucanpreview' )
-                                               );
-                                       }
+                               if ( $this->getTitle()->isSubpageOf( $wgUser->getUserPage() ) ) {
+                                       if ( $this->formtype !== 'preview' ) {
+                                               if ( $this->isCssSubpage && $wgAllowUserCss ) {
+                                                       $wgOut->wrapWikiMsg(
+                                                               "<div id='mw-usercssyoucanpreview'>\n$1\n</div>",
+                                                               array( 'usercssyoucanpreview' )
+                                                       );
+                                               }
 
-                                       if ( $this->isJsSubpage && $wgAllowUserJs ) {
-                                               $wgOut->wrapWikiMsg(
-                                                       "<div id='mw-userjsyoucanpreview'>\n$1\n</div>",
-                                                       array( 'userjsyoucanpreview' )
-                                               );
+                                               if ( $this->isJsSubpage && $wgAllowUserJs ) {
+                                                       $wgOut->wrapWikiMsg(
+                                                               "<div id='mw-userjsyoucanpreview'>\n$1\n</div>",
+                                                               array( 'userjsyoucanpreview' )
+                                                       );
+                                               }
                                        }
                                }
                        }
@@ -2996,6 +3003,12 @@ HTML
 
                if ( $this->formtype == 'preview' ) {
                        $this->showPreview( $previewOutput );
+               } else {
+                       // Empty content container for LivePreview
+                       $pageViewLang = $this->mTitle->getPageViewLanguage();
+                       $attribs = array( 'lang' => $pageViewLang->getHtmlCode(), 'dir' => $pageViewLang->getDir(),
+                               'class' => 'mw-content-' . $pageViewLang->getDir() );
+                       $wgOut->addHTML( Html::rawElement( 'div', $attribs ) );
                }
 
                $wgOut->addHTML( '</div>' );
@@ -3803,36 +3816,6 @@ HTML
                return $buttons;
        }
 
-       /**
-        * Output preview text only. This can be sucked into the edit page
-        * via JavaScript, and saves the server time rendering the skin as
-        * well as theoretically being more robust on the client (doesn't
-        * disturb the edit box's undo history, won't eat your text on
-        * failure, etc).
-        *
-        * @todo This doesn't include category or interlanguage links.
-        *       Would need to enhance it a bit, "<s>maybe wrap them in XML
-        *       or something...</s>" that might also require more skin
-        *       initialization, so check whether that's a problem.
-        */
-       function livePreview() {
-               global $wgOut;
-               $wgOut->disable();
-               header( 'Content-type: text/xml; charset=utf-8' );
-               header( 'Cache-control: no-cache' );
-
-               $previewText = $this->getPreviewText();
-               #$categories = $skin->getCategoryLinks();
-
-               $s =
-                       '<?xml version="1.0" encoding="UTF-8" ?>' . "\n" .
-                       Xml::tags( 'livepreview', null,
-                               Xml::element( 'preview', null, $previewText )
-                               #.      Xml::element( 'category', null, $categories )
-                       );
-               echo $s;
-       }
-
        /**
         * Creates a basic error page which informs the user that
         * they have attempted to edit a nonexistent section.
@@ -4003,7 +3986,7 @@ HTML
                                // breaks one of the entities whilst editing.
                                if ( ( substr( $invalue, $i, 1 ) == ";" ) && ( strlen( $hexstring ) <= 6 ) ) {
                                        $codepoint = hexdec( $hexstring );
-                                       $result .= codepointToUtf8( $codepoint );
+                                       $result .= UtfNormal\Utils::codepointToUtf8( $codepoint );
                                } else {
                                        $result .= "&#x" . $hexstring . substr( $invalue, $i, 1 );
                                }