r99907 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99906‎ | r99907 | r99908 >
Date:19:57, 15 October 2011
Author:ialex
Status:ok
Tags:
Comment:
Removed usage of $wgTitle
Modified paths:
  • /trunk/extensions/ReaderFeedback/ReaderFeedback.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ReaderFeedback/ReaderFeedback.hooks.php
@@ -4,15 +4,14 @@
55 /**
66 * Add ReaderFeedback css/js.
77 */
8 - public static function injectStyleAndJS() {
9 - global $wgOut, $wgTitle;
10 - if( $wgOut->hasHeadItem( 'ReaderFeedback' ) )
 8+ public static function injectStyleAndJS( $out ) {
 9+ if( $out->hasHeadItem( 'ReaderFeedback' ) )
1110 return true; # Don't double-load
12 - if( !isset($wgTitle) || !$wgOut->isArticleRelated() ) {
13 - return self::InjectStyleForSpecial(); // try special page CSS?
 11+ if( !$out->getTitle() || !$out->isArticleRelated() ) {
 12+ return self::InjectStyleForSpecial( $out ); // try special page CSS?
1413 }
1514 # Try to only add to relevant pages
16 - if( !ReaderFeedback::isPageRateable($wgTitle) ) {
 15+ if( !ReaderFeedback::isPageRateable( $out->getTitle() ) ) {
1716 return true;
1817 }
1918 global $wgScriptPath, $wgJsMimeType, $wgFeedbackStylePath, $wgFeedbackStyleVersion;
@@ -22,9 +21,9 @@
2322 $cssFile = "$stylePath/readerfeedback.css?$wgFeedbackStyleVersion";
2423 $jsFile = "$stylePath/readerfeedback.js?$wgFeedbackStyleVersion";
2524 // Add CSS
26 - $wgOut->addExtensionStyle( $cssFile );
 25+ $out->addExtensionStyle( $cssFile );
2726 // Add JS
28 - $wgOut->addScriptFile( $jsFile );
 27+ $out->addScriptFile( $jsFile );
2928
3029 return true;
3130 }
@@ -41,18 +40,17 @@
4241 /**
4342 * Add ReaderFeedback css for relevant special pages.
4443 */
45 - public static function InjectStyleForSpecial() {
46 - global $wgTitle, $wgOut;
47 - if( empty($wgTitle) || $wgTitle->getNamespace() !== NS_SPECIAL ) {
 44+ public static function InjectStyleForSpecial( $out ) {
 45+ if ( !is_object( $out->getTitle() ) || $out->getTitle()->getNamespace() !== NS_SPECIAL ) {
4846 return true;
4947 }
5048 $spPages = array( 'RatingHistory' );
5149 foreach( $spPages as $key ) {
52 - if( $wgTitle->isSpecial( $key ) ) {
 50+ if( $out->getTitle()->isSpecial( $key ) ) {
5351 global $wgScriptPath, $wgFeedbackStylePath, $wgFeedbacktyleVersion;
5452 $stylePath = str_replace( '$wgScriptPath', $wgScriptPath, $wgFeedbackStylePath );
5553 $encCssFile = htmlspecialchars( "$stylePath/readerfeedback.css?$wgFeedbacktyleVersion" );
56 - $wgOut->addExtensionStyle( $encCssFile );
 54+ $out->addExtensionStyle( $encCssFile );
5755 break;
5856 }
5957 }
@@ -164,9 +162,8 @@
165163 }
166164
167165 public static function addRatingLink( &$skintemplate, &$nav_urls, &$oldid, &$revid ) {
168 - global $wgTitle;
169166 # Add rating tab
170 - if( isset($wgTitle) && ReaderFeedback::isPageRateable($wgTitle) ) {
 167+ if( $skintemplate->getTitle() && ReaderFeedback::isPageRateable( $skintemplate->getTitle() ) ) {
171168 $nav_urls['ratinghist'] = array(
172169 'text' => wfMsg( 'ratinghistory-link' ),
173170 'href' => $skintemplate->makeSpecialUrl( 'RatingHistory',

Status & tagging log