From 6eb0ed92076f4a3409e997deb0b57d6819df03b8 Mon Sep 17 00:00:00 2001 From: Ilmari Karonen Date: Sun, 6 Feb 2011 21:08:48 +0000 Subject: [PATCH] (bug 23315) Add new body classes to allow easier styling of special pages. 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 | 1 + includes/OutputPage.php | 12 ++---------- includes/Skin.php | 7 +++++++ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 3c2defafdd..fd06eebe3a 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 36b6124946..441c069a55 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -2368,16 +2368,8 @@ class OutputPage { # A 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 ) ); diff --git a/includes/Skin.php b/includes/Skin.php index 6623d26650..cf3f69d9c7 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -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 { -- 2.20.1