r109529 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109528‎ | r109529 | r109530 >
Date:12:52, 19 January 2012
Author:siebrand
Status:ok (Comments)
Tags:backcompat, languagegetmagic 
Comment:
Remove use of deprecated LanguageGetMagic hook.
Remove a few globals or constants that were used for magic words.
Trim trailing whitespace and update indentation in a few place.
Modified paths:
  • /trunk/extensions/ShoutBox/ShoutBox.i18n.magic.php (added) (history)
  • /trunk/extensions/ShoutBox/ShoutBox.php (modified) (history)
  • /trunk/extensions/SimpleSecurity/SimpleSecurity.i18n.magic.php (added) (history)
  • /trunk/extensions/SimpleSecurity/SimpleSecurity.php (modified) (history)
  • /trunk/extensions/SimpleSecurity/SimpleSecurity_body.php (modified) (history)
  • /trunk/extensions/SmoothGallery/SmoothGallery.php (modified) (history)
  • /trunk/extensions/SmoothGallery/SmoothGalleryParser.php (modified) (history)
  • /trunk/extensions/StockCharts/StockCharts.i18n.magic.php (added) (history)
  • /trunk/extensions/StockCharts/StockCharts.php (modified) (history)
  • /trunk/extensions/SubPageList/SubPageCount.class.php (modified) (history)
  • /trunk/extensions/SubPageList/SubPageList.class.php (modified) (history)
  • /trunk/extensions/SubPageList/SubPageList.i18n.magic.php (modified) (history)
  • /trunk/extensions/SubPageList/SubPageList.php (modified) (history)
  • /trunk/extensions/ThumbParser/ThumbParser.i18n.magic.php (added) (history)
  • /trunk/extensions/ThumbParser/ThumbParser.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SubPageList/SubPageList.i18n.magic.php
