Note that jquery.json will be removed in 1.25
[lhc/web/wiklou.git] / includes / EditPage.php
index 98e0ec4..3d57e95 100644 (file)
@@ -2236,14 +2236,15 @@ class EditPage {
                        $username = $parts[0];
                        $user = User::newFromName( $username, false /* allow IP users*/ );
                        $ip = User::isIP( $username );
+                       $block = Block::newFromTarget( $user, $user );
                        if ( !( $user && $user->isLoggedIn() ) && !$ip ) { # User does not exist
                                $wgOut->wrapWikiMsg( "<div class=\"mw-userpage-userdoesnotexist error\">\n$1\n</div>",
                                        array( 'userpage-userdoesnotexist', wfEscapeWikiText( $username ) ) );
-                       } elseif ( $user->isBlocked() ) { # Show log extract if the user is currently blocked
+                       } elseif ( !is_null( $block ) && $block->getType() != Block::TYPE_AUTO ) { # Show log extract if the user is currently blocked
                                LogEventsList::showLogExtract(
                                        $wgOut,
                                        'block',
-                                       $user->getUserPage(),
+                                       MWNamespace::getCanonicalName( NS_USER ) . ':' . $block->getTarget(),
                                        '',
                                        array(
                                                'lim' => 1,
@@ -2621,6 +2622,7 @@ class EditPage {
         */
        protected function showHeader() {
                global $wgOut, $wgUser, $wgMaxArticleSize, $wgLang;
+               global $wgAllowUserCss, $wgAllowUserJs;
 
                if ( $this->mTitle->isTalkPage() ) {
                        $wgOut->addWikiMsg( 'talkpagetext' );
@@ -2721,14 +2723,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' )
@@ -3451,6 +3453,7 @@ HTML
         */
        function getPreviewText() {
                global $wgOut, $wgUser, $wgRawHtml, $wgLang;
+               global $wgAllowUserCss, $wgAllowUserJs;
 
                wfProfileIn( __METHOD__ );
 
@@ -3516,8 +3519,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;
                                }
@@ -3555,7 +3564,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() );
@@ -3830,46 +3839,34 @@ HTML
        public function getEditButtons( &$tabindex ) {
                $buttons = array();
 
-               // @todo FIXME: Hardcoded square brackets.
-               $temp = array(
+               $attribs = array(
                        'id' => 'wpSave',
                        'name' => 'wpSave',
                        'type' => 'submit',
                        'tabindex' => ++$tabindex,
                        'value' => wfMessage( 'savearticle' )->text(),
-                       'accesskey' => wfMessage( 'accesskey-save' )->text(),
-                       'title' => wfMessage( 'tooltip-save' )->text()
-                               . ' [' . wfMessage( 'accesskey-save' )->text() . ']',
-               );
-               $buttons['save'] = Xml::element( 'input', $temp, '' );
+               ) + Linker::tooltipAndAccesskeyAttribs( 'save' );
+               $buttons['save'] = Xml::element( 'input', $attribs, '' );
 
                ++$tabindex; // use the same for preview and live preview
-               // @todo FIXME: Hardcoded square brackets.
-               $temp = array(
+               $attribs = array(
                        'id' => 'wpPreview',
                        'name' => 'wpPreview',
                        'type' => 'submit',
                        'tabindex' => $tabindex,
                        'value' => wfMessage( 'showpreview' )->text(),
-                       'accesskey' => wfMessage( 'accesskey-preview' )->text(),
-                       'title' => wfMessage( 'tooltip-preview' )->text()
-                               . ' [' . wfMessage( 'accesskey-preview' )->text() . ']',
-               );
-               $buttons['preview'] = Xml::element( 'input', $temp, '' );
+               ) + Linker::tooltipAndAccesskeyAttribs( 'preview' );
+               $buttons['preview'] = Xml::element( 'input', $attribs, '' );
                $buttons['live'] = '';
 
-               // @todo FIXME: Hardcoded square brackets.
-               $temp = array(
+               $attribs = array(
                        'id' => 'wpDiff',
                        'name' => 'wpDiff',
                        'type' => 'submit',
                        'tabindex' => ++$tabindex,
                        'value' => wfMessage( 'showdiff' )->text(),
-                       'accesskey' => wfMessage( 'accesskey-diff' )->text(),
-                       'title' => wfMessage( 'tooltip-diff' )->text()
-                               . ' [' . wfMessage( 'accesskey-diff' )->text() . ']',
-               );
-               $buttons['diff'] = Xml::element( 'input', $temp, '' );
+               ) + Linker::tooltipAndAccesskeyAttribs( 'diff' );
+               $buttons['diff'] = Xml::element( 'input', $attribs, '' );
 
                wfRunHooks( 'EditPageBeforeEditButtons', array( &$this, &$buttons, &$tabindex ) );
                return $buttons;