(bug 23315) Add new body classes to allow easier styling of special pages.
authorIlmari Karonen <vyznev@users.mediawiki.org>
Sun, 6 Feb 2011 21:08:48 +0000 (21:08 +0000)
committerIlmari Karonen <vyznev@users.mediawiki.org>
Sun, 6 Feb 2011 21:08:48 +0000 (21:08 +0000)
Also eliminate some duplicate code introduced into SpecialPage::headElement() in r61071 by calling Skin::getPageClasses() instead, and use $sk parameter instead of $wgUser->getSkin() to get skin name.

RELEASE-NOTES
includes/OutputPage.php
includes/Skin.php

index 3c2defa..fd06eeb 100644 (file)
@@ -63,6 +63,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   specified a filename without extension.
 * (bug 26851) Special:UserRights now allows to prefill the reason field
 * New maintenance script to fix double redirects (maintenance/fixDoubleRedirects.php)
+* (bug 23315) New body classes to allow easier styling of special pages
 
 === Bug fixes in 1.18 ===
 * (bug 23119) WikiError class and subclasses are now marked as deprecated
index 36b6124..441c069 100644 (file)
@@ -2368,16 +2368,8 @@ class OutputPage {
                        # A <body> class is probably not the best way to do this . . .
                        $bodyAttrs['class'] .= ' capitalize-all-nouns';
                }
-               $bodyAttrs['class'] .= ' ns-' . $this->getTitle()->getNamespace();
-               if ( $this->getTitle()->getNamespace() == NS_SPECIAL ) {
-                       $bodyAttrs['class'] .= ' ns-special';
-               } elseif ( $this->getTitle()->isTalkPage() ) {
-                       $bodyAttrs['class'] .= ' ns-talk';
-               } else {
-                       $bodyAttrs['class'] .= ' ns-subject';
-               }
-               $bodyAttrs['class'] .= ' ' . Sanitizer::escapeClass( 'page-' . $this->getTitle()->getPrefixedText() );
-               $bodyAttrs['class'] .= ' skin-' . Sanitizer::escapeClass( $wgUser->getSkin()->getSkinName() );
+               $bodyAttrs['class'] .= ' ' . $sk->getPageClasses( $this->getTitle() );
+               $bodyAttrs['class'] .= ' skin-' . Sanitizer::escapeClass( $sk->getSkinName() );
 
                $sk->addToBodyAttributes( $this, $bodyAttrs ); // Allow skins to add body attributes they need
                wfRunHooks( 'OutputPageBodyAttributes', array( $this, $sk, &$bodyAttrs ) );
index 6623d26..cf3f69d 100644 (file)
@@ -652,6 +652,13 @@ abstract class Skin extends Linker {
 
                if ( $title->getNamespace() == NS_SPECIAL ) {
                        $type = 'ns-special';
+                       // bug 23315: provide a class based on the canonical special page name without subpages
+                       list( $canonicalName ) = SpecialPage::resolveAliasWithSubpage( $title->getDBkey() );
+                       if ( $canonicalName ) {
+                               $type .= ' ' . Sanitizer::escapeClass( "special-$canonicalName" );
+                       } else {
+                               $type .= ' mw-invalidspecialpage';
+                       }
                } elseif ( $title->isTalkPage() ) {
                        $type = 'ns-talk';
                } else {