Module:Wikidata/doc

De Baripedia

Ceci est la page de documentation pour Module:Wikidata

Erreur Lua : impossible de créer le processus : proc_open n’est pas disponible. Vérifiez la directive de configuration PHP « disable_functions ». This module is a modification of the original at Module:Sandbox/Tom Morris which was created 19 May 2013.

The module "Wikidata" contains:

  • a call (getValue) that allows the calling script to retrieve the wiki-linked value(s) for any property from Wikidata by supplying the property ID as the first parameter.
  • a call (getRawValue) that allows the calling script to retrieve the non-linked value(s) for any property from Wikidata by supplying the property ID as the first parameter.
  • a call (getDateValue) that allows the calling script to retrieve the date value(s) for any property from Wikidata by supplying the property ID as the first parameter. It allows specifying that the date be returned in dmy or mdy format by supplying "dmy" or "mdy" as an optional third parameter.

If the property is not defined in Wikidata for the article that invokes this code, then an empty string ("") is returned.

Parameters[modifier le wikicode]

  • For the generalised linked case (getValue), two unnamed parameters are supplied. The first is the ID of the property that is to be retrieved (e.g. p19 for birthplace or p26 for spouse). The second may be null, "FETCH_WIKIDATA", or any other string, which becomes the returned value.
  • For the generalised unlinked case (getRawValue), two unnamed parameters are supplied. The first is the ID of the property that is to be retrieved (e.g. p21 for gender). The second may be null, "FETCH_WIKIDATA", or any other string, which becomes the returned value.
  • For the generalised date case (getDateValue), three unnamed parameters are supplied. The first is the ID of the property that is to be retrieved (e.g. p569 for date of birth). The second may be null, "FETCH_WIKIDATA", or any other string, which becomes the returned value. The third is the format that the date should be returned in, either dmy or mdy.

Usage[modifier le wikicode]

Example:spouse[modifier le wikicode]

  • {{#invoke:Wikidata|getValue|p26|}} = returns nothing, so suppresses the display of spouse in an infobox
  • {{#invoke:Wikidata|getValue|p26|FETCH_WIKIDATA}} = returns the linked value(s) of property p26 (spouse) stored in wikidata for the corresponding article (e.g. for article Bill Clinton, it returns Hillary Rodham Clinton)
  • {{#invoke:Wikidata|getValue|p26|[[Hillary Clinton]]}} = returns Hillary Clinton, allowing an infobox to use a local value rather than the value stored in Wikidata.

Example in Infobox template[modifier le wikicode]

Inside an infobox definition, it may be called like this:

  • | data55 = {{#invoke:Wikidata|getValue|p26|{{{spouse|FETCH_WIKIDATA}}} }}

which causes the infobox to:

  1. not display spouse if the infobox parameter |spouse is set to be blank (as "| spouse ="}
  2. display the linked value(s) from Wikidata if the infobox parameter |spouse is not supplied
  3. display the local infobox parameter |spouse if it is supplied (e.g. "|spouse = Hillary Clinton")

Optionally, it could be called as:

  • | data55 = {{#invoke:Wikidata|getValue|p26|{{{spouse|}}} }}

which should behave as the parameter does now, unless the parameter is set to FETCH_WIKIDATA when it displays the linked value(s) fetched from Wikidata.

Example:birth place[modifier le wikicode]

This works in just the same way as the calls above:

  • {{#invoke:Wikidata|getValue|p19|}} = returns nothing, so suppresses the display of birth place in an infobox
  • {{#invoke:Wikidata|getValue|p19|FETCH_WIKIDATA}} = returns the linked value(s) of property p19 (place of birth) stored in wikidata for the corresponding article (e.g. for article Bill Clinton, it returns Hope, Arkansas)
  • {{#invoke:Wikidata|getValue|p19|[[Hope, Arkansas|Hope]]}} = returns Hope, allowing an infobox to use a local value rather than the value stored in Wikidata.

Example:gender[modifier le wikicode]

We don't want the returned value linked, so use:

  • - {{#invoke:Wikidata|getRawValue|p21|FETCH_WIKIDATA}}

Example:date of birth[modifier le wikicode]

If we want the date of birth in dmy format, we use:

  • - {{#invoke:Wikidata|getDateValue|p569|FETCH_WIKIDATA|dmy}}

If we want the date of birth in mdy format, we use:

  • - {{#invoke:Wikidata|getDateValue|p569|FETCH_WIKIDATA|mdy}}

Testing[modifier le wikicode]

Testing spouse[modifier le wikicode]

Copy and paste the following into any article and preview it (please don't save!):

* - {{#invoke:Wikidata|getValue|p26|}}
* - {{#invoke:Wikidata|getValue|p26|FETCH_WIKIDATA}}
* - {{#invoke:Wikidata|getValue|p26|[[Hillary Clinton]]}}

In Bill Clinton you should get:


In Barack Obama you should get:


In Richard Burton you should get:


In Franz Kafka you should get:

Testing birthplace[modifier le wikicode]

Copy and paste the following into any article and preview it (please don't save!):

* - {{#invoke:Wikidata|getValue|p19|}}
* - {{#invoke:Wikidata|getValue|p19|FETCH_WIKIDATA}}
* - {{#invoke:Wikidata|getValue|p19|[[Newport]]}}

Try William Ellery and check that the Wikidata call correctly disambiguates.

Testing getValue, getRawValue and getDateValue[modifier le wikicode]

Copy and paste the following into any article and preview it (please don't save!):

* - {{#invoke:Wikidata|getValue|p19|FETCH_WIKIDATA}}
* - {{#invoke:Wikidata|getValue|p26|FETCH_WIKIDATA}}
* - {{#invoke:Wikidata|getValue|p27|FETCH_WIKIDATA}}
* - {{#invoke:Wikidata|getValue|p140|FETCH_WIKIDATA}}
* - {{#invoke:Wikidata|getRawValue|p21|FETCH_WIKIDATA}}
* - {{#invoke:Wikidata|getDateValue|p569|FETCH_WIKIDATA|dmy}}
* - {{#invoke:Wikidata|getDateValue|p569|FETCH_WIKIDATA|mdy}}

This should return the Wikidata values for birthplace, spouse, citizenship, religion, gender and date of birth (twice) if they exist. The dob is first in dmy format and then in mdy.