Index: trunk/extensions/redircite/redircite.php |
— | — | @@ -16,7 +16,6 @@ |
17 | 17 | * |
18 | 18 | */ |
19 | 19 | |
20 | | -$wgExtensionFunctions[] = 'redircite_setup'; |
21 | 20 | $wgExtensionCredits['other'][] = array( |
22 | 21 | 'name' => 'redircite', |
23 | 22 | 'author' => 'Roan Kattouw', |
— | — | @@ -25,19 +24,20 @@ |
26 | 25 | 'url' => 'http://www.mediawiki.org/wiki/Extension:Redircite' |
27 | 26 | ); |
28 | 27 | |
29 | | -function redircite_setup() { |
30 | | - global $wgParser, $wgHooks; |
31 | | - $wgParser->setHook('redircite', 'redircite_render'); |
32 | | - $wgHooks['ParserAfterTidy'][] = 'redircite_afterTidy'; |
| 28 | +$wgHooks['ParserAfterTidy'][] = 'redircite_afterTidy'; |
| 29 | +$wgHooks['ParserFirstCallInit'][] = 'redircite_setup'; |
| 30 | +function redircite_setup($parser) { |
| 31 | + $parser->setHook('redircite', 'redircite_render'); |
| 32 | + return true; |
33 | 33 | } |
34 | 34 | |
35 | | -$markerList = array(); |
| 35 | +$redirciteMarkerList = array(); |
36 | 36 | function redircite_render($input, $args, $parser) { |
37 | | - // Generate HTML code and add it to the $markerList array |
| 37 | + // Generate HTML code and add it to the $redirciteMarkerList array |
38 | 38 | // Add "xx-redircite-marker-NUMBER-redircite-xx" to the output, |
39 | | - // which will be translated to the HTML stored in $markerList by |
| 39 | + // which will be translated to the HTML stored in $redirciteMarkerList by |
40 | 40 | // redircite_afterTidy() |
41 | | - global $markerList; |
| 41 | + global $redirciteMarkerList; |
42 | 42 | $lparse = clone $parser; |
43 | 43 | $link1 = $lparse->parse("[[$input]]", $parser->mTitle, $parser->mOptions, false, false); |
44 | 44 | $link1text = $link1->getText(); |
— | — | @@ -54,16 +54,16 @@ |
55 | 55 | $link2 = $lparse->parse("[[{$title2->getPrefixedText()}|$input]]", $parser->mTitle, $parser->mOptions, false, false); |
56 | 56 | $link2text = $link2->getText(); |
57 | 57 | |
58 | | - $marker = "xx-redircite-marker-" . count($markerList) . "-redircite-xx"; |
59 | | - $markerList[] = "<span onmouseout='this.firstChild.innerHTML = \"$input\";' onmouseover='this.firstChild.innerHTML = \"{$title2->getPrefixedText()}\";'>$link2text</span>"; |
| 58 | + $marker = "xx-redircite-marker-" . count($redirciteMarkerList) . "-redircite-xx"; |
| 59 | + $redirciteMarkerList[] = "<span onmouseout='this.firstChild.innerHTML = \"$input\";' onmouseover='this.firstChild.innerHTML = \"{$title2->getPrefixedText()}\";'>$link2text</span>"; |
60 | 60 | return $marker; |
61 | 61 | } |
62 | 62 | |
63 | 63 | function redircite_afterTidy(&$parser, &$text) { |
64 | 64 | // Translate the markers added by redircite_render() to the HTML |
65 | | - // associated with them through $markerList |
66 | | - global $markerList; |
67 | | - foreach($markerList as $i => $output) |
| 65 | + // associated with them through $redirciteMarkerList |
| 66 | + global $redirciteMarkerList; |
| 67 | + foreach($redirciteMarkerList as $i => $output) |
68 | 68 | $text = preg_replace("/xx-redircite-marker-$i-redircite-xx/", $output, $text); |
69 | 69 | return true; |
70 | 70 | } |
\ No newline at end of file |