Introduce $wgBetterDirectionality that lets us work on support for rtl ui in ltr wiki and vice versa.
This commit is contained in:
parent
304366de8b
commit
55493f65e8
6 changed files with 30 additions and 10 deletions
|
|
@ -2282,6 +2282,12 @@ $wgVectorExtraStyles = null;
|
|||
*/
|
||||
$wgEdititis = false;
|
||||
|
||||
/**
|
||||
* Experimental better directionality support.
|
||||
*/
|
||||
$wgBetterDirectionality = false;
|
||||
|
||||
|
||||
/** @} */ # End of output format settings }
|
||||
|
||||
/*************************************************************************//**
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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 '';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue