Directionality improvements as part of bug 6100 (under $wgBetterDirectionality) for...
authorRobin Pepermans <robin@users.mediawiki.org>
Wed, 22 Jun 2011 13:10:46 +0000 (13:10 +0000)
committerRobin Pepermans <robin@users.mediawiki.org>
Wed, 22 Jun 2011 13:10:46 +0000 (13:10 +0000)
* exclude File namespace from div with lang & dir attributes, since most information on file pages is in the user language
* add <div id="mw-imagepage-content"> around the actual wikitext that is in the content language

includes/ImagePage.php
includes/SkinTemplate.php

index f962a99..b90043e 100644 (file)
@@ -113,7 +113,13 @@ class ImagePage extends Article {
 
                # No need to display noarticletext, we use our own message, output in openShowImage()
                if ( $this->getID() ) {
+                       # When $wgBetterDirectionality is enabled, NS_FILE is in the user language,
+                       # but this section (the actual wikitext) should be in page content language
+                       $pageLang = $this->mTitle->getPageLanguage();
+                       $wgOut->addHTML( Xml::openElement( 'div', array( 'id' => 'mw-imagepage-content',
+                               'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir() ) ) );
                        parent::view();
+                       $wgOut->addHTML( Xml::closeElement( 'div' ) );
                } else {
                        # Just need to set the right headers
                        $wgOut->setArticleFlag( true );
@@ -302,7 +308,7 @@ class ImagePage extends Article {
 
        protected function openShowImage() {
                global $wgOut, $wgUser, $wgImageLimits, $wgRequest,
-                       $wgLang, $wgContLang, $wgEnableUploads;
+                       $wgLang, $wgEnableUploads;
 
                $this->loadFile();
 
@@ -321,7 +327,7 @@ class ImagePage extends Article {
                $maxWidth = $max[0];
                $maxHeight = $max[1];
                $sk = $wgUser->getSkin();
-               $dirmark = $wgContLang->getDirMark();
+               $dirmark = wfUILang()->getDirMark();
 
                if ( $this->displayImg->exists() ) {
                        # image
index 2287bc6..86d3172 100644 (file)
@@ -456,9 +456,9 @@ class SkinTemplate extends Skin {
 
                global $wgBetterDirectionality;
                if ( $wgBetterDirectionality ) {
-                       // not for special pages AND only when viewing AND if the page exists
+                       // not for special pages or file pages AND only when viewing AND if the page exists
                        // (or is in MW namespace, because that has default content)
-                       if( $this->getTitle()->getNamespace() != NS_SPECIAL &&
+                       if( !in_array( $this->getTitle()->getNamespace(), array( NS_SPECIAL, NS_FILE ) ) &&
                                in_array( $action, array( 'view', 'render', 'print' ) ) &&
                                ( $this->getTitle()->exists() || $this->getTitle()->getNamespace() == NS_MEDIAWIKI ) ) {
                                $pageLang = $this->getTitle()->getPageLanguage();