From 3b32851a94207e5f1903d0db047c4ab4f775e617 Mon Sep 17 00:00:00 2001 From: Robin Pepermans Date: Thu, 16 Feb 2012 16:05:43 +0000 Subject: [PATCH] (Bug 31417) Content-holding div needs an ID. Since the introduction of the class mw-content-ltr/rtl, it has been used to get the page text which is very bad because there are two class names and it is not always on the same place (if at all). This ID will always hold the bodytext (excluding categories, ArticleFeedback, ...). --- RELEASE-NOTES-1.20 | 2 ++ includes/SkinTemplate.php | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/RELEASE-NOTES-1.20 b/RELEASE-NOTES-1.20 index 106837601d..8ed0ccb246 100644 --- a/RELEASE-NOTES-1.20 +++ b/RELEASE-NOTES-1.20 @@ -17,6 +17,8 @@ production. * (bug 32341) Add upload by URL domain limitation. * &useskin=default will now always display the default skin. Useful for users with a preference for the non-default skin to look at something using the default skin. +* (bug 31417) New ID mw-content-text around the actual page text, without categories, + contentSub, ... The same div often also contains the class mw-content-ltr/rtl. === Bug fixes in 1.20 === * (bug 30245) Use the correct way to construct a log page title. diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 6e370fb95c..b96fe77d7a 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -397,18 +397,23 @@ class SkinTemplate extends Skin { $tpl->set( 'bottomscripts', $this->bottomScripts() ); $tpl->set( 'printfooter', $this->printSource() ); - # Add a
around the body text + # An ID that includes the actual body text; without categories, contentSub, ... + $realBodyAttribs = array( 'id' => 'mw-content-text' ); + + # Add a mw-content-ltr/rtl class to be able to style based on text direction + # when the content is different from the UI language, i.e.: # 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( !in_array( $title->getNamespace(), array( NS_SPECIAL, NS_FILE ) ) && in_array( $request->getVal( 'action', 'view' ), array( 'view', 'historysubmit' ) ) && ( $title->exists() || $title->getNamespace() == NS_MEDIAWIKI ) ) { $pageLang = $title->getPageLanguage(); - $realBodyAttribs = array( 'lang' => $pageLang->getHtmlCode(), 'dir' => $pageLang->getDir(), - 'class' => 'mw-content-'.$pageLang->getDir() ); - $out->mBodytext = Html::rawElement( 'div', $realBodyAttribs, $out->mBodytext ); + $realBodyAttribs['lang'] = $pageLang->getHtmlCode(); + $realBodyAttribs['dir'] = $pageLang->getDir(); + $realBodyAttribs['class'] = 'mw-content-'.$pageLang->getDir(); } + $out->mBodytext = Html::rawElement( 'div', $realBodyAttribs, $out->mBodytext ); $tpl->setRef( 'bodytext', $out->mBodytext ); # Language links -- 2.20.1