From 9077baef30f8c8d04e830e96227da0bbcb4ad692 Mon Sep 17 00:00:00 2001 From: Robin Pepermans Date: Sat, 18 Jun 2011 13:12:52 +0000 Subject: [PATCH] Follow-up to r90265: directionality improvements as part of bug 6100 (under $wgBetterDirectionality): * Correct directionality when viewing diffs * Correct arrows for Pager * CSS/JS pages always 'en' (LTR) * Messages on Special:Allmessages have lang and dir attributes based on the selected language --- includes/Pager.php | 5 +++-- includes/diff/DifferenceEngine.php | 15 +++++++++++++-- includes/parser/ParserOptions.php | 6 ++++-- includes/specials/SpecialAllmessages.php | 5 ++++- skins/common/shared.css | 22 ++++++++++++++++++++++ 5 files changed, 46 insertions(+), 7 deletions(-) diff --git a/includes/Pager.php b/includes/Pager.php index c10dd9557e..3d87eb736a 100644 --- a/includes/Pager.php +++ b/includes/Pager.php @@ -945,7 +945,7 @@ abstract class TablePager extends IndexPager { * A navigation bar with images */ function getNavigationBar() { - global $wgStylePath, $wgContLang; + global $wgStylePath, $wgContLang, $wgLang, $wgBetterDirectionality; if ( !$this->isNavigationBarShown() ) { return ''; @@ -970,7 +970,8 @@ abstract class TablePager extends IndexPager { 'next' => 'arrow_disabled_right_25.png', 'last' => 'arrow_disabled_last_25.png', ); - if( $wgContLang->isRTL() ) { + $isRTL = ( $wgBetterDirectionality ? $wgLang->isRTL() : $wgContLang->isRTL() ); + if( $isRTL ) { $keys = array_keys( $labels ); $images = array_combine( $keys, array_reverse( $images ) ); $disabledImages = array_combine( $keys, array_reverse( $disabledImages ) ); diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php index a43eba98c9..0306e790b1 100644 --- a/includes/diff/DifferenceEngine.php +++ b/includes/diff/DifferenceEngine.php @@ -506,7 +506,8 @@ CONTROL; global $wgOut, $wgUser; wfProfileIn( __METHOD__ ); # Add "current version as of X" title - $wgOut->addHTML( "

{$this->mPagetitle}

\n" ); + $wgOut->addHTML( "
+

{$this->mPagetitle}

\n" ); # Page content may be handled by a hooked call instead... if ( wfRunHooks( 'ArticleContentOnDiff', array( $this, $wgOut ) ) ) { # Use the current version parser cache if applicable @@ -935,7 +936,17 @@ CONTROL; * @return string */ static function addHeader( $diff, $otitle, $ntitle, $multi = '', $notice = '' ) { - $header = ""; + global $wgBetterDirectionality; + $dirclass = ''; + if( $wgBetterDirectionality ) { + global $wgContLang, $wgOut, $wgTitle; + // shared.css sets diff in interface language/dir, + // but the actual content should be in the page language/dir + $getPageLang = $wgOut->parserOptions()->getTargetLanguage( $wgTitle ); + $pageLang = ( $getPageLang ? $getPageLang : $wgContLang ); + $dirclass = ' diff-contentalign-'.$pageLang->alignStart(); + } + $header = "
"; if ( $diff ) { // Safari/Chrome show broken output if cols not used $header .= " diff --git a/includes/parser/ParserOptions.php b/includes/parser/ParserOptions.php index 0ce4354684..49473cabec 100644 --- a/includes/parser/ParserOptions.php +++ b/includes/parser/ParserOptions.php @@ -67,8 +67,10 @@ class ParserOptions { function getTidy() { return $this->mTidy; } function getInterfaceMessage() { return $this->mInterfaceMessage; } function getTargetLanguage( $title = null ) { - // Parse mediawiki messages with correct target language - if ( $title && $title->getNamespace() == NS_MEDIAWIKI ) { + if ( $title && $title->isCssOrJsPage() ) { + return Language::factory( 'en' ); // css/js should always be LTR + } elseif ( $title && $title->getNamespace() == NS_MEDIAWIKI ) { + // Parse mediawiki messages with correct target language list( /* $unused */, $lang ) = MessageCache::singleton()->figureMessage( $title->getText() ); $obj = wfGetLangObj( $lang ); return $obj; diff --git a/includes/specials/SpecialAllmessages.php b/includes/specials/SpecialAllmessages.php index 78e9c04fc8..d65f25f0d8 100644 --- a/includes/specials/SpecialAllmessages.php +++ b/includes/specials/SpecialAllmessages.php @@ -411,7 +411,10 @@ class AllmessagesTablePager extends TablePager { } function getCellAttrs( $field, $value ){ - if( $this->mCurrentRow->am_customised && $field == 'am_title' ){ + global $wgBetterDirectionality; + if( $field != 'am_title' && $wgBetterDirectionality ) { + return array( 'lang' => $this->langcode, 'dir' => $this->lang->getDir() ); + } elseif( $this->mCurrentRow->am_customised && $field == 'am_title' ) { return array( 'rowspan' => '2', 'class' => $field ); } else { return array( 'class' => $field ); diff --git a/skins/common/shared.css b/skins/common/shared.css index 004b3dce22..f3f2bdea3c 100644 --- a/skins/common/shared.css +++ b/skins/common/shared.css @@ -715,3 +715,25 @@ th.headerSortDown { unicode-bidi: embed; } +#mw-clearyourcache, #mw-sitecsspreview, #mw-sitejsspreview, #mw-usercsspreview, #mw-userjspreview { + direction: ltr; + unicode-bidi: embed; +} + +/* Correct user & content directionality when viewing a diff */ +.diff-currentversion-title, .diff { + direction: ltr; + unicode-bidi: embed; +} +/* @noflip */ .diff-contentalign-right td { + direction: rtl; + unicode-bidi: embed; +} +/* @noflip */ .diff-contentalign-left td { + direction: ltr; + unicode-bidi: embed; +} +.diff-otitle, .diff-ntitle, .diff-lineno { + direction: ltr !important; + unicode-bidi: embed; +} -- 2.20.1