Modul:Wb: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
imported>Juergen.Kett |
imported>Juergen.Kett |
||
Zeile 11: | Zeile 11: | ||
p.qualifier = nil; | p.qualifier = nil; | ||
− | local rowDel1 = "< | + | local rowDel1 = "<tr>" |
− | local rowDel2 = "</ | + | local rowDel2 = "</tr>\n" |
− | local colDel1 = "< | + | local colDel1 = "<tc>" |
− | local colDel2 = "</ | + | local colDel2 = "</tc>" |
function p.initEntity(qid) | function p.initEntity(qid) |
Version vom 29. Mai 2020, 13:44 Uhr
Die Dokumentation für dieses Modul kann unter Modul:Wb/Doku erstellt werden
local p = {}; p.id = nil; p.entity = nil; p.claims = nil; p.keys = {}; p.index = 1; p.property = nil; p.value = nil; p.qualifier = nil; local rowDel1 = "<tr>" local rowDel2 = "</tr>\n" local colDel1 = "<tc>" local colDel2 = "</tc>" function p.initEntity(qid) p.entity = mw.wikibase.getEntity(qid) p.claims = p.entity["claims"] -- p.i, p.v = next(p.claims, nil) -- mw.logObject(p.entity) p.keys = {} p.index=1 local i = 1 for k in pairs(p.claims) do p.keys[i]=k i = i + 1 end mw.logObject(p.keys) end function p.getFormatedStatements(frame) id = frame.args.id return p._getFormatedStatements(id) end function p._getFormatedStatements(id) ret = "" p.entity = mw.wikibase.getEntity(id) p.claims = p.entity["claims"] for key, claimgroup in pairs(p.claims) do if claimgroup then for key2, claim in pairs(claimgroup) do qualifiers=p.getFormatedQualifiers(claim["qualifiers"]) value = mw.wikibase.renderSnak(claim["mainsnak"]) ret = ret .. rowDel1 .. colDel1 .. key .. colDel2 .. colDel1 .. value .. colDel2 .. colDel1 .. qualifiers .. colDel2 .. rowDel2 end end end return ret end function p.getFormatedQualifiers(snaks) local ret = "" if snaks then for key, snak in pairs(snaks) do ret = ret .. rowDel1 .. colDel1 .. key .. colDel2 .. colDel1 .. mw.wikibase.renderSnak(snak[1]) .. colDel2 .. rowDel2 end end return ret ; end function p.nextStatement() p.property = p.keys[p.index] mw.log(p.property) if p.property then claim = p.claims[p.property] snak = claim[1]["mainsnak"] p.value = mw.wikibase.renderSnak(snak) mw.logObject(p.value) p.index = p.index + 1 end end p.getLabel = function (frame) local pid = frame.args.pid local label = mw.wikibase.getLabel(pid) return label end return p