Index: trunk/extensions/ThumbParser/ThumbParser.php |
— | — | @@ -27,36 +27,5 @@ |
28 | 28 | $wgExtensionMessagesFiles['ThumbParserMagic'] = $dir . 'ThumbParser.i18n.magic.php'; |
29 | 29 | |
30 | 30 | # Define a setup function |
31 | | -$wgHooks['ParserFirstCallInit'][] = 'efThumbParserFunction_Setup'; |
32 | | - |
33 | | -function efThumbParserFunction_Setup( $parser ) { |
34 | | - # Set a function hook associating the "example" magic word with our function |
35 | | - $parser->setFunctionHook( 'thumb', 'efThumbParserFunction_Render' ); |
36 | | - return true; |
37 | | -} |
38 | | - |
39 | | -function efThumbParserFunction_Render( $parser, $param1 = '') { |
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 | | -} |
| 31 | +$wgAutoloadClasses['ThumbParserHooks'] = "$dir/ThumbParser.hooks.php"; |
| 32 | +$wgHooks['ParserFirstCallInit'][] = 'ThumbParserHooks::efThumbParserFunction_Setup'; |
Index: trunk/extensions/ThumbParser/ThumbParser.hooks.php |
— | — | @@ -0,0 +1,34 @@ |
| 2 | +<?php |
| 3 | +class ThumbParserHooks { |
| 4 | + function efThumbParserFunction_Setup( $parser ) { |
| 5 | + # Set a function hook associating the "example" magic word with our function |
| 6 | + $parser->setFunctionHook( 'thumb', 'efThumbParserFunction_Render' ); |
| 7 | + return true; |
| 8 | + } |
| 9 | + |
| 10 | + function efThumbParserFunction_Render( $parser, $param1 = '') { |
| 11 | + # The parser function itself |
| 12 | + # The input parameters are wikitext with templates expanded |
| 13 | + # The output should be wikitext too |
| 14 | + global $wgThumbLimits, $wgUser; |
| 15 | + $param1 = strtolower($param1); |
| 16 | + $parser->disableCache(); # Mark this content as uncacheable |
| 17 | + $wopt = $wgUser->getOption('thumbsize'); |
| 18 | + switch ($param1) { |
| 19 | + case 'size': |
| 20 | + $output = $wgThumbLimits[$wopt]; |
| 21 | + break; |
| 22 | + case 'px': |
| 23 | + $output = $wgThumbLimits[$wopt].'px'; |
| 24 | + break; |
| 25 | + case 'width': |
| 26 | + $size = intval($wgThumbLimits[$wopt])+10; |
| 27 | + $strsize = strval($size); |
| 28 | + $output = $strsize."px"; |
| 29 | + break; |
| 30 | + default: |
| 31 | + $output = $wgThumbLimits[$wopt]; |
| 32 | + } |
| 33 | + return $output; |
| 34 | + } |
| 35 | +} |
Property changes on: trunk/extensions/ThumbParser/ThumbParser.hooks.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 36 | + native |