« Module:Wikidata » : différence entre les versions

Contenu supprimé Contenu ajouté
Zolo (discussion | contributions)
Aucun résumé des modifications
m Cosmétique (pas de changement fonctionnel)
Ligne 105 :
function p.getDate(statement)
--[[
returns an object containing a timestamp for easy sorting, and other data
2 types of object
dateobject
Ligne 117 :
end
 
-- si p585 : dateobject
if q.P585 and q.P585[1].snaktype == 'value' then -- P585: punctual date
return dates.dateobject(q.P585[1].datavalue.value)
Ligne 126 :
ending = dates.dateobject(q.P582[1].datavalue.value)
end
if q.P580 and q.P580[1].snaktype == 'value' then
begin = dates.dateobject(q.P580[1].datavalue.value)
end
Ligne 178 :
local function hasqualifier(claim, qualifier, qualifiervalues)
qualifier = string.upper(qualifier)
 
if not qualifier then -- si aucun qualificatif est demandé, ça passe
return true
Ligne 185 :
return false
end
 
if (not qualifiervalues) or (qualifiervalues == {}) then
return true -- si aucune valeur spécifique n'est exigée
end
 
if type(qualifiervalues) == 'string' then
qualifiervalues = {qualifiervalues}
end
 
for i, j in pairs(claim.qualifiers[qualifier]) do
local val = p.getRawvalue(j)
Ligne 211 :
return false
end
if not source then -- si toutes les sources sont valides, du moment qu'elles utilisent sourceproperty
return true
end
Ligne 267 :
local timeA = p.getDate(a)
local timeB = p.getDate(b)
if inverted then
return comparedate(timeB, timeA)
else
Ligne 294 :
 
function p.getDatavalue(snak, params)
if not params then
params = {}
end
local formatting = params.formatting
Ligne 301 :
return nil
end
 
local datatype = snak.datavalue.type
local value = snak.datavalue.value
Ligne 313 :
return p.formatEntity('Q' .. value['numeric-id'], params)
end
 
elseif datatype == 'string' then
if params.displayformat == 'weblink' then
Ligne 340 :
return value -- note : les coordonnées Wikidata peuvent être utilisée depuis Module:Coordinates. Faut-il aussi autoriser à appeler Module:Coordiantes ici ?
end
 
 
elseif datatype == 'quantity' then -- todo : gérer les paramètre précision
Ligne 346 :
return value.amount
else
local str = string.sub(value.amount,2) --
return formatText.do_formatnum({str})
end
Ligne 367 :
end
return claims
end
 
function p.getClaims( args ) -- returns a table of the claims matching some conditions given in args
Ligne 383 :
entity = getEntity( args.entity )
end
if (not entity) or (not entity.claims) then
return nil
end
Ligne 393 :
args.rank = 'best'
end
local claims = {}
-- ~= '' lorsque le paramètre est écrit mais laissé blanc dans une fonction frame
for i, statement in pairs(entity.claims[property]) do
if
(
not args.excludespecial
or
not (isSpecial(statement.mainsnak))
)
Ligne 405 :
(
not args.targetvalue
or
hastargetvalue(statement, args.targetvalue)
)
and
Ligne 438 :
claims = bestranked(claims)
end
if args.sorttype then
claims = p.sortclaims(claims, args.sorttype)
end
 
if args.numval then
return numval(claims, args.numval)
Ligne 465 :
 
local function getQualifiers(statement, qualifs, params)
if not statement.qualifiers then
return nil
end
local vals = {}
for i, j in pairs(qualifs) do
if statement.qualifiers[j] then
Ligne 480 :
end
return vals
end
 
function p.getFormattedQualifiers(statement, qualifs, params)
Ligne 503 :
str = (showlang(statement) or '') .. str
end
if args.showqualifiers then
local qualifs = args.showqualifiers
if type(qualifs) == 'string' then
Ligne 510 :
local foundvalues = p.getFormattedQualifiers(statement, qualifs, args)
if foundvalues then
str = str .. linguistic.inparentheses(foundvalues, lang)
end
end
 
if args.showdate then -- when "showdate and chronosort are both set, date retrieval is performed twice
local timedata = p.getDate(statement)
Ligne 523 :
end
 
if args.showsource and statement.references then --[[needs abritrary access
local sourcestring = ''
for i, ref in pairs(statement.references) do
Ligne 542 :
sourcestring = sourcestring .. s
end
end
str = str .. sourcestring ]]--
end
Ligne 576 :
label = mw.wikibase.label(entity)
end
if label then
return label
end
 
if default == 'nolabel' then
return i18n['no-label']
Ligne 594 :
end
local descriptions = entity.descriptions
if not descriptions then
return nil
end
Ligne 613 :
 
local function formattedLabel(label, entity, args)
if not args then
args = {}
end
Ligne 650 :
lang = args.lang
end
if string.sub(entity, 1, 10) == 'Property:P' then
entity = string.sub(entity, 10)
elseif (string.sub(entity, 1, 1) ~= 'P' and string.sub(entity, 1, 1) ~= 'Q') or (not tonumber(string.sub(entity, 2))) then
Ligne 667 :
 
function p._formatStatements( args )--Format statement and concat them cleanly
if args.value == '-' then
return nil
end
Ligne 679 :
 
function p.showQualifier( args )
local qualifs = args.qualifiers or args.qualifier
if type(qualifs) == 'string' then
qualifs = mw.text.split(qualifs, ',')
Ligne 691 :
end
local str = ''
for i, j in pairs(claims) do
local new = p.getFormattedQualifiers(j, qualifs, args) or ''
str = str .. new
Ligne 698 :
end
 
function p._formatAndCat(args)
local val = p._formatStatements( args )
if val then
Ligne 717 :
if val and args.addcat == true then
return val .. addtrackingcat(args.property)
else
return val
end
end
---FONCTIONS depuis le FRAME
function p.getaDate(frame)
return p.getTheDate(frame.args)
Ligne 763 :
end
 
function p.formatAndCat(frame)
local args = {}
if frame == mw.getCurrentFrame() then