@@ -16,6 +16,8 @@
1717 $magicWords['en'] = array(
1818 'splist' => array( 0, 'splist' ),
1919 'subpages' => array( 0, 'subpages' ),
 20+ 'subpagelist' => array( 0, 'subpagelist' ),
 21+ 'subpagecount' => array( 0, 'subpagecount' ),
2022 );
2123
2224 /** Arabic (العربية) */
Index: trunk/extensions/SubPageList/SubPageList.php
@@ -60,9 +60,7 @@
6161 $wgAutoloadClasses['SPLHooks'] = $egSPLIP . '/SubPageList.hooks.php';
6262
6363 $wgHooks['ParserFirstCallInit'][] = 'SubPageList::staticInit';
64 -$wgHooks['LanguageGetMagic'][] = 'SubPageList::staticMagic';
6564 $wgHooks['ParserFirstCallInit'][] = 'SubPageCount::staticInit';
66 -$wgHooks['LanguageGetMagic'][] = 'SubPageCount::staticMagic';
6765
6866 $wgHooks['ArticleInsertComplete'][] = 'SPLHooks::onArticleInsertComplete';
6967 $wgHooks['ArticleDeleteComplete'][] = 'SPLHooks::onArticleDeleteComplete';
Index: trunk/extensions/SubPageList/SubPageCount.class.php
@@ -16,20 +16,10 @@
1717 * @copyright © 2008 James McCormack, preceding version Martin Schallnahs, original Rob Church
1818 */
1919 final class SubPageCount extends SubPageBase {
20 -
2120 /**
2221 * No LSB in pre-5.3 PHP *sigh*.
2322 * This is to be refactored as soon as php >=5.3 becomes acceptable.
2423 */
25 - public static function staticMagic( array &$magicWords, $langCode ) {
26 - $instance = new self;
27 - return $instance->magic( $magicWords, $langCode );
28 - }
29 -
30 - /**
31 - * No LSB in pre-5.3 PHP *sigh*.
32 - * This is to be refactored as soon as php >=5.3 becomes acceptable.
33 - */
3424 public static function staticInit( Parser &$wgParser ) {
3525 $instance = new self;
3626 return $instance->init( $wgParser );
Index: trunk/extensions/SubPageList/SubPageList.class.php
@@ -16,20 +16,9 @@
1717 * @copyright © 2008 James McCormack, preceding version Martin Schallnahs, original Rob Church
1818 */
1919 final class SubPageList extends SubPageBase {
20 -
2120 /**
2221 * No LST in pre-5.3 PHP *sigh*.
2322 * This is to be refactored as soon as php >=5.3 becomes acceptable.
24 - */
25 - public static function staticMagic( array &$magicWords, $langCode ) {
26 - $className = __CLASS__;
27 - $instance = new $className();
28 - return $instance->magic( $magicWords, $langCode );
29 - }
30 -
31 - /**
32 - * No LST in pre-5.3 PHP *sigh*.
33 - * This is to be refactored as soon as php >=5.3 becomes acceptable.
3423 */
3524 public static function staticInit( Parser &$wgParser ) {
3625 $className = __CLASS__;
Index: trunk/extensions/StockCharts/StockCharts.i18n.magic.php
@@ -0,0 +1,10 @@
 2+<?php
 3+/**
 4+ * Internationalization file for magic words.
 5+ */
 6+
 7+$magicWords = array();
 8+
 9+$magicWords['en'] = array(
 10+ 'stockchart' => array( 0, 'stockchart' ),
 11+);
Property changes on: trunk/extensions/StockCharts/StockCharts.i18n.magic.php
___________________________________________________________________
Added: svn:eol-style
112 + native
Added: svn:keywords
213 + Id
Index: trunk/extensions/StockCharts/StockCharts.php
@@ -18,7 +18,6 @@
1919 */
2020
2121 $wgHooks['ParserFirstCallInit'][] = 'efStockChartsSetHooks';
22 -$wgHooks['LanguageGetMagic'][] = 'efStockChartsMagic';
2322
2423 $wgExtensionCredits['parserhook'][] = array(
2524 'name' => 'StockCharts',
@@ -26,11 +25,12 @@
2726 'author' => 'Brendan Meutzner, Anton Zolotkov, Roger Fong',
2827 'descriptionmsg' => 'stockcharts-desc',
2928 'url' => 'https://www.mediawiki.org/wiki/Extension:StockCharts',
30 - 'version' => '0.2',
 29+ 'version' => '0.3',
3130 );
3231
3332 # Internationalisation file
3433 $wgExtensionMessagesFiles['StockCharts'] = dirname( __FILE__ ) . '/StockCharts.i18n.php';
 34+$wgExtensionMessagesFiles['StockChartsMagic'] = dirname( __FILE__ ) . '/StockCharts.i18n.magic.php';
3535
3636 $wgAutoloadClasses['StockCharts'] = dirname( __FILE__ ) . '/StockCharts_body.php';
3737
@@ -39,8 +39,3 @@
4040 $parser->setFunctionHook( 'stockchart', array( 'StockCharts', 'renderParserFunction' ) ); // hook for {{#stockchart ..}}
4141 return true;
4242 }
43 -
44 -function efStockChartsMagic( &$magicWords, $langCode ) {
45 - $magicWords['stockchart'] = array( 0, 'stockchart' );
46 - return true;
47 -}
Index: trunk/extensions/SmoothGallery/SmoothGallery.php
@@ -35,7 +35,7 @@
3636 $wgExtensionCredits['other'][] = array(
3737 'path' => __FILE__,
3838 'name' => 'SmoothGallery parser extension',
39 - 'version' => '1.1h',
 39+ 'version' => '1.1i',
4040 'author' => 'Ryan Lane',
4141 'descriptionmsg' => 'smoothgallery-desc',
4242 'url' => 'https://www.mediawiki.org/wiki/Extension:SmoothGallery',
@@ -47,11 +47,7 @@
4848
4949 $dir = dirname( __FILE__ ) . '/';
5050 $wgExtensionMessagesFiles['SmoothGallery'] = $dir . 'SmoothGallery.i18n.php';
51 -if( version_compare( $wgVersion, '1.16alpha', '>=' ) ) {
52 - $wgExtensionMessagesFiles['SmoothGalleryMagic'] = $dir . 'SmoothGallery.i18n.magic.php';
53 -} else {
54 - $wgHooks['LanguageGetMagic'][] = 'smoothGalleryLanguageGetMagic';
55 -}
 51+$wgExtensionMessagesFiles['SmoothGalleryMagic'] = $dir . 'SmoothGallery.i18n.magic.php';
5652 $wgAutoloadClasses['SmoothGallery'] = $dir . 'SmoothGalleryClass.php';
5753 $wgAutoloadClasses['SmoothGalleryParser'] = $dir . 'SmoothGalleryParser.php';
5854
@@ -150,12 +146,3 @@
151147 }
152148 return true;
153149 }
154 -
155 -/**
156 - * We ignore langCode - parser function names can be translated but
157 - * we are not using this feature
158 - */
159 -function smoothGalleryLanguageGetMagic( $magicWords, $langCode ) {
160 - $magicWords['sgallery'] = array( 0, 'sgallery' );
161 - return true;
162 -}
Index: trunk/extensions/SmoothGallery/SmoothGalleryParser.php
@@ -1,7 +1,6 @@
22 <?php
33
44 class SmoothGalleryParser {
5 -
65 var $set;
76 var $argumentArray;
87 var $galleriesArray;
@@ -287,5 +286,4 @@
288287
289288 return $images;
290289 }
291 -
292290 }
Index: trunk/extensions/SimpleSecurity/SimpleSecurity.i18n.magic.php
@@ -0,0 +1,11 @@
 2+<?php
 3+/**
 4+ * Internationalization file for magic words.
 5+ */
 6+
 7+$magicWords = array();
 8+
 9+$magicWords['en'] = array(
 10+ 'ifgroup' => array( 0, 'ifgroup' ),
 11+ 'ifusercan' => array( 0, 'ifusercan' ),
 12+);
Property changes on: trunk/extensions/SimpleSecurity/SimpleSecurity.i18n.magic.php
___________________________________________________________________
Added: svn:eol-style
113 + native
Added: svn:keywords
214 + Id
Index: trunk/extensions/SimpleSecurity/SimpleSecurity_body.php
@@ -22,15 +22,15 @@
2323
2424 function setup() {
2525 global $wgParser, $wgHooks, $wgLogTypes, $wgLogNames, $wgLogHeaders, $wgLogActions,
26 - $wgSecurityMagicIf, $wgSecurityMagicGroup, $wgSecurityExtraActions, $wgSecurityExtraGroups,
 26+ $wgSecurityExtraActions, $wgSecurityExtraGroups,
2727 $wgRestrictionTypes, $wgRestrictionLevels, $wgGroupPermissions,
2828 $wgSecurityRenderInfo, $wgSecurityAllowUnreadableLinks, $wgSecurityGroupsArticle;
2929
3030 # Add our hooks
3131 $wgHooks['UserGetRights'][] = $this;
3232 $wgHooks['ImgAuthBeforeStream'][] = $this;
33 - if ( $wgSecurityMagicIf ) $wgParser->setFunctionHook( $wgSecurityMagicIf, array( $this, 'ifUserCan' ) );
34 - if ( $wgSecurityMagicGroup ) $wgParser->setFunctionHook( $wgSecurityMagicGroup, array( $this, 'ifGroup' ) );
 33+ $wgParser->setFunctionHook( 'ifusercan', array( $this, 'ifUserCan' ) );
 34+ $wgParser->setFunctionHook( 'ifgroup', array( $this, 'ifGroup' ) );
3535 if ( $wgSecurityRenderInfo ) $wgHooks['OutputPageBeforeHTML'][] = $this;
3636 if ( $wgSecurityAllowUnreadableLinks ) $wgHooks['BeforePageDisplay'][] = $this;
3737
@@ -72,7 +72,6 @@
7373
7474 }
7575
76 -
7776 /**
7877 * Process the ifUserCan conditional security directive
7978 */
@@ -80,7 +79,6 @@
8180 return Title::newFromText( $pagename )->userCan( $action ) ? $then : $else;
8281 }
8382
84 -
8583 /**
8684 * Process the ifGroup conditional security directive
8785 * - evaluates to true if current uset belongs to any of the comma-separated users and/or groups in the first parameter
@@ -91,7 +89,6 @@
9290 return count( $intersection ) > 0 ? $then : $else;
9391 }
9492
95 -
9693 /**
9794 * Convert the urls with guids for hrefs into non-clickable text of class "unreadable"
9895 */
@@ -104,7 +101,6 @@
105102 return true;
106103 }
107104
108 -
109105 /**
110106 * Render security info if any restrictions on this title
111107 * Also make restricted pages not archive by robots
@@ -462,5 +458,4 @@
463459 }
464460 return $db;
465461 }
466 -
467462 }
Index: trunk/extensions/SimpleSecurity/SimpleSecurity.php
@@ -22,17 +22,15 @@
2323 * @copyright © 2007-2011 Aran Dunkley
2424 * @license GNU General Public Licence 2.0 or later
2525 */
26 -define( 'SIMPLESECURITY_VERSION', '5.0.4, 2011-06-29' );
 26+define( 'SIMPLESECURITY_VERSION', '5.1.0, 2012-01-19' );
