Extension:WSArrays

The WSArrays (or ComplexArrays) extension creates an additional set of parser functions that operate on multidimensional and associative arrays.

Functions
This extension defines several parser functions:

complexarraydefine
This function creates a new array, identified by 'key'. The syntax used to define a new array is called WSON, an MediaWiki friendly version of JSON. The syntax of WSON is exactly the same as that of JSON, however, in WSON all { and } are replaced with respectively (( and )).

An example:

(( "foo": "bar", "baz": ["qux", "quux"] ))

Explanation

 * key (required): The name of the array;
 * wson (required): The array in WSON (see above).

complexarrayprint
This function prints the values of the array in a custom format.

Explanation

 * key (required): The name of the (sub)array that should be printed;
 * options (optional):
 * ordered: Print the result as an ordered list;
 * map: Map the result in a string;
 * markup: Print the result as WSON.
 * map (optional, required when option is map): The string the result should be mapped on;
 * subject (optional, default is @@): The string that should be replaced in the map.

Examples
We have an array called 'foobar':


 * 0
 * foo: bar
 * baz: quz
 * 1
 * foo: quz
 * baz: bar
 * 2
 * baz: bar
 * foo: bar

complexarraypush
This parser function pushes a new value or subarray to the end of an existing (sub)array.

Explanation

 * key (required): The name of the (sub)array;
 * value (required): A value in plaintext or a subarray in WSON.

Examples
We have an array called 'foobar':


 * 0
 * foo: bar
 * baz: quz
 * 1
 * foo: quz
 * baz: bar
 * 2
 * baz: bar
 * foo: bar

complexarraysize
This parser function returns the size of a (sub)array.

Explanation

 * key (required): The name of the (sub)array;
 * options (optional):
 * top: Only count the number of items in the top array (not recursively).

Examples
We have an array called 'foobar':


 * 0
 * foo: bar
 * baz: quz
 * 1
 * foo: quz
 * baz: bar
 * 2
 * baz: bar
 * foo: bar

complexarrayaddvalue
This parser function adds a value or subarray to an existing array or replaces an existing subarray with that value.

Explanation

 * key (required): The name of the subarray that will be created;
 * value (required): A value in plaintext or a subarray in WSON.

Examples
We have an array called 'foobar':


 * 0
 * foo: bar
 * baz: quz
 * 1
 * foo: quz
 * baz: bar
 * 2
 * baz: bar
 * foo: bar

complexarrayreset
This parser function resets all arrays or one array.

Explanation

 * key (optional): The name of the array that must be unset, when empty, all arrays will be unset.

complexarraysort
This parser function sorts an array.

Explanation

 * key (required): The array that needs to be sorted;
 * options (optional):
 * multisort: Sort the array using multisort;
 * asort: Sort the array using asort;
 * arsort: Sort the array using arsort;
 * krsort: Sort the array using krsort;
 * natcasesort: Sort the array using natcasesort;
 * natsort: Sort the array using natsort;
 * rsort: Sort the array using rsort;
 * shuffle: Shuffle the array;
 * keysort: Sort a two-dimensional array according to the values of a key in the second array. You can change the order to descending by appending ",desc" in options (so "keysort,desc").
 * sortingkey (optional, required when using keysort): The key with which the array must be sorted when using keysort.

See the PHP documentation for the sorting algorithms.

Examples
We have an array called 'foobar':


 * 0
 * foo: bar
 * baz: quz
 * 1
 * foo: quz
 * baz: bar
 * 2
 * baz: bar
 * foo: bar

complexarraymaptemplate
This parser function maps the contents of an array in a template.

Explanation

 * key (required): The name of the array that needs to be mapped;
 * template (required): The name of the template the array must be mapped to.

Examples
We have an array called 'foobar', an array called 'boofar' and an array called 'bazbar', resp.:

foobar:
 * 0
 * foo: bar
 * baz: quz
 * 1
 * baz: bar
 * foo: bar
 * 2
 * foo: quz
 * baz: bar
 * bar: ["bex","box"]

boofar:
 * foobar
 * bazbar
 * boofar

bazbar:
 * foo: bar
 * boo: far

Arrays of mixed types are sometimes not handled properly.

Semantic MediaWiki
Make sure you have completed step three of the installation process (see below).

This extension introduces a new format for displaying Semantic MediaWiki results. In order to use the new format, use. Because the result printer defines a new complexarray, you need to provide a name for that array using.

Semantic variables
A list of semantic variables is included in the complexarray when you query a list of pages. The following variables are included:


 * catitle: The title of the page
 * cafullurl: The full URL of the page
 * canamespace: The namespace the page lives in
 * caexists: Whether or not the page exists (0/1)
 * cadisplaytitle: The displaytitle of the page

Additional parameters
WSArrays defines three new parameters:


 * name: The name of the array that is going to be created
 * hide: Option to hide semantic variables from the result (yes/no)
 * unassociative: Option to display the result in an unassociative array (yes/no)

Configuration parameters
WSArrays has 1 configuration parameter.


 * $wfMaxDefinedArrays : The maximum number of arrays defined at any given time. Accepts any positive integer (-1 to disable).