r96187 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96186‎ | r96187 | r96188 >
Date:14:27, 3 September 2011
Author:siebrand
Status:ok
Tags:
Comment:
User Linker class statically and update interfaces.
Put multiple globals on one line.
Modified paths:
  • /trunk/extensions/Collection/Collection.body.php (modified) (history)
  • /trunk/extensions/Collection/Collection.hooks.php (modified) (history)
  • /trunk/extensions/Collection/Collection.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Collection/Collection.php
@@ -268,8 +268,6 @@
269269 $wgAjaxExportList[] = 'wfAjaxCollectionAddCategory';
270270
271271 function wfAjaxCollectionGetBookCreatorBoxContent( $ajaxHint = '', $oldid = null, $pageName = null ) {
272 - global $wgUser;
273 -
274272 if ( !is_null( $oldid ) ) {
275273 $oldid = intval( $oldid );
276274 }
@@ -282,7 +280,7 @@
283281 $title = Title::newMainPage();
284282 }
285283
286 - $html = CollectionHooks::getBookCreatorBoxContent( $wgUser->getSkin(), $title, $ajaxHint, $oldid );
 284+ $html = CollectionHooks::getBookCreatorBoxContent( $title, $ajaxHint, $oldid );
287285
288286 $json = new Services_JSON();
289287 $result = array();
Index: trunk/extensions/Collection/Collection.hooks.php
@@ -1,5 +1,4 @@
22 <?php
3 -
43 /*
54 * Collection Extension for MediaWiki
65 *
@@ -97,7 +96,7 @@
9897 if ( !CollectionSession::isEnabled() ) {
9998 $out .= Xml::tags( 'li',
10099 array( 'id' => 'coll-create_a_book' ),
101 - $sk->link(
 100+ Linker::link(
102101 SpecialPage::getTitleFor( 'Book' ),
103102 wfMsgHtml( 'coll-create_a_book' ),
104103 array(
@@ -111,7 +110,7 @@
112111 } else {
113112 $out .= Xml::tags( 'li',
114113 array( 'id' => 'coll-book_creator_disable' ),
115 - $sk->link(
 114+ Linker::link(
116115 SpecialPage::getTitleFor( 'Book' ),
117116 wfMsgHtml( 'coll-book_creator_disable' ),
118117 array(
@@ -140,7 +139,7 @@
141140 $params['writer'] = $writer;
142141 $out .= Xml::tags( 'li',
143142 array( 'id' => 'coll-download-as-' . $writer ),
144 - $sk->link(
 143+ Linker::link(
145144 SpecialPage::getTitleFor( 'Book' ),
146145 wfMsgHtml( 'coll-download_as', htmlspecialchars( $wgCollectionFormats[$writer] ) ),
147146 array(
@@ -200,17 +199,16 @@
201200 if ( $skin ) {
202201 $title = $skin->getTitle();
203202 } else {
204 - global $wgTitle, $wgUser;
 203+ global $wgTitle;
205204 $title = $wgTitle;
206 - $skin = $wgUser->getSkin();
207205 }
208206
209207 if ( $title->isSpecial( 'Book' ) ) {
210208 $cmd = $wgRequest->getVal( 'bookcmd', '' );
211209 if ( $cmd == 'suggest' ) {
212 - $siteNotice .= self::renderBookCreatorBox( $title, $skin, 'suggest' );
 210+ $siteNotice .= self::renderBookCreatorBox( $title, 'suggest' );
213211 } elseif ( $cmd == '' ) {
214 - $siteNotice .= self::renderBookCreatorBox( $title, $skin, 'showbook' );
 212+ $siteNotice .= self::renderBookCreatorBox( $title, 'showbook' );
215213 }
216214 return true;
217215 }
@@ -225,7 +223,7 @@
226224 return true;
227225 }
228226
229 - $siteNotice .= self::renderBookCreatorBox( $title, $skin );
 227+ $siteNotice .= self::renderBookCreatorBox( $title );
230228 return true;
231229 }
232230
@@ -235,7 +233,7 @@
236234 * @param $mode string
237235 * @return string
238236 */
239 - static function renderBookCreatorBox( $title, $skin, $mode = '' ) {
 237+ static function renderBookCreatorBox( $title, $mode = '' ) {
240238 global $wgCollectionStyleVersion;
241239 global $wgOut;
242240 global $wgScriptPath;
@@ -273,7 +271,7 @@
274272 array( 'class' => 'collection-creatorbox-row' ),
275273 Xml::tags( 'div',
276274 array( 'class' => 'mw-float-end' ),
277 - $skin->link(
 275+ Linker::link(
278276 Title::newFromText( wfMsg( 'coll-helppage' ) ),
279277 Xml::element( 'img',
280278 array(
@@ -298,7 +296,7 @@
299297 wfMsgHtml( 'coll-book_creator' )
300298 )
301299 . ' ('
302 - . $skin->link(
 300+ . Linker::link(
303301 SpecialPage::getTitleFor( 'Book' ),
304302 wfMsgHtml( 'coll-disable' ),
305303 array(
@@ -316,21 +314,21 @@
317315 'id' => 'coll-book_creator_box',
318316 'class' => 'collection-creatorbox-row',
319317 ),
320 - self::getBookCreatorBoxContent( $skin, $title, $addRemoveState, $oldid )
 318+ self::getBookCreatorBoxContent( $title, $addRemoveState, $oldid )
321319 );
322320
323321 $html .= Xml::closeElement( 'div' );
324322 return $html;
325323 }
326324
327 - static function getBookCreatorBoxContent( $skin, $title, $ajaxHint = null, $oldid = null ) {
 325+ static function getBookCreatorBoxContent( $title, $ajaxHint = null, $oldid = null ) {
328326 global $wgScriptPath;
329327
330328 $imagePath = "$wgScriptPath/extensions/Collection/images";
331329
332 - return self::getBookCreatorBoxAddRemoveLink( $skin, $imagePath, $ajaxHint, $title, $oldid )
333 - . self::getBookCreatorBoxShowBookLink( $skin, $imagePath, $ajaxHint )
334 - . self::getBookCreatorBoxSuggestLink( $skin, $imagePath, $ajaxHint );
 330+ return self::getBookCreatorBoxAddRemoveLink( $imagePath, $ajaxHint, $title, $oldid )
 331+ . self::getBookCreatorBoxShowBookLink( $imagePath, $ajaxHint )
 332+ . self::getBookCreatorBoxSuggestLink( $imagePath, $ajaxHint );
335333 }
336334
337335 /**
@@ -341,7 +339,7 @@
342340 * @param $oldid
343341 * @return string
344342 */
345 - static function getBookCreatorBoxAddRemoveLink( $sk, $imagePath, $ajaxHint, $title, $oldid ) {
 343+ static function getBookCreatorBoxAddRemoveLink( $imagePath, $ajaxHint, $title, $oldid ) {
346344 $namespace = $title->getNamespace();
347345 $ptext = $title->getPrefixedText();
348346
@@ -389,7 +387,7 @@
390388 }
391389 }
392390
393 - return $sk->link(
 391+ return Linker::link(
394392 SpecialPage::getTitleFor( 'Book' ),
395393 Xml::element( 'img',
396394 array(
@@ -412,8 +410,9 @@
413411
414412 }
415413
416 - static function getBookCreatorBoxShowBookLink( $sk, $imagePath, $ajaxHint ) {
 414+ static function getBookCreatorBoxShowBookLink( $imagePath, $ajaxHint ) {
417415 $numArticles = CollectionSession::countArticles();
 416+
418417 if ( $ajaxHint == 'showbook' ) {
419418 return Xml::tags( 'strong',
420419 array(
@@ -431,7 +430,7 @@
432431 . ' (' . wfMsgExt( 'coll-n_pages', array( 'parsemag', 'escape' ), $numArticles ) . ')'
433432 );
434433 } else {
435 - return $sk->link(
 434+ return Linker::link(
436435 SpecialPage::getTitleFor( 'Book' ),
437436 Xml::element( 'img',
438437 array(
@@ -454,7 +453,7 @@
455454 }
456455 }
457456
458 - static function getBookCreatorBoxSuggestLink( $sk, $imagePath, $ajaxHint ) {
 457+ static function getBookCreatorBoxSuggestLink( $imagePath, $ajaxHint ) {
459458 if ( wfMsg( 'coll-suggest_enabled' ) != '1' ) {
460459 return '';
461460 }
@@ -476,7 +475,7 @@
477476 . '&#160;' . wfMsgHtml( 'coll-make_suggestions' )
478477 );
479478 } else {
480 - return $sk->link(
 479+ return Linker::link(
481480 SpecialPage::getTitleFor( 'Book' ),
482481 Xml::element( 'img',
483482 array(
@@ -517,4 +516,3 @@
518517 return true;
519518 }
520519 }
521 -
Index: trunk/extensions/Collection/Collection.body.php
@@ -1,5 +1,4 @@
22 <?php
3 -
43 /*
54 * Collection Extension for MediaWiki
65 *
@@ -39,11 +38,7 @@
4039 }
4140
4241 function execute( $par ) {
43 - global $wgOut;
44 - global $wgRequest;
45 - global $wgUser;
46 - global $wgContLang;
47 - global $wgCollectionMaxArticles;
 42+ global $wgOut, $wgRequest, $wgUser, $wgContLang, $wgCollectionMaxArticles;
4843
4944 // support previous URLs (e.g. used in templates) which used the "$par" part
5045 // (i.e. subpages of the Special page)
@@ -305,9 +300,7 @@
306301 }
307302
308303 function renderBookCreatorPage( $referer, $par ) {
309 - global $wgOut;
310 - global $wgUser;
311 - global $wgJsMimeType;
 304+ global $wgOut, $wgJsMimeType;
312305
313306 $this->setHeaders();
314307 $wgOut->setPageTitle( wfMsg( 'coll-book_creator' ) );
@@ -327,7 +320,6 @@
328321 if ( is_null( $title ) || $title->equals( $this->getTitle( $par ) ) ) {
329322 $title = Title::newMainPage();
330323 }
331 - $sk = $wgUser->getSkin();
332324
333325 $wgOut->addHTML(
334326 Xml::tags( 'div',
@@ -356,7 +348,7 @@
357349 array(
358350 'class' => 'collection-button cancel',
359351 ),
360 - $sk->link(
 352+ Linker::link(
361353 $title,
362354 wfMsgHtml( 'coll-cancel' ),
363355 array(
@@ -430,8 +422,7 @@
431423 }
432424
433425 static function getBookPagePrefixes() {
434 - global $wgUser;
435 - global $wgCommunityCollectionNamespace;
 426+ global $wgUser, $wgCommunityCollectionNamespace;
436427
437428 $result = array();
438429
@@ -458,8 +449,7 @@
459450 }
460451
461452 function renderSpecialPage() {
462 - global $wgCollectionFormats;
463 - global $wgOut;
 453+ global $wgCollectionFormats, $wgOut;
464454
465455 if ( !CollectionSession::hasSession() ) {
466456 CollectionSession::startSession();
@@ -619,8 +609,7 @@
620610 }
621611
622612 static function addCategory( $title ) {
623 - global $wgCollectionMaxArticles;
624 - global $wgCollectionArticleNamespaces;
 613+ global $wgCollectionMaxArticles, $wgCollectionArticleNamespaces;
625614
626615 $limit = $wgCollectionMaxArticles - CollectionSession::countArticles();
627616 if ( $limit <= 0 ) {
@@ -876,12 +865,8 @@
877866 }
878867
879868 function getLicenseInfos() {
880 - global $wgCollectionLicenseName;
881 - global $wgCollectionLicenseURL;
882 - global $wgRightsIcon;
883 - global $wgRightsPage;
884 - global $wgRightsText;
885 - global $wgRightsUrl;
 869+ global $wgCollectionLicenseName, $wgCollectionLicenseURL, $wgRightsIcon;
 870+ global $wgRightsPage, $wgRightsText, $wgRightsUrl;
886871
887872 $licenseInfo = array(
888873 "type" => "license",
@@ -1082,9 +1067,7 @@
10831068 }
10841069
10851070 function download() {
1086 - global $wgOut;
1087 - global $wgRequest;
1088 - global $wgCollectionContentTypeToFilename;
 1071+ global $wgOut, $wgRequest, $wgCollectionContentTypeToFilename;
10891072
10901073 $tempfile = tmpfile();
10911074 $r = self::mwServeCommand( 'render_status', array(
@@ -1210,10 +1193,7 @@
12111194 }
12121195
12131196 static function mwServeCommand( $command, $args ) {
1214 - global $wgOut;
1215 - global $wgCollectionMWServeURL;
1216 - global $wgCollectionMWServeCredentials;
1217 - global $wgCollectionFormatToServeURL;
 1197+ global $wgOut, $wgCollectionMWServeURL, $wgCollectionMWServeCredentials, $wgCollectionFormatToServeURL;
12181198
12191199 $serveURL = $wgCollectionMWServeURL;
12201200 if ( array_key_exists( $args['writer'], $wgCollectionFormatToServeURL ) )

Status & tagging log