From: Brion Vibber Date: Sun, 10 Aug 2008 19:48:30 +0000 (+0000) Subject: Cleanup for r39054 "Bug 15079, 'Add class="ns-talk" / "ns-subject" to ', also... X-Git-Tag: 1.31.0-rc.0~45965 X-Git-Url: http://git.cyclocoop.org//%27%40script%40/%27?a=commitdiff_plain;h=f19dca7bba7fc9334528141f4a923782e42db800;p=lhc%2Fweb%2Fwiklou.git Cleanup for r39054 "Bug 15079, 'Add class="ns-talk" / "ns-subject" to ', also added ns-special for special pages." * Avoid code duplication between Skin and SkinTemplate * Encapsulate namespace class logic into one function * Split giant huge line of ?:s with legible code :) --- diff --git a/includes/Skin.php b/includes/Skin.php index d4d4bdea34..abf2bb7e1a 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -588,13 +588,25 @@ END; } $a['onload'] = $wgOut->getOnloadHandler(); $a['class'] = - 'mediawiki ns-'.$wgTitle->getNamespace(). + 'mediawiki' . + ' '.$this->getNamespaceClasses( $wgTitle ) . ' '.( $wgContLang->isRTL() ? "rtl" : "ltr" ). ' '.Sanitizer::escapeClass( 'page-'.$wgTitle->getPrefixedText() ). - ' '. $wgTitle->isTalkPage() ? "ns-talk" : ( $wgTitle->getNamespace() == NS_SPECIAL ? "ns-special" : "ns-subject" ) . ' skin-'. Sanitizer::escapeClass( $this->getSkinName( ) ); return $a; } + + function getNamespaceClasses( $title ) { + $numeric = 'ns-'.$title->getNamespace(); + if( $title->getNamespace() == NS_SPECIAL ) { + $type = "ns-special"; + } elseif( $title->isTalkPage() ) { + $type = "ns-talk"; + } else { + $type = "ns-subject"; + } + return "$numeric $type"; + } /** * URL to the logo diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index cbe7a71970..c1b7cf9b3f 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -192,7 +192,6 @@ class SkinTemplate extends Skin { $tpl->set( 'pagetitle', $wgOut->getHTMLTitle() ); $tpl->set( 'displaytitle', $wgOut->mPageLinkTitle ); $tpl->set( 'pageclass', Sanitizer::escapeClass( 'page-'.$this->mTitle->getPrefixedText() ) ); - $tpl->set( 'talkclass', ( $wgTitle->isTalkPage() ? "ns-talk" : ( $wgTitle->getNamespace() == NS_SPECIAL ? "ns-special" : "ns-subject" ) ) ); $tpl->set( 'skinnameclass', ( "skin-" . Sanitizer::escapeClass( $this->getSkinName ( ) ) ) ); $nsname = isset( $wgCanonicalNamespaceNames[ $this->mTitle->getNamespace() ] ) ? @@ -255,7 +254,7 @@ class SkinTemplate extends Skin { $tpl->set( 'handheld', $wgRequest->getBool( 'handheld' ) ); $tpl->set( 'csslinks', $this->buildCssLinks() ); $tpl->setRef( 'loggedin', $this->loggedin ); - $tpl->set('nsclass', 'ns-'.$this->mTitle->getNamespace()); + $tpl->set( 'nsclass', $this->getNamespaceClasses( $this->mTitle ) ); $tpl->set('notspecialpage', $this->mTitle->getNamespace() != NS_SPECIAL); /* XXX currently unused, might get useful later $tpl->set( "editable", ($this->mTitle->getNamespace() != NS_SPECIAL ) ); diff --git a/skins/MonoBook.php b/skins/MonoBook.php index fc37c99c92..00399b16ab 100644 --- a/skins/MonoBook.php +++ b/skins/MonoBook.php @@ -104,7 +104,7 @@ class MonoBookTemplate extends QuickTemplate { data['body_ondblclick']) { ?> ondblclick="text('body_ondblclick') ?>" data['body_onload']) { ?> onload="text('body_onload') ?>" - class="mediawiki text('nsclass') ?> text('dir') ?> text('pageclass') ?> text('talkclass') ?> text('skinnameclass') ?>"> + class="mediawiki text('nsclass') ?> text('dir') ?> text('pageclass') ?> text('skinnameclass') ?>">