Index: trunk/extensions/ParserFunctions/ParserFunctions_body.php |
— | — | @@ -108,14 +108,6 @@ |
109 | 109 | return $result; |
110 | 110 | } |
111 | 111 | |
112 | | - public static function ifHook( $parser, $test = '', $then = '', $else = '' ) { |
113 | | - if ( $test !== '' ) { |
114 | | - return $then; |
115 | | - } else { |
116 | | - return $else; |
117 | | - } |
118 | | - } |
119 | | - |
120 | 112 | public static function ifObj( $parser, $frame, $args ) { |
121 | 113 | $test = isset( $args[0] ) ? trim( $frame->expand( $args[0] ) ) : ''; |
122 | 114 | if ( $test !== '' ) { |
— | — | @@ -125,14 +117,6 @@ |
126 | 118 | } |
127 | 119 | } |
128 | 120 | |
129 | | - public static function ifeq( $parser, $left = '', $right = '', $then = '', $else = '' ) { |
130 | | - if ( $left == $right ) { |
131 | | - return $then; |
132 | | - } else { |
133 | | - return $else; |
134 | | - } |
135 | | - } |
136 | | - |
137 | 121 | public static function ifeqObj( $parser, $frame, $args ) { |
138 | 122 | $left = isset( $args[0] ) ? trim( $frame->expand( $args[0] ) ) : ''; |
139 | 123 | $right = isset( $args[1] ) ? trim( $frame->expand( $args[1] ) ) : ''; |
— | — | @@ -165,47 +149,7 @@ |
166 | 150 | } |
167 | 151 | } |
168 | 152 | |
169 | | - public static function switchHook( $parser /*,...*/ ) { |
170 | | - $args = func_get_args(); |
171 | | - array_shift( $args ); |
172 | | - $primary = trim( array_shift( $args ) ); |
173 | | - $found = $defaultFound = false; |
174 | | - $parts = null; |
175 | | - $default = null; |
176 | | - $mwDefault =& MagicWord::get( 'default' ); |
177 | | - foreach ( $args as $arg ) { |
178 | | - $parts = array_map( 'trim', explode( '=', $arg, 2 ) ); |
179 | | - if ( count( $parts ) == 2 ) { |
180 | | - # Found "=" |
181 | | - if ( $found || $parts[0] == $primary ) { |
182 | | - # Found a match, return now |
183 | | - return $parts[1]; |
184 | | - } elseif ( $defaultFound || $mwDefault->matchStartAndRemove( $parts[0] ) ) { |
185 | | - $default = $parts[1]; |
186 | | - } # else wrong case, continue |
187 | | - } elseif ( count( $parts ) == 1 ) { |
188 | | - # Multiple input, single output |
189 | | - # If the value matches, set a flag and continue |
190 | | - if ( $parts[0] == $primary ) { |
191 | | - $found = true; |
192 | | - } elseif ( $mwDefault->matchStartAndRemove( $parts[0] ) ) { |
193 | | - $defaultFound = true; |
194 | | - } |
195 | | - } # else RAM corruption due to cosmic ray? |
196 | | - } |
197 | | - # Default case |
198 | | - # Check if the last item had no = sign, thus specifying the default case |
199 | | - if ( count( $parts ) == 1 ) { |
200 | | - return $parts[0]; |
201 | | - } elseif ( !is_null( $default ) ) { |
202 | | - return $default; |
203 | | - } else { |
204 | | - return ''; |
205 | | - } |
206 | | - } |
207 | | - |
208 | 153 | /** |
209 | | - * @static |
210 | 154 | * @param $parser Parser |
211 | 155 | * @param $frame PPFrame |
212 | 156 | * @param $args |
— | — | @@ -348,10 +292,6 @@ |
349 | 293 | return $parser->mExpensiveFunctionCount <= $wgExpensiveParserFunctionLimit; |
350 | 294 | } |
351 | 295 | |
352 | | - public static function ifexist( $parser, $title = '', $then = '', $else = '' ) { |
353 | | - return self::ifexistCommon( $parser, false, $title, $then, $else ); |
354 | | - } |
355 | | - |
356 | 296 | public static function ifexistCommon( $parser, $frame, $titletext = '', $then = '', $else = '' ) { |
357 | 297 | global $wgContLang; |
358 | 298 | $title = Title::newFromText( $titletext ); |
Index: trunk/extensions/ParserFunctions/ParserFunctions.php |
— | — | @@ -50,7 +50,7 @@ |
51 | 51 | $wgExtensionCredits['parserhook'][] = array( |
52 | 52 | 'path' => __FILE__, |
53 | 53 | 'name' => 'ParserFunctions', |
54 | | - 'version' => '1.4.0', |
| 54 | + 'version' => '1.4.1', |
55 | 55 | 'url' => 'https://www.mediawiki.org/wiki/Extension:ParserFunctions', |
56 | 56 | 'author' => array( 'Tim Starling', 'Robert Rohde', 'Ross McClure', 'Juraj Simlovic' ), |
57 | 57 | 'descriptionmsg' => 'pfunc_desc', |
— | — | @@ -76,22 +76,13 @@ |
77 | 77 | function wfRegisterParserFunctions( $parser ) { |
78 | 78 | global $wgPFEnableStringFunctions, $wgPFEnableConvert; |
79 | 79 | |
80 | | - if ( defined( get_class( $parser ) . '::SFH_OBJECT_ARGS' ) ) { |
81 | | - // These functions accept DOM-style arguments |
82 | | - $parser->setFunctionHook( 'if', 'ExtParserFunctions::ifObj', SFH_OBJECT_ARGS ); |
83 | | - $parser->setFunctionHook( 'ifeq', 'ExtParserFunctions::ifeqObj', SFH_OBJECT_ARGS ); |
84 | | - $parser->setFunctionHook( 'switch', 'ExtParserFunctions::switchObj', SFH_OBJECT_ARGS ); |
85 | | - $parser->setFunctionHook( 'ifexist', 'ExtParserFunctions::ifexistObj', SFH_OBJECT_ARGS ); |
86 | | - $parser->setFunctionHook( 'ifexpr', 'ExtParserFunctions::ifexprObj', SFH_OBJECT_ARGS ); |
87 | | - $parser->setFunctionHook( 'iferror', 'ExtParserFunctions::iferrorObj', SFH_OBJECT_ARGS ); |
88 | | - } else { |
89 | | - $parser->setFunctionHook( 'if', 'ExtParserFunctions::ifHook' ); |
90 | | - $parser->setFunctionHook( 'ifeq', 'ExtParserFunctions::ifeq' ); |
91 | | - $parser->setFunctionHook( 'switch', 'ExtParserFunctions::switchHook' ); |
92 | | - $parser->setFunctionHook( 'ifexist', 'ExtParserFunctions::ifexist' ); |
93 | | - $parser->setFunctionHook( 'ifexpr', 'ExtParserFunctions::ifexpr' ); |
94 | | - $parser->setFunctionHook( 'iferror', 'ExtParserFunctions::iferror' ); |
95 | | - } |
| 80 | + // These functions accept DOM-style arguments |
| 81 | + $parser->setFunctionHook( 'if', 'ExtParserFunctions::ifObj', SFH_OBJECT_ARGS ); |
| 82 | + $parser->setFunctionHook( 'ifeq', 'ExtParserFunctions::ifeqObj', SFH_OBJECT_ARGS ); |
| 83 | + $parser->setFunctionHook( 'switch', 'ExtParserFunctions::switchObj', SFH_OBJECT_ARGS ); |
| 84 | + $parser->setFunctionHook( 'ifexist', 'ExtParserFunctions::ifexistObj', SFH_OBJECT_ARGS ); |
| 85 | + $parser->setFunctionHook( 'ifexpr', 'ExtParserFunctions::ifexprObj', SFH_OBJECT_ARGS ); |
| 86 | + $parser->setFunctionHook( 'iferror', 'ExtParserFunctions::iferrorObj', SFH_OBJECT_ARGS ); |
96 | 87 | |
97 | 88 | $parser->setFunctionHook( 'expr', 'ExtParserFunctions::expr' ); |
98 | 89 | $parser->setFunctionHook( 'time', 'ExtParserFunctions::time' ); |