Check for $wgAllowUserCss and $wgAllowUserJs in EditPage.php
authorwithoutaname <drevitchi@gmail.com>
Mon, 16 Jun 2014 19:33:50 +0000 (12:33 -0700)
committerWithoutaname <drevitchi@gmail.com>
Fri, 20 Jun 2014 18:16:11 +0000 (18:16 +0000)
This change checks for the truth values of $wgAllowUserCss and
$wgAllowUserJs before displaying the system/preview messages
userjsyoucanpreview, usercssyoucanpreview, userjspreview and
usercsspreview; if false, it will simply display the standard
messages used by other wiki pages.

Change-Id: I6a5fa8b29010f26435125479e72c423b5e4290f8

includes/EditPage.php

index 98e0ec4..2cd335d 100644 (file)
@@ -2621,6 +2621,7 @@ class EditPage {
         */
        protected function showHeader() {
                global $wgOut, $wgUser, $wgMaxArticleSize, $wgLang;
+               global $wgAllowUserCss, $wgAllowUserJs;
 
                if ( $this->mTitle->isTalkPage() ) {
                        $wgOut->addWikiMsg( 'talkpagetext' );
@@ -2721,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' )
@@ -3451,6 +3452,7 @@ HTML
         */
        function getPreviewText() {
                global $wgOut, $wgUser, $wgRawHtml, $wgLang;
+               global $wgAllowUserCss, $wgAllowUserJs;
 
                wfProfileIn( __METHOD__ );
 
@@ -3516,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;
                                }