Modul:Wb: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
imported>Juergen.Kett |
imported>Juergen.Kett |
||
Zeile 39: | Zeile 39: | ||
for key2, claim in pairs(claimgroup) do | for key2, claim in pairs(claimgroup) do | ||
qualifiers=p.getFormatedQualifiers(claim["qualifiers"]) | qualifiers=p.getFormatedQualifiers(claim["qualifiers"]) | ||
+ | |||
value = mw.wikibase.renderSnak(claim["mainsnak"]) | value = mw.wikibase.renderSnak(claim["mainsnak"]) | ||
ret = ret .. rowDelA .. colDelA .. prop .. colDelB .. colDelA .. value .. colDelB .. colDelA .. tableDelA .. qualifiers .. tableDelB .. colDelB .. rowDelB | ret = ret .. rowDelA .. colDelA .. prop .. colDelB .. colDelA .. value .. colDelB .. colDelA .. tableDelA .. qualifiers .. tableDelB .. colDelB .. rowDelB | ||
Zeile 53: | Zeile 54: | ||
for key, snak in pairs(snaks) do | for key, snak in pairs(snaks) do | ||
prop = mw.wikibase.getLabel(key) | prop = mw.wikibase.getLabel(key) | ||
− | ret = ret .. rowDelA .. colDelA .. prop .. colDelB .. colDelA .. mw.wikibase.renderSnak( | + | for key2, snak2 in pairs(snak) do |
+ | ret = ret .. rowDelA .. colDelA .. prop .. colDelB .. colDelA .. mw.wikibase.renderSnak(snak2) .. colDelB .. rowDelB | ||
+ | end | ||
end | end | ||
end | end |
Version vom 30. Mai 2020, 09:18 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; local rowDelA = "<tr>" local rowDelB = "</tr>\n" local colDelA = "<td>" local colDelB = "</td>" local tableDelA = "<table>" local tableDelB = "</table>" local refUrl = nil function p.getFormatedStatements(frame) id = frame.args.id rowDelA = frame.args.rowDelA rowDelB = frame.args.rowDelB colDelA = frame.args.colDelA colDelB = frame.args.colDelB tableDelA = frame.args.tableDelA tableDelB = frame.args.tableDelB return p._getFormatedStatements(id) end function p._getFormatedStatements(id) local ret = "" local qualifiers = "" local prop = "" local value = "" p.entity = mw.wikibase.getEntity(id) if not p.entity then return "no entity with id found: " .. id end p.claims = p.entity["claims"] for key, claimgroup in pairs(p.claims) do if claimgroup then prop = mw.wikibase.getLabel(key) for key2, claim in pairs(claimgroup) do qualifiers=p.getFormatedQualifiers(claim["qualifiers"]) value = mw.wikibase.renderSnak(claim["mainsnak"]) ret = ret .. rowDelA .. colDelA .. prop .. colDelB .. colDelA .. value .. colDelB .. colDelA .. tableDelA .. qualifiers .. tableDelB .. colDelB .. rowDelB end end end return ret end function p.getFormatedQualifiers(snaks) local ret = "" local prop = "" if snaks then for key, snak in pairs(snaks) do prop = mw.wikibase.getLabel(key) for key2, snak2 in pairs(snak) do ret = ret .. rowDelA .. colDelA .. prop .. colDelB .. colDelA .. mw.wikibase.renderSnak(snak2) .. colDelB .. rowDelB end end end return ret ; end -- wird nicht mehr benötigt 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) p.index = p.index + 1 end end -- wird nicht mehr benötigt 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 p.getLabel = function (frame) local id = frame.args.id if id then return mw.wikibase.getLabel(id) end return "" end return p