(Bug 31417) Content-holding div needs an ID.
authorRobin Pepermans <robin@users.mediawiki.org>
Thu, 16 Feb 2012 16:05:43 +0000 (16:05 +0000)
committerRobin Pepermans <robin@users.mediawiki.org>
Thu, 16 Feb 2012 16:05:43 +0000 (16:05 +0000)
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
includes/SkinTemplate.php

index 1068376..8ed0ccb 100644 (file)
@@ -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.
index 6e370fb..b96fe77 100644 (file)
@@ -397,18 +397,23 @@ class SkinTemplate extends Skin {
                $tpl->set( 'bottomscripts', $this->bottomScripts() );
                $tpl->set( 'printfooter', $this->printSource() );
 
-               # Add a <div class="mw-content-ltr/rtl"> 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