وحدة:Wikidata2/template
الاستخدام
- [خطأ: الوظيفة "wdurl" غير موجودة. (Q48534628)]:
local p = {}
local wl = require('وحدة:ص.م')
local track = require('وحدة:Wikidata/تتبع').makecategory1
function string.ends(String,End)
return End=='' or string.sub(String,-string.len(End))==End
end
function template ( args )
local rows = mw.html.create( 'tr' )
local years = args[1] .. "–" .. args[2]
local goals;
if args[4] and args[4] ~="" then
goals = "(" .. args[4] .. ")"
end
rows:attr('colspan', 4)
--head:css('background-color', '#E1E1E1')
rows:tag('td'):tag("span"):addClass('nowrap'):wikitext(years)
rows:tag('td'):wikitext(args[3])
rows:tag('td'):tag("span"):addClass('nowrap'):wikitext(args[2] or "-")
rows:tag('td'):tag("span"):addClass('nowrap'):wikitext(goals)
return tostring(rows)
end
function p.football( statement , options)
Args = {}
op = options
op.enbarten = 'true'
if statement then
if statement.type then
if statement.type == 'statement' then
local value = statement.mainsnak.datavalue.value
local entit = getEntityIdFromValue( value )
local s = formatSnak( statement.mainsnak, options ).value
if s then
if statement.references then
if options.reff and options.reff ~= '' then
reff = formatReferences( statement, options )
s = s..reff
end
end
local entit = getEntityIdFromValue( value )
if statement.qualifiers
then
function tato(number , Q_n)
if Q_n then
op["property"] = Q_n
Args[number] = formatStatements({
property = Q_n , firstvalue= "t",
illwd2= options.illwd2,
enlabelcate= options.enlabelcate,
}, statement.qualifiers) or ''
end
end
tato(0 , options.Q0)
Args[1] = s
tato(2 , options.Q1)
tato(3 , options.Q2)
tato(4 , options.Q3)
tato(5 , options.Q4)
tato(6 , options.Q5)
tato(7 , options.Q6)
tato(8 , options.Q7)
tato(9 , options.Q8)
tato(10 , options.Q9)
tato(11 , options.Q10)
end
s = Args
end
end
end
end
return Args
end
function p.foot( claims , options)
local icon = track({property="P54", id= options.entityId or "",category= "[[تصنيف:فرق لاعب كرة من ويكي بيانات]][[تصنيف:فرق لاعب من ويكي بيانات]]"})
local Other = {}
for i, statement in pairs( claims ) do
options.num = i
local stat = p.football( statement, options )
table.insert( Other, stat )
end
Labs = {}
lenth = 0
function make_lab(numb , q)
val = options[q]
if options[val] and options[val] ~= "" then Labs[numb] = options[val] elseif val and val ~= "" then Labs[numb] = mw.wikibase.label( val ) end
if val and val ~= "" then lenth = lenth + 1 end
end
make_lab(0 , "Q0" )
Labs[1] = options.Q1_lab or "value"
make_lab(2 , "Q1" )
make_lab(3 , "Q2" )
make_lab(4 , "Q3" )
make_lab(5 , "Q4" )
make_lab(6 , "Q5" )
make_lab(7 , "Q6" )
make_lab(8 , "Q7" )
make_lab(9 , "Q8" )
make_lab(10 , "Q9" )
make_lab(11 , "Q10" )
local fs = {}
class=""
local tab = mw.html.create( 'table' )
tab:addClass('wikitable sortable')
local head = tab:tag('tr')
head:attr('colspan', lenth )
i = 0
while true do
if Labs[i] then head:tag('th'):wikitext( Labs[i] ) end
i = i + 1
if i == 11 then break end
end
for _, v in ipairs(Other) do
ii = 0
if v[0] then
ca = tab:tag('tr')
while true do
if Labs[ii] and v[ii] then
ca:tag('td'):wikitext( v[ii] )
end
ii = ii + 1
if ii == 11 then break end
end
end
end
local content = mw.getCurrentFrame():expandTemplate{ title = "صندوق معلومات سيرة كرة قدم/تعديل ويكي بيانات", args ={id = options.entityId or ""} }
if #fs > 0 then
local edit_at_wd = tab:tag('tr')
:tag('td')
:attr('scope', 'col')
:css('background-color', '#F9F9F9')
:css('color', '#000000')
:css('text-align', "left")
:attr('colspan', lenth)
:wikitext(content)
:done()
--table.insert( fs, tostring(edit_at_wd) )
end
--if tot == '' then tot = nil end
--return tot
return tab --table.concat(fs)
end
return p