Extension:WSArrays/fr

L'extension WSArrays (ou ComplexArrays) crée un ensemble supplémentaire de fonctions d'analyse qui utilisent les tableaux multidimensionnels et associatifs.

Fonctions
Cette extension définit plus de 20 fonctions d'analyse :



complexarraydefine
Cette fonction crée un nouveau tableau identifié par key.

Explications

 * key (required): nom du tableau
 * array (required): tableau en WSON, ou en utilisant un délimiteur.
 * delimiter (optional, default: ,): délimiteur utilisé pour définir un tableau simple.
 * noparse (optional): Arguments to tell the parser what to parse in the 'array' (see #Manipulation of the parser).

complexarraydefinedarrays
Cette fonction de débogage crée un nouveau tableau contenant les clés de tous les tableaux actuellement définis.

Explications

 * key (obligatoire) : nom du tableau qui contiendra les clés des tableaux définis actuellement



complexarrayprint
Cette fonction imprime les valeurs du tableau dans un format personnalisé.

Explication

 * key (obligatoire): Nom du (sous)tableau à imprimer;
 * options (optionnel):
 * markup: Imprimez le résultat en WSON.
 * noparse (optionnel): Initialiser à true pour dire à l'analyseur de ne pas traiter la sortie selon la syntaxe wiki.

Exemples
On dispose d'un tableau foobar :


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

complexarraysize
Cette fonction d'analyse renvoie la taille d'un (sous)tableau.

Explanation

 * key (obligatoire): Nom du (sous) tableau
 * options (optionnel):
 * top: ne comptez que le nombre d'éléments dans le tableau principal (et non pas récursivement).

Exemples
On dispose d'un tableau foobar :


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

complexarrayslice
Cette fonction d'analyse peut extraire une tranche de tableau.

Explanation

 * new_key (obligatoire): nom du tableau à créer
 * key (obligatoire): nom du tableau à segmenter
 * offset (obligatoire): Avec un décalage positif le nouveau tableau commencera à cet index dans le premier tableau. Si le décalage est négatif, il est compté à partir de la fin du premier tableau.
 * length (optionnel): longueur du nouveau tableau.

Exemples
On dispose d'un tableau foobar :


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

complexarraysearch
Cette fonction d'analyse sémantique recherche un mot clé dans un tableau et renvoie la clé correspondant à cette  valeur. Renvoie 0 si rien n'est trouvé.

Explications

 * key (obligatoire): nom du tableau dans lequel se fera la recherche
 * keyword (obligatoire): mot-clé à rechercher.

Examples
On dispose d'un tableau foobar :


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

complexarraysearcharray
Cette fonction d'analyse syntaxique recherche un mot clé dans un tableau et  crée un nouveau tableau avec les clés en cas de correspondance. If there are no matches, it will return 0.

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

Examples
On dispose d'un tableau 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 (obligatoire): The key which should be unset

Examples
On dispose d'un tableau 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 (obligatoire): The name of the subarray that will be created;
 * value (obligatoire): A value in plaintext or a subarray in any supported markup language.

Examples
On dispose d'un tableau 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 (optionnel): 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 (obligatoire): The array that needs to be sorted;
 * options (optionnel):
 * 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
On dispose d'un tableau 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.

Explications

 * key (obligatoire): Nom du tableau.

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

Explications

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

Exemples
On dispose d'un tableau 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.

Explication

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

Exemples
On dispose d'un tableau 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.

Explication

 * new_key (obligatoire): The name of the array that is going to be created;
 * key1 (obligatoire): The name of the first array;
 * key2 (obligatoire): The name of the second array;
 * keyn (optionnel): The name of the n'th array;
 * options
 * recursive: Fusion récursive
 * recursive: Fusion récursive

Exemples
On dispose d'un tableau foobar :


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

et un tableau 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.

Explications

 * new_key (obligatoire): The name of the array that is going to be created;
 * key1 (obligatoire): The name of the first array;
 * key2 (obligatoire): The name of the second array;
 * keyn (optionnel): The name of the n'th array;
 * keyn (optionnel): 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.

Explications

 * new_key (obligatoire): Nom du tableau à créer
 * key1 (obligatoire): Nom du premier tableau
 * key2 (obligatoire): Le nom du deuxième tableau
 * keyn (optionnel): Nom du nième tableau;
 * keyn (optionnel): Nom du nième tableau;

Exemples
On dispose d'un tableau foobar :


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

et un tableau 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.

Explication

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

Exemples
On dispose d'un tableau 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.

Explication

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

Exemples
Nous avons respectivement un tableau appelé foobar, un tableau appelé boofar et un tableau appelé bazbar :

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
Ces fonctions utilisent des tableaux anonymes. 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).

Explication

 * value (obligatoire): Valeur à segmenter
 * delimiter (obligatoire): Délimiteur à utiliser pour la segmentation
 * variable (obligatoire): chaîne à remplacer dans formula
 * formula (obligatoire): Chaîne où variable est à remplacer
 * new_delimiter (obligatoire): Délimiteur entre les résultats.

complexarrayparent
Cette fonction renvoie la clé du parent de la clé donnée.

Explication

 * key (obligatoire): Clé à partir de laquelle la clé parent doit être renvoyée

Exemples


Opérateur Wairudokado
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. Again, this documentation only applies to the parser functions listed above.

By default, all input is automatically parsed by the parser before it is passed over to WSArrays (except for the 'map' in and .) This allows you to use template parameters as well as magic words and templates when manipulating or defining arrays. This is however not always what you want. 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.

What if I want to parse the template later on?
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.

Arguments
You can include the following arguments as a comma-separated list in the 'noparse'-parameter of any applicable function.

Using WSArrays in other extensions
WSArrays provides an interface to easily use, manipulate and create arrays from any extension in the wiki.

Initialisation
In order to use the interface, include the  class into your extension, like so:

Getting the contents of an array
The contents of the array "foobar" can be retrieved like so:

Getting the contents of a subarray
The contents of "foobar[Foo][Bar]" can be retrieved like so:

Changing the contents of an array
The contents of the array "foobar" can be changed like so:

The contents of a specific value or subarray can also be changed like so:

Unsetting an array
An array can be unset like so:

Configuration
WSArrays possède quelques paramètres de configuration.


 * Option to skip version control and force the initialization of WSArrays, accepts a boolean (default: false). This may crash your wiki.
 * Option to skip version control and force the initialization of WSArrays, accepts a boolean (default: false). This may crash your wiki.


 * Option to enable the Semantic MediaWiki result printer, accepts a boolean (default: false). Setting this to true if you have not correctly installed the result printer (see ) will result in your wiki not working.
 * Option to enable the Semantic MediaWiki result printer, accepts a boolean (default: false). Setting this to true if you have not correctly installed the result printer (see ) will result in your wiki not working.