From: MatmaRex Date: Mon, 22 Apr 2013 13:57:44 +0000 (+0200) Subject: Clean up the class building logic in OutputPage X-Git-Tag: 1.31.0-rc.0~19819 X-Git-Url: http://git.cyclocoop.org///%22%40url%40//%22?a=commitdiff_plain;h=e60f36bc03cf4529631ad57eaddd92519abd9c1d;p=lhc%2Fweb%2Fwiklou.git Clean up the class building logic in OutputPage Build the classes using an array that is finally imploded, instead of concatenating strings repeatedly. Change-Id: I2a09282d5ba33f131a4311c58e49dab5eefce418 --- diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 2f1f62ee96..3abfff0637 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -2510,20 +2510,29 @@ $templates $ret .= "$closeHead\n"; } - $bodyAttrs = array(); + $bodyClasses = array(); + $bodyClasses[] = 'mediawiki'; # Classes for LTR/RTL directionality support - $bodyAttrs['class'] = "mediawiki $userdir sitedir-$sitedir"; + $bodyClasses[] = $userdir; + $bodyClasses[] = "sitedir-$sitedir"; if ( $this->getLanguage()->capitalizeAllNouns() ) { # A class is probably not the best way to do this . . . - $bodyAttrs['class'] .= ' capitalize-all-nouns'; + $bodyClasses[] = 'capitalize-all-nouns'; } - $bodyAttrs['class'] .= ' ' . $sk->getPageClasses( $this->getTitle() ); - $bodyAttrs['class'] .= ' skin-' . Sanitizer::escapeClass( $sk->getSkinName() ); - $bodyAttrs['class'] .= ' action-' . Sanitizer::escapeClass( Action::getActionName( $this->getContext() ) ); - $sk->addToBodyAttributes( $this, $bodyAttrs ); // Allow skins to add body attributes they need + $bodyClasses[] = $sk->getPageClasses( $this->getTitle() ); + $bodyClasses[] = 'skin-' . Sanitizer::escapeClass( $sk->getSkinName() ); + $bodyClasses[] = 'action-' . Sanitizer::escapeClass( Action::getActionName( $this->getContext() ) ); + + $bodyAttrs = array(); + // While the implode() is not strictly needed, it's used for backwards compatibility + // (this used to be built as a string and hooks likely still expect that). + $bodyAttrs['class'] = implode( ' ', $bodyClasses ); + + // Allow skins and extensions to add body attributes they need + $sk->addToBodyAttributes( $this, $bodyAttrs ); wfRunHooks( 'OutputPageBodyAttributes', array( $this, $sk, &$bodyAttrs ) ); $ret .= Html::openElement( 'body', $bodyAttrs ) . "\n";