Redo r107066 properly: apply CSSJanus to user CSS previews when needed. Ping r94421
authorRoan Kattouw <catrope@users.mediawiki.org>
Wed, 4 Jan 2012 20:01:29 +0000 (20:01 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Wed, 4 Jan 2012 20:01:29 +0000 (20:01 +0000)
includes/OutputPage.php

index 05b3bf0..090a08b 100644 (file)
@@ -3166,7 +3166,8 @@ $templates
         * @return string
         */
        public function buildCssLinks() {
-               global $wgUseSiteCss, $wgAllowUserCss, $wgAllowUserCssPrefs;
+               global $wgUseSiteCss, $wgAllowUserCss, $wgAllowUserCssPrefs,
+                       $wgLang, $wgContLang;
 
                $this->getSkin()->setupSkinUserCss( $this );
 
@@ -3195,8 +3196,15 @@ $templates
                                $otherTags .= $this->makeResourceLoaderLink( 'user', ResourceLoaderModule::TYPE_STYLES, false,
                                        array( 'excludepage' => $this->getTitle()->getPrefixedDBkey() )
                                );
+                               
                                // Load the previewed CSS
-                               $otherTags .= Html::inlineStyle( $this->getRequest()->getText( 'wpTextbox1' ) );
+                               // If needed, Janus it first. This is user-supplied CSS, so it's
+                               // assumed to be right for the content language directionality.
+                               $previewedCSS = $this->getRequest()->getText( 'wpTextbox1' );
+                               if ( $wgLang->getDir() !== $wgContLang->getDir() ) {
+                                       $previewedCSS = CSSJanus::transform( $previewedCSS, true, false );
+                               }
+                               $otherTags .= Html::inlineStyle( $previewedCSS );
                        } else {
                                // Load the user styles normally
                                $moduleStyles[] = 'user';