Follow-up to r90265: directionality improvements as part of bug 6100 (under $wgBetter...
authorRobin Pepermans <robin@users.mediawiki.org>
Sat, 18 Jun 2011 13:12:52 +0000 (13:12 +0000)
committerRobin Pepermans <robin@users.mediawiki.org>
Sat, 18 Jun 2011 13:12:52 +0000 (13:12 +0000)
* 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
includes/diff/DifferenceEngine.php
includes/parser/ParserOptions.php
includes/specials/SpecialAllmessages.php
skins/common/shared.css

index c10dd95..3d87eb7 100644 (file)
@@ -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 ) );
index a43eba9..0306e79 100644 (file)
@@ -506,7 +506,8 @@ CONTROL;
                global $wgOut, $wgUser;
                wfProfileIn( __METHOD__ );
                # Add "current version as of X" title
-               $wgOut->addHTML( "<hr /><h2>{$this->mPagetitle}</h2>\n" );
+               $wgOut->addHTML( "<hr class='diff-hr' />
+               <h2 class='diff-currentversion-title'>{$this->mPagetitle}</h2>\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 = "<table class='diff'>";
+               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 = "<table class='diff $dirclass'>";
                if ( $diff ) { // Safari/Chrome show broken output if cols not used
                        $header .= "
                        <col class='diff-marker' />
index 0ce4354..49473ca 100644 (file)
@@ -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;
index 78e9c04..d65f25f 100644 (file)
@@ -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 );
index 004b3dc..f3f2bde 100644 (file)
@@ -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;
+}