Modul:Infobox: Unterschied zwischen den Versionen
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
Zeile 21: | Zeile 21: | ||
function getValueWithUnit(prop) | function getValueWithUnit(prop) | ||
local result = '' | local result = '' | ||
local propValue = prop.mainsnak and prop.mainsnak.datavalue | local propValue = prop.mainsnak and prop.mainsnak.datavalue or prop.datavalue | ||
if propValue and propValue.value and propValue.value.amount then | if propValue and propValue.value and propValue.value.amount then | ||
result = result .. lang:formatNum(tonumber(propValue.value.amount)) | result = result .. lang:formatNum(tonumber(propValue.value.amount)) | ||
Zeile 102: | Zeile 102: | ||
end | end | ||
result = result .. screenPpi | result = result .. screenPpi | ||
end | |||
return result | |||
end | |||
function dump(o) | |||
if type(o) == 'table' then | |||
local s = '{ ' | |||
for k,v in pairs(o) do | |||
if type(k) ~= 'number' then k = '"'..k..'"' end | |||
s = s .. '['..k..'] = ' .. dump(v) .. ',' | |||
end | |||
return s .. '} ' | |||
else | |||
return tostring(o) | |||
end | |||
end | |||
function getValueLabel(propValue) | |||
if propValue['type'] == 'wikibase-entityid' then | |||
local linkTarget = mw.wikibase.sitelink( "Q" .. propValue.value['numeric-id'] ) | |||
local linkTitle = mw.wikibase.label( "Q" ..propValue.value['numeric-id'] ) | |||
return linkTarget and linkTitle and mw.ustring.format( "[[%s|%s]]", linkTarget, linkTitle ) | |||
or linkTitle | |||
elseif propValue and propValue['type'] == 'string' then | |||
return propValue.value | |||
end | |||
end | |||
function renderCPU() | |||
local entity = mw.wikibase.getEntityObject() | |||
result = '' | |||
if not entity or not entity.claims then return end --the entity doesnt exist or have no claims | |||
local property = entity.claims['P28'] | |||
if property then | |||
local linkRenderer = require( "Modul:PropertyLink" ) | |||
result = result .. linkRenderer.property({ args = { "P28" } }) | |||
if property and property[1] and property[1].mainsnak and property[1].mainsnak.datavalue and property[1].mainsnak.datavalue.value and property[1].mainsnak.datavalue.value["numeric-id"] then | |||
local processorObjectId = "Q" .. property[1].mainsnak.datavalue.value["numeric-id"] | |||
local processorObject = mw.wikibase.getEntityObject(processorObjectId) | |||
if not processorObject or not processorObject.claims then | |||
return result | |||
end | |||
local p2 = processorObject.claims["P2"] | |||
if p2 and p2[1] and p2[1].mainsnak and p2[1].mainsnak.datavalue then | |||
local label = getValueLabel(p2[1].mainsnak.datavalue) | |||
result = label .. " " .. result | |||
end | |||
if property[1].qualifiers['P30'] then | |||
p30 = property[1].qualifiers['P30'][1] | |||
result = result .. ", " .. getValueWithUnit(p30) | |||
end | |||
local p31 = processorObject.claims["P31"] | |||
for key, prop in pairs(p31) do | |||
if prop and prop.mainsnak and prop.mainsnak.datavalue then | |||
local propValue = prop.mainsnak.datavalue | |||
result = result .. ", " .. getValue(prop) .. "-Kern"; | |||
if prop.qualifiers["P32"] and prop.qualifiers["P32"][1] and prop.qualifiers["P32"][1].datavalue then | |||
result = result .. " " .. getValueLabel(prop.qualifiers["P32"][1].datavalue) .. " CPU" | |||
end | |||
end | |||
end | |||
end | |||
end | end | ||
return result | return result | ||
Zeile 107: | Zeile 169: | ||
return { | return { | ||
renderAnzeige = renderAnzeige | renderAnzeige = renderAnzeige, | ||
renderCPU = renderCPU | |||
} | } |