r70045 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70044‎ | r70045 | r70046 >
Date:21:08, 27 July 2010
Author:platonides
Status:deferred
Tags:
Comment:
Use the parser provided by the hook.
Modified paths:
  • /trunk/extensions/WiktionaryInflection/WiktionaryInflection.php (modified) (history)

Diff [purge]

Index: trunk/extensions/WiktionaryInflection/WiktionaryInflection.php
@@ -57,32 +57,33 @@
5858 return new InflectionRule($ruleAttributes);
5959 }
6060
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 ) ) {
6664 $language = $argv["lang"];
67 - else
 65+ } else {
6866 return "?<!-- missing required \"lang\" parameter. -->";
69 - if(array_key_exists("pos", $argv))
 67+ }
 68+ if ( array_key_exists("pos", $argv) ) {
7069 $partOfSpeech = $argv["pos"];
71 - else
 70+ } else {
7271 return "?<!-- missing required \"pos\" parameter. -->";
73 - if(array_key_exists("generate", $argv))
 72+ }
 73+ if ( array_key_exists( "generate", $argv ) ) {
7474 $inflectionTypeToGenerate = $argv["generate"];
75 - else
 75+ } else {
7676 return "?<!-- missing required \"generate\" parameter. -->";
 77+ }
7778
78 - $entry = $wgParser->mTitle->getText();
 79+ $entry = $parser->mTitle->getText();
7980
8081 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 )
8485 {
8586 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) ) ) )
8788 {
8889 $inflectedForm = preg_replace(
8990 "/" . $rule->entryMatchPattern . "/",
@@ -91,7 +92,7 @@
9293 if($count >= 1)
9394 return $inflectedForm;
9495 }
95 - } elseif($rule->inflKeyPattern) {
 96+ } elseif ($rule->inflKeyPattern) {
9697 $inflectedForm = preg_replace(
9798 "/" . $rule->inflKeyPattern . "/",
9899 $rule->generationReplacementPattern[$inflectionTypeToGenerate],

Status & tagging log