Revert "Follow-up ee320648fd1: output mw-content-{ltr,rtl} unconditionally"
authorCatrope <roan.kattouw@gmail.com>
Fri, 15 May 2015 16:56:50 +0000 (16:56 +0000)
committerCatrope <roan.kattouw@gmail.com>
Fri, 15 May 2015 18:37:15 +0000 (18:37 +0000)
This reverts commit 143c81451eb841b8dfc886dcc6c5d794837b4fc2.

Applying mw-content-{ltr,rtl} to non-view pages caused problems, like
on the history page. MediaWiki:*.js pages always have ltr as their content
directionality, but the history page should be in the UI directionality
regardless of what the content directionality of the page is (since
none of the page content is even displayed!)

Bug: T99258
Change-Id: I87dea50e00b0833f077418ac8581d909f0b77746

includes/skins/SkinTemplate.php

index d7e0132..5364719 100644 (file)
@@ -421,11 +421,15 @@ class SkinTemplate extends Skin {
                $realBodyAttribs = array( 'id' => 'mw-content-text' );
 
                # Add a mw-content-ltr/rtl class to be able to style based on text direction
-               # when the content is different from the UI language
-               $pageLang = $title->getPageViewLanguage();
-               $realBodyAttribs['lang'] = $pageLang->getHtmlCode();
-               $realBodyAttribs['dir'] = $pageLang->getDir();
-               $realBodyAttribs['class'] = 'mw-content-' . $pageLang->getDir();
+               # when the content is different from the UI language, i.e.:
+               # not for special pages or file pages AND only when viewing
+               if ( !in_array( $title->getNamespace(), array( NS_SPECIAL, NS_FILE ) ) &&
+                       Action::getActionName( $this ) === 'view' ) {
+                       $pageLang = $title->getPageViewLanguage();
+                       $realBodyAttribs['lang'] = $pageLang->getHtmlCode();
+                       $realBodyAttribs['dir'] = $pageLang->getDir();
+                       $realBodyAttribs['class'] = 'mw-content-' . $pageLang->getDir();
+               }
 
                $out->mBodytext = Html::rawElement( 'div', $realBodyAttribs, $out->mBodytext );
                $tpl->setRef( 'bodytext', $out->mBodytext );