From 55493f65e83b388aed79a0bfb6ca7feb7591a415 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Niklas=20Laxstr=C3=B6m?= Date: Thu, 8 Jul 2010 13:34:03 +0000 Subject: [PATCH] Introduce $wgBetterDirectionality that lets us work on support for rtl ui in ltr wiki and vice versa. --- includes/DefaultSettings.php | 6 ++++++ includes/GlobalFunctions.php | 5 +++++ includes/Html.php | 5 ++++- includes/OutputPage.php | 8 +++----- includes/SkinTemplate.php | 14 +++++++++++--- skins/Vector.php | 2 +- 6 files changed, 30 insertions(+), 10 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index d193611e5d..d5aeebfad5 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -2282,6 +2282,12 @@ $wgVectorExtraStyles = null; */ $wgEdititis = false; +/** + * Experimental better directionality support. + */ +$wgBetterDirectionality = false; + + /** @} */ # End of output format settings } /*************************************************************************//** diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 5236e207ea..132519c40b 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -561,6 +561,11 @@ function wfGetLangObj( $langcode = false ) { return $wgContLang; } +function wfUILang() { + global $wgBetterDirectionality; + return wfGetLangObj( $wgBetterDirectionality ? false: true ); +} + /** * Get a message from anywhere, for the current user language. * diff --git a/includes/Html.php b/includes/Html.php index fea5fb7aca..e2bf59dd23 100644 --- a/includes/Html.php +++ b/includes/Html.php @@ -609,7 +609,10 @@ class Html { $attribs["xmlns:$tag"] = $ns; } } - return $ret . Html::openElement( 'html', $attribs ) . "\n"; + $html = Html::openElement( 'html', $attribs ); + if ( $html ) $html .= "\n"; + $ret .= $html; + return $ret; } /** diff --git a/includes/OutputPage.php b/includes/OutputPage.php index bf9935c3f6..d5a54021b9 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -2099,9 +2099,7 @@ class OutputPage { } $sk->setupUserCss( $this ); - $dir = $wgContLang->getDir(); - $htmlAttribs = array( 'lang' => $wgContLanguageCode, 'dir' => $dir ); - $ret = Html::htmlHeader( $htmlAttribs ); + $ret = Html::htmlHeader( array( 'lang' => wfUILang()->getCode() ) ); if ( $this->getHTMLTitle() == '' ) { $this->setHTMLTitle( wfMsg( 'pagetitle', $this->getPageTitle() ) ); @@ -2156,6 +2154,7 @@ class OutputPage { } # Class bloat + $dir = wfUILang()->getDir(); $bodyAttrs['class'] = "mediawiki $dir"; if ( $wgLang->capitalizeAllNouns() ) { @@ -2427,8 +2426,7 @@ class OutputPage { */ protected function styleLink( $style, $options ) { if( isset( $options['dir'] ) ) { - global $wgContLang; - $siteDir = $wgContLang->getDir(); + $siteDir = wfUILang()->getDir(); if( $siteDir != $options['dir'] ) { return ''; } diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index f24a4dd33f..b1ea8f6b84 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -297,9 +297,12 @@ class SkinTemplate extends Skin { $tpl->setRef( 'scriptpath', $wgScriptPath ); $tpl->setRef( 'serverurl', $wgServer ); $tpl->setRef( 'logopath', $wgLogo ); - $tpl->setRef( 'lang', $wgContLanguageCode ); - $tpl->set( 'dir', $wgContLang->getDir() ); - $tpl->set( 'rtl', $wgContLang->isRTL() ); + + $lang = wfUILang(); + $tpl->set( 'lang', $lang->getCode() ); + $tpl->set( 'dir', $lang->getDir() ); + $tpl->set( 'rtl', $lang->isRTL() ); + $tpl->set( 'capitalizeallnouns', $wgLang->capitalizeAllNouns() ? ' capitalize-all-nouns' : '' ); $tpl->set( 'showjumplinks', $wgUser->getOption( 'showjumplinks' ) ); $tpl->set( 'username', $wgUser->isAnon() ? null : $this->username ); @@ -415,6 +418,11 @@ class SkinTemplate extends Skin { $tpl->set( 'bottomscripts', $this->bottomScripts() ); $printfooter = "
\n" . $this->printSource() . "
\n"; + global $wgBetterDirectionality; + if ( $wgBetterDirectionality ) { + $realBodyAttribs = array( 'lang' => $wgContLanguageCode, 'dir' => $wgContLang->getDir() ); + $out->mBodytext = Html::rawElement( 'div', $realBodyAttribs, $out->mBodytext ); + } $out->mBodytext .= $printfooter . $this->generateDebugHTML(); $tpl->setRef( 'bodytext', $out->mBodytext ); diff --git a/skins/Vector.php b/skins/Vector.php index 96db057d34..2a7c7c5332 100644 --- a/skins/Vector.php +++ b/skins/Vector.php @@ -682,7 +682,7 @@ class VectorTemplate extends QuickTemplate { if ( !is_array( $elements ) ) { $elements = array( $elements ); // If there's a series of elements, reverse them when in RTL mode - } else if ( $wgContLang->isRTL() ) { + } else if ( wfUILang()->isRTL() ) { $elements = array_reverse( $elements ); } // Render elements -- 2.20.1