r74170 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74169‎ | r74170 | r74171 >
Date:22:36, 2 October 2010
Author:siebrand
Status:ok
Tags:
Comment:
* remove MediaWiki pre-1.8 compatibility and remove SprintfDateCompat.php
* bump version to 1.4.0
* run stylize.php
Modified paths:
  • /trunk/extensions/ParserFunctions/COPYING (modified) (history)
  • /trunk/extensions/ParserFunctions/Expr.php (modified) (history)
  • /trunk/extensions/ParserFunctions/ParserFunctions.php (modified) (history)
  • /trunk/extensions/ParserFunctions/ParserFunctions_body.php (modified) (history)
  • /trunk/extensions/ParserFunctions/README (modified) (history)
  • /trunk/extensions/ParserFunctions/SprintfDateCompat.php (deleted) (history)
  • /trunk/extensions/ParserFunctions/testExpr.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ParserFunctions/SprintfDateCompat.php
@@ -1,221 +0,0 @@
2 -<?php
3 -
4 -# sprintfDate support for MW<1.8 installations
5 -class SprintfDateCompat {
6 -
7 - static function sprintfDate( $format, $ts ) {
8 - global $wgContLang;
9 -
10 - $s = '';
11 - $raw = false;
12 - $roman = false;
13 - $unix = false;
14 - $rawToggle = false;
15 - for ( $p = 0; $p < strlen( $format ); $p++ ) {
16 - $num = false;
17 - $code = $format[$p];
18 - if ( $code == 'x' && $p < strlen( $format ) - 1 ) {
19 - $code .= $format[++$p];
20 - }
21 -
22 - switch ( $code ) {
23 - case 'xx':
24 - $s .= 'x';
25 - break;
26 - case 'xn':
27 - $raw = true;
28 - break;
29 - case 'xN':
30 - $rawToggle = !$rawToggle;
31 - break;
32 - case 'xr':
33 - $roman = true;
34 - break;
35 - case 'xg':
36 - $s .= $wgContLang->getMonthNameGen( substr( $ts, 4, 2 ) );
37 - break;
38 - case 'd':
39 - $num = substr( $ts, 6, 2 );
40 - break;
41 - case 'D':
42 - if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
43 - # Weekday abbreviations are not available in MW<1.8
44 - #$s .= $this->getWeekdayAbbreviation( date( 'w', $unix ) + 1 );
45 - $s .= date( 'D', $unix );
46 - break;
47 - case 'j':
48 - $num = intval( substr( $ts, 6, 2 ) );
49 - break;
50 - case 'l':
51 - if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
52 - $s .= $wgContLang->getWeekdayName( date( 'w', $unix ) + 1 );
53 - break;
54 - case 'N':
55 - if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
56 - $w = date( 'w', $unix );
57 - $num = $w ? $w : 7;
58 - break;
59 - case 'w':
60 - if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
61 - $num = date( 'w', $unix );
62 - break;
63 - case 'z':
64 - if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
65 - $num = date( 'z', $unix );
66 - break;
67 - case 'W':
68 - if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
69 - $num = date( 'W', $unix );
70 - break;
71 - case 'F':
72 - $s .= $wgContLang->getMonthName( substr( $ts, 4, 2 ) );
73 - break;
74 - case 'm':
75 - $num = substr( $ts, 4, 2 );
76 - break;
77 - case 'M':
78 - $s .= $wgContLang->getMonthAbbreviation( substr( $ts, 4, 2 ) );
79 - break;
80 - case 'n':
81 - $num = intval( substr( $ts, 4, 2 ) );
82 - break;
83 - case 't':
84 - if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
85 - $num = date( 't', $unix );
86 - break;
87 - case 'L':
88 - if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
89 - $num = date( 'L', $unix );
90 - break;
91 - # 'o' is supported since PHP 5.1.0
92 - # return literal if not supported
93 - # TODO: emulation for pre 5.1.0 versions
94 - case 'o':
95 - if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
96 - if ( version_compare(PHP_VERSION, '5.1.0') === 1 )
97 - $num = date( 'o', $unix );
98 - else
99 - $s .= 'o';
100 - break;
101 - case 'Y':
102 - $num = substr( $ts, 0, 4 );
103 - break;
104 - case 'y':
105 - $num = substr( $ts, 2, 2 );
106 - break;
107 - case 'a':
108 - $s .= intval( substr( $ts, 8, 2 ) ) < 12 ? 'am' : 'pm';
109 - break;
110 - case 'A':
111 - $s .= intval( substr( $ts, 8, 2 ) ) < 12 ? 'AM' : 'PM';
112 - break;
113 - case 'g':
114 - $h = substr( $ts, 8, 2 );
115 - $num = $h % 12 ? $h % 12 : 12;
116 - break;
117 - case 'G':
118 - $num = intval( substr( $ts, 8, 2 ) );
119 - break;
120 - case 'h':
121 - $h = substr( $ts, 8, 2 );
122 - $num = sprintf( '%02d', $h % 12 ? $h % 12 : 12 );
123 - break;
124 - case 'H':
125 - $num = substr( $ts, 8, 2 );
126 - break;
127 - case 'i':
128 - $num = substr( $ts, 10, 2 );
129 - break;
130 - case 's':
131 - $num = substr( $ts, 12, 2 );
132 - break;
133 - case 'c':
134 - if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
135 - $s .= date( 'c', $unix );
136 - break;
137 - case 'r':
138 - if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
139 - $s .= date( 'r', $unix );
140 - break;
141 - case 'U':
142 - if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
143 - $num = $unix;
144 - break;
145 - case 'B':
146 - if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
147 - $num = date( 'B', $unix );
148 - break;
149 - case 'S':
150 - if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
151 - $num = date( 'S', $unix );
152 - break;
153 -
154 - case '\\':
155 - # Backslash escaping
156 - if ( $p < strlen( $format ) - 1 ) {
157 - $s .= $format[++$p];
158 - } else {
159 - $s .= '\\';
160 - }
161 - break;
162 - case '"':
163 - # Quoted literal
164 - if ( $p < strlen( $format ) - 1 ) {
165 - $endQuote = strpos( $format, '"', $p + 1 );
166 - if ( $endQuote === false ) {
167 - # No terminating quote, assume literal "
168 - $s .= '"';
169 - } else {
170 - $s .= substr( $format, $p + 1, $endQuote - $p - 1 );
171 - $p = $endQuote;
172 - }
173 - } else {
174 - # Quote at end of string, assume literal "
175 - $s .= '"';
176 - }
177 - break;
178 - default:
179 - $s .= $format[$p];
180 - }
181 - if ( $num !== false ) {
182 - if ( $rawToggle || $raw ) {
183 - $s .= $num;
184 - $raw = false;
185 - } elseif ( $roman ) {
186 - $s .= self::romanNumeral( $num );
187 - $roman = false;
188 - } else {
189 - $s .= $wgContLang->formatNum( $num, true );
190 - }
191 - $num = false;
192 - }
193 - }
194 - return $s;
195 - }
196 -
197 - /**
198 - * Roman number formatting up to 3000
199 - */
200 - static function romanNumeral( $num ) {
201 - static $table = array(
202 - array( '', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX', 'X' ),
203 - array( '', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC', 'C' ),
204 - array( '', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM', 'M' ),
205 - array( '', 'M', 'MM', 'MMM' )
206 - );
207 -
208 - $num = intval( $num );
209 - if ( $num > 3000 || $num <= 0 ) {
210 - return $num;
211 - }
212 -
213 - $s = '';
214 - for ( $pow10 = 1000, $i = 3; $i >= 0; $pow10 /= 10, $i-- ) {
215 - if ( $num >= $pow10 ) {
216 - $s .= $table[$i][floor($num / $pow10)];
217 - }
218 - $num = $num % $pow10;
219 - }
220 - return $s;
221 - }
222 -}
Index: trunk/extensions/ParserFunctions/Expr.php
@@ -47,7 +47,7 @@
4848 define( 'EXPR_PI', 36 );
4949
5050 class ExprError extends Exception {
51 - public function __construct($msg, $parameter = ''){
 51+ public function __construct( $msg, $parameter = '' ) {
5252 wfLoadExtensionMessages( 'ParserFunctions' );
5353 $this->message = '<strong class="error">' . wfMsgForContent( "pfunc_expr_$msg", htmlspecialchars( $parameter ) ) . '</strong>';
5454 }
@@ -173,7 +173,7 @@
174174
175175 while ( $p < $end ) {
176176 if ( count( $operands ) > $this->maxStackSize || count( $operators ) > $this->maxStackSize ) {
177 - throw new ExprError('stack_exhausted');
 177+ throw new ExprError( 'stack_exhausted' );
178178 }
179179 $char = $expr[$p];
180180 $char2 = substr( $expr, $p, 2 );
@@ -191,7 +191,7 @@
192192 } elseif ( false !== strpos( EXPR_NUMBER_CLASS, $char ) ) {
193193 // Number
194194 if ( $expecting != 'expression' ) {
195 - throw new ExprError('unexpected_number');
 195+ throw new ExprError( 'unexpected_number' );
196196 }
197197
198198 // Find the rest of it
@@ -207,14 +207,14 @@
208208 $remaining = substr( $expr, $p );
209209 if ( !preg_match( '/^[A-Za-z]*/', $remaining, $matches ) ) {
210210 // This should be unreachable
211 - throw new ExprError('preg_match_failure');
 211+ throw new ExprError( 'preg_match_failure' );
212212 }
213213 $word = strtolower( $matches[0] );
214214 $p += strlen( $word );
215215
216216 // Interpret the word
217 - if ( !isset( $this->words[$word] ) ){
218 - throw new ExprError('unrecognised_word', $word);
 217+ if ( !isset( $this->words[$word] ) ) {
 218+ throw new ExprError( 'unrecognised_word', $word );
219219 }
220220 $op = $this->words[$word];
221221 switch( $op ) {
@@ -223,7 +223,7 @@
224224 if ( $expecting != 'expression' ) {
225225 continue;
226226 }
227 - $operands[] = exp(1);
 227+ $operands[] = exp( 1 );
228228 $expecting = 'operator';
229229 continue 2;
230230 case EXPR_PI:
@@ -274,7 +274,7 @@
275275 }
276276
277277 // Finally the single-character operators
278 -
 278+
279279 elseif ( $char == '+' ) {
280280 ++$p;
281281 if ( $expecting == 'expression' ) {
@@ -309,7 +309,7 @@
310310 ++$p;
311311 } elseif ( $char == '(' ) {
312312 if ( $expecting == 'operator' ) {
313 - throw new ExprError('unexpected_operator', '(');
 313+ throw new ExprError( 'unexpected_operator', '(' );
314314 }
315315 $operators[] = EXPR_OPEN;
316316 ++$p;
@@ -324,7 +324,7 @@
325325 if ( $lastOp ) {
326326 array_pop( $operators );
327327 } else {
328 - throw new ExprError('unexpected_closing_bracket');
 328+ throw new ExprError( 'unexpected_closing_bracket' );
329329 }
330330 $expecting = 'operator';
331331 ++$p;
@@ -342,12 +342,12 @@
343343 $op = EXPR_GREATER;
344344 ++$p;
345345 } else {
346 - throw new ExprError('unrecognised_punctuation', UtfNormal::cleanUp( $char ));
 346+ throw new ExprError( 'unrecognised_punctuation', UtfNormal::cleanUp( $char ) );
347347 }
348348
349349 // Binary operator processing
350350 if ( $expecting == 'expression' ) {
351 - throw new ExprError('unexpected_operator', $name);
 351+ throw new ExprError( 'unexpected_operator', $name );
352352 }
353353
354354 // Shunting yard magic
@@ -364,7 +364,7 @@
365365 // Finish off the operator array
366366 while ( $op = array_pop( $operators ) ) {
367367 if ( $op == EXPR_OPEN ) {
368 - throw new ExprError('unclosed_bracket');
 368+ throw new ExprError( 'unclosed_bracket' );
369369 }
370370 $this->doOperation( $op, $operands );
371371 }
@@ -375,182 +375,182 @@
376376 function doOperation( $op, &$stack ) {
377377 switch ( $op ) {
378378 case EXPR_NEGATIVE:
379 - if ( count( $stack ) < 1 ) throw new ExprError('missing_operand', $this->names[$op]);
 379+ if ( count( $stack ) < 1 ) throw new ExprError( 'missing_operand', $this->names[$op] );
380380 $arg = array_pop( $stack );
381381 $stack[] = -$arg;
382382 break;
383383 case EXPR_POSITIVE:
384 - if ( count( $stack ) < 1 ) throw new ExprError('missing_operand', $this->names[$op]);
 384+ if ( count( $stack ) < 1 ) throw new ExprError( 'missing_operand', $this->names[$op] );
385385 break;
386386 case EXPR_TIMES:
387 - if ( count( $stack ) < 2 ) throw new ExprError('missing_operand', $this->names[$op]);
 387+ if ( count( $stack ) < 2 ) throw new ExprError( 'missing_operand', $this->names[$op] );
388388 $right = array_pop( $stack );
389389 $left = array_pop( $stack );
390390 $stack[] = $left * $right;
391391 break;
392392 case EXPR_DIVIDE:
393 - if ( count( $stack ) < 2 ) throw new ExprError('missing_operand', $this->names[$op]);
 393+ if ( count( $stack ) < 2 ) throw new ExprError( 'missing_operand', $this->names[$op] );
394394 $right = array_pop( $stack );
395395 $left = array_pop( $stack );
396 - if ( $right == 0 ) throw new ExprError('division_by_zero', $this->names[$op]);
 396+ if ( $right == 0 ) throw new ExprError( 'division_by_zero', $this->names[$op] );
397397 $stack[] = $left / $right;
398398 break;
399399 case EXPR_MOD:
400 - if ( count( $stack ) < 2 ) throw new ExprError('missing_operand', $this->names[$op]);
 400+ if ( count( $stack ) < 2 ) throw new ExprError( 'missing_operand', $this->names[$op] );
401401 $right = array_pop( $stack );
402402 $left = array_pop( $stack );
403 - if ( $right == 0 ) throw new ExprError('division_by_zero', $this->names[$op]);
 403+ if ( $right == 0 ) throw new ExprError( 'division_by_zero', $this->names[$op] );
404404 $stack[] = $left % $right;
405405 break;
406406 case EXPR_PLUS:
407 - if ( count( $stack ) < 2 ) throw new ExprError('missing_operand', $this->names[$op]);
 407+ if ( count( $stack ) < 2 ) throw new ExprError( 'missing_operand', $this->names[$op] );
408408 $right = array_pop( $stack );
409409 $left = array_pop( $stack );
410410 $stack[] = $left + $right;
411411 break;
412412 case EXPR_MINUS:
413 - if ( count( $stack ) < 2 ) throw new ExprError('missing_operand', $this->names[$op]);
 413+ if ( count( $stack ) < 2 ) throw new ExprError( 'missing_operand', $this->names[$op] );
414414 $right = array_pop( $stack );
415415 $left = array_pop( $stack );
416416 $stack[] = $left - $right;
417417 break;
418418 case EXPR_AND:
419 - if ( count( $stack ) < 2 ) throw new ExprError('missing_operand', $this->names[$op]);
 419+ if ( count( $stack ) < 2 ) throw new ExprError( 'missing_operand', $this->names[$op] );
420420 $right = array_pop( $stack );
421421 $left = array_pop( $stack );
422422 $stack[] = ( $left && $right ) ? 1 : 0;
423423 break;
424424 case EXPR_OR:
425 - if ( count( $stack ) < 2 ) throw new ExprError('missing_operand', $this->names[$op]);
 425+ if ( count( $stack ) < 2 ) throw new ExprError( 'missing_operand', $this->names[$op] );
426426 $right = array_pop( $stack );
427427 $left = array_pop( $stack );
428428 $stack[] = ( $left || $right ) ? 1 : 0;
429429 break;
430430 case EXPR_EQUALITY:
431 - if ( count( $stack ) < 2 ) throw new ExprError('missing_operand', $this->names[$op]);
 431+ if ( count( $stack ) < 2 ) throw new ExprError( 'missing_operand', $this->names[$op] );
432432 $right = array_pop( $stack );
433433 $left = array_pop( $stack );
434434 $stack[] = ( $left == $right ) ? 1 : 0;
435435 break;
436436 case EXPR_NOT:
437 - if ( count( $stack ) < 1 ) throw new ExprError('missing_operand', $this->names[$op]);
 437+ if ( count( $stack ) < 1 ) throw new ExprError( 'missing_operand', $this->names[$op] );
438438 $arg = array_pop( $stack );
439 - $stack[] = (!$arg) ? 1 : 0;
 439+ $stack[] = ( !$arg ) ? 1 : 0;
440440 break;
441441 case EXPR_ROUND:
442 - if ( count( $stack ) < 2 ) throw new ExprError('missing_operand', $this->names[$op]);
 442+ if ( count( $stack ) < 2 ) throw new ExprError( 'missing_operand', $this->names[$op] );
443443 $digits = intval( array_pop( $stack ) );
444444 $value = array_pop( $stack );
445445 $stack[] = round( $value, $digits );
446446 break;
447447 case EXPR_LESS:
448 - if ( count( $stack ) < 2 ) throw new ExprError('missing_operand', $this->names[$op]);
 448+ if ( count( $stack ) < 2 ) throw new ExprError( 'missing_operand', $this->names[$op] );
449449 $right = array_pop( $stack );
450450 $left = array_pop( $stack );
451451 $stack[] = ( $left < $right ) ? 1 : 0;
452452 break;
453453 case EXPR_GREATER:
454 - if ( count( $stack ) < 2 ) throw new ExprError('missing_operand', $this->names[$op]);
 454+ if ( count( $stack ) < 2 ) throw new ExprError( 'missing_operand', $this->names[$op] );
455455 $right = array_pop( $stack );
456456 $left = array_pop( $stack );
457457 $stack[] = ( $left > $right ) ? 1 : 0;
458458 break;
459459 case EXPR_LESSEQ:
460 - if ( count( $stack ) < 2 ) throw new ExprError('missing_operand', $this->names[$op]);
 460+ if ( count( $stack ) < 2 ) throw new ExprError( 'missing_operand', $this->names[$op] );
461461 $right = array_pop( $stack );
462462 $left = array_pop( $stack );
463463 $stack[] = ( $left <= $right ) ? 1 : 0;
464464 break;
465465 case EXPR_GREATEREQ:
466 - if ( count( $stack ) < 2 ) throw new ExprError('missing_operand', $this->names[$op]);
 466+ if ( count( $stack ) < 2 ) throw new ExprError( 'missing_operand', $this->names[$op] );
467467 $right = array_pop( $stack );
468468 $left = array_pop( $stack );
469469 $stack[] = ( $left >= $right ) ? 1 : 0;
470470 break;
471471 case EXPR_NOTEQ:
472 - if ( count( $stack ) < 2 ) throw new ExprError('missing_operand', $this->names[$op]);
 472+ if ( count( $stack ) < 2 ) throw new ExprError( 'missing_operand', $this->names[$op] );
473473 $right = array_pop( $stack );
474474 $left = array_pop( $stack );
475475 $stack[] = ( $left != $right ) ? 1 : 0;
476476 break;
477477 case EXPR_EXPONENT:
478 - if ( count( $stack ) < 2 ) throw new ExprError('missing_operand', $this->names[$op]);
 478+ if ( count( $stack ) < 2 ) throw new ExprError( 'missing_operand', $this->names[$op] );
479479 $right = array_pop( $stack );
480480 $left = array_pop( $stack );
481 - $stack[] = $left * pow(10,$right);
 481+ $stack[] = $left * pow( 10, $right );
482482 break;
483483 case EXPR_SINE:
484 - if ( count( $stack ) < 1 ) throw new ExprError('missing_operand', $this->names[$op]);
 484+ if ( count( $stack ) < 1 ) throw new ExprError( 'missing_operand', $this->names[$op] );
485485 $arg = array_pop( $stack );
486 - $stack[] = sin($arg);
 486+ $stack[] = sin( $arg );
487487 break;
488488 case EXPR_COSINE:
489 - if ( count( $stack ) < 1 ) throw new ExprError('missing_operand', $this->names[$op]);
 489+ if ( count( $stack ) < 1 ) throw new ExprError( 'missing_operand', $this->names[$op] );
490490 $arg = array_pop( $stack );
491 - $stack[] = cos($arg);
 491+ $stack[] = cos( $arg );
492492 break;
493493 case EXPR_TANGENS:
494 - if ( count( $stack ) < 1 ) throw new ExprError('missing_operand', $this->names[$op]);
 494+ if ( count( $stack ) < 1 ) throw new ExprError( 'missing_operand', $this->names[$op] );
495495 $arg = array_pop( $stack );
496 - $stack[] = tan($arg);
 496+ $stack[] = tan( $arg );
497497 break;
498498 case EXPR_ARCSINE:
499 - if ( count( $stack ) < 1 ) throw new ExprError('missing_operand', $this->names[$op]);
 499+ if ( count( $stack ) < 1 ) throw new ExprError( 'missing_operand', $this->names[$op] );
500500 $arg = array_pop( $stack );
501 - if ( $arg < -1 || $arg > 1 ) throw new ExprError('invalid_argument', $this->names[$op] );
502 - $stack[] = asin($arg);
 501+ if ( $arg < -1 || $arg > 1 ) throw new ExprError( 'invalid_argument', $this->names[$op] );
 502+ $stack[] = asin( $arg );
503503 break;
504504 case EXPR_ARCCOS:
505 - if ( count( $stack ) < 1 ) throw new ExprError('missing_operand', $this->names[$op]);
 505+ if ( count( $stack ) < 1 ) throw new ExprError( 'missing_operand', $this->names[$op] );
506506 $arg = array_pop( $stack );
507 - if ( $arg < -1 || $arg > 1 ) throw new ExprError('invalid_argument', $this->names[$op] );
508 - $stack[] = acos($arg);
 507+ if ( $arg < -1 || $arg > 1 ) throw new ExprError( 'invalid_argument', $this->names[$op] );
 508+ $stack[] = acos( $arg );
509509 break;
510510 case EXPR_ARCTAN:
511 - if ( count( $stack ) < 1 ) throw new ExprError('missing_operand', $this->names[$op]);
 511+ if ( count( $stack ) < 1 ) throw new ExprError( 'missing_operand', $this->names[$op] );
512512 $arg = array_pop( $stack );
513 - $stack[] = atan($arg);
 513+ $stack[] = atan( $arg );
514514 break;
515515 case EXPR_EXP:
516 - if ( count( $stack ) < 1 ) throw new ExprError('missing_operand', $this->names[$op]);
 516+ if ( count( $stack ) < 1 ) throw new ExprError( 'missing_operand', $this->names[$op] );
517517 $arg = array_pop( $stack );
518 - $stack[] = exp($arg);
 518+ $stack[] = exp( $arg );
519519 break;
520520 case EXPR_LN:
521 - if ( count( $stack ) < 1 ) throw new ExprError('missing_operand', $this->names[$op]);
 521+ if ( count( $stack ) < 1 ) throw new ExprError( 'missing_operand', $this->names[$op] );
522522 $arg = array_pop( $stack );
523 - if ( $arg <= 0 ) throw new ExprError('invalid_argument_ln', $this->names[$op]);
524 - $stack[] = log($arg);
 523+ if ( $arg <= 0 ) throw new ExprError( 'invalid_argument_ln', $this->names[$op] );
 524+ $stack[] = log( $arg );
525525 break;
526526 case EXPR_ABS:
527 - if ( count( $stack ) < 1 ) throw new ExprError('missing_operand', $this->names[$op]);
 527+ if ( count( $stack ) < 1 ) throw new ExprError( 'missing_operand', $this->names[$op] );
528528 $arg = array_pop( $stack );
529 - $stack[] = abs($arg);
 529+ $stack[] = abs( $arg );
530530 break;
531531 case EXPR_FLOOR:
532 - if ( count( $stack ) < 1 ) throw new ExprError('missing_operand', $this->names[$op]);
 532+ if ( count( $stack ) < 1 ) throw new ExprError( 'missing_operand', $this->names[$op] );
533533 $arg = array_pop( $stack );
534 - $stack[] = floor($arg);
 534+ $stack[] = floor( $arg );
535535 break;
536536 case EXPR_TRUNC:
537 - if ( count( $stack ) < 1 ) throw new ExprError('missing_operand', $this->names[$op]);
 537+ if ( count( $stack ) < 1 ) throw new ExprError( 'missing_operand', $this->names[$op] );
538538 $arg = array_pop( $stack );
539539 $stack[] = (int)$arg;
540540 break;
541541 case EXPR_CEIL:
542 - if ( count( $stack ) < 1 ) throw new ExprError('missing_operand', $this->names[$op]);
 542+ if ( count( $stack ) < 1 ) throw new ExprError( 'missing_operand', $this->names[$op] );
543543 $arg = array_pop( $stack );
544 - $stack[] = ceil($arg);
 544+ $stack[] = ceil( $arg );
545545 break;
546546 case EXPR_POW:
547 - if ( count( $stack ) < 2 ) throw new ExprError('missing_operand', $this->names[$op]);
 547+ if ( count( $stack ) < 2 ) throw new ExprError( 'missing_operand', $this->names[$op] );
548548 $right = array_pop( $stack );
549549 $left = array_pop( $stack );
550 - if ( false === ($stack[] = pow($left, $right)) ) throw new ExprError('division_by_zero', $this->names[$op]);
 550+ if ( false === ( $stack[] = pow( $left, $right ) ) ) throw new ExprError( 'division_by_zero', $this->names[$op] );
551551 break;
552552 default:
553553 // Should be impossible to reach here.
554 - throw new ExprError('unknown_error');
 554+ throw new ExprError( 'unknown_error' );
555555 }
556556 }
557557 }
Index: trunk/extensions/ParserFunctions/testExpr.php
@@ -1,30 +1,30 @@
22 <?php
33
4 -require_once ( getenv('MW_INSTALL_PATH') !== false
5 - ? getenv('MW_INSTALL_PATH')."/maintenance/commandLine.inc"
 4+require_once ( getenv( 'MW_INSTALL_PATH' ) !== false
 5+ ? getenv( 'MW_INSTALL_PATH' ) . "/maintenance/commandLine.inc"
66 : dirname( __FILE__ ) . '/../../maintenance/commandLine.inc' );
77 require( 'Expr.php' );
8 -
 8+
99 $tests = file( 'exprTests.txt' );
1010
1111 $pass = $fail = 0;
1212
1313 // Each test is on one line. The test must always evaluate to '1'.
1414 $parser = new ExprParser;
15 -foreach( $tests as $test ) {
16 - $test = trim($test);
 15+foreach ( $tests as $test ) {
 16+ $test = trim( $test );
1717 if ( in_string( ';', $test ) )
18 - list($input,$expected) = explode(';', $test);
 18+ list( $input, $expected ) = explode( ';', $test );
1919 else {
2020 $input = $test;
2121 $expected = 1;
2222 }
23 -
24 - $expected = trim($expected);
25 - $input = trim($input);
2623
 24+ $expected = trim( $expected );
 25+ $input = trim( $input );
 26+
2727 $result = $parser->doExpression( $input );
28 - if ($result != $expected) {
 28+ if ( $result != $expected ) {
2929 print
3030 "FAILING test -- $input
3131 gave a final result of $result, instead of $expected.\n";
@@ -35,4 +35,4 @@
3636 }
3737 }
3838
39 -print "Passed $pass tests, failed $fail tests, out of a total of ".($pass+$fail)."\n";
\ No newline at end of file
 39+print "Passed $pass tests, failed $fail tests, out of a total of " . ( $pass + $fail ) . "\n";
\ No newline at end of file
Index: trunk/extensions/ParserFunctions/COPYING
@@ -1,4 +1,4 @@
2 -The ParserFunctions extension may be copied and redistributed under the GNU
 2+The ParserFunctions extension may be copied and redistributed under the GNU
33 General Public License.
44
55 -------------------------------------------------------------------------------
@@ -281,4 +281,3 @@
282282 YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
283283 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
284284 POSSIBILITY OF SUCH DAMAGES.
285 -
Index: trunk/extensions/ParserFunctions/ParserFunctions_body.php
@@ -6,7 +6,7 @@
77 var $mTimeChars = 0;
88 var $mMaxTimeChars = 6000; # ~10 seconds
99
10 - function clearState( $parser) {
 10+ function clearState( $parser ) {
1111 $this->mTimeChars = 0;
1212 $parser->pf_ifexist_breakdown = array();
1313 $parser->pf_markerRegex = null;
@@ -27,17 +27,17 @@
2828
2929 // The first line represents Parser from release 1.12 forward.
3030 // subsequent lines are hacks to accomodate old Mediawiki versions.
31 - if ( defined('Parser::MARKER_SUFFIX') )
 31+ if ( defined( 'Parser::MARKER_SUFFIX' ) )
3232 $suffix = preg_quote( Parser::MARKER_SUFFIX, '/' );
33 - elseif ( isset($parser->mMarkerSuffix) )
 33+ elseif ( isset( $parser->mMarkerSuffix ) )
3434 $suffix = preg_quote( $parser->mMarkerSuffix, '/' );
35 - elseif ( defined('MW_PARSER_VERSION') &&
 35+ elseif ( defined( 'MW_PARSER_VERSION' ) &&
3636 strcmp( MW_PARSER_VERSION, '1.6.1' ) > 0 )
3737 $suffix = "QINU\x07";
3838 else $suffix = 'QINU';
39 -
40 - $parser->pf_markerRegex = '/' .$prefix. '(?:(?!' .$suffix. ').)*' . $suffix . '/us';
4139
 40+ $parser->pf_markerRegex = '/' . $prefix . '(?:(?!' . $suffix . ').)*' . $suffix . '/us';
 41+
4242 wfProfileOut( __METHOD__ );
4343 return $parser->pf_markerRegex;
4444 }
@@ -60,23 +60,23 @@
6161 function expr( $parser, $expr = '' ) {
6262 try {
6363 return $this->getExprParser()->doExpression( $expr );
64 - } catch(ExprError $e) {
 64+ } catch ( ExprError $e ) {
6565 return $e->getMessage();
6666 }
6767 }
6868
6969 function ifexpr( $parser, $expr = '', $then = '', $else = '' ) {
70 - try{
 70+ try {
7171 $ret = $this->getExprParser()->doExpression( $expr );
7272 if ( is_numeric( $ret ) ) {
7373 $ret = floatval( $ret );
7474 }
75 - if( $ret ) {
 75+ if ( $ret ) {
7676 return $then;
7777 } else {
7878 return $else;
7979 }
80 - } catch (ExprError $e){
 80+ } catch ( ExprError $e ) {
8181 return $e->getMessage();
8282 }
8383 }
@@ -152,12 +152,12 @@
153153 function switchHook( $parser /*,...*/ ) {
154154 $args = func_get_args();
155155 array_shift( $args );
156 - $primary = trim(array_shift($args));
 156+ $primary = trim( array_shift( $args ) );
157157 $found = $defaultFound = false;
158158 $parts = null;
159159 $default = null;
160160 $mwDefault =& MagicWord::get( 'default' );
161 - foreach( $args as $arg ) {
 161+ foreach ( $args as $arg ) {
162162 $parts = array_map( 'trim', explode( '=', $arg, 2 ) );
163163 if ( count( $parts ) == 2 ) {
164164 # Found "="
@@ -179,7 +179,7 @@
180180 }
181181 # Default case
182182 # Check if the last item had no = sign, thus specifying the default case
183 - if ( count( $parts ) == 1) {
 183+ if ( count( $parts ) == 1 ) {
184184 return $parts[0];
185185 } elseif ( !is_null( $default ) ) {
186186 return $default;
@@ -250,22 +250,22 @@
251251 */
252252 public function rel2abs( $parser , $to = '' , $from = '' ) {
253253
254 - $from = trim($from);
255 - if( $from == '' ) {
 254+ $from = trim( $from );
 255+ if ( $from == '' ) {
256256 $from = $parser->getTitle()->getPrefixedText();
257257 }
258258
259259 $to = rtrim( $to , ' /' );
260260
261261 // if we have an empty path, or just one containing a dot
262 - if( $to == '' || $to == '.' ) {
 262+ if ( $to == '' || $to == '.' ) {
263263 return $from;
264264 }
265265
266266 // if the path isn't relative
267 - if ( substr( $to , 0 , 1) != '/' &&
268 - substr( $to , 0 , 2) != './' &&
269 - substr( $to , 0 , 3) != '../' &&
 267+ if ( substr( $to , 0 , 1 ) != '/' &&
 268+ substr( $to , 0 , 2 ) != './' &&
 269+ substr( $to , 0 , 3 ) != '../' &&
270270 $to != '..' )
271271 {
272272 $from = '';
@@ -285,8 +285,8 @@
286286 $newExploded = array();
287287
288288 foreach ( $exploded as $current ) {
289 - if( $current == '..' ) { // removing one level
290 - if( !count( $newExploded ) ){
 289+ if ( $current == '..' ) { // removing one level
 290+ if ( !count( $newExploded ) ) {
291291 // attempted to access a node above root node
292292 wfLoadExtensionMessages( 'ParserFunctions' );
293293 return '<strong class="error">' . wfMsgForContent( 'pfunc_rel2abs_invalid_depth', $fullPath ) . '</strong>';
@@ -326,26 +326,26 @@
327327 $title = Title::newFromText( $titletext );
328328 $wgContLang->findVariantLink( $titletext, $title, true );
329329 if ( $title ) {
330 - if( $title->getNamespace() == NS_MEDIA ) {
 330+ if ( $title->getNamespace() == NS_MEDIA ) {
331331 /* If namespace is specified as NS_MEDIA, then we want to
332332 * check the physical file, not the "description" page.
333333 */
334334 if ( !$this->incrementIfexistCount( $parser, $frame ) ) {
335335 return $else;
336336 }
337 - $file = wfFindFile($title);
 337+ $file = wfFindFile( $title );
338338 if ( !$file ) {
339339 return $else;
340340 }
341 - $parser->mOutput->addImage($file->getName());
 341+ $parser->mOutput->addImage( $file->getName() );
342342 return $file->exists() ? $then : $else;
343 - } elseif( $title->getNamespace() == NS_SPECIAL ) {
 343+ } elseif ( $title->getNamespace() == NS_SPECIAL ) {
344344 /* Don't bother with the count for special pages,
345345 * since their existence can be checked without
346346 * accessing the database.
347347 */
348348 return SpecialPage::exists( $title->getDBkey() ) ? $then : $else;
349 - } elseif( $title->isExternal() ) {
 349+ } elseif ( $title->isExternal() ) {
350350 /* Can't check the existence of pages on other sites,
351351 * so just return $else. Makes a sort of sense, since
352352 * they don't exist _locally_.
@@ -392,16 +392,16 @@
393393 if ( isset( $this->mTimeCache[$format][$date][$local] ) ) {
394394 return $this->mTimeCache[$format][$date][$local];
395395 }
396 -
397 - #compute the timestamp string $ts
398 - #PHP >= 5.2 can handle dates before 1970 or after 2038 using the DateTime object
399 - #PHP < 5.2 is limited to dates between 1970 and 2038
400 -
 396+
 397+ # compute the timestamp string $ts
 398+ # PHP >= 5.2 can handle dates before 1970 or after 2038 using the DateTime object
 399+ # PHP < 5.2 is limited to dates between 1970 and 2038
 400+
401401 $invalidTime = false;
402 -
403 - if ( class_exists( 'DateTime' ) ) { #PHP >= 5.2
404 - # the DateTime constructor must be used because it throws exceptions
405 - # when errors occur, whereas date_create appears to just output a warning
 402+
 403+ if ( class_exists( 'DateTime' ) ) { # PHP >= 5.2
 404+ # the DateTime constructor must be used because it throws exceptions
 405+ # when errors occur, whereas date_create appears to just output a warning
406406 # that can't really be detected from within the code
407407 try {
408408 # Determine timezone
@@ -427,16 +427,16 @@
428428
429429 # Generate timestamp
430430 $ts = $dateObject->format( 'YmdHis' );
431 - } catch (Exception $ex) {
 431+ } catch ( Exception $ex ) {
432432 $invalidTime = true;
433433 }
434 - } else { #PHP < 5.2
 434+ } else { # PHP < 5.2
435435 if ( $date !== '' ) {
436436 $unix = @strtotime( $date );
437437 } else {
438438 $unix = time();
439439 }
440 -
 440+
441441 if ( $unix == -1 || $unix == false ) {
442442 $invalidTime = true;
443443 } else {
@@ -444,21 +444,21 @@
445445 # Use the time zone
446446 if ( isset( $wgLocaltimezone ) ) {
447447 $oldtz = getenv( 'TZ' );
448 - putenv( 'TZ='.$wgLocaltimezone );
 448+ putenv( 'TZ=' . $wgLocaltimezone );
449449 }
450450 wfSuppressWarnings(); // E_STRICT system time bitching
451451 $ts = date( 'YmdHis', $unix );
452452 wfRestoreWarnings();
453453 if ( isset( $wgLocaltimezone ) ) {
454 - putenv( 'TZ='.$oldtz );
 454+ putenv( 'TZ=' . $oldtz );
455455 }
456456 } else {
457457 $ts = wfTimestamp( TS_MW, $unix );
458458 }
459459 }
460460 }
461 -
462 - #format the timestamp and return the result
 461+
 462+ # format the timestamp and return the result
463463 if ( $invalidTime ) {
464464 wfLoadExtensionMessages( 'ParserFunctions' );
465465 $result = '<strong class="error">' . wfMsgForContent( 'pfunc_time_error' ) . '</strong>';
@@ -468,16 +468,7 @@
469469 wfLoadExtensionMessages( 'ParserFunctions' );
470470 return '<strong class="error">' . wfMsgForContent( 'pfunc_time_too_long' ) . '</strong>';
471471 } else {
472 -
473 - if ( method_exists( $wgContLang, 'sprintfDate' ) ) {
474 - $result = $wgContLang->sprintfDate( $format, $ts );
475 - } else {
476 - if ( !class_exists( 'SprintfDateCompat' ) ) {
477 - require( dirname( __FILE__ ) . '/SprintfDateCompat.php' );
478 - }
479 -
480 - $result = SprintfDateCompat::sprintfDate( $format, $ts );
481 - }
 472+ $result = $wgContLang->sprintfDate( $format, $ts );
482473 }
483474 }
484475 $this->mTimeCache[$format][$date][$local] = $result;
@@ -498,7 +489,7 @@
499490 * @param int $offset Offset starting at 1
500491 * @return string
501492 */
502 - public function titleparts( $parser, $title = '', $parts = 0, $offset = 0) {
 493+ public function titleparts( $parser, $title = '', $parts = 0, $offset = 0 ) {
503494 $parts = intval( $parts );
504495 $offset = intval( $offset );
505496 $ntitle = Title::newFromText( $title );
@@ -531,17 +522,17 @@
532523 private function tooLongError() {
533524 global $wgPFStringLengthLimit, $wgContLang;
534525 wfLoadExtensionMessages( 'ParserFunctions' );
535 -
536 - return '<strong class="error">' .
 526+
 527+ return '<strong class="error">' .
537528 wfMsgExt( 'pfunc_string_too_long',
538 - array( 'escape', 'parsemag', 'content' ),
 529+ array( 'escape', 'parsemag', 'content' ),
539530 $wgContLang->formatNum( $wgPFStringLengthLimit ) ) .
540531 '</strong>';
541532 }
542533
543534 /**
544535 * {{#len:string}}
545 - *
 536+ *
546537 * Reports number of characters in string.
547538 */
548539 function runLen ( $parser, $inStr = '' ) {
@@ -567,17 +558,17 @@
568559
569560 $inStr = $this->killMarkers( $parser, (string)$inStr );
570561 $inNeedle = $this->killMarkers( $parser, (string)$inNeedle );
571 -
572 - if( !$this->checkLength( $inStr ) ||
 562+
 563+ if ( !$this->checkLength( $inStr ) ||
573564 !$this->checkLength( $inNeedle ) ) {
574565 wfProfileOut( __METHOD__ );
575566 return $this->tooLongError();
576567 }
577568
578 - if( $inNeedle == '' ) { $inNeedle = ' '; }
 569+ if ( $inNeedle == '' ) { $inNeedle = ' '; }
579570
580571 $pos = mb_strpos( $inStr, $inNeedle, $inOffset );
581 - if( $pos === false ) { $pos = ""; }
 572+ if ( $pos === false ) { $pos = ""; }
582573
583574 wfProfileOut( __METHOD__ );
584575 return $pos;
@@ -596,17 +587,17 @@
597588
598589 $inStr = $this->killMarkers( $parser, (string)$inStr );
599590 $inNeedle = $this->killMarkers( $parser, (string)$inNeedle );
600 -
601 - if( !$this->checkLength( $inStr ) ||
 591+
 592+ if ( !$this->checkLength( $inStr ) ||
602593 !$this->checkLength( $inNeedle ) ) {
603594 wfProfileOut( __METHOD__ );
604595 return $this->tooLongError();
605596 }
606597
607 - if( $inNeedle == '' ) { $inNeedle = ' '; }
 598+ if ( $inNeedle == '' ) { $inNeedle = ' '; }
608599
609600 $pos = mb_strrpos( $inStr, $inNeedle );
610 - if( $pos === false ) { $pos = -1; }
 601+ if ( $pos === false ) { $pos = -1; }
611602
612603 wfProfileOut( __METHOD__ );
613604 return $pos;
@@ -616,10 +607,10 @@
617608 * {{#sub: string | start | length }}
618609 *
619610 * Returns substring of "string" starting at "start" and having
620 - * "length" characters.
 611+ * "length" characters.
621612 *
622613 * Note: If length is zero, the rest of the input is returned.
623 - * Note: A negative value for "start" operates from the end of the
 614+ * Note: A negative value for "start" operates from the end of the
624615 * "string".
625616 * Note: A negative value for "length" returns a string reduced in
626617 * length by that amount.
@@ -629,19 +620,19 @@
630621
631622 $inStr = $this->killMarkers( $parser, (string)$inStr );
632623
633 - if( !$this->checkLength( $inStr ) ) {
 624+ if ( !$this->checkLength( $inStr ) ) {
634625 wfProfileOut( __METHOD__ );
635626 return $this->tooLongError();
636627 }
637 -
638 - if ( intval($inLength) == 0 ) {
 628+
 629+ if ( intval( $inLength ) == 0 ) {
639630 $result = mb_substr( $inStr, $inStart );
640631 } else {
641632 $result = mb_substr( $inStr, $inStart, $inLength );
642633 }
643634
644635 wfProfileOut( __METHOD__ );
645 - return $result;
 636+ return $result;
646637 }
647638
648639 /**
@@ -657,18 +648,18 @@
658649 $inStr = $this->killMarkers( $parser, (string)$inStr );
659650 $inSubStr = $this->killMarkers( $parser, (string)$inSubStr );
660651
661 - if( !$this->checkLength( $inStr ) ||
 652+ if ( !$this->checkLength( $inStr ) ||
662653 !$this->checkLength( $inSubStr ) ) {
663654 wfProfileOut( __METHOD__ );
664655 return $this->tooLongError();
665656 }
666657
667 - if( $inSubStr == '' ) { $inSubStr = ' '; }
668 -
 658+ if ( $inSubStr == '' ) { $inSubStr = ' '; }
 659+
669660 $result = mb_substr_count( $inStr, $inSubStr );
670661
671662 wfProfileOut( __METHOD__ );
672 - return $result;
 663+ return $result;
673664 }
674665
675666 /**
@@ -676,11 +667,11 @@
677668 *
678669 * Replaces each occurrence of "from" in "string" with "to".
679670 * At most "limit" replacements are performed.
680 - *
 671+ *
681672 * Note: Armored against replacements that would generate huge strings.
682673 * Note: If "from" is an empty string, single space is used instead.
683674 */
684 - function runReplace( $parser, $inStr = '',
 675+ function runReplace( $parser, $inStr = '',
685676 $inReplaceFrom = '', $inReplaceTo = '', $inLimit = -1 ) {
686677 global $wgPFStringLengthLimit;
687678 wfProfileIn( __METHOD__ );
@@ -689,36 +680,36 @@
690681 $inReplaceFrom = $this->killMarkers( $parser, (string)$inReplaceFrom );
691682 $inReplaceTo = $this->killMarkers( $parser, (string)$inReplaceTo );
692683
693 - if( !$this->checkLength( $inStr ) ||
 684+ if ( !$this->checkLength( $inStr ) ||
694685 !$this->checkLength( $inReplaceFrom ) ||
695 - !$this->checkLength( $inReplaceTo ) ) {
 686+ !$this->checkLength( $inReplaceTo ) ) {
696687 wfProfileOut( __METHOD__ );
697688 return $this->tooLongError();
698689 }
699690
700 - if( $inReplaceFrom == '' ) { $inReplaceFrom = ' '; }
 691+ if ( $inReplaceFrom == '' ) { $inReplaceFrom = ' '; }
701692
702693 // Precompute limit to avoid generating enormous string:
703694 $diff = mb_strlen( $inReplaceTo ) - mb_strlen( $inReplaceFrom );
704 - if( $diff > 0 ) {
 695+ if ( $diff > 0 ) {
705696 $limit = ( ( $wgPFStringLengthLimit - mb_strlen( $inStr ) ) / $diff ) + 1;
706697 } else {
707698 $limit = -1;
708699 }
709700
710 - $inLimit = intval($inLimit);
711 - if( $inLimit >= 0 ) {
712 - if( $limit > $inLimit || $limit == -1 ) { $limit = $inLimit; }
 701+ $inLimit = intval( $inLimit );
 702+ if ( $inLimit >= 0 ) {
 703+ if ( $limit > $inLimit || $limit == -1 ) { $limit = $inLimit; }
713704 }
714705
715706 // Use regex to allow limit and handle UTF-8 correctly.
716707 $inReplaceFrom = preg_quote( $inReplaceFrom, '/' );
717708 $inReplaceTo = StringUtils::escapeRegexReplacement( $inReplaceTo );
718709
719 - $result = preg_replace( '/' . $inReplaceFrom . '/u',
720 - $inReplaceTo, $inStr, $limit);
 710+ $result = preg_replace( '/' . $inReplaceFrom . '/u',
 711+ $inReplaceTo, $inStr, $limit );
721712
722 - if( !$this->checkLength( $result ) ) {
 713+ if ( !$this->checkLength( $result ) ) {
723714 wfProfileOut( __METHOD__ );
724715 return $this->tooLongError();
725716 }
@@ -744,22 +735,22 @@
745736 $inStr = $this->killMarkers( $parser, (string)$inStr );
746737 $inDiv = $this->killMarkers( $parser, (string)$inDiv );
747738
748 - if( $inDiv == '' ) { $inDiv = ' '; }
 739+ if ( $inDiv == '' ) { $inDiv = ' '; }
749740
750 - if( !$this->checkLength( $inStr ) ||
751 - !$this->checkLength( $inDiv ) ) {
 741+ if ( !$this->checkLength( $inStr ) ||
 742+ !$this->checkLength( $inDiv ) ) {
752743 wfProfileOut( __METHOD__ );
753744 return $this->tooLongError();
754745 }
755746
756747 $inDiv = preg_quote( $inDiv, '/' );
757 -
758 - $matches = preg_split( '/'.$inDiv.'/u', $inStr, $inLim );
759 -
760 - if( $inPos >= 0 && isset( $matches[$inPos] ) ) {
 748+
 749+ $matches = preg_split( '/' . $inDiv . '/u', $inStr, $inLim );
 750+
 751+ if ( $inPos >= 0 && isset( $matches[$inPos] ) ) {
761752 $result = $matches[$inPos];
762 - } elseif ( $inPos < 0 && isset( $matches[count($matches) + $inPos] ) ) {
763 - $result = $matches[count($matches) + $inPos];
 753+ } elseif ( $inPos < 0 && isset( $matches[count( $matches ) + $inPos] ) ) {
 754+ $result = $matches[count( $matches ) + $inPos];
764755 } else {
765756 $result = '';
766757 }
Index: trunk/extensions/ParserFunctions/ParserFunctions.php
@@ -4,9 +4,8 @@
55 die( 'This file is a MediaWiki extension, it is not a valid entry point' );
66 }
77
8 -
98 /**
10 - * CONFIGURATION
 9+ * CONFIGURATION
1110 * These variables may be overridden in LocalSettings.php after you include the
1211 * extension file.
1312 */
@@ -20,12 +19,12 @@
2120 /**
2221 * Enable string functions.
2322 *
24 - * Set this to true if you want your users to be able to implement their own
25 - * parsers in the ugliest, most inefficient programming language known to man:
 23+ * Set this to true if you want your users to be able to implement their own
 24+ * parsers in the ugliest, most inefficient programming language known to man:
2625 * MediaWiki wikitext with ParserFunctions.
2726 *
2827 * WARNING: enabling this may have an adverse impact on the sanity of your users.
29 - * An alternative, saner solution for embedding complex text processing in
 28+ * An alternative, saner solution for embedding complex text processing in
3029 * MediaWiki templates can be found at: http://www.mediawiki.org/wiki/Extension:Lua
3130 */
3231 $wgPFEnableStringFunctions = false;
@@ -35,15 +34,15 @@
3635 $wgExtensionCredits['parserhook'][] = array(
3736 'path' => __FILE__,
3837 'name' => 'ParserFunctions',
39 - 'version' => '1.3.0',
 38+ 'version' => '1.4.0',
4039 'url' => 'http://www.mediawiki.org/wiki/Extension:ParserFunctions',
41 - 'author' => array('Tim Starling', 'Robert Rohde', 'Ross McClure', 'Juraj Simlovic'),
 40+ 'author' => array( 'Tim Starling', 'Robert Rohde', 'Ross McClure', 'Juraj Simlovic' ),
4241 'descriptionmsg' => 'pfunc_desc',
4342 );
4443
45 -$wgAutoloadClasses['ExtParserFunctions'] = dirname(__FILE__).'/ParserFunctions_body.php';
46 -$wgExtensionMessagesFiles['ParserFunctions'] = dirname(__FILE__) . '/ParserFunctions.i18n.php';
47 -$wgExtensionMessagesFiles['ParserFunctionsMagic'] = dirname(__FILE__) . '/ParserFunctions.i18n.magic.php';
 44+$wgAutoloadClasses['ExtParserFunctions'] = dirname( __FILE__ ) . '/ParserFunctions_body.php';
 45+$wgExtensionMessagesFiles['ParserFunctions'] = dirname( __FILE__ ) . '/ParserFunctions.i18n.php';
 46+$wgExtensionMessagesFiles['ParserFunctionsMagic'] = dirname( __FILE__ ) . '/ParserFunctions.i18n.magic.php';
4847
4948 $wgParserTestFiles[] = dirname( __FILE__ ) . "/funcsParserTests.txt";
5049 $wgParserTestFiles[] = dirname( __FILE__ ) . "/stringFunctionTests.txt";
@@ -91,7 +90,7 @@
9291 $parser->setFunctionHook( 'rel2abs', array( &$this, 'rel2abs' ) );
9392 $parser->setFunctionHook( 'titleparts', array( &$this, 'titleparts' ) );
9493
95 - //String Functions
 94+ // String Functions
9695 if ( $wgPFEnableStringFunctions ) {
9796 $parser->setFunctionHook( 'len', array( &$this, 'runLen' ) );
9897 $parser->setFunctionHook( 'pos', array( &$this, 'runPos' ) );
Index: trunk/extensions/ParserFunctions/README
@@ -1,4 +1,4 @@
2 -ParserFunctions v1.1.1
 2+ParserFunctions v1.4.0
33
44 1. Licensing
55 2. How to install
@@ -18,4 +18,4 @@
1919 ParserFunctions ships with two tests
2020 - Parser tests. These get added to the main parser tests, see there for docs
2121 - Expression tests. These are designed to test the math-related functions
22 - See testExpr.php
\ No newline at end of file
 22+ See testExpr.php

Status & tagging log