Mòdul:Wikidades: diferència entre les revisions

Contingut suprimit Contingut afegit
proteccions després de pcall, direction per rtl
case=function, icones d'etiquetes a getParentValues
Línia 152:
if not isSet(label) then return label end
if type(localcase) == "smallcapsfunction" then
return localcase(label)
elseif localcase == "smallcaps" then
return '<span style="font-variant: small-caps;">' .. label .. '</span>'
elseif cases[localcase] then
Linha 1.475 ⟶ 1.477:
end
 
local function getPropertyValue(id, property, parameter, langs, editicon, labelicon, case)
local snaks = mw.wikibase.getBestStatements(id, property)
local mysnak = getSnak(snaks, {1, "mainsnak"})
Linha 1.486 ⟶ 1.488:
if mysnak.datavalue then
entity_id = "Q" .. tostring(mysnak.datavalue.value['numeric-id'])
result, _ = getSnakValue(mysnak, {formatting=parameter, lang=langs, editicon=editicon, labelicon=labelicon, case=case})
end
Linha 1.500 ⟶ 1.502:
propertyLink,
labelShow,
labelicon0,
editicon,
labelicon1,
labelicon,
upto_number,
upto,
upto_label,
upto_linkId,
upto_value,
last_only,
grammatical_case,
include_self)
if upto_linkIdupto_value == nil then upto_linkIdupto_value = "" end
local upto_link_ids = {}
for q in mw.text.gsplit(upto_linkIdupto_value, '[^Q%d]') do
upto_link_ids[resolveEntityId(q)] = true
end
local propertySups = mw.text.split(propertySupString, '[^P%d]')
local lastlabel = uc_first(uptoupto_label or '')
local maxloop = tonumber(uptoupto_number) or ((lastlabel .. upto_linkIdupto_value) == '' and 10 or 50)
local labelFilter = {}
Linha 1.531 ⟶ 1.534:
for iter = 1, maxloop do
local link, label, labelwicon, linktext, _id, _link
for _, propertySup in pairs(propertySups) do
_id, _link = getPropertyValue(id, propertySup, prop_format, languages, editicon, labeliconlabelicon1, grammatical_case)
if _id and _link then id = _id; link = _link break end
end
Linha 1.546 ⟶ 1.549:
end
_, label = getPropertyValue(id, propertyLabel, label_format, languages, false, false, "infoboxlabel")
if labelicon0 then
_, labelwicon = getPropertyValue(id, propertyLabel, label_format, languages, labelicon0, "infoboxlabel")
else
labelwicon = label
end
if labelShow == nil or labelFilter[label] then
result[#result + 1] = {labellabelwicon, link}
if label then
Linha 1.599 ⟶ 1.607:
end
 
-- Returns pairs of instanceparent label and property value fetching a recursive tree
function p.getParentValues(frame)
local args = frame.args or frame -- via invoke or require
Linha 1.614 ⟶ 1.622:
local property_format = getArg(args.formatting)
local label_format = getArg(args.labelformat, "label")
local uptoupto_number = getArg(args.upto)
local last_only = getArg(args.last_only, false)
local labelShow = getArg(args.labelshow)
Linha 1.621 ⟶ 1.629:
local case = getArg(args.case)
local upto_label
if isSet(args.uptolabelid) then
uptoupto_label, _ = getLabelByLangs(args.uptolabelid, languages) -- TODO table of label ids
elseif type(upto_number) == 'string' then
upto_label = upto_number
upto_number = nil
require(wiki.module_title .. '/debug').track('upto') -- replace by uptolabelid
end
Linha 1.633 ⟶ 1.646:
labelShow = table.concat(showLabelList,"/")
end
end
local rowformat = args.rowformat; if not isSet(rowformat) then rowformat = "$0 = $1" end
local labelicon0, labelicon1 = labelicon, labelicon
if string.find(label_format, '{{.*$0.*}}') or (string.find(rowformat, '{{.*$0.*}}') and label_format ~= 'raw') then
labelicon0 = false
end
Linha 1.643 ⟶ 1.662:
propertyLink,
labelShow,
editiconlabelicon0,
labeliconlabelicon1,
uptoupto_number,
upto_label,
args.uptovalueid or args.uptolinkid,
last_only,
Linha 1.652 ⟶ 1.672:
if #result == 0 then return end
local rowformat = args.rowformat; if not isSet(rowformat) then rowformat = "$0 = $1" end
local separator = args.separator; if not isSet(separator) then separator = "<br />" end
local sorting = args.sorting; if sorting == "" then sorting = nil end