Index: trunk/extensions/WiktionaryInflection/WiktionaryInflection.php |
— | — | @@ -57,32 +57,33 @@ |
58 | 58 | return new InflectionRule($ruleAttributes); |
59 | 59 | } |
60 | 60 | |
61 | | -function renderInflection($input, $argv) { |
62 | | - global $wgParser, $wgUser; |
63 | | - |
64 | | - $key = $wgParser->replaceVariables($input, end( $wgParser->mArgStack )); |
65 | | - if(array_key_exists("lang", $argv)) |
| 61 | +function renderInflection($input, $argv, $parser, $frame) { |
| 62 | + $key = $parser->replaceVariables( $input, $frame ); |
| 63 | + if( array_key_exists( "lang", $argv ) ) { |
66 | 64 | $language = $argv["lang"]; |
67 | | - else |
| 65 | + } else { |
68 | 66 | return "?<!-- missing required \"lang\" parameter. -->"; |
69 | | - if(array_key_exists("pos", $argv)) |
| 67 | + } |
| 68 | + if ( array_key_exists("pos", $argv) ) { |
70 | 69 | $partOfSpeech = $argv["pos"]; |
71 | | - else |
| 70 | + } else { |
72 | 71 | return "?<!-- missing required \"pos\" parameter. -->"; |
73 | | - if(array_key_exists("generate", $argv)) |
| 72 | + } |
| 73 | + if ( array_key_exists( "generate", $argv ) ) { |
74 | 74 | $inflectionTypeToGenerate = $argv["generate"]; |
75 | | - else |
| 75 | + } else { |
76 | 76 | return "?<!-- missing required \"generate\" parameter. -->"; |
| 77 | + } |
77 | 78 | |
78 | | - $entry = $wgParser->mTitle->getText(); |
| 79 | + $entry = $parser->mTitle->getText(); |
79 | 80 | |
80 | 81 | try { |
81 | | - $rules = readRules($language, $partOfSpeech); |
82 | | - foreach($rules as $rule) { |
83 | | - if($rule->entryMatchPattern) |
| 82 | + $rules = readRules( $language, $partOfSpeech ); |
| 83 | + foreach ( $rules as $rule ) { |
| 84 | + if ( $rule->entryMatchPattern ) |
84 | 85 | { |
85 | 86 | if(!$rule->inflKeyPattern || |
86 | | - ($rule->inflKeyPattern && preg_match("/" . $rule->inflKeyPattern . "/", $wgParser->replaceVariables($key, $wgParser->mArgStack)))) |
| 87 | + ($rule->inflKeyPattern && preg_match("/" . $rule->inflKeyPattern . "/", $parser->replaceVariables($key, $frame) ) ) ) |
87 | 88 | { |
88 | 89 | $inflectedForm = preg_replace( |
89 | 90 | "/" . $rule->entryMatchPattern . "/", |
— | — | @@ -91,7 +92,7 @@ |
92 | 93 | if($count >= 1) |
93 | 94 | return $inflectedForm; |
94 | 95 | } |
95 | | - } elseif($rule->inflKeyPattern) { |
| 96 | + } elseif ($rule->inflKeyPattern) { |
96 | 97 | $inflectedForm = preg_replace( |
97 | 98 | "/" . $rule->inflKeyPattern . "/", |
98 | 99 | $rule->generationReplacementPattern[$inflectionTypeToGenerate], |