Index: trunk/extensions/QrCode/QrCode.php |
— | — | @@ -12,33 +12,33 @@ |
13 | 13 | * which is, in turn, based on C libqrencode library |
14 | 14 | * Copyright (C) 2006-2010 by Kentaro Fukuchi |
15 | 15 | * http://megaui.net/fukuchi/works/qrencode/index.en.html |
16 | | - * |
17 | | - * |
18 | 16 | */ |
19 | 17 | |
20 | | -if ( !defined( 'MEDIAWIKI' ) ) |
| 18 | +if ( !defined( 'MEDIAWIKI' ) ) { |
21 | 19 | die( 'This is a MediaWiki extension, and must be run from within MediaWiki.' ); |
| 20 | +} |
22 | 21 | |
23 | 22 | $wgExtensionCredits['parserhook'][] = array( |
24 | 23 | 'path' => __FILE__, |
25 | 24 | 'name' => 'QrCode', |
26 | 25 | 'version' => '0.02', |
27 | | - 'author' =>'David Raison', |
| 26 | + 'author' => array( 'David Raison' ), |
28 | 27 | 'url' => 'http://www.mediawiki.org/wiki/Extension:QrCode', |
29 | 28 | 'descriptionmsg' => 'qrcode-desc' |
30 | 29 | ); |
31 | 30 | |
32 | 31 | $wgAutoloadClasses['QRcode'] = dirname(__FILE__) . '/phpqrcode/qrlib.php'; |
33 | | -$wgExtensionFunctions[] = "efQrcodeSetup"; |
34 | 32 | $wgExtensionMessagesFiles['QrCode'] = dirname(__FILE__) .'/QrCode.i18n.php'; |
| 33 | + |
35 | 34 | $wgHooks['LanguageGetMagic'][] = 'wfQrCodeLanguageGetMagic'; |
| 35 | +$wgHooks['ParserFirstCallInit'][] = 'efQrcodeRegisterFunction'; |
36 | 36 | |
37 | | -function efQrcodeSetup(){ |
38 | | - global $wgParser; |
39 | | - $wgParser->setFunctionHook( 'qrcode', array(new MwQrCode, 'showCode' )); |
| 37 | +function efQrcodeRegisterFunction( Parser &$parser ) { |
| 38 | + $parser->setFunctionHook( 'qrcode', array( new MWQrCode(), 'showCode' ) ); |
| 39 | + return true; |
40 | 40 | } |
41 | 41 | |
42 | | -function wfQrCodeLanguageGetMagic( &$magicWords, $langCode='en' ) { |
| 42 | +function wfQrCodeLanguageGetMagic( &$magicWords, $langCode = 'en' ) { |
43 | 43 | $magicWords['qrcode'] = array( 0, 'qrcode' ); |
44 | 44 | return true; |
45 | 45 | } |
— | — | @@ -49,7 +49,7 @@ |
50 | 50 | $wgQrCodeBoundary = 2; // boundary around square |
51 | 51 | $wgQrCodeBot = 'QrCodeBot'; |
52 | 52 | |
53 | | -class MwQrCode { |
| 53 | +class MWQrCode { |
54 | 54 | |
55 | 55 | private $_dstFileName; // what the file will be named? |
56 | 56 | private $_label; // What will the qrcode contain? |
— | — | @@ -112,7 +112,7 @@ |
113 | 113 | * @return output of the _publish method |
114 | 114 | */ |
115 | 115 | private function _generate(){ |
116 | | - global $wgTmpDirectory; |
| 116 | + global $wgTmpDirectory, $wgQrCodeECC, $wgQrCodeSize, $wgQrCodeBoundary; |
117 | 117 | $tmpName = tempnam( $wgTmpDirectory, 'qrcode' ); |
118 | 118 | |
119 | 119 | QRcode::png( $this->_label, $tmpName, $this->_ecc, $this->_size, $this->_boundary ); |
— | — | @@ -164,4 +164,5 @@ |
165 | 165 | return true; |
166 | 166 | } |
167 | 167 | } |
168 | | -} |
| 168 | + |
| 169 | +} |
\ No newline at end of file |