* @return Skin The current skin
* @todo FIXME : need to check the old failback system [AV]
*/
- function &getSkin( $t = null ) {
- if ( !isset( $this->mSkin ) ) {
- wfProfileIn( __METHOD__ );
-
- global $wgHiddenPrefs;
- if( !in_array( 'skin', $wgHiddenPrefs ) ) {
- # get the user skin
- global $wgRequest;
- $userSkin = $this->getOption( 'skin' );
- $userSkin = $wgRequest->getVal( 'useskin', $userSkin );
- } else {
- # if we're not allowing users to override, then use the default
- global $wgDefaultSkin;
- $userSkin = $wgDefaultSkin;
+ function getSkin( $t = null ) {
+ if ( $t ) {
+ $skin = $this->createSkinObject();
+ $skin->setTitle( $t );
+ return $skin;
+ } else {
+ if ( ! $this->mSkin ) {
+ $this->mSkin = $this->createSkinObject();
}
-
- $this->mSkin = Skin::newFromKey( $userSkin );
- wfProfileOut( __METHOD__ );
- }
- if( $t || !$this->mSkin->getTitle() ) {
- if ( !$t ) {
+
+ if ( ! $this->mSkin->getTitle() ) {
global $wgOut;
$t = $wgOut->getTitle();
+ $this->mSkin->setTitle($t);
}
- $this->mSkin->setTitle( $t );
+
+ return $this->mSkin;
}
- return $this->mSkin;
+ }
+
+ // Creates a Skin object, for getSkin()
+ private function createSkinObject() {
+ wfProfileIn( __METHOD__ );
+
+ global $wgHiddenPrefs;
+ if( !in_array( 'skin', $wgHiddenPrefs ) ) {
+ # get the user skin
+ global $wgRequest;
+ $userSkin = $this->getOption( 'skin' );
+ $userSkin = $wgRequest->getVal( 'useskin', $userSkin );
+ } else {
+ # if we're not allowing users to override, then use the default
+ global $wgDefaultSkin;
+ $userSkin = $wgDefaultSkin;
+ }
+
+ $skin = Skin::newFromKey( $userSkin );
+ wfProfileOut( __METHOD__ );
+
+ return $skin;
}
/**