From: Kunal Mehta Date: Thu, 7 Aug 2014 17:28:22 +0000 (+0100) Subject: includes/specialpage: Use Config instead of globals (almost!) X-Git-Tag: 1.31.0-rc.0~14529 X-Git-Url: https://git.cyclocoop.org/admin/?a=commitdiff_plain;h=21424161ba5d6280bad02ac0b65962fc3e0b3c98;p=lhc%2Fweb%2Fwiklou.git includes/specialpage: Use Config instead of globals (almost!) SpecialPageFactory is very scary and will need some refactoring to be de-globalified. Change-Id: I1de6301e195d94faddf134a53b456029b1079ec8 --- diff --git a/includes/specialpage/ChangesListSpecialPage.php b/includes/specialpage/ChangesListSpecialPage.php index 806a48a5dc..c28aa86776 100644 --- a/includes/specialpage/ChangesListSpecialPage.php +++ b/includes/specialpage/ChangesListSpecialPage.php @@ -410,12 +410,11 @@ abstract class ChangesListSpecialPage extends SpecialPage { * @return string */ public static function makeLegend( IContextSource $context ) { - global $wgRecentChangesFlags; $user = $context->getUser(); # The legend showing what the letters and stuff mean $legend = Html::openElement( 'dl' ) . "\n"; # Iterates through them and gets the messages for both letter and tooltip - $legendItems = $wgRecentChangesFlags; + $legendItems = $context->getConfig()->get( 'RecentChangesFlags' ); if ( !( $user->useRCPatrol() || $user->useNPPatrol() ) ) { unset( $legendItems['unpatrolled'] ); } diff --git a/includes/specialpage/QueryPage.php b/includes/specialpage/QueryPage.php index b8fc05e5b6..ae0003dc18 100644 --- a/includes/specialpage/QueryPage.php +++ b/includes/specialpage/QueryPage.php @@ -203,8 +203,7 @@ abstract class QueryPage extends SpecialPage { * @return bool */ function isExpensive() { - global $wgDisableQueryPages; - return $wgDisableQueryPages; + return $this->getConfig()->get( 'DisableQueryPages' ); } /** @@ -225,9 +224,7 @@ abstract class QueryPage extends SpecialPage { * @return bool */ function isCached() { - global $wgMiserMode; - - return $this->isExpensive() && $wgMiserMode; + return $this->isExpensive() && $this->getConfig()->get( 'MiserMode' ); } /** @@ -472,8 +469,6 @@ abstract class QueryPage extends SpecialPage { * @param string $par */ function execute( $par ) { - global $wgQueryCacheLimit, $wgDisableQueryPageUpdate; - $user = $this->getUser(); if ( !$this->userCanExecute( $user ) ) { $this->displayRestrictionError(); @@ -508,7 +503,7 @@ abstract class QueryPage extends SpecialPage { # Fetch the timestamp of this update $ts = $this->getCachedTimestamp(); $lang = $this->getLanguage(); - $maxResults = $lang->formatNum( $wgQueryCacheLimit ); + $maxResults = $lang->formatNum( $this->getConfig()->get( 'QueryCacheLimit' ) ); if ( $ts ) { $updated = $lang->userTimeAndDate( $ts, $user ); @@ -523,8 +518,8 @@ abstract class QueryPage extends SpecialPage { # If updates on this page have been disabled, let the user know # that the data set won't be refreshed for now - if ( is_array( $wgDisableQueryPageUpdate ) - && in_array( $this->getName(), $wgDisableQueryPageUpdate ) + if ( is_array( $this->getConfig()->get( 'DisableQueryPageUpdate' ) ) + && in_array( $this->getName(), $this->getConfig()->get( 'DisableQueryPageUpdate' ) ) ) { $out->wrapWikiMsg( "
\n$1\n
", @@ -671,18 +666,17 @@ abstract class QueryPage extends SpecialPage { * @return bool */ function doFeed( $class = '', $limit = 50 ) { - global $wgFeed, $wgFeedClasses, $wgFeedLimit; - - if ( !$wgFeed ) { + if ( !$this->getConfig()->get( 'Feed' ) ) { $this->getOutput()->addWikiMsg( 'feed-unavailable' ); return false; } - $limit = min( $limit, $wgFeedLimit ); + $limit = min( $limit, $this->getConfig()->get( 'FeedLimit' ) ); - if ( isset( $wgFeedClasses[$class] ) ) { + $feedClasses = $this->getConfig()->get( 'FeedClasses' ); + if ( isset( $feedClasses[$class] ) ) { /** @var RSSFeed|AtomFeed $feed */ - $feed = new $wgFeedClasses[$class]( + $feed = new $feedClasses[$class]( $this->feedTitle(), $this->feedDesc(), $this->feedUrl() ); @@ -743,9 +737,10 @@ abstract class QueryPage extends SpecialPage { } function feedTitle() { - global $wgLanguageCode, $wgSitename; $desc = $this->getDescription(); - return "$wgSitename - $desc [$wgLanguageCode]"; + $code = $this->getConfig()->get( 'LanguageCode' ); + $sitename = $this->getConfig()->get( 'Sitename' ); + return "$sitename - $desc [$code]"; } function feedDesc() { diff --git a/includes/specialpage/SpecialPage.php b/includes/specialpage/SpecialPage.php index 0070c74b04..c52b84b0fd 100644 --- a/includes/specialpage/SpecialPage.php +++ b/includes/specialpage/SpecialPage.php @@ -621,11 +621,9 @@ class SpecialPage { * @param array $params */ protected function addFeedLinks( $params ) { - global $wgFeedClasses; - $feedTemplate = wfScript( 'api' ); - foreach ( $wgFeedClasses as $format => $class ) { + foreach ( $this->getConfig()->get( 'FeedClasses' ) as $format => $class ) { $theseParams = $params + array( 'feedformat' => $format ); $url = wfAppendQuery( $feedTemplate, $theseParams ); $this->getOutput()->addFeedLink( $format, $url ); @@ -641,8 +639,8 @@ class SpecialPage { * @since 1.21 */ public function getFinalGroupName() { - global $wgSpecialPageGroups; $name = $this->getName(); + $specialPageGroups = $this->getConfig()->get( 'SpecialPageGroups' ); // Allow overbidding the group from the wiki side $msg = $this->msg( 'specialpages-specialpagegroup-' . strtolower( $name ) )->inContentLanguage(); @@ -655,8 +653,8 @@ class SpecialPage { // Group '-' is used as default to have the chance to determine, // if the special pages overrides this method, // if not overridden, $wgSpecialPageGroups is checked for b/c - if ( $group === '-' && isset( $wgSpecialPageGroups[$name] ) ) { - $group = $wgSpecialPageGroups[$name]; + if ( $group === '-' && isset( $specialPageGroups[$name] ) ) { + $group = $specialPageGroups[$name]; } }