From: Daniel Friesen Date: Thu, 3 Mar 2011 10:22:46 +0000 (+0000) Subject: Reduce usage of $wgOut inside Skin. X-Git-Tag: 1.31.0-rc.0~31676 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/modifier.php?a=commitdiff_plain;h=bc19677685f1da849325ff0cabbfd2c4b35e8430;p=lhc%2Fweb%2Fwiklou.git Reduce usage of $wgOut inside Skin. --- diff --git a/includes/Skin.php b/includes/Skin.php index 6c563319fc..e8a53c286c 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -653,11 +653,19 @@ abstract class Skin extends Linker { return $wgLogo; } - function getCategoryLinks() { - global $wgOut, $wgUseCategoryBrowser; - global $wgContLang, $wgUser; + /** + * The format without an explicit $out argument is deprecated + */ + function getCategoryLinks( OutputPage $out=null ) { + global $wgUseCategoryBrowser, $wgContLang, $wgUser; - if ( count( $wgOut->mCategoryLinks ) == 0 ) { + if ( is_null( $out ) ) { + // Backwards compatibility for when there was no $out arg + global $wgOut; + $out = $wgOut; + } + + if ( count( $out->mCategoryLinks ) == 0 ) { return ''; } @@ -670,7 +678,7 @@ abstract class Skin extends Linker { $embed = ""; $pop = ''; - $allCats = $wgOut->getCategoryLinks(); + $allCats = $out->getCategoryLinks(); $s = ''; $colon = wfMsgExt( 'colon-separator', 'escapenoentities' ); @@ -745,15 +753,25 @@ abstract class Skin extends Linker { return $return; } - function getCategories() { - $catlinks = $this->getCategoryLinks(); + /** + * The ->getCategories() form is deprecated, please instead use + * the ->getCategories( $out ) form with whatout OutputPage is on hand + */ + function getCategories( OutputPage $out=null ) { + if ( is_null( $out ) ) { + // Backwards compatibility for when there was no $out arg + global $wgOut; + $out = $wgOut; + } + + $catlinks = $this->getCategoryLinks( $out ); $classes = 'catlinks'; - global $wgOut, $wgUser; + global $wgUser; // Check what we're showing - $allCats = $wgOut->getCategoryLinks(); + $allCats = $out->getCategoryLinks(); $showHidden = $wgUser->getBoolOption( 'showhiddencats' ) || $this->mTitle->getNamespace() == NS_CATEGORY; @@ -804,11 +822,11 @@ abstract class Skin extends Linker { * area. * @return String HTML containing debug data, if enabled (otherwise empty). */ - protected function generateDebugHTML() { - global $wgShowDebug, $wgOut; + protected function generateDebugHTML( OutputPage $out ) { + global $wgShowDebug; if ( $wgShowDebug ) { - $listInternals = $this->formatDebugHTML( $wgOut->mDebugtext ); + $listInternals = $this->formatDebugHTML( $out->mDebugtext ); return "\n
\nDebug data:\n"; } @@ -905,16 +923,23 @@ abstract class Skin extends Linker { return ''; } - function subPageSubtitle() { + /** + * The format without an explicit $out argument is deprecated + */ + function subPageSubtitle( OutputPage $out=null ) { + if ( is_null( $out ) ) { + // Backwards compatibility for when there was no $out arg + global $wgOut; + $out = $wgOut; + } + $subpages = ''; - if ( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages, $this ) ) ) { + if ( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages, $this, $out ) ) ) { return $subpages; } - global $wgOut; - - if ( $wgOut->isArticle() && MWNamespace::hasSubpages( $this->mTitle->getNamespace() ) ) { + if ( $out->isArticle() && MWNamespace::hasSubpages( $out->getTitle()->getNamespace() ) ) { $ptext = $this->mTitle->getPrefixedText(); if ( preg_match( '/\//', $ptext ) ) { $links = explode( '/', $ptext ); @@ -1463,9 +1488,16 @@ abstract class Skin extends Linker { /** * Gets new talk page messages for the current user. * @return MediaWiki message or if no new talk page messages, nothing + * The format without an explicit $out argument is deprecated */ - function getNewtalks() { - global $wgUser, $wgOut; + function getNewtalks( OutputPage $out=null ) { + global $wgUser; + + if ( is_null( $out ) ) { + // Backwards compatibility for when there was no $out arg + global $wgOut; + $out = $wgOut; + } $newtalks = $wgUser->getNewMessageLinks(); $ntl = ''; @@ -1474,7 +1506,7 @@ abstract class Skin extends Linker { $userTitle = $this->mUser->getUserPage(); $userTalkTitle = $userTitle->getTalkPage(); - if ( !$userTalkTitle->equals( $this->mTitle ) ) { + if ( !$userTalkTitle->equals( $out->getTitle() ) ) { $newMessagesLink = $this->link( $userTalkTitle, wfMsgHtml( 'newmessageslink' ), @@ -1497,7 +1529,7 @@ abstract class Skin extends Linker { $newMessagesDiffLink ); # Disable Squid cache - $wgOut->setSquidMaxage( 0 ); + $out->setSquidMaxage( 0 ); } } elseif ( count( $newtalks ) ) { // _>" " for BC <= 1.16 @@ -1512,7 +1544,7 @@ abstract class Skin extends Linker { } $parts = implode( $sep, $msgs ); $ntl = wfMsgHtml( 'youhavenewmessagesmulti', $parts ); - $wgOut->setSquidMaxage( 0 ); + $out->setSquidMaxage( 0 ); } return $ntl; diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index c62bafc68e..ce686f6d2c 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -248,7 +248,7 @@ class SkinTemplate extends Skin { $tpl->set( 'isarticle', $out->isArticle() ); $tpl->setRef( 'thispage', $this->thispage ); - $subpagestr = $this->subPageSubtitle(); + $subpagestr = $this->subPageSubtitle( $out ); $tpl->set( 'subtitle', !empty( $subpagestr ) ? '' . $subpagestr . '' . $out->getSubtitle() : @@ -261,7 +261,7 @@ class SkinTemplate extends Skin { '' ); - $tpl->set( 'catlinks', $this->getCategories() ); + $tpl->set( 'catlinks', $this->getCategories( $out ) ); if( $out->isSyndicated() ) { $feeds = array(); foreach( $out->getSyndicationLinks() as $format => $link ) { @@ -334,7 +334,7 @@ class SkinTemplate extends Skin { } } - $newtalks = $this->getNewtalks(); + $newtalks = $this->getNewtalks( $out ); wfProfileOut( __METHOD__ . '-stuff2' ); @@ -399,7 +399,7 @@ class SkinTemplate extends Skin { } else { $tpl->set( 'copyright', false ); $tpl->set( 'viewcount', false ); - $tpl->set( 'lastmod', false ); + $tpl->set( 'lastmod', false ); $tpl->set( 'credits', false ); $tpl->set( 'numberofwatchingusers', false ); } @@ -456,13 +456,14 @@ class SkinTemplate extends Skin { $tpl->set( 'sitenotice', $this->getSiteNotice() ); $tpl->set( 'bottomscripts', $this->bottomScripts( $out ) ); + // @todo Give printfooter userlangattributes $printfooter = "
\n" . $this->printSource() . "
\n"; global $wgBetterDirectionality; if ( $wgBetterDirectionality ) { $realBodyAttribs = array( 'lang' => $wgLanguageCode, 'dir' => $wgContLang->getDir() ); $out->mBodytext = Html::rawElement( 'div', $realBodyAttribs, $out->mBodytext ); } - $out->mBodytext .= $printfooter . $this->generateDebugHTML(); + $out->mBodytext .= $printfooter . $this->generateDebugHTML( $out ); $tpl->setRef( 'bodytext', $out->mBodytext ); # Language links