From 28ea73bc3a07a4588f1b5fde4f5c41522eaa9518 Mon Sep 17 00:00:00 2001 From: Robin Pepermans Date: Wed, 22 Jun 2011 13:10:46 +0000 Subject: [PATCH] Directionality improvements as part of bug 6100 (under $wgBetterDirectionality) for the File namespace: * exclude File namespace from div with lang & dir attributes, since most information on file pages is in the user language * add
around the actual wikitext that is in the content language --- includes/ImagePage.php | 10 ++++++++-- includes/SkinTemplate.php | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/includes/ImagePage.php b/includes/ImagePage.php index f962a995a0..b90043e312 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -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 diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 2287bc6715..86d3172f6f 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -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(); -- 2.20.1