2727
2828 # Load the SimpleSecurity class and messages
2929 $dir = dirname( __FILE__ ) . '/';
3030 $wgExtensionMessagesFiles['SimpleSecurity'] = $dir . 'SimpleSecurity.i18n.php';
 31+$wgExtensionMessagesFiles['SimpleSecurityMagic'] = $dir . 'SimpleSecurity.i18n.magic.php';
3132 $wgAutoloadClasses['SimpleSecurity'] = $dir . 'SimpleSecurity_body.php';
3233
3334 # Global security settings
34 -# TODO: Localize magic words
35 -$wgSecurityMagicIf = "ifusercan"; # the name for doing a permission-based conditional
36 -$wgSecurityMagicGroup = "ifgroup"; # the name for doing a group-based conditional
3735 $wgSecurityLogActions = array( 'edit', 'download' ); # Actions that should be logged
3836 $wgSecurityAllowUser = false; # Allow restrictions based on user not just group
3937 $wgSecurityAllowUnreadableLinks = false; # Should links to unreadable pages be allowed? (MW1.7+)
@@ -58,7 +56,6 @@
5957 # Don't use the DB hook by default since it's voodoo
6058 if( !isset( $wgSecurityUseDBHook ) ) $wgSecurityUseDBHook = false;
6159
62 -$wgHooks['LanguageGetMagic'][] = 'wfSimpleSecurityLanguageGetMagic';
6360 $wgExtensionCredits['parserhook'][] = array(
6461 'path' => __FILE__,
6562 'name' => "SimpleSecurity",
@@ -75,16 +72,6 @@
7673 # If using the DBHook, apply it now (must be done from the root scope since it creates classes)
7774 if( $wgSecurityUseDBHook ) SimpleSecurity::applyDatabaseHook();
7875
79 -/**
80 - * Register magic words
81 - */
82 -function wfSimpleSecurityLanguageGetMagic( &$magicWords, $langCode = 0 ) {
83 - global $wgSecurityMagicIf, $wgSecurityMagicGroup;
84 - $magicWords[$wgSecurityMagicIf] = array( $langCode, $wgSecurityMagicIf );
85 - $magicWords[$wgSecurityMagicGroup] = array( $langCode, $wgSecurityMagicGroup );
86 - return true;
87 -}
88 -
8976 function wfSimpleSecurityMessagesPreLoad( $title, &$text ) {
9077 global $wgSecurityExtraActions, $wgSecurityExtraGroups;
9178
Index: trunk/extensions/ThumbParser/ThumbParser.i18n.magic.php
@@ -0,0 +1,10 @@
 2+<?php
 3+/**
 4+ * Internationalization file for magic words.
 5+ */
 6+
 7+$magicWords = array();
 8+
 9+$magicWords['en'] = array(
 10+ 'thumb' => array( 0, 'thumb' ),
 11+);
Property changes on: trunk/extensions/ThumbParser/ThumbParser.i18n.magic.php
___________________________________________________________________
Added: svn:eol-style
112 + native
Added: svn:keywords
213 + Id
Index: trunk/extensions/ThumbParser/ThumbParser.php
@@ -1,6 +1,6 @@
22 <?php
3 -/**
4 -* @addtogroup Extensions
 3+/**
 4+* @addtogroup Extensions
55 */
66 // Check environment
77 if ( !defined( 'MEDIAWIKI' ) ) {
@@ -18,55 +18,45 @@
1919 'description'=>'Prints users Thumb size',
2020 'descriptionmsg' => 'thumbparser-desc',
2121 'author'=>'[http://www.dasch-tour.de DaSch]',
22 - 'version'=>'0.1',
 22+ 'version'=>'0.2',
2323 );
2424 $dir = dirname( __FILE__ ) . '/';
2525
2626 // Internationalization
2727 $wgExtensionMessagesFiles['ThumbParser'] = $dir . 'ThumbParser.i18n.php';
 28+$wgExtensionMessagesFiles['ThumbParserMagic'] = $dir . 'ThumbParser.i18n.magic.php';
2829
2930 # Define a setup function
3031 $wgHooks['ParserFirstCallInit'][] = 'efThumbParserFunction_Setup';
31 -# Add a hook to initialise the magic word
32 -$wgHooks['LanguageGetMagic'][] = 'efThumbParserFunction_Magic';
33 -
 32+
3433 function efThumbParserFunction_Setup( $parser ) {
3534 # Set a function hook associating the "example" magic word with our function
3635 $parser->setFunctionHook( 'thumb', 'efThumbParserFunction_Render' );
3736 return true;
3837 }
39 -
40 -function efThumbParserFunction_Magic( &$magicWords, $langCode ) {
41 - # Add the magic word
42 - # The first array element is case sensitive, in this case it is not case sensitive
43 - # All remaining elements are synonyms for our parser function
44 - $magicWords['thumb'] = array( 0, 'thumb' );
45 - # unless we return true, other parser functions extensions won't get loaded.
46 - return true;
47 -}
48 -
 38+
4939 function efThumbParserFunction_Render( $parser, $param1 = '') {
50 - # The parser function itself
51 - # The input parameters are wikitext with templates expanded
52 - # The output should be wikitext too
53 - global $wgThumbLimits, $wgUser;
54 - $param1 = strtolower($param1);
55 - $parser->disableCache(); # Mark this content as uncacheable
56 - $wopt = $wgUser->getOption('thumbsize');
57 - switch ($param1) {
58 - case 'size':
59 - $output = $wgThumbLimits[$wopt];
60 - break;
61 - case 'px':
62 - $output = $wgThumbLimits[$wopt].'px';
63 - break;
64 - case 'width':
65 - $size = intval($wgThumbLimits[$wopt])+10;
66 - $strsize = strval($size);
67 - $output = $strsize."px";
68 - break;
69 - default:
70 - $output = $wgThumbLimits[$wopt];
71 - }
72 - return $output;
73 -}
\ No newline at end of file
 40+ # The parser function itself
 41+ # The input parameters are wikitext with templates expanded
 42+ # The output should be wikitext too
 43+ global $wgThumbLimits, $wgUser;
 44+ $param1 = strtolower($param1);
 45+ $parser->disableCache(); # Mark this content as uncacheable
 46+ $wopt = $wgUser->getOption('thumbsize');
 47+ switch ($param1) {
 48+ case 'size':
 49+ $output = $wgThumbLimits[$wopt];
 50+ break;
 51+ case 'px':
 52+ $output = $wgThumbLimits[$wopt].'px';
 53+ break;
 54+ case 'width':
 55+ $size = intval($wgThumbLimits[$wopt])+10;
 56+ $strsize = strval($size);
 57+ $output = $strsize."px";
 58+ break;
 59+ default:
 60+ $output = $wgThumbLimits[$wopt];
 61+ }
 62+ return $output;
 63+}
Index: trunk/extensions/ShoutBox/ShoutBox.php
@@ -57,7 +57,7 @@
5858 $wgExtensionCredits['parserhook'][] = array(
5959 'path' => __FILE__,
6060 'name' => 'ShoutBox',
61 - 'version' => '0.2.2',
 61+ 'version' => '0.3.0',
6262 'author' => array( 'Jim R. Wilson', 'Jack Phoenix' ),
6363 'url' => 'https://www.mediawiki.org/wiki/Extension:ShoutBox',
6464 'descriptionmsg' => 'shoutbox-desc',
@@ -79,17 +79,18 @@
8080 // Internationalization file
8181 $dir = dirname( __FILE__ ) . '/';
8282 $wgExtensionMessagesFiles['ShoutBox'] = $dir . 'ShoutBox.i18n.php';
 83+$wgExtensionMessagesFiles['ShoutBoxMagic'] = $dir . 'ShoutBox.i18n.magic.php';
8384
8485 // Hooked functions
8586 $wgHooks['ParserFirstCallInit'][] = 'ShoutBox::setup';
86 -$wgHooks['LanguageGetMagic'][] = 'ShoutBox::parserFunctionMagic';
8787 $wgHooks['ParserBeforeTidy'][] = 'ShoutBox::placeholderCorrections';
8888
 89+// @todo FIXME: Move classes out of the init file.
 90+
8991 /**
9092 * Wrapper class for encapsulating ShoutBox related parser methods
9193 */
9294 class ShoutBox {
93 -
9495 /**
9596 * Sets up parser functions.
9697 *
@@ -103,18 +104,6 @@
104105 }
105106
106107 /**
107 - * Adds magic words for parser functions.
108 - *
109 - * @param $magicWords Array: available magic words
110 - * @param $langCode String: language code
111 - * @return Boolean: always true
112 - */
113 - public static function parserFunctionMagic( &$magicWords, $langCode = 'en' ) {
114 - $magicWords['shoutbox'] = array( 0, 'shoutbox' );
115 - return true;
116 - }
117 -
118 - /**
119108 * Embeds ShoutBox
120109 *
121110 * @param $parser Object: Instance of running Parser.
Index: trunk/extensions/ShoutBox/ShoutBox.i18n.magic.php
@@ -0,0 +1,10 @@
 2+<?php
 3+/**
 4+ * Internationalization file for magic words.
 5+ */
 6+
 7+$magicWords = array();
 8+
 9+$magicWords['en'] = array(
 10+ 'shoutbox' => array( 0, 'shoutbox' ),
 11+);
Property changes on: trunk/extensions/ShoutBox/ShoutBox.i18n.magic.php
___________________________________________________________________
Added: svn:eol-style
112 + native
Added: svn:keywords
213 + Id

Comments

#Comment by Bsitu (talk | contribs)   20:05, 19 January 2012

$wgExtensionMessagesFiles['StockCharts'] =  dirname( __FILE__ ) . '/StockCharts.i18n.php';
$wgExtensionMessagesFiles['StockChartsMagic'] =  dirname( __FILE__ ) . '/StockCharts.i18n.magic.php';

$wgAutoloadClasses['StockCharts'] = dirname( __FILE__ ) . '/StockCharts_body.php';

dirname( __FILE__ ) should be assigned to variable and use the variable instead of multiple call to this function

Status & tagging log