Index: trunk/extensions/Arrays/RELEASE-NOTES |
— | — | @@ -1,16 +1,20 @@ |
2 | 2 | Changelog: |
3 | 3 | ========== |
4 | 4 | |
| 5 | + * (trunk) -- Version 2.0rc2 |
| 6 | + - '#arraysearcharray' with 'e' using 'Regex Fun' no longer requires an escaped transform (parameter 6) |
| 7 | + input. It works just like the '#regex' parser functions replacement parameter. |
| 8 | + |
5 | 9 | * December 4, 2011 -- Version 2.0rc |
6 | | - This release is built upon 1.4 alpha. See changes of 1.4 alpha as well. |
7 | | - 'ArrayExtension' is now simply called 'Arrays'. Therefore you have to adjust your LocalSettings.php. |
| 10 | + This release is built upon 1.4 alpha. See changes of 1.4 alpha as well. |
| 11 | + 'ArrayExtension' is now simply called 'Arrays'. Therefore you have to adjust your LocalSettings.php. |
8 | 12 | - Compatibility mode variable '$egArraysCompatibilityMode' ('$egArrayExtensionCompatbilityMode' in |
9 | 13 | Version 1.4 alpha) is set to false by default. See Version 1.4 alpha for further information. |
10 | 14 | - Additional changes to the compatibility mode behavior in version 2.0 include: |
11 | 15 | + '#arrayindex' will return its default also in case of existing index but empty value. This |
12 | | - makes the function consistent with Variables '#var' and hash tables '#hashvalue'. |
13 | | - + '#arraymerge', '#arrayunion', '#arraydiff' and '#arrayintersect' with only one array for |
14 | | - the operation will make a copy of that array instead of creating no array at all. |
| 16 | + makes the function consistent with Variables '#var' and HashTables '#hashvalue'. |
| 17 | + + '#arrayunion', '#arraydiff' and '#arrayintersect' with only one array for the operation will make |
| 18 | + a copy of that array instead of creating no array at all (just like '#arraymerge' behaved already). |
15 | 19 | + Default separator for '#arrayprint' now is the languages default separator instead of ', '. |
16 | 20 | + '#arrayprint' will no longer expand the given wiki markup twice. Instead, it will escape special |
17 | 21 | characters of array values before they will be inserted into the markup. This way it won't be |
Index: trunk/extensions/Arrays/Arrays.php |
— | — | @@ -11,7 +11,7 @@ |
12 | 12 | * @ingroup Arrays |
13 | 13 | * |
14 | 14 | * @licence MIT License |
15 | | - * @version: 2.0rc |
| 15 | + * @version: 2.0rc2 |
16 | 16 | * |
17 | 17 | * @author Li Ding < lidingpku@gmail.com > |
18 | 18 | * @author Jie Bao |
— | — | @@ -53,7 +53,7 @@ |
54 | 54 | * |
55 | 55 | * @since 2.0 (before in 'Arrays' class since 1.3.2) |
56 | 56 | */ |
57 | | - const VERSION = '2.0rc'; |
| 57 | + const VERSION = '2.0rc2'; |
58 | 58 | |
59 | 59 | /** |
60 | 60 | * Store for arrays. |
— | — | @@ -105,7 +105,7 @@ |
106 | 106 | self::initFunction( $parser, 'arrayindex', SFH_OBJECT_ARGS ); |
107 | 107 | self::initFunction( $parser, 'arraysize' ); |
108 | 108 | self::initFunction( $parser, 'arraysearch', SFH_OBJECT_ARGS ); |
109 | | - self::initFunction( $parser, 'arraysearcharray' ); |
| 109 | + self::initFunction( $parser, 'arraysearcharray', SFH_OBJECT_ARGS ); |
110 | 110 | self::initFunction( $parser, 'arrayslice' ); |
111 | 111 | self::initFunction( $parser, 'arrayreset', SFH_OBJECT_ARGS ); |
112 | 112 | self::initFunction( $parser, 'arrayunique' ); |
— | — | @@ -445,7 +445,7 @@ |
446 | 446 | * note it is extended to support regular expression match and index |
447 | 447 | */ |
448 | 448 | static function pfObj_arraysearch( Parser &$parser, PPFrame $frame, $args ) { |
449 | | - |
| 449 | + // Get Parameters |
450 | 450 | $arrayId = trim( $frame->expand( $args[0] ) ); |
451 | 451 | $index = isset( $args[2] ) ? trim( $frame->expand( $args[2] ) ) : 0; |
452 | 452 | |
— | — | @@ -505,17 +505,13 @@ |
506 | 506 | * "needle" can be a regular expression or a string search value. If "needle" is a regular expression, "transform" can contain |
507 | 507 | * "$n" where "n" stands for a number to access a variable from the regex result. |
508 | 508 | */ |
509 | | - static function pf_arraysearcharray( |
510 | | - Parser &$parser, |
511 | | - $arrayId_new, |
512 | | - $arrayId = null, |
513 | | - $needle = '/^(\s*)$/', |
514 | | - $index = 0, |
515 | | - $limit = '', |
516 | | - $transform = '' |
517 | | - ) { |
| 509 | + static function pfObj_arraysearcharray( Parser &$parser, PPFrame $frame, $args ) { |
518 | 510 | $store = self::get( $parser ); |
519 | | - |
| 511 | + |
| 512 | + // get first two parameters |
| 513 | + $arrayId = isset( $args[1] ) ? trim( $frame->expand( $args[1] ) ) : null; |
| 514 | + $arrayId_new = isset( $args[0] ) ? trim( $frame->expand( $args[0] ) ) : ''; |
| 515 | + |
520 | 516 | if( $arrayId === null ) { |
521 | 517 | global $egArraysCompatibilityMode; |
522 | 518 | if( ! $egArraysCompatibilityMode ) { // COMPATIBILITY-MODE |
— | — | @@ -523,6 +519,13 @@ |
524 | 520 | } |
525 | 521 | return ''; |
526 | 522 | } |
| 523 | + |
| 524 | + // Get Parameters the other parameters |
| 525 | + $needle = isset( $args[2] ) ? trim( $frame->expand( $args[2] ) ) : '/^(\s*)$/'; |
| 526 | + $index = isset( $args[3] ) ? trim( $frame->expand( $args[3] ) ) : 0; |
| 527 | + $limit = isset( $args[4] ) ? trim( $frame->expand( $args[4] ) ) : ''; |
| 528 | + $rawTransform = isset( $args[5] ) ? $args[5] : null; |
| 529 | + |
527 | 530 | // also takes care of negative index by calculating start index: |
528 | 531 | $validIndex = $store->validate_array_index( $arrayId, $index, false ); |
529 | 532 | |
— | — | @@ -556,10 +559,14 @@ |
557 | 560 | |
558 | 561 | if( preg_match( $needle, $value ) ) { |
559 | 562 | // Found something! |
560 | | - if( $transform !== '' ) { |
| 563 | + if( $rawTransform !== null ) { |
561 | 564 | // Transform the found string. Can we use 'Regex Fun' ? |
562 | 565 | if( $regexFunSupport ) { |
563 | 566 | // do the transformation with Regex Fun to support 'e' flag: |
| 567 | + $transform = trim( $frame->expand( |
| 568 | + $rawTransform, |
| 569 | + PPFrame::NO_ARGS | PPFrame::NO_TEMPLATES // leave expanding of templates to 'Regex Fun' |
| 570 | + ) ); |
564 | 571 | $value = ExtRegexFun::doPregReplace( |
565 | 572 | $needle, |
566 | 573 | $transform, |
— | — | @@ -571,6 +578,7 @@ |
572 | 579 | } |
573 | 580 | else { |
574 | 581 | // regular preg_replace: |
| 582 | + $transform = trim( $frame->expand( $rawTransform ) ); |
575 | 583 | $value = preg_replace( $needle, $transform, $value ); |
576 | 584 | } |
577 | 585 | } |
Index: trunk/extensions/Arrays/Arrays_Settings.php |
— | — | @@ -17,7 +17,6 @@ |
18 | 18 | */ |
19 | 19 | |
20 | 20 | /** |
21 | | - * Full compatbility to versions before 1.4. |
22 | 21 | * Set to false by default since version 2.0. |
23 | 22 | * |
24 | 23 | * @since 2.0 (as '$egArrayExtensionCompatbilityMode' in 1.4 alpha) |