Introduce $wgBetterDirectionality that lets us work on support for rtl ui in ltr...
authorNiklas Laxström <nikerabbit@users.mediawiki.org>
Thu, 8 Jul 2010 13:34:03 +0000 (13:34 +0000)
committerNiklas Laxström <nikerabbit@users.mediawiki.org>
Thu, 8 Jul 2010 13:34:03 +0000 (13:34 +0000)
includes/DefaultSettings.php
includes/GlobalFunctions.php
includes/Html.php
includes/OutputPage.php
includes/SkinTemplate.php
skins/Vector.php

index d193611..d5aeebf 100644 (file)
@@ -2282,6 +2282,12 @@ $wgVectorExtraStyles = null;
  */
 $wgEdititis = false;
 
+/**
+ * Experimental better directionality support.
+ */
+$wgBetterDirectionality = false;
+
+
 /** @} */ # End of output format settings }
 
 /*************************************************************************//**
index 5236e20..132519c 100644 (file)
@@ -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.
  *
index fea5fb7..e2bf59d 100644 (file)
@@ -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;
        }
 
        /**
index bf9935c..d5a5402 100644 (file)
@@ -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 '';
                        }
index f24a4dd..b1ea8f6 100644 (file)
@@ -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 = "<div class=\"printfooter\">\n" . $this->printSource() . "</div>\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 );
 
index 96db057..2a7c7c5 100644 (file)
@@ -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