More style cleanup -- encapsulate the page name class along with the naemspace classes.
authorBrion Vibber <brion@users.mediawiki.org>
Sun, 10 Aug 2008 20:10:37 +0000 (20:10 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Sun, 10 Aug 2008 20:10:37 +0000 (20:10 +0000)
* Reduce code duplication
* Fix Modern class since my last commit
* Update offline skin for DumpHTML

includes/Skin.php
includes/SkinTemplate.php
skins/Modern.php
skins/MonoBook.php

index abf2bb7..68b1798 100644 (file)
@@ -589,14 +589,13 @@ END;
                $a['onload'] = $wgOut->getOnloadHandler();
                $a['class'] =
                        'mediawiki' .
-                       ' '.$this->getNamespaceClasses( $wgTitle ) .
                        ' '.( $wgContLang->isRTL() ? "rtl" : "ltr" ).
-                       ' '.Sanitizer::escapeClass( 'page-'.$wgTitle->getPrefixedText() ).
+                       ' '.$this->getPageClasses( $wgTitle ) .
                        ' skin-'. Sanitizer::escapeClass( $this->getSkinName( ) );
                return $a;
        }
        
-       function getNamespaceClasses( $title ) {
+       function getPageClasses( $title ) {
                $numeric = 'ns-'.$title->getNamespace();
                if( $title->getNamespace() == NS_SPECIAL ) {
                        $type = "ns-special";
@@ -605,7 +604,8 @@ END;
                } else {
                        $type = "ns-subject";
                }
-               return "$numeric $type";
+               $name = Sanitizer::escapeClass( 'page-'.$title->getPrefixedText() );
+               return "$numeric $type $name";
        }
 
        /**
index c1b7cf9..53f99a4 100644 (file)
@@ -191,7 +191,7 @@ class SkinTemplate extends Skin {
                $tpl->set( 'title', $wgOut->getPageTitle() );
                $tpl->set( 'pagetitle', $wgOut->getHTMLTitle() );
                $tpl->set( 'displaytitle', $wgOut->mPageLinkTitle );
-               $tpl->set( 'pageclass', Sanitizer::escapeClass( 'page-'.$this->mTitle->getPrefixedText() ) );
+               $tpl->set( 'pageclass', $this->getPageClasses( $this->mTitle ) );
                $tpl->set( 'skinnameclass', ( "skin-" . Sanitizer::escapeClass( $this->getSkinName ( ) ) ) );
 
                $nsname = isset( $wgCanonicalNamespaceNames[ $this->mTitle->getNamespace() ] ) ?
@@ -254,7 +254,6 @@ class SkinTemplate extends Skin {
                $tpl->set( 'handheld', $wgRequest->getBool( 'handheld' ) );
                $tpl->set( 'csslinks', $this->buildCssLinks() );
                $tpl->setRef( 'loggedin', $this->loggedin );
-               $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 ) );
index 381de4e..d37086c 100644 (file)
@@ -95,7 +95,7 @@ class ModernTemplate extends QuickTemplate {
        </head>
 <body<?php if($this->data['body_ondblclick']) { ?> ondblclick="<?php $this->text('body_ondblclick') ?>"<?php } ?>
 <?php if($this->data['body_onload'    ]) { ?> onload="<?php     $this->text('body_onload')     ?>"<?php } ?>
- class="mediawiki <?php $this->text('nsclass') ?> <?php $this->text('dir') ?> <?php $this->text('pageclass') ?> <?php $this->text('talkclass') ?> <?php $this->text('skinnameclass') ?>">
+ class="mediawiki <?php $this->text('dir') ?> <?php $this->text('pageclass') ?> <?php $this->text('skinnameclass') ?>">
 
        <!-- heading -->
        <div id="mw_header"><h1 id="firstHeading"><?php $this->data['displaytitle']!=""?$this->html('title'):$this->text('title') ?></h1></div>
index 00399b1..2c02d68 100644 (file)
@@ -104,7 +104,7 @@ class MonoBookTemplate extends QuickTemplate {
        </head>
 <body<?php if($this->data['body_ondblclick']) { ?> ondblclick="<?php $this->text('body_ondblclick') ?>"<?php } ?>
 <?php if($this->data['body_onload']) { ?> onload="<?php $this->text('body_onload') ?>"<?php } ?>
- class="mediawiki <?php $this->text('nsclass') ?> <?php $this->text('dir') ?> <?php $this->text('pageclass') ?> <?php $this->text('skinnameclass') ?>">
+ class="mediawiki <?php $this->text('dir') ?> <?php $this->text('pageclass') ?> <?php $this->text('skinnameclass') ?>">
        <div id="globalWrapper">
                <div id="column-content">
        <div id="content">