Extension:WSArrays/dtp

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

Functions
This extension defines over 20 parser functions:

complexarraydefine
This function creates a new array, identified by 'key'.

Explanation

 * key (required) &mdash; The name of the array;
 * array (required) &mdash; The array as WSON, or using a delimiter.
 * delimiter (optional, default: ,) &mdash; The delimiter used when defining a simple array.
 * noparse (optional) &mdash; Arguments to tell the parser what to parse in the 'array' (see #Manipulation of the parser).

complexarraydefinedarrays
This debug function creates a new array containing the keys of all currently defined arrays.

Explanation

 * key (required) &mdash; The name of the array that will contain the keys of the currently defined arrays

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

Explanation

 * key (required) &mdash; The name of the (sub)array that should be printed;
 * options (optional) :
 * markup &mdash; Print the result as WSON.
 * noparse (optional) &mdash; Set to "true" to tell the parser not treat the output as wiki syntax.

Examples
We have an array called 'foobar':


 * 0
 * foo: bar
 * baz: quz
 * 1
 * foo: quz
 * baz: bar
 * 2
 * baz: bar
 * foo: bar
 * 3
 * baz: . UNIQ347fb3f0c7f3d9c-5

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

Explanation

 * key (required) &mdash; The name of the (sub)array;
 * options (optional):
 * top &mdash; 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

complexarrayslice
This parser function can extract a slice from an array.

Explanation

 * new_key (required) &mdash; The name of the array that is going to be created;
 * key (required) &mdash; The name of the array that needs to be sliced;
 * offset (required) &mdash; For a positive offset, the new array will start at that offset in the first array. For a negative offset, the new array will start that far from the end of the first array;
 * length (optional) &mdash; The length of the new array.

Examples
We have an array called foobar:


 * 0
 * foo: bar
 * baz: quz
 * 1
 * baz: bar
 * foo: bar
 * 2
 * boo: bar
 * far: quz
 * 3
 * foo: quux
 * bar: bar

complexarraysearch
This parser function searches through an array for a keyword and returns the corresponding key of the first match. If there are no matches, it will return 0.

Explanation

 * key (required) &mdash; The name of the array that is going to be searched;
 * keyword (required) &mdash; The keyword that is going to get searched for.

Examples
We have an array called foobar:


 * 0
 * foo: bar
 * baz: quz
 * 1
 * baz: bar
 * foo: bar
 * 2
 * boo: bar
 * far: quz
 * 3
 * foo: quux
 * bar: bar

complexarraysearcharray
This parser function searches through an array for a keyword and creates a new array with the corresponding keys of the matches. If there are no matches, it will return 0.

Explanation
The keyword that is going to get searched for.
 * new_key (required) &mdash; The name of the array that is going to be created containing all the keys;
 * key (required) &mdash; The name of the array that is going to be searched;
 * keyword (required) &mdash;

Examples
We have an array called foobar:


 * 0
 * foo: bar
 * baz: quz
 * 1
 * baz: bar
 * foo: bar
 * 2
 * boo: bar
 * far: quz
 * 3
 * foo: quux
 * bar: bar

complexarrayunset
This function unsets the given key.

Explanation

 * key (required) &mdash; The key which should be unset

Examples
Suppose we have an array called "foobar":


 * foo
 * bar
 * qux
 * baz

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

Explanation

 * key (required) &mdash; The name of the subarray that will be created;
 * value (required) &mdash; A value in plaintext or a subarray in any supported markup language.

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) &mdash; 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) &mdash; The array that needs to be sorted;
 * options (optional):
 * multisort &mdash; Sort the array using multisort;
 * asort &mdash; Sort the array using asort;
 * arsort &mdash; Sort the array using arsort;
 * krsort &mdash; Sort the array using krsort;
 * natcasesort &mdash; Sort the array using natcasesort;
 * natsort &mdash; Sort the array using natsort;
 * rsort &mdash; Sort the array using rsort;
 * shuffle &mdash; Shuffle the array;
 * keysort &mdash; 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) &mdash; 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

complexarrayunique
This parser function removes duplicate keys and values from a array.

Explanation

 * key (required) &mdash; The name of the array.

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

Explanation

 * key (required) &mdash; The name of the (sub)array;
 * value (required) &mdash; A value in plaintext or any supported markup language.
 * noparse (optional) &mdash; Arguments to tell the parser what to parse in the 'subject' (see #Manipulation of the parser).

Examples
We have an array called 'foobar':


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

complexarrayextract
This parser function creates a new array from a subarray.

Explanation

 * new_key (required) &mdash; The name of the array that is going to be created;
 * subarray (required) &mdash; The subarray that needs to be extracted.

Examples
We have an array called 'foobar':


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

complexarraymerge
This parser function creates a new array by merging two or more arrays.

Explanation

 * new_key (required) &mdash; The name of the array that is going to be created;
 * key1 (required) &mdash; The name of the first array;
 * key2 (required) &mdash; The name of the second array;
 * keyn (optional) &mdash; The name of the n'th array;
 * options
 * recursive &mdash; Merge recursively
 * recursive &mdash; Merge recursively

Examples
We have an array called 'foobar':


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

and an array called 'boofar':


 * 0
 * boo: bar
 * far: quz
 * 1
 * foo: quux
 * bar: bar

complexarraydiff
This parser function calculates the difference between two or more arrays and stores that in a new array. It shadows the PHP function.

Explanation

 * new_key (required) &mdash; The name of the array that is going to be created;
 * key1 (required) &mdash; The name of the first array;
 * key2 (required) &mdash; The name of the second array;
 * keyn (optional) &mdash; The name of the n'th array;
 * keyn (optional) &mdash; The name of the n'th array;

complexarraypusharray
This parser function creates a new array by pushing one or more arrays to the end of another array.

Explanation
The name of the second array;
 * new_key (required) &mdash; The name of the array that is going to be created;
 * key1 (required) &mdash; The name of the first array;
 * key2 (required) &mdash;
 * keyn (optional) &mdash; The name of the n'th array;

Examples
We have an array called 'foobar':


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

and an array called 'boofar':


 * 0
 * boo: bar
 * far: quz
 * 1
 * foo: quux
 * bar: bar

complexarraymap
This parser function iterates over an array and maps the values of the array onto a mapping key.

Explanation

 * key (required) &mdash; The name of the array that is going to be mapped;
 * mapping_key (required) &mdash; The keyword that will be replaced in the subject;
 * subject (required) &mdash; The string on which the mapping will be applied;
 * delimiter (optional) &mdash; The delimiter appended to every line, except the last;
 * show (optional) &mdash; Set this to  in order to show the mapping key when no string value for it exists.

Examples
We have an array called foobar:


 * 0
 * bar
 * quz
 * 1
 * bar
 * bar
 * 2
 * bar
 * quz
 * 3
 * quux

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

Explanation

 * key (required) &mdash; The name of the array that needs to be mapped;
 * template (required) &mdash; 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

Anonymous
These functions use anonymous arrays. The function handles both the definition and output of the array. You do not have to define an array beforehand.

complexarrayarraymap
This parser function is very similar to #complexarraymap, but the input and output is handled in the same function (which makes it anonymous).

Explanation

 * value (required) &mdash; The value to be split;
 * delimiter (required) &mdash; The delimiter to split value on;
 * variable (required) &mdash; String to be replaced in 'formula';
 * formula (required) &mdash; String where 'variable' is replaced;
 * new_delimiter (required) &mdash; The delimiter between results.

complexarrayparent
This function returns the key of the parent of the given key.

Explanation

 * key (required) &mdash; The key from which the parent key should be returned

Wairudokado operator
The Wairudokado operator (Japanese: ワイルドカード, pronounced Wairudokādo, meaning wildcard; a tribute to the Scope Resolution Operator in PHP) is a powerful operator that gives users the ability to use wildcards when manipulating or printing subarrays.

Example
This operator can be used on every parser function that supports subarrays (such as ). Suppose we have the array foobar:


 * 0
 * name: Foo
 * 1
 * name: Bar
 * 2
 * name: Baz
 * 3
 * name: Bex

And we want to print every value of "name". We could use a to iterate over the array and print each value seperately, but we can also use a Wairudokado operator in the #complexarrayprint function.

Semantic MediaWiki
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 ; if   is left empty, the result printer will print the array as WSON.

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 two new parameters:


 * name: The name of the array that is going to be created
 * simple: Option to hide Semantic variables from page results as well as hiding mailto: prefixes on email results (yes/no, default: yes)

Seeing tables instead of complex arrays
In case Semantic MediaWiki renders a table when format is, you must first check if you have set   to. If this is the case and it still does not work, WSArrays might not have been able to create a symbolic link from the SemanticMediaWiki folder to the WSArrays folder. This link can be manually created by copying the file  from the extension's root folder to.

Writing extensions
While WSArrays provides many functions for manipulating and showing arrays, sometimes these are not enough. For this reason, we provide an interface to easily extend the functionality of WSArrays with new parser functions.

Extensions are placed in the extensions/ directory. Each extension is implemented as a derived class from. The name of the file in which this class will be located, must be the same as the class name (case-sensitive). An example for the class  would be. The class must implement at least the following methods:

Returning the result
is executed by the parser hook. You can read how to write parser functions here. The documentation below is specific to WSArrays.

Manipulating arrays
All arrays in WSArrays must be stored as a ComplexArray object. If you want to manipulate an existing array, you must convert the ComplexArray object to an array, manipulate the array and then convert it back to a ComplexArray object.

or when using :

Registering the extension
In order to enable the extension, you must add the extension name and aliases to.

Add the following to :

Manipulation of the parser
WSArrays manipulates the Parser in several ways. In order to use WSArrays to its fullest extend, it is important to know about this. This only applies to the following parser functions:


 * 
 * 
 * 

How WSArrays manipulates the parser
WSArrays manipulates the parser by using SFH_OBJECT_ARGS. This way, the parser arguments are passed as PPNode objects instead of plain text. This allows for conditional expansion of the parse tree (see doc.wikimedia.org for more information). Using SFH_OBJECT_ARGS we can tell the parser to not parse the elements and return the raw text inputted by the user, which we can then parse in WSArrays.

How to control the manipulation
Different people have different needs, which is why we allow you to control the manipulation of the parser. Kawagu, dokumentasi diti papaaplai do kouyadan guno di pintayad id sawat no.

By default, all input is automatically parsed by the parser before it is passed over to WSArrays (except for the 'map' in and .) Iti papasaga di do momoguno templat parameto di tosonong miaga boros magik om templat soira momanipulasi toi ko' papatantu kouludan. Iti nopo nga okon ko ndo nunu ii korohian nu kasari. For instance, when you want to use a very complex template inside of an array, and you don't want to completely break when you use on it, you can tell WSArrays to not parse the input. If you then print the array, the template is printed as if it were enclosed with nowiki tags.



Poingkuro ndo nung maan ku uyado iri tamplat kawaagu?
Not parsing the template entirely is probably not what you want. WSArrays tells the parser to parse the element when necessary, such as when using it in a map or when printing it as a value.

Banta
Milo ko pohompit do banta diti sabaagi koma-pinopoinsuai katayadan id 'noparse'-hinonggo nopo guno parameto di milo gunoon.



Momoguno WSArrays id lolombus suai
WSArrays popotounda do intofas mooi do osonong gunoon, manipulasi om momonosi kouludan mantad honggo nopo lolombus id wiki.

koimpuunan
Suang goos do momoguno intofas, kohompit do kalas  id suang lolombus nu, miagal.



Manganu tonsi do kouludan
Tonsi kouludan "foobar" milo maan onuo kawagi miagal:



Manganu tonsi do subkouludan
Tonsi foobar[Foo][Bar] milo maan onuo kawagu miagal:



Simbanai tonsi kouludan
Tonsi kouludan "foobar" milo maan simbanai miagal:

Tonsi di kigatang pointantu toi ko subkouludan milo maan simbanai miagal:



Au pointatap kouludan
Kouludan milo au maan tatapon miagal:

Configuration
WSArrays has several configuration parameters.


 * Pilion do manalib kawo kontrol om sasagan papadakat do WSArrays, romito boolean (ladtak: false). Iti milo mamaraag wiki nu.
 * Pilion do manalib kawo kontrol om sasagan papadakat do WSArrays, romito boolean (ladtak: false). Iti milo mamaraag wiki nu.


 * Pilion do papasaga Semantic MediaWiki aasil printo, romito boolean (ladtak : false). Tatapo' diti kumaa true nung au koontok padakatan nu do aasil printo (intangai ) kootus do au mamanau wiki nu.
 * Pilion do papasaga Semantic MediaWiki aasil printo, romito boolean (ladtak : false). Tatapo' diti kumaa true nung au koontok padakatan nu do aasil printo (intangai ) kootus do au mamanau wiki nu.



Intangai po

 * "Kouludan" lolombus - Pasaga'o do popoindalan miampai kouludan di otigas.