Index: trunk/extensions/BookManager/BookManager.body.php |
— | — | @@ -3,65 +3,55 @@ |
4 | 4 | class BookManagerFunctions { |
5 | 5 | const VERSION = "0.1.6 "; |
6 | 6 | |
7 | | - static function register( ) { |
8 | | - global $wgParser; |
9 | | - |
| 7 | + static function register( $parser ) { |
10 | 8 | # optional SFH_NO_HASH to omit the hash from calls (e.g. {{int:...}} |
11 | 9 | # instead of {{#int:...}}) |
12 | | - $wgParser->setFunctionHook( 'prevpagename', array( __CLASS__, 'prevpagename' ), SFH_NO_HASH ); |
13 | | - $wgParser->setFunctionHook( 'prevpagenamee', array( __CLASS__, 'prevpagenamee' ), SFH_NO_HASH ); |
14 | | - $wgParser->setFunctionHook( 'nextpagename', array( __CLASS__, 'nextpagename' ), SFH_NO_HASH ); |
15 | | - $wgParser->setFunctionHook( 'nextpagenamee', array( __CLASS__, 'nextpagenamee' ), SFH_NO_HASH ); |
16 | | - $wgParser->setFunctionHook( 'rootpagename', array( __CLASS__, 'rootpagename' ), SFH_NO_HASH ); |
17 | | - $wgParser->setFunctionHook( 'rootpagenamee', array( __CLASS__, 'rootpagenamee' ), SFH_NO_HASH ); |
18 | | - $wgParser->setFunctionHook( 'chaptername', array( __CLASS__, 'chaptername' ), SFH_NO_HASH ); |
19 | | - $wgParser->setFunctionHook( 'chapternamee', array( __CLASS__, 'chapternamee' ), SFH_NO_HASH ); |
| 10 | + $parser->setFunctionHook( 'prevpagename', array( __CLASS__, 'prevpagename' ), SFH_NO_HASH ); |
| 11 | + $parser->setFunctionHook( 'prevpagenamee', array( __CLASS__, 'prevpagenamee' ), SFH_NO_HASH ); |
| 12 | + $parser->setFunctionHook( 'nextpagename', array( __CLASS__, 'nextpagename' ), SFH_NO_HASH ); |
| 13 | + $parser->setFunctionHook( 'nextpagenamee', array( __CLASS__, 'nextpagenamee' ), SFH_NO_HASH ); |
| 14 | + $parser->setFunctionHook( 'rootpagename', array( __CLASS__, 'rootpagename' ), SFH_NO_HASH ); |
| 15 | + $parser->setFunctionHook( 'rootpagenamee', array( __CLASS__, 'rootpagenamee' ), SFH_NO_HASH ); |
| 16 | + $parser->setFunctionHook( 'chaptername', array( __CLASS__, 'chaptername' ), SFH_NO_HASH ); |
| 17 | + $parser->setFunctionHook( 'chapternamee', array( __CLASS__, 'chapternamee' ), SFH_NO_HASH ); |
| 18 | + |
| 19 | + return true; |
20 | 20 | } |
21 | 21 | /**** All the BookManager functions to declare magicword id ****/ |
22 | 22 | static function DeclareVarIds( &$aCustomVariableIds ) { |
23 | 23 | # aCustomVariableIds is where MediaWiki wants to store its |
24 | 24 | # list of custom variable ids. We oblige by adding ours: |
25 | | - $aCustomVariableIds[] = MAG_PREVPAGENAME; |
26 | | - $aCustomVariableIds[] = MAG_PREVPAGENAMEE; |
27 | | - $aCustomVariableIds[] = MAG_NEXTPAGENAME; |
28 | | - $aCustomVariableIds[] = MAG_NEXTPAGENAMEE; |
29 | | - $aCustomVariableIds[] = MAG_ROOTPAGENAME; |
30 | | - $aCustomVariableIds[] = MAG_ROOTPAGENAMEE; |
31 | | - $aCustomVariableIds[] = MAG_CHAPTERNAME; |
32 | | - $aCustomVariableIds[] = MAG_CHAPTERNAMEE; |
| 25 | + $aCustomVariableIds[] = 'prevpagename'; |
| 26 | + $aCustomVariableIds[] = 'prevpagenamee'; |
| 27 | + $aCustomVariableIds[] = 'nextpagename'; |
| 28 | + $aCustomVariableIds[] = 'nextpagenamee'; |
| 29 | + $aCustomVariableIds[] = 'rootpagename'; |
| 30 | + $aCustomVariableIds[] = 'rootpagenamee'; |
| 31 | + $aCustomVariableIds[] = 'chaptername'; |
| 32 | + $aCustomVariableIds[] = 'chapternamee'; |
33 | 33 | return true; |
34 | 34 | } |
35 | | - /**** All the BookManager functions to declare magicwords ****/ |
| 35 | + /**** All the BookManager functions to declare magicwords ****/ |
36 | 36 | static function LanguageGetMagic( &$magicWords, $langCode = "en" ) { |
37 | | - switch ( $langCode ) { |
38 | | - default: |
39 | | - # PREVPAGENAME |
40 | | - $magicWords[MAG_PREVPAGENAME] = array ( 0, 'PREVPAGENAME' ); |
41 | | - $magicWords['prevpagename'] = $magicWords[MAG_PREVPAGENAME]; |
42 | | - # PREVPAGENAME |
43 | | - $magicWords[MAG_PREVPAGENAMEE] = array ( 0, 'PREVPAGENAMEE' ); |
44 | | - $magicWords['prevpagenamee'] = $magicWords[MAG_PREVPAGENAMEE]; |
45 | | - # NEXTPAGENAME |
46 | | - $magicWords[MAG_NEXTPAGENAME] = array ( 0, 'NEXTPAGENAME' ); |
47 | | - $magicWords['nextpagename'] = $magicWords[MAG_NEXTPAGENAME]; |
48 | | - # NEXTPAGENAMEE |
49 | | - $magicWords[MAG_NEXTPAGENAMEE] = array ( 0, 'NEXTPAGENAMEE' ); |
50 | | - $magicWords['nextpagenamee'] = $magicWords[MAG_NEXTPAGENAMEE]; |
51 | | - # ROOTPAGENAME |
52 | | - $magicWords[MAG_ROOTPAGENAME] = array ( 0, 'ROOTPAGENAME' , 'BOOKNAME' ); |
53 | | - $magicWords['rootpagename'] = $magicWords[MAG_ROOTPAGENAME]; |
54 | | - # ROOTPAGENAMEE |
55 | | - $magicWords[MAG_ROOTPAGENAMEE] = array ( 0, 'ROOTPAGENAMEE' , 'BOOKNAMEE' ); |
56 | | - $magicWords['rootpagenamee'] = $magicWords[MAG_ROOTPAGENAMEE]; |
57 | | - # CHAPTERNAME |
58 | | - $magicWords[MAG_CHAPTERNAME] = array ( 0, 'CHAPTERNAME' ); |
59 | | - $magicWords['chaptername'] = $magicWords[MAG_CHAPTERNAME]; |
60 | | - # CHAPTERNAMEE |
61 | | - $magicWords[MAG_CHAPTERNAMEE] = array ( 0, 'CHAPTERNAMEE' ); |
62 | | - $magicWords['chapternamee'] = $magicWords[MAG_CHAPTERNAMEE]; |
63 | | - } |
| 37 | + # PREVPAGENAME |
| 38 | + $magicWords['prevpagename'] = array ( 0, 'PREVPAGENAME' ); |
| 39 | + # PREVPAGENAME |
| 40 | + $magicWords['prevpagenamee'] = array ( 0, 'PREVPAGENAMEE' ); |
| 41 | + # NEXTPAGENAME |
| 42 | + $magicWords['nextpagename'] = array ( 0, 'NEXTPAGENAME' ); |
| 43 | + # NEXTPAGENAMEE |
| 44 | + $magicWords['nextpagenamee'] = array ( 0, 'NEXTPAGENAMEE' ); |
| 45 | + # ROOTPAGENAME |
| 46 | + $magicWords['rootpagename'] = array ( 0, 'ROOTPAGENAME' , 'BOOKNAME' ); |
| 47 | + # ROOTPAGENAMEE |
| 48 | + $magicWords['rootpagenamee'] = array ( 0, 'ROOTPAGENAMEE' , 'BOOKNAMEE' ); |
| 49 | + # CHAPTERNAME |
| 50 | + $magicWords['chaptername'] = array ( 0, 'CHAPTERNAME' ); |
| 51 | + # CHAPTERNAMEE |
| 52 | + $magicWords['chapternamee'] = array ( 0, 'CHAPTERNAMEE' ); |
| 53 | + |
64 | 54 | return true; |
65 | | - } |
| 55 | + } |
66 | 56 | /**** All the BookManager private functions ****/ |
67 | 57 | |
68 | 58 | |
— | — | @@ -257,28 +247,28 @@ |
258 | 248 | |
259 | 249 | static function AssignAValue( &$parser, &$cache, &$magicWordId, &$ret ) { |
260 | 250 | switch( $magicWordId ) { |
261 | | - case MAG_PREVPAGENAME: |
| 251 | + case 'prevpagename': |
262 | 252 | $ret = BookManagerFunctions::prevpagename( $parser ); |
263 | 253 | return true; |
264 | | - case MAG_PREVPAGENAMEE: |
| 254 | + case 'prevpagenamee': |
265 | 255 | $ret = BookManagerFunctions::prevpagenamee( $parser ); |
266 | 256 | return true; |
267 | | - case MAG_NEXTPAGENAME: |
| 257 | + case 'nextpagename': |
268 | 258 | $ret = BookManagerFunctions::nextpagename( $parser ); |
269 | 259 | return true; |
270 | | - case MAG_NEXTPAGENAMEE: |
| 260 | + case 'nextpagenamee': |
271 | 261 | $ret = BookManagerFunctions::nextpagenamee( $parser ); |
272 | 262 | return true; |
273 | | - case MAG_ROOTPAGENAME: |
| 263 | + case 'rootpagename': |
274 | 264 | $ret = BookManagerFunctions::rootpagename( $parser ); |
275 | 265 | return true; |
276 | | - case MAG_ROOTPAGENAMEE: |
| 266 | + case 'rootpagenamee': |
277 | 267 | $ret = BookManagerFunctions::rootpagenamee( $parser ); |
278 | 268 | return true; |
279 | | - case MAG_CHAPTERNAME: |
| 269 | + case 'chaptername': |
280 | 270 | $ret = BookManagerFunctions::chaptername( $parser ); |
281 | 271 | return true; |
282 | | - case MAG_CHAPTERNAMEE: |
| 272 | + case 'chapternamee': |
283 | 273 | $ret = BookManagerFunctions::chapternamee( $parser ); |
284 | 274 | return true; |
285 | 275 | } |
— | — | @@ -293,12 +283,12 @@ |
294 | 284 | */ |
295 | 285 | |
296 | 286 | static function addText( &$out, &$text ) { |
297 | | - global $wgTitle, $wgParser, $wgBookManagerNamespaces, $wgBookManagerNavbar; |
298 | | - $ns = $wgTitle->getNamespace(); |
| 287 | + global $wgParser, $wgBookManagerNamespaces, $wgBookManagerNavbar; |
| 288 | + $ns = $out->getTitle()->getNamespace(); |
299 | 289 | $opt = array( |
300 | 290 | 'parseinline', |
301 | 291 | ); |
302 | | - $currenttitletext = $wgTitle->getText(); |
| 292 | + $currenttitletext = $out->getTitle()->getText(); |
303 | 293 | $prev = self::pageText( $wgParser, $currenttitletext, - 1 ); |
304 | 294 | $base = Title::newFromText($currenttitletext)->getBaseText(); |
305 | 295 | $next = self::pageText( $wgParser, $currenttitletext, + 1 ); |
Index: trunk/extensions/BookManager/BookManager.php |
— | — | @@ -63,17 +63,8 @@ |
64 | 64 | $wgCommunityCollectionNamespace = NS_PROJECT; |
65 | 65 | |
66 | 66 | /**** Register magic words ****/ |
67 | | -$wgExtensionFunctions[] = 'BookManagerFunctions::register'; |
| 67 | +$wgHooks['ParserFirstCallInit'][] = 'BookManagerFunctions::register'; |
68 | 68 | |
69 | | -define( 'MAG_PREVPAGENAME', 'magicbookmanagercustomvar0' ); |
70 | | -define( 'MAG_PREVPAGENAMEE', 'magicbookmanagercustomvar1' ); |
71 | | -define( 'MAG_NEXTPAGENAME', 'magicbookmanagercustomvar2' ); |
72 | | -define( 'MAG_NEXTPAGENAMEE', 'magicbookmanagercustomvar3' ); |
73 | | -define( 'MAG_ROOTPAGENAME', 'magicbookmanagercustomvar4' ); |
74 | | -define( 'MAG_ROOTPAGENAMEE', 'magicbookmanagercustomvar5' ); |
75 | | -define( 'MAG_CHAPTERNAME', 'magicbookmanagercustomvar6' ); |
76 | | -define( 'MAG_CHAPTERNAMEE', 'magicbookmanagercustomvar7' ); |
77 | | - |
78 | 69 | $wgHooks['LanguageGetMagic'][] = 'BookManagerFunctions::LanguageGetMagic'; |
79 | 70 | |
80 | 71 | $wgHooks['MagicWordwgVariableIDs'][] = 'BookManagerFunctions::DeclareVarIds'; |