Módulo:Infobox/Futebolista
Aspeto
![]() | Este módulo está classificado como pré-alfa. Ele está incompleto, e pode ou não estar em desenvolvimento activo. Ele deve ser utilizado desde páginas do domínio artigos. Os módulos ficam em pre-alfa até o editor original (ou alguém que toma conta se ele for abandonado por algum tempo) está satisfeito com a estrutura básica. |
Descrição
[editar código-fonte]Uso
[editar código-fonte]Outra documentação:
local p = {}
local wd = require "Módulo:Infobox/Wikidata"
local countrymod = require "Módulo:Country data"
local frame = mw.getCurrentFrame()
function p._teams(teamtype, headers)
-- recup os dados
local claims = wd.getClaims{
rank = 'valid',
property = 'P54',
sorttype = 'chronological',
condition = function(claim)
local v = wd.getMainId(claim)
return wd.isInstance(teamtype, v, 3)
end,
}
if not claims then
return nil
end
-- Criando a tabela e os cabeçalhos =
mw.html.create("") local tab1 = mw.html.create("tr") headers =
headers or {"Temporadas", "Clubes", "M (B.)[[Categoria:!Página utilizando P54]]"}
for i, j in pairs(headers) do
tab1:tag("th"):wikitext(j):done()
end
tab:node(tab1):done()
-- Integração dos dados
local function cleanLabel(id)
local label = wd.getLabel(id)
if not label then
return nil
end
local patterns = {
["[Ee]quip[ae] de ?"] = "",
["menos que "] = "-",
["de soccer"] = "",
["de futebal"] = "",
[" feminino "] = " fém. ",
["[Aa]ssociation [Ff]ootball [Cc]lub"] = "AFC",
["[Ff]ootball [Cc]lub ?d?e?u?'?"] = "FC ",
["Sporting Clube? ?d?e?u?"] = "SC ",
["Sports Club"] = "SC",
["Club Atlético "] = "CA ",
["Club Deportivo "] = "CD ",
["Associação Atlética "] = "AA ",
["Futebol Clube"] = "FC",
["Fútbol Club"] = "FC",
["Associação Desportiva "] = "AD ",
["Clube Desportivo "] = "CD ",
["Club de Deportes "] = "CD ",
}
for i, j in pairs(patterns) do
label = mw.ustring.gsub(label, i, j)
end
return label
end
for i, j in pairs(claims) do
local teamid = wd.getMainId(j)
local period = wd.getFormattedDate(j, {precision = 'year', textformat = 'infobox', linktopic = 'football'})
local matches = wd.getFormattedQualifiers(j, {'P1350'})
local goals = wd.getFormattedQualifiers(j, {'P1351'})
local condition = wd.getFormattedQualifiers(j, {'P1642'})
local teamname = wd.formatEntity(teamid, {labelformat = function(id) return cleanLabel(teamid) end} )
local atdate = wd.getFormattedQualifiers(j, {'P580'}, {displayformat = 'raw'}) -- data em forma -- para ajustar a bandeira de acordo com a data
local teamcountry = wd.formatStatements{entity = teamid, property = 'P1532', displayformat = 'raw'} -- nacionalidade esportiva da equipe, para a bandeira (seleção)
if teamcountry == nil then -- se não tiver nacionalidade esportiva, procuramos o país (caso geral)
teamcountry = wd.formatStatements{entity = teamid, property = 'P17', displayformat = 'raw'}
end
if teamcountry == "Q145" then -- se país=Reino Unido, procuramos a zona operacional do campeonato do clube, para adaptar a bandeira
local championnat = wd.formatStatements{entity = teamid, property = 'P118', displayformat = 'raw', numval = 1}
local zone = wd.formatStatements{entity = championnat, property = 'P2541', displayformat = 'raw', numval = 1}
if zone ~= nil then
teamcountry = zone
end
end
local flag = countrymod.standarddisplay(teamcountry, {label = '-', date = atdate or 'default'}) or ''
local formattedteam = flag .. ' ' .. teamname
if condition then
if string.find (condition, 'empréstimo') then
formattedteam = frame:expandTemplate{ title = 'empréstimo'} .. ' ' .. formattedteam
else
formattedteam = formattedteam .. ' <small>(' .. condition .. ')</small>'
end
end
local stats = matches
if stats and goals then
goals = mw.text.trim(goals) -- exibir bug na Módulo: Wikidata aparentemente
stats = stats .. "(" .. goals .. ")"
end
tab :tag('tr')
:tag('td'):addClass('data'):wikitext(period):done()
:tag('td'):addClass('data'):wikitext(formattedteam):done()
:tag('td'):addClass('data'):cssText( 'white-space:nowrap; text-align:center'):wikitext(stats):done()
:done()
end
return tostring(tab)
end
function p.teams(frame) -- para os clubes de futebol só seria Q476028, mas até wikidata é completamente perfeito ...
return p._teams('Q847017')
end
function p.selections(frame) -- para seleções geográficas
return p._teams('Q6979593', {"Anos", "Seleções", "M (B.)"})
end
